diff bin/run_local.py @ 1512:3693b226b0b8

update coloredlogs Ignore-this: c152bd3f4a87270a064d737cbe8a90b0
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 30 Mar 2017 05:54:42 +0000
parents 8796803a1b45
children 5c04a54df635
line wrap: on
line diff
--- a/bin/run_local.py	Thu Mar 30 05:22:48 2017 +0000
+++ b/bin/run_local.py	Thu Mar 30 05:54:42 2017 +0000
@@ -31,16 +31,18 @@
 log = logging.getLogger() # this has to get the root logger
 log.name = progName # but we can rename it for clarity
 
+class FractionTimeFilter(logging.Filter):
+    def filter(self, record):
+        record.fractionTime = (
+            time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(record.created)) +
+            ("%.3f" % (record.created % 1)).lstrip('0'))
+        # Don't filter the record.
+        return 1
 
-class CSH(coloredlogs.ColoredStreamHandler):
-    def render_timestamp(self, created):
-        return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(created)) + (
-            "%.3f" % (created % 1)).lstrip('0')
-
-    def render_name(self, name):
-        return name
-
-log.addHandler(CSH(show_hostname=False, show_name=True))
+coloredlogs.install(
+    level='DEBUG',
+    fmt='%(fractionTime)s %(name)s[%(process)d] %(levelname)s %(message)s')
+logging.getLogger().handlers[0].addFilter(FractionTimeFilter())
 
 
 def setTerminalTitle(s):