Skip to content

Instantly share code, notes, and snippets.

@praveenkumar
Created July 21, 2016 06:52
Show Gist options
  • Select an option

  • Save praveenkumar/313b742bbb8ee4a7886694c8145d0858 to your computer and use it in GitHub Desktop.

Select an option

Save praveenkumar/313b742bbb8ee4a7886694c8145d0858 to your computer and use it in GitHub Desktop.
Log separater script for dgplug
#!/usr/bin/env python3
from dateutil import parser
def get_logs(fh, log_file):
for line in fh:
if "endclass" in line:
return fh
else:
with open(log_file, 'w') as fh:
fh.write(line)
with open('Logs-2015-07-28-14-16') as fh:
for line in fh:
if "Class Started" in line:
date_info = parser.parse(line[21:45])
log_file = "Logs-%s.txt" % date_info.strftime('%Y-%m-%d-%H-%M')
fh = get_logs(fh, log_file)
else:
print line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment