From 8d6f150b58b505754f8951f6f3c8c0a3c5816481 Mon Sep 17 00:00:00 2001 From: Yoshihiro Kaneko Date: Sun, 15 Jun 2014 19:06:38 +0900 Subject: [PATCH] ryu.lib.hub: add logging wrapper for wsgi server This patch adds a wrapper to relay the log of the wsgi server to the logger. Signed-off-by: Yoshihiro Kaneko Signed-off-by: FUJITA Tomonori --- ryu/lib/hub.py | 7 ++++++- ryu/log.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ryu/lib/hub.py b/ryu/lib/hub.py index 3d87809b..836b9242 100644 --- a/ryu/lib/hub.py +++ b/ryu/lib/hub.py @@ -120,9 +120,14 @@ if HUB_TYPE == 'eventlet': sock, addr = self.server.accept() spawn(self.handle, sock, addr) + class LoggingWrapper(object): + def write(self, message): + LOG.info(message.rstrip('\n')) + class WSGIServer(StreamServer): def serve_forever(self): - eventlet.wsgi.server(self.server, self.handle) + self.logger = LoggingWrapper() + eventlet.wsgi.server(self.server, self.handle, self.logger) WebSocketWSGI = websocket.WebSocketWSGI diff --git a/ryu/log.py b/ryu/log.py index d4af519a..de2b31c0 100644 --- a/ryu/log.py +++ b/ryu/log.py @@ -72,7 +72,7 @@ def init_log(): if CONF.log_config_file: try: logging.config.fileConfig(CONF.log_config_file, - disable_existing_loggers=True) + disable_existing_loggers=False) except ConfigParser.Error as e: print('Failed to parse %s: %s' % (CONF.log_config_file, e), file=sys.stderr)