Skip to content

Instantly share code, notes, and snippets.

@yeputons
Created September 16, 2016 21:21
Show Gist options
  • Save yeputons/bcf613a5f334827b00b5af442cee1926 to your computer and use it in GitHub Desktop.
Save yeputons/bcf613a5f334827b00b5af442cee1926 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import re
import sys
with open(sys.argv[1]) as f:
data = f.read()
mapping = {
"kInfo": "INFO",
"kWarning": "WARN",
"kError": "ERROR",
"kFatal": "FATAL"
}
for src, dest in mapping.items():
data = re.sub("([^\s]+)->Message\((\s*)%s," % src, "PS_LOG_%s(\\2\\1," % dest, data)
data = re.sub("([^\s]+)\.Message\((\s*)%s," % src, "PS_LOG_%s(\\2(&\\1)," % dest, data)
with open(sys.argv[1], "w") as f:
f.write(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment