Move log.setup to Bootstrap and use cfg.CONF opts
This patch uses cfg.CONF as ConfigOpts in common/config instead of creating a new instance of it. This is needed since most of Oslo's modules use the global CONF object to register their config parameters. The patch also moves log.setup call into Bootstrap and calls it after configs are loaded. Fixes bug: #1190524 Change-Id: Ib601418a7dbcad84c79b640b93bc5798ec4a62c4
This commit is contained in:
parent
2326efcd54
commit
8fa310cc7a
@ -1,45 +1,37 @@
|
||||
; Loaded via logging.config.fileConfig
|
||||
; @todo Customize for Marconi loggers
|
||||
|
||||
[loggers]
|
||||
keys=root
|
||||
keys=root,server,combined
|
||||
|
||||
[formatters]
|
||||
keys=normal,normal_with_name,debug
|
||||
|
||||
[handlers]
|
||||
keys=production,file,devel
|
||||
|
||||
[formatters]
|
||||
keys=minimal,normal,debug
|
||||
|
||||
|
||||
###########
|
||||
# Loggers #
|
||||
###########
|
||||
|
||||
[logger_root]
|
||||
level=WARNING
|
||||
handlers=file
|
||||
level=NOTSET
|
||||
handlers=devel
|
||||
|
||||
[logger_access]
|
||||
level=INFO
|
||||
qualname=access
|
||||
handlers=access_file
|
||||
[logger_server]
|
||||
level=DEBUG
|
||||
handlers=devel
|
||||
qualname=marconi-server
|
||||
|
||||
|
||||
################
|
||||
# Log Handlers #
|
||||
################
|
||||
[logger_combined]
|
||||
level=DEBUG
|
||||
handlers=devel
|
||||
qualname=marconi-combined
|
||||
|
||||
[handler_production]
|
||||
class=handlers.SysLogHandler
|
||||
level=ERROR
|
||||
formatter=normal
|
||||
formatter=normal_with_name
|
||||
args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
|
||||
|
||||
[handler_file]
|
||||
class=handlers.WatchedFileHandler
|
||||
level=WARNING
|
||||
formatter=normal
|
||||
args=('error.log',)
|
||||
class=FileHandler
|
||||
level=DEBUG
|
||||
formatter=normal_with_name
|
||||
args=('marconi.log', 'w')
|
||||
|
||||
[handler_devel]
|
||||
class=StreamHandler
|
||||
@ -47,16 +39,11 @@ level=NOTSET
|
||||
formatter=debug
|
||||
args=(sys.stdout,)
|
||||
|
||||
|
||||
##################
|
||||
# Log Formatters #
|
||||
##################
|
||||
|
||||
[formatter_minimal]
|
||||
format=%(message)s
|
||||
|
||||
[formatter_normal]
|
||||
format=%(asctime)s %(levelname)s %(message)s
|
||||
|
||||
[formatter_normal_with_name]
|
||||
format=(%(name)s): %(asctime)s %(levelname)s %(message)s
|
||||
|
||||
[formatter_debug]
|
||||
format=(%(name)s): %(asctime)s %(levelname)s %(module)s %(funcName)s %(message)s
|
||||
format=(%(name)s): %(asctime)s %(levelname)s %(module)s %(funcName)s %(message)s
|
||||
|
@ -1,7 +1,24 @@
|
||||
[DEFAULT]
|
||||
; debug = False
|
||||
; verbose = False
|
||||
; auth_strategy =
|
||||
# Show more verbose log output (sets INFO log level output)
|
||||
#verbose = False
|
||||
|
||||
# Show debugging output in logs (sets DEBUG log level output)
|
||||
#debug = False
|
||||
|
||||
# Log to this file!
|
||||
log_file = /var/log/marconi/server.log
|
||||
|
||||
; auth_strategy =
|
||||
|
||||
# ================= Syslog Options ============================
|
||||
|
||||
# Send logs to syslog (/dev/log) instead of to file specified
|
||||
# by `log_file`
|
||||
#use_syslog = False
|
||||
|
||||
# Facility to use. If unset defaults to LOG_USER.
|
||||
#syslog_log_facility = LOG_LOCAL0
|
||||
|
||||
|
||||
[drivers]
|
||||
# Transport driver module (e.g., marconi.transport.wsgi, marconi.transport.zmq)
|
||||
|
@ -17,6 +17,7 @@ from marconi.common import config
|
||||
from marconi.common import decorators
|
||||
from marconi.common import exceptions
|
||||
from marconi.openstack.common import importutils
|
||||
from marconi.openstack.common import log
|
||||
from marconi import transport # NOQA.
|
||||
|
||||
|
||||
@ -25,6 +26,8 @@ cfg = config.namespace('drivers').from_options(
|
||||
transport='marconi.transport.wsgi',
|
||||
storage='marconi.storage.sqlite')
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class Bootstrap(object):
|
||||
"""Defines the Marconi bootstrapper.
|
||||
@ -35,14 +38,19 @@ class Bootstrap(object):
|
||||
|
||||
def __init__(self, config_file=None, cli_args=None):
|
||||
cfg_handle.load(filename=config_file, args=cli_args)
|
||||
log.setup("marconi")
|
||||
|
||||
@decorators.lazy_property(write=False)
|
||||
def storage(self):
|
||||
msg = _("Loading Storage Driver")
|
||||
LOG.debug(msg)
|
||||
storage_module = import_driver(cfg.storage)
|
||||
return storage_module.Driver()
|
||||
|
||||
@decorators.lazy_property(write=False)
|
||||
def transport(self):
|
||||
msg = _("Loading Transport Driver")
|
||||
LOG.debug(msg)
|
||||
transport_module = import_driver(cfg.transport)
|
||||
return transport_module.Driver(self.storage)
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
import sys
|
||||
|
||||
from marconi import bootstrap
|
||||
from marconi.openstack.common import log
|
||||
|
||||
|
||||
def fail(returncode, e):
|
||||
@ -26,7 +25,6 @@ def fail(returncode, e):
|
||||
|
||||
def run():
|
||||
try:
|
||||
log.setup('marconi')
|
||||
server = bootstrap.Bootstrap(cli_args=sys.argv[1:])
|
||||
server.run()
|
||||
except KeyboardInterrupt:
|
||||
|
@ -71,7 +71,7 @@ def _init():
|
||||
__getattr__ = dict.__getitem__
|
||||
__setattr__ = dict.__setitem__
|
||||
|
||||
conf = cfg.ConfigOpts()
|
||||
conf = cfg.CONF
|
||||
|
||||
def namespace(name, title=None):
|
||||
"""Create a config namespace.
|
||||
|
Loading…
Reference in New Issue
Block a user