[tor-commits] [bridgedb/master] import after logging is configured

arma at torproject.org arma at torproject.org
Wed Sep 21 01:35:54 UTC 2011


commit 40c835ba1e0e2600ebde9fe36320d600ea15bdec
Author: aagbsn <aagbsn at extc.org>
Date:   Mon Sep 19 17:14:09 2011 -0700

    import after logging is configured
    
    bridgedb.Server tries to graciously import GeoIP support, but because
    logging is not yet configured at import time Python creates a default
    handler that goes to the console and ignores further basicConfig calls
    
    See also:
    http://stackoverflow.com/questions/1943747/ \
    python-logging-before-you-run-logging-basicconfig
    
    Our solution is to relocate the import so that configureLogging() is
    called first.
---
 lib/bridgedb/Main.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index 2ef56bf..3e06936 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -18,7 +18,6 @@ from twisted.internet import reactor
 import bridgedb.Bridges as Bridges
 import bridgedb.Dist as Dist
 import bridgedb.Time as Time
-import bridgedb.Server as Server
 import bridgedb.Storage
 import bridgedb.Opt as Opt
 import bridgedb.Bucket as Bucket
@@ -235,6 +234,11 @@ def startup(cfg):
     # Set up logging.
     configureLogging(cfg)
 
+    #XXX import Server after logging is set up
+    # Otherwise, python will create a default handler that logs to
+    # the console and ignore further basicConfig calls
+    import bridgedb.Server as Server
+
     # Load the master key, or create a new one.
     key = getKey(cfg.MASTER_KEY_FILE)
 





More information about the tor-commits mailing list