# HG changeset patch # User Drew Perttula # Date 2017-03-30 05:54:42 # Node ID 3693b226b0b82ebf73c4ce6471609bf4ff8d6769 # Parent f1c062f3b227f48bc0dfc1f187116942cabe2fc8 update coloredlogs Ignore-this: c152bd3f4a87270a064d737cbe8a90b0 diff --git a/bin/run_local.py b/bin/run_local.py --- a/bin/run_local.py +++ b/bin/run_local.py @@ -31,16 +31,18 @@ progName = sys.argv[0].split('/')[-1] 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): diff --git a/requirements.txt b/requirements.txt --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ nose-watcher==0.1.3 watchdog==0.8.3 freezegun==0.3.8 ipdb==0.10.2 -coloredlogs==1.0.1 +coloredlogs==6.0 genshi==0.7 pyjade==4.0.0 python-dateutil==2.6.0