Skip to content

Instantly share code, notes, and snippets.

@evansd
Created December 12, 2022 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evansd/521ce3a55ac47aad58f8ecb75206219b to your computer and use it in GitHub Desktop.
Save evansd/521ce3a55ac47aad58f8ecb75206219b to your computer and use it in GitHub Desktop.
#!/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