only output if we have something to output
This commit is contained in:
parent
022083d7b9
commit
e1da7964f6
1 changed files with 4 additions and 4 deletions
|
@ -60,7 +60,7 @@ def search_logs(opts, logfiles):
|
||||||
if st and end:
|
if st and end:
|
||||||
dur = '%.2f' % (float(end) - float(st))
|
dur = '%.2f' % (float(end) - float(st))
|
||||||
else:
|
else:
|
||||||
dur = "Unknown"
|
dur = None
|
||||||
|
|
||||||
msg += '%s\t%s\t%s\t%s\t%s\t%s' % (timestamp, hostname, things[0], things[1], things[2], things[3])
|
msg += '%s\t%s\t%s\t%s\t%s\t%s' % (timestamp, hostname, things[0], things[1], things[2], things[3])
|
||||||
if not opts.verbose:
|
if not opts.verbose:
|
||||||
|
@ -68,16 +68,16 @@ def search_logs(opts, logfiles):
|
||||||
for term in ['task_userid', 'cmd']:
|
for term in ['task_userid', 'cmd']:
|
||||||
if term in slurp:
|
if term in slurp:
|
||||||
msg += '\t%s:%s' % (term, slurp.get(term, None))
|
msg += '\t%s:%s' % (term, slurp.get(term, None))
|
||||||
if opts.profile:
|
if opts.profile and dur:
|
||||||
msg += '\t%s:%s' % ('dur', dur)
|
msg += '\t%s:%s' % ('dur', dur)
|
||||||
|
|
||||||
msg += '\n'
|
msg += '\n'
|
||||||
else:
|
else:
|
||||||
|
if opts.profile and dur:
|
||||||
|
msg += '\t%s:%s' % ('dur', dur)
|
||||||
msg += '\n'
|
msg += '\n'
|
||||||
msg += json.dumps(slurp, indent=4)
|
msg += json.dumps(slurp, indent=4)
|
||||||
msg += '\n'
|
msg += '\n'
|
||||||
if opts.profile:
|
|
||||||
msg += 'Duration: %s\n' % dur
|
|
||||||
|
|
||||||
|
|
||||||
return msg
|
return msg
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue