diff options
author | lufte <javierayres@gmail.com> | 2018-08-17 00:59:14 -0300 |
---|---|---|
committer | Jay Kamat <jaygkamat@gmail.com> | 2018-08-18 13:45:59 -0700 |
commit | ed52384a19ac607dd2e5c85943fe184c7c83f0f2 (patch) | |
tree | 4c02bc2b23ade4c493614896a93225ef4cc06e2a | |
parent | 35ec43a181cba6c896d891e55c1a9b832d6b295b (diff) | |
download | qutebrowser-ed52384a19ac607dd2e5c85943fe184c7c83f0f2.tar.gz qutebrowser-ed52384a19ac607dd2e5c85943fe184c7c83f0f2.zip |
Perform attribute updates on a record's clone
(cherry picked from commit 68b9dff74733278fb8095215db3bd5f00fa3aa50)
-rw-r--r-- | qutebrowser/utils/log.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index 48711614d..ef8aa2ae5 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -25,6 +25,7 @@ import html as pyhtml import logging import contextlib import collections +import copy import faulthandler import traceback import warnings @@ -637,17 +638,18 @@ class HTMLFormatter(logging.Formatter): self._colordict['reset'] = '</font>' def format(self, record): - record.__dict__.update(self._colordict) - if record.levelname in self._log_colors: - color = self._log_colors[record.levelname] - record.log_color = self._colordict[color] + record_clone = copy.copy(record) + record_clone.__dict__.update(self._colordict) + if record_clone.levelname in self._log_colors: + color = self._log_colors[record_clone.levelname] + record_clone.log_color = self._colordict[color] else: - record.log_color = '' + record_clone.log_color = '' for field in ['msg', 'filename', 'funcName', 'levelname', 'module', 'name', 'pathname', 'processName', 'threadName']: - data = str(getattr(record, field)) - setattr(record, field, pyhtml.escape(data)) - msg = super().format(record) + data = str(getattr(record_clone, field)) + setattr(record_clone, field, pyhtml.escape(data)) + msg = super().format(record_clone) if not msg.endswith(self._colordict['reset']): msg += self._colordict['reset'] return msg |