Skip to content

Commit

Permalink
Reimplement older key support
Browse files Browse the repository at this point in the history
  • Loading branch information
jfurr authored and jfurr committed Jan 12, 2019
1 parent 6faede5 commit 870af44
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mongolog/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,16 @@ def new_key(self, key):
As of mongo 3.6 . and $ are permitted in keys. But keys may not start with $
If we encounter a key that starts with a $ we replace it with it's unicode equivalent.
"""
if key[0] == "$":
key = u"$" + key[1:]
if pymongo_version >= 3:
if key[0] == "$":
key = u"$" + key[1:]
else:
# Older mongo doesn't support $ or . in keys
if "." in key:
key = key.replace(u".", u".")
elif "$" in key:
key = key.replace(u"$", u"$")

return key

def create_log_record(self, record):
Expand Down

0 comments on commit 870af44

Please sign in to comment.