Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix side effect of record modified affecting the next in line handler. #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions hoover/handlers.py
@@ -1,6 +1,9 @@
'''A couple of logging handlers which should play nicely with the Python
logging library.'''
import sys, logging, socket

import copy

try:
from simplejson import dumps
except ImportError:
Expand Down Expand Up @@ -37,6 +40,8 @@ def __init__(self, session=None, token='', inputname='', input=None,

def emit(self, record):
if isinstance(record.msg, (list, dict)):
# prevent sideffect for other handlers processing the same record.
record = copy.copy(record)
record.msg = dumps(record.msg, cls=self.json_class, default=str)
msg = self.format(record)
async_post_to_endpoint(self.endpoint, msg)
Expand Down