From: Ben Darnell Date: Sun, 9 Sep 2012 04:06:46 +0000 (-0700) Subject: Compensate for move to non-root loggers by calling basicConfig in IOLoop.start. X-Git-Tag: v3.0.0~272^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d07525c3a738ec67572e0c761fbf8d8333c22fc;p=thirdparty%2Ftornado.git Compensate for move to non-root loggers by calling basicConfig in IOLoop.start. The root logging methods call basicConfig automatically, but non-root loggers do not. --- diff --git a/tornado/ioloop.py b/tornado/ioloop.py index db0eeb7e7..b941087c1 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -31,6 +31,7 @@ from __future__ import absolute_import, division, with_statement import datetime import errno import heapq +import logging import os import select import thread @@ -254,6 +255,15 @@ class IOLoop(object): The loop will run until one of the I/O handlers calls stop(), which will make the loop stop after the current event iteration completes. """ + if not logging.getLogger().handlers: + # The IOLoop catches and logs exceptions, so it's + # important that log output be visible. However, python's + # default behavior for non-root loggers (prior to python + # 3.2) is to print an unhelpful "no handlers could be + # found" message rather than the actual log entry, so we + # must explicitly configure logging if we've made it this + # far without anything. + logging.basicConfig() if self._stopped: self._stopped = False return