Merge "Log unhandled exceptions"

This commit is contained in:
Jenkins 2013-11-25 00:41:05 +00:00 committed by Gerrit Code Review
commit ecf2ed21df
1 changed files with 5 additions and 16 deletions

View File

@ -25,7 +25,6 @@ from __future__ import print_function
import datetime import datetime
import errno import errno
import json import json
import logging
import os import os
import signal import signal
import sys import sys
@ -43,7 +42,7 @@ import webob.exc
from glance.common import exception from glance.common import exception
from glance.common import utils from glance.common import utils
import glance.openstack.common.log as os_logging import glance.openstack.common.log as logging
bind_opts = [ bind_opts = [
@ -88,17 +87,6 @@ CONF.register_opts(socket_opts)
CONF.register_opts(eventlet_opts) CONF.register_opts(eventlet_opts)
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.strip("\n"))
def get_bind_addr(default_port=None): def get_bind_addr(default_port=None):
"""Return the host and port to bind to.""" """Return the host and port to bind to."""
return (CONF.bind_host, CONF.bind_port or default_port) return (CONF.bind_host, CONF.bind_port or default_port)
@ -234,7 +222,7 @@ class Server(object):
self.sock = get_socket(default_port) self.sock = get_socket(default_port)
os.umask(0o27) # ensure files are created with the correct privileges os.umask(0o27) # ensure files are created with the correct privileges
self.logger = os_logging.getLogger('eventlet.wsgi.server') self.logger = logging.getLogger('glance.wsgi.server')
if CONF.workers == 0: if CONF.workers == 0:
# Useful for profiling, test, debug etc. # Useful for profiling, test, debug etc.
@ -323,7 +311,7 @@ class Server(object):
try: try:
eventlet.wsgi.server(self.sock, eventlet.wsgi.server(self.sock,
self.application, self.application,
log=WritableLogger(self.logger), log=logging.WritableLogger(self.logger),
custom_pool=self.pool, custom_pool=self.pool,
debug=False) debug=False)
except socket.error as err: except socket.error as err:
@ -335,7 +323,8 @@ class Server(object):
"""Start a WSGI server in a new green thread.""" """Start a WSGI server in a new green thread."""
self.logger.info(_("Starting single process server")) self.logger.info(_("Starting single process server"))
eventlet.wsgi.server(sock, application, custom_pool=self.pool, eventlet.wsgi.server(sock, application, custom_pool=self.pool,
log=WritableLogger(self.logger), debug=False) log=logging.WritableLogger(self.logger),
debug=False)
class Middleware(object): class Middleware(object):