From: W. Trevor King Date: Thu, 24 Jan 2013 07:43:53 +0000 (-0500) Subject: util:wsgi: If we're logging to a file, shift libbe.LOG too X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=400c9251eedbd1caa3b28135b4bc5d2bf2124ac5;p=be.git 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. --- 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'))