mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #30726 from sjmh/fix/log4mongo
Fix improper use of yield in generator
This commit is contained in:
commit
ce3be26e8f
@ -69,33 +69,32 @@ class FormatterWithHost(logging.Formatter, NewStyleClassMixIn):
|
|||||||
|
|
||||||
def setup_handlers():
|
def setup_handlers():
|
||||||
handler_id = 'log4mongo_handler'
|
handler_id = 'log4mongo_handler'
|
||||||
if handler_id not in __opts__:
|
if handler_id in __opts__:
|
||||||
yield False
|
config_fields = {
|
||||||
|
'host': 'host',
|
||||||
|
'port': 'port',
|
||||||
|
'database_name': 'database_name',
|
||||||
|
'collection': 'collection',
|
||||||
|
'username': 'username',
|
||||||
|
'password': 'password',
|
||||||
|
'write_concern': 'w'
|
||||||
|
}
|
||||||
|
|
||||||
config_fields = {
|
config_opts = {}
|
||||||
'host': 'host',
|
for config_opt, arg_name in config_fields.iteritems():
|
||||||
'port': 'port',
|
config_opts[arg_name] = __opts__[handler_id].get(config_opt)
|
||||||
'database_name': 'database_name',
|
|
||||||
'collection': 'collection',
|
|
||||||
'username': 'username',
|
|
||||||
'password': 'password',
|
|
||||||
'write_concern': 'w'
|
|
||||||
}
|
|
||||||
|
|
||||||
config_opts = {}
|
config_opts['level'] = LOG_LEVELS[
|
||||||
for config_opt, arg_name in config_fields.iteritems():
|
__opts__[handler_id].get(
|
||||||
config_opts[arg_name] = __opts__[handler_id].get(config_opt)
|
'log_level',
|
||||||
|
__opts__.get('log_level', 'error')
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
config_opts['level'] = LOG_LEVELS[
|
handler = MongoHandler(
|
||||||
__opts__[handler_id].get(
|
formatter=FormatterWithHost(),
|
||||||
'log_level',
|
**config_opts
|
||||||
__opts__.get('log_level', 'error')
|
|
||||||
)
|
)
|
||||||
]
|
yield handler
|
||||||
|
else:
|
||||||
handler = MongoHandler(
|
yield False
|
||||||
formatter=FormatterWithHost(),
|
|
||||||
**config_opts
|
|
||||||
)
|
|
||||||
|
|
||||||
yield handler
|
|
||||||
|
Loading…
Reference in New Issue
Block a user