Created
December 12, 2022 13:17
-
-
Save evansd/521ce3a55ac47aad58f8ecb75206219b to your computer and use it in GitHub Desktop.
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 python | |
import fileinput | |
import datetime | |
THRESHOLD = 50000 | |
MARKER = "==> " | |
SPACER = " " * len(MARKER) | |
last_ts = None | |
for line in fileinput.input(): | |
ts_str, _, content = line.partition(" ") | |
# Python <3.11 can't cope with the precision of these timestamps so strip the | |
# final characters | |
ts_str = ts_str[:-4] | |
ts = datetime.datetime.fromisoformat(ts_str) | |
delta = ts - last_ts if last_ts is not None else datetime.timedelta() | |
diff = delta.seconds * 1000000 + delta.microseconds | |
flag = MARKER if diff >= THRESHOLD else SPACER | |
content = content[18:] | |
print(f"{flag}{diff:05d} {content}", end="") | |
last_ts = ts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment