Created
July 21, 2016 06:52
-
-
Save praveenkumar/313b742bbb8ee4a7886694c8145d0858 to your computer and use it in GitHub Desktop.
Log separater script for dgplug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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