-
Notifications
You must be signed in to change notification settings - Fork 32
Closed
Description
If the event_dict contains a key that is also part of a dotted key the StructlogFormatter throws a TypeError.
Reproducible example:
from ecs_logging import StructlogFormatter
logs = {'event': 'RuntimeError', 'event.dataset': 'dev_setup.log'}
matter = StructlogFormatter()
matter("", "name", logs)Results in a TypeError
TypeError: 'str' object does not support item assignment
I think the problem is in this line.
def merge_dicts(from_, into):
"""Merge deeply nested dictionary structures.
When called has side-effects within 'destination'.
"""
for key, value in from_.items():
if isinstance(value, dict):
merge_dicts(value, into.setdefault(key, {})) <------
else:
into[key] = value
return intointo.setdefault() returns the value of the key if the key is already present in the dictionary. In the example above the value is a string which causes the TypeError.