Skip to content

Commit

Permalink
changes to mongolog/handlers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
John Furr authored and John Furr committed Dec 6, 2015
1 parent ebe6e93 commit 8a41064
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mongolog/handlers.py
Expand Up @@ -50,23 +50,22 @@ def __init__(self, level=NOTSET, connection=None, w=1, j=False, verbose=None, ti
# Used to determine which time setting is used in the simple record_type
self.time_zone = time_zone

# If True will print each log_record to console before logging to mongo
# Useful for debugging since "func" will provides name of test method.
# If True will print each log_record to console before writing to mongo
self.verbose = verbose

if not self.connection:
print("'connection' key not provided in logging config")
print("Will try to connect with default")

# Set a defaul connection key
self.connection = 'mongodb://localhost:27017/'
self.connection = u'mongodb://localhost:27017/'

self.connect()

return super(BaseMongoLogHandler, self).__init__(level)

def __unicode__(self):
return self.connection
return u'%s' % self.connection

def __str__(self):
return self.__unicode__()
Expand Down Expand Up @@ -109,7 +108,8 @@ def get_collection(self):

def create_log_record(self, record):
"""
Override in subclasses to change log record formatting.
See SimpleMongoLogHandler and VerboseMongoLogHandler
"""
return LogRecord(json.loads(json.dumps(record.__dict__, default=str)))

Expand Down

0 comments on commit 8a41064

Please sign in to comment.