diff options
author | Seth Vidal <skvidal@fedoraproject.org> | 2013-07-04 15:49:10 -0400 |
---|---|---|
committer | Seth Vidal <skvidal@fedoraproject.org> | 2013-07-04 15:49:10 -0400 |
commit | 022083d7b97b8e08ea1fba2ddb67c7d735e08f0b (patch) | |
tree | c7f229ee1fd1a0c24b587b84e8c0abd5601896c1 | |
parent | 88caed356a960bc10623306fdd5b2e6c94590dbb (diff) | |
download | ansible-022083d7b97b8e08ea1fba2ddb67c7d735e08f0b.tar.gz ansible-022083d7b97b8e08ea1fba2ddb67c7d735e08f0b.tar.xz ansible-022083d7b97b8e08ea1fba2ddb67c7d735e08f0b.zip |
sortable, I think
-rwxr-xr-x | scripts/logview | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/scripts/logview b/scripts/logview index 02a9b592e..3bb610c31 100755 --- a/scripts/logview +++ b/scripts/logview @@ -54,26 +54,31 @@ def search_logs(opts, logfiles): things = line.split('\t') if things[2] in opts.search_terms or 'ANY' in opts.search_terms: slurp = json.loads(things[4]) + if opts.profile: + st = slurp.get('task_start', 0) + end = slurp.get('task_end', 0) + if st and end: + dur = '%.2f' % (float(end) - float(st)) + else: + dur = "Unknown" + 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 type(slurp) == dict: for term in ['task_userid', 'cmd']: if term in slurp: msg += '\t%s:%s' % (term, slurp.get(term, None)) + if opts.profile: + msg += '\t%s:%s' % ('dur', dur) + msg += '\n' else: msg += '\n' msg += json.dumps(slurp, indent=4) msg += '\n' - if opts.profile: - st = slurp.get('task_start', 0) - end = slurp.get('task_end', 0) - if st and end: - dur = '%.2f' % (float(end) - float(st)) - else: - dur = "Unknown" - msg += ' Duration: %s sec\n' % dur - + if opts.profile: + msg += 'Duration: %s\n' % dur + return msg |