From 400c9251eedbd1caa3b28135b4bc5d2bf2124ac5 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 24 Jan 2013 02:43:53 -0500 Subject: [PATCH] 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. --- libbe/util/wsgi.py | 5 +++++ 1 file changed, 5 insertions(+) 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')) -- 2.26.2