Merge "Ensure log-level config option is applied consistently."
This commit is contained in:
commit
86f3adbc62
@ -254,5 +254,13 @@ class KeystoneLoggingContext(context.OSContextGenerator):
|
||||
debug = config('debug')
|
||||
if debug:
|
||||
ctxt['root_level'] = 'DEBUG'
|
||||
log_level = config('log-level')
|
||||
log_level_accepted_params = ['WARNING', 'INFO', 'DEBUG', 'ERROR']
|
||||
if log_level in log_level_accepted_params:
|
||||
ctxt['log_level'] = config('log-level')
|
||||
else:
|
||||
log("log-level must be one of the following states "
|
||||
"(WARNING, INFO, DEBUG, ERROR) keeping the current state.")
|
||||
ctxt['log_level'] = None
|
||||
|
||||
return ctxt
|
||||
|
@ -1,3 +1,4 @@
|
||||
# icehouse
|
||||
[loggers]
|
||||
keys=root
|
||||
|
||||
@ -17,7 +18,11 @@ handlers=file
|
||||
|
||||
[handler_production]
|
||||
class=handlers.SysLogHandler
|
||||
{% if log_level -%}
|
||||
level={{ log_level }}
|
||||
{% else -%}
|
||||
level=ERROR
|
||||
{% endif -%}
|
||||
formatter=normal_with_name
|
||||
args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
|
||||
|
||||
|
@ -18,7 +18,11 @@ handlers=file
|
||||
|
||||
[handler_production]
|
||||
class=handlers.SysLogHandler
|
||||
{% if log_level -%}
|
||||
level={{ log_level }}
|
||||
{% else -%}
|
||||
level=ERROR
|
||||
{% endif -%}
|
||||
formatter=normal_with_name
|
||||
args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
|
||||
|
||||
|
@ -167,7 +167,4 @@ class TestKeystoneContexts(CharmTestCase):
|
||||
ctxt = context.KeystoneLoggingContext()
|
||||
|
||||
mock_config.return_value = None
|
||||
self.assertEqual({}, ctxt())
|
||||
|
||||
mock_config.return_value = 'True'
|
||||
self.assertEqual({'root_level': 'DEBUG'}, ctxt())
|
||||
self.assertEqual({'log_level': None}, ctxt())
|
||||
|
Loading…
x
Reference in New Issue
Block a user