Mercurial > code > home > repos > light9
changeset 1512:3693b226b0b8
update coloredlogs
Ignore-this: c152bd3f4a87270a064d737cbe8a90b0
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Thu, 30 Mar 2017 05:54:42 +0000 |
parents | f1c062f3b227 |
children | 776717e5cd1a |
files | bin/run_local.py requirements.txt |
diffstat | 2 files changed, 12 insertions(+), 10 deletions(-) [+] |
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):