Better method for eventlet.wsgi.server logging.

This commit is contained in:
Todd Willey 2011-01-05 01:54:31 -05:00
parent aab31f797b
commit ada65e007e
2 changed files with 12 additions and 5 deletions

View File

@ -67,7 +67,7 @@ flags.DEFINE_string('logging_exception_prefix',
flags.DEFINE_list('default_log_levels',
['amqplib=WARN',
'sqlalchemy=WARN',
'audit=INFO'],
'eventlet.wsgi.server=WARN'],
'list of logger=LEVEL pairs')
flags.DEFINE_bool('use_syslog', False, 'output to syslog')

View File

@ -37,9 +37,15 @@ import webob.exc
from nova import log as logging
class NullWsgiLogger(object):
def write(*args):
pass
class WritableLogger(object):
"""A thin wrapper that responds to `write` and logs."""
def __init__(self, logger, level=logging.DEBUG):
self.logger = logger
self.level = level
def write(self, msg):
self.logger.log(self.level, msg)
class Server(object):
@ -64,8 +70,9 @@ class Server(object):
def _run(self, application, socket):
"""Start a WSGI server in a new green thread."""
logger = logging.getLogger('eventlet.wsgi.server')
eventlet.wsgi.server(socket, application, custom_pool=self.pool,
log=NullWsgiLogger())
log=WritableLogger(logger))
class Application(object):