Skip to content

Commit

Permalink
Merge 78ca92e into e670adb
Browse files Browse the repository at this point in the history
  • Loading branch information
gnulnx committed Jan 11, 2019
2 parents e670adb + 78ca92e commit 397ffaf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
17 changes: 13 additions & 4 deletions mongolog/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,23 @@ def check_keys(self, record):
return record

for k, v in record['msg'].items():
record['msg'][self.new_key(k)] = record['msg'].pop(k)
self._check_keys(k, v, record['msg'])

if isinstance(v, dict):
for old_key in record['msg'][k].keys():
record['msg'][k][self.new_key(old_key)] = record['msg'][k].pop(old_key)
# if isinstance(v, dict):
# for old_key in record['msg'][k].keys():
# record['msg'][k][self.new_key(old_key)] = record['msg'][k].pop(old_key)

return record

def _check_keys(self, k, v, _dict):
_dict[self.new_key(k)] = _dict.pop(k)

if isinstance(v, dict):
for nk, vk in v.items():
self._check_keys(nk, vk, v)
# for in _dict[k].items():
# _dict[k][self.new_key(old_key)] = _dict[k].pop(old_key)

def create_log_record(self, record):
"""
Convert the python LogRecord to a MongoLog Record.
Expand Down
10 changes: 9 additions & 1 deletion mongolog/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,15 @@ def test_dot_in_key(self):
self.logger.info({
'META': {
'user.name': 'jfurr',
'user$name': 'jfurr'
'user$name': 'jfurr',
'META2': {
'blah.blah': 'blah',
'blah$blah': 'blah',
'META3': {
'meta3.meta3': 'meta3',
'meta$meta': 'meta3',
}
}
},
'user.name': 'jfurr',
'user$name': 'jfurr'
Expand Down

0 comments on commit 397ffaf

Please sign in to comment.