]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Compensate for move to non-root loggers by calling basicConfig in IOLoop.start.
authorBen Darnell <ben@bendarnell.com>
Sun, 9 Sep 2012 04:06:46 +0000 (21:06 -0700)
committerBen Darnell <ben@bendarnell.com>
Sun, 9 Sep 2012 04:06:46 +0000 (21:06 -0700)
The root logging methods call basicConfig automatically, but non-root loggers
do not.

tornado/ioloop.py

index db0eeb7e747c6d0daa6a48317daaf9bc06171cf2..b941087c1d1b5fe08ffed0bf6dffba1a4c12a440 100644 (file)
@@ -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