tab/space issues

This commit is contained in:
Seth Vidal 2013-07-03 23:14:33 -04:00
parent 97a906435a
commit 0ef3ff79ad

View file

@ -33,28 +33,27 @@ def parse_args(args):
return opts, args
def search_logs(opts, logfiles):
msg = ''
for fn in logfiles:
hostname=os.path.basename(fn).replace('.log', '')
timestamp = os.path.basename(os.path.dirname(fn))
for line in open(fn):
things = line.split('\t')
if things[2] in opts.search_terms:
slurp = json.loads(things[4])
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))
msg += '\n'
else:
msg += '\n'
msg += json.dumps(slurp, indent=4)
msg += '\n'
return msg
msg = ''
for fn in logfiles:
hostname=os.path.basename(fn).replace('.log', '')
timestamp = os.path.basename(os.path.dirname(fn))
for line in open(fn):
things = line.split('\t')
if things[2] in opts.search_terms:
slurp = json.loads(things[4])
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))
msg += '\n'
else:
msg += '\n'
msg += json.dumps(slurp, indent=4)
msg += '\n'
return msg
def main(args):