Ability to customize default_log_levels for each project
Add a new parameter default_log_levels to log.set_defaults. We need to default its value to None since this is a backwards incompatible change otherwise. However, if someone is not setting a specific value, we do need to set the usual default levels exposed DEFAULT_LOG_LEVELS public variable so others can use the default log levels to construct their custom defaults. Change-Id: I49a82c5b3446784d254ca558f51b6c3e5c2028eb Closes-Bug: #1297950
This commit is contained in:
@@ -120,6 +120,12 @@ generic_log_opts = [
|
||||
help='Log output to standard error.')
|
||||
]
|
||||
|
||||
DEFAULT_LOG_LEVELS = ['amqp=WARN', 'amqplib=WARN', 'boto=WARN',
|
||||
'qpid=WARN', 'sqlalchemy=WARN', 'suds=INFO',
|
||||
'oslo.messaging=INFO', 'iso8601=WARN',
|
||||
'requests.packages.urllib3.connectionpool=WARN',
|
||||
'urllib3.connectionpool=WARN']
|
||||
|
||||
log_opts = [
|
||||
cfg.StrOpt('logging_context_format_string',
|
||||
default='%(asctime)s.%(msecs)03d %(process)d %(levelname)s '
|
||||
@@ -138,18 +144,7 @@ log_opts = [
|
||||
'%(instance)s',
|
||||
help='Prefix each line of exception output with this format.'),
|
||||
cfg.ListOpt('default_log_levels',
|
||||
default=[
|
||||
'amqp=WARN',
|
||||
'amqplib=WARN',
|
||||
'boto=WARN',
|
||||
'qpid=WARN',
|
||||
'sqlalchemy=WARN',
|
||||
'suds=INFO',
|
||||
'oslo.messaging=INFO',
|
||||
'iso8601=WARN',
|
||||
'requests.packages.urllib3.connectionpool=WARN',
|
||||
'urllib3.connectionpool=WARN'
|
||||
],
|
||||
default=DEFAULT_LOG_LEVELS,
|
||||
help='List of logger=LEVEL pairs.'),
|
||||
cfg.BoolOpt('publish_errors',
|
||||
default=False,
|
||||
@@ -410,9 +405,18 @@ def setup(product_name, version='unknown'):
|
||||
sys.excepthook = _create_logging_excepthook(product_name)
|
||||
|
||||
|
||||
def set_defaults(logging_context_format_string):
|
||||
def set_defaults(logging_context_format_string,
|
||||
default_log_levels=None):
|
||||
# Just in case the caller is not setting the
|
||||
# default_log_level. This is insurance because
|
||||
# we introduced the default_log_level parameter
|
||||
# later in a backwards in-compatible change
|
||||
if default_log_levels is None:
|
||||
default_log_levels = DEFAULT_LOG_LEVELS
|
||||
cfg.set_defaults(
|
||||
log_opts, logging_context_format_string=logging_context_format_string)
|
||||
log_opts,
|
||||
logging_context_format_string=logging_context_format_string,
|
||||
default_log_levels=default_log_levels)
|
||||
|
||||
|
||||
def _find_facility_from_conf():
|
||||
|
||||
Reference in New Issue
Block a user