Merge "Ensure log-level config option is applied consistently."

This commit is contained in:
Jenkins 2016-03-10 11:22:19 +00:00 committed by Gerrit Code Review
commit 86f3adbc62
4 changed files with 18 additions and 4 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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())