From 67d676fe92f0c66bf96c62700caff7c5cb139f51 Mon Sep 17 00:00:00 2001 From: saffi Date: Sun, 29 Jan 2017 16:11:11 +0200 Subject: [PATCH] Fix side effect of record modified affecting the next in line handler. --- hoover/handlers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hoover/handlers.py b/hoover/handlers.py index 20b8b47..aa6fae7 100644 --- a/hoover/handlers.py +++ b/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: @@ -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)