Skip to content

Instantly share code, notes, and snippets.

@toddlipcon
Created May 17, 2018 16:42
Show Gist options
  • Save toddlipcon/1b46db45ae8fd496253eaaea09de0f7f to your computer and use it in GitHub Desktop.
Save toddlipcon/1b46db45ae8fd496253eaaea09de0f7f to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import time
import re
import sys
def convert_ts(ts_match):
ts_i = int(ts_match.group(0))
phys, logical = (ts_i >> 12, ts_i & ((1 << 12) - 1))
phys_sec = phys / 1000000
phys_micros = phys % 1000000
f = time.strftime("%F %H:%M:%S", time.localtime(phys_sec))
return "%s.%06d L=%d" % (f, phys_micros, logical)
for l in sys.stdin.xreadlines():
print re.sub(r"\d{10,19}", convert_ts, l),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment