avoid KeyError in logging with IPython 2

This commit is contained in:
MinRK
2014-09-13 15:43:09 -07:00
parent 1a09bef767
commit 573f34a5b5

View File

@@ -175,6 +175,13 @@ class JupyterHubApp(Application):
"""override default log format to include time"""
return u"%(color)s[%(levelname)1.1s %(asctime)s.%(msecs).03d %(name)s]%(end_color)s %(message)s"
def _log_format_changed(self, name, old, new):
"""Change the log formatter when log_format is set."""
# FIXME: IPython < 3 compat
_log_handler = self.log.handlers[0]
_log_formatter = self._log_formatter_cls(fmt=new, datefmt=self.log_datefmt)
_log_handler.setFormatter(_log_formatter)
def init_logging(self):
# This prevents double log messages because tornado use a root logger that
# self.log is a child of. The logging module dipatches log messages to a log
@@ -186,7 +193,7 @@ class JupyterHubApp(Application):
logger.propagate = True
logger.parent = self.log
logger.setLevel(self.log.level)
# IPython < 3 compat
# FIXME: IPython < 3 compat
self._log_format_changed('', '', self.log_format)
def init_ports(self):