aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorW. Trevor King <wking@tremily.us>2013-01-24 02:43:53 -0500
committerW. Trevor King <wking@tremily.us>2013-01-24 02:43:53 -0500
commit400c9251eedbd1caa3b28135b4bc5d2bf2124ac5 (patch)
tree694ef78ac53e2d42d3327a3221bc66a63b14a90b
parent932679f1e82a57feb4743e52d6c60f7331f057c2 (diff)
downloadbugseverywhere-400c9251eedbd1caa3b28135b4bc5d2bf2124ac5.tar.gz
util:wsgi: If we're logging to a file, shift libbe.LOG too
This avoids attempts to log to stderr if we're daemonizing the server.
-rw-r--r--libbe/util/wsgi.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/libbe/util/wsgi.py b/libbe/util/wsgi.py
index 8f407e4..b731ec8 100644
--- a/libbe/util/wsgi.py
+++ b/libbe/util/wsgi.py
@@ -58,6 +58,7 @@ try:
except ImportError:
OpenSSL = None
+import libbe
import libbe.command
import libbe.command.base
import libbe.command.util
@@ -686,6 +687,10 @@ class ServerCommand (libbe.command.base.Command):
handler = logging.handlers.TimedRotatingFileHandler(
path, when='w6', interval=1, backupCount=4,
encoding=libbe.util.encoding.get_text_file_encoding())
+ while libbe.LOG.handlers:
+ handler = libbe.LOG.handlers[0]
+ libbe.LOG.removeHandler(handler)
+ libbe.LOG.addHandler(handler)
else:
handler = logging.StreamHandler(self.stdout)
handler.setFormatter(logging.Formatter('%(message)s'))