Change nova-api-proxy logging backend to oslo_log
This changes the logging backend to oslo_log, from native python logging This is required for the containerization of the nova-api-proxy Change-Id: I0fb847c2d6b3178c15e78d063eb7c356a6c61979 Story: 2004007 Task: 27607 Depends-On: https://review.openstack.org/612427 Signed-off-by: Lachlan Plant <lachlan.plant@windriver.com>
This commit is contained in:
parent
fce17d8115
commit
a65fe97f70
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
||||
# Copyright (c) 2015-2018 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -11,9 +11,9 @@ import signal
|
||||
import eventlet
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from nova_api_proxy.common import config
|
||||
from nova_api_proxy.common.service import Server
|
||||
from nova_api_proxy.common import log as logging
|
||||
from nova_api_proxy.common import histogram
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -68,7 +68,9 @@ def main():
|
||||
signal.signal(signal.SIGUSR1, process_signal_handler)
|
||||
signal.signal(signal.SIGUSR2, process_signal_handler)
|
||||
|
||||
logging.register_options(cfg.CONF)
|
||||
config.parse_args(sys.argv)
|
||||
logging.setup(cfg.CONF, 'nova-api-proxy')
|
||||
|
||||
should_use_ssl = CONF.use_ssl
|
||||
LOG.debug("Load paste apps")
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
||||
# Copyright (c) 2015-2018 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -10,7 +10,7 @@ import webob.exc
|
||||
|
||||
from paste.request import construct_url
|
||||
from oslo_config import cfg
|
||||
from nova_api_proxy.common import log as logging
|
||||
from oslo_log import log as logging
|
||||
from nova_api_proxy.common import utils
|
||||
from nova_api_proxy.common.service import Middleware
|
||||
from nova_api_proxy.common.service import Request
|
||||
@ -37,7 +37,6 @@ proxy_opts = [
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(proxy_opts)
|
||||
CONF.import_opt('debug', 'nova_api_proxy.common.log')
|
||||
|
||||
|
||||
class APIController(Middleware):
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
||||
# Copyright (c) 2015-2018 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -9,8 +9,8 @@ import webob.dec
|
||||
import webob.exc
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as proxy_log
|
||||
from nova_api_proxy.common import utils
|
||||
from nova_api_proxy.common import log as proxy_log
|
||||
from nova_api_proxy.common.service import Middleware
|
||||
|
||||
LOG = proxy_log.getLogger(__name__)
|
||||
|
@ -7,7 +7,7 @@
|
||||
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
|
||||
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
||||
#
|
||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
||||
# Copyright (c) 2015-2018 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -16,7 +16,7 @@ import httplib
|
||||
import urllib
|
||||
from paste.proxy import TransparentProxy
|
||||
from paste.proxy import parse_headers
|
||||
from nova_api_proxy.common import log as logging
|
||||
from oslo_log import log as logging
|
||||
from nova_api_proxy.common.service import Application
|
||||
from nova_api_proxy.common.timestamp import get_monotonic_timestamp_in_ms
|
||||
from nova_api_proxy.common import histogram
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
||||
# Copyright (c) 2015-2018 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -8,7 +8,7 @@ import os
|
||||
from oslo_config import cfg
|
||||
from paste import deploy
|
||||
|
||||
from nova_api_proxy.common import log as logging
|
||||
from oslo_log import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2015 Wind River Systems, Inc.
|
||||
# Copyright (c) 2015-2018 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -7,7 +7,7 @@ import math
|
||||
import array
|
||||
import datetime
|
||||
|
||||
from nova_api_proxy.common import log as logging
|
||||
from oslo_log import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -1,64 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
import os
|
||||
import logging
|
||||
import inspect
|
||||
from oslo_config import cfg
|
||||
from logging.handlers import SysLogHandler
|
||||
|
||||
conf_opts = [
|
||||
cfg.BoolOpt('debug',
|
||||
default=False,
|
||||
help='Print debugging output (set logging level to '
|
||||
'DEBUG instead of default INFO level).'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(conf_opts)
|
||||
|
||||
|
||||
def _get_binary_name():
|
||||
return os.path.basename(inspect.stack()[-1][1])
|
||||
|
||||
|
||||
class ProxySysLogHandler(SysLogHandler):
|
||||
def __init__(self, app, *args, **kwargs):
|
||||
self.binary_name = _get_binary_name()
|
||||
self.app = app
|
||||
SysLogHandler.__init__(self, *args, **kwargs)
|
||||
|
||||
def format(self, record):
|
||||
msg = logging.handlers.SysLogHandler.format(self, record)
|
||||
return self.binary_name + '(' + self.app + ')' + ': ' + msg
|
||||
|
||||
|
||||
_loggers = {}
|
||||
|
||||
|
||||
def _set_log_level(logger, debug):
|
||||
if debug:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
else:
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
|
||||
def toggle_debug_log(debug):
|
||||
for k in _loggers.keys():
|
||||
_set_log_level(_loggers[k], debug)
|
||||
|
||||
|
||||
def getLogger(name='unknown'):
|
||||
if name not in _loggers:
|
||||
_loggers[name] = logging.getLogger(name)
|
||||
|
||||
_set_log_level(_loggers[name], CONF.debug)
|
||||
|
||||
syslog = ProxySysLogHandler(name, address='/dev/log',
|
||||
facility=SysLogHandler.LOG_LOCAL5)
|
||||
_loggers[name].addHandler(syslog)
|
||||
|
||||
return _loggers[name]
|
@ -11,12 +11,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Copyright (c) 2015-2016 Wind River Systems, Inc.
|
||||
# Copyright (c) 2015-2018 Wind River Systems, Inc.
|
||||
#
|
||||
|
||||
import errno
|
||||
import os
|
||||
import logging
|
||||
import eventlet
|
||||
import webob.dec
|
||||
import webob.exc
|
||||
@ -25,12 +24,12 @@ import eventlet.wsgi
|
||||
from eventlet.green import socket
|
||||
from eventlet.green import ssl
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from nova_api_proxy.common import log as proxy_log
|
||||
from nova_api_proxy.common.exception import ProxyException
|
||||
|
||||
|
||||
LOG = proxy_log.getLogger(__name__)
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
URL_LENGTH_LIMIT = 50000
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user