Fix ColoredFormatted: Colored record could affect other formatters.
--- a/pycolib/coloredformatter.py Mon Aug 19 14:18:26 2013 +0200
+++ b/pycolib/coloredformatter.py Mon Aug 19 16:32:33 2013 +0200
@@ -35,7 +35,8 @@
def format(self, record):
"""Override, add color as specified."""
- original_record = copy(record)
+ # work on copy, do not alter original record, which is processed by other formatters too
+ record = copy(record)
### message color
fg, bg = self.get_color('message', record)
@@ -47,10 +48,7 @@
if fg or bg:
record.levelname = highlight(1, fg, bg) + record.levelname + highlight(0)
- res = logging.Formatter.format(self, record)
-
- record = original_record
- return res
+ return logging.Formatter.format(self, record)
def set_color(self, fieldname, levelname, fg=None, bg=None):