Skip to content

Commit 9bd1cf4

Browse files
#1 fix record attribute changed when used.
1 parent fd02b0a commit 9bd1cf4

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

jsonformatter/jsonformatter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ def formatMessage(self, record):
184184
def format(self, record):
185185
result = dictionary()
186186

187+
# store origin attributes
187188
_msg, _args = record.msg, record.args
188189
record.msg, record.args = '', tuple()
189190

@@ -198,6 +199,7 @@ def format(self, record):
198199
self._style._fmt = v
199200
result[k] = getattr(record, v, None) if v in record.__dict__ else self.formatMessage(record)
200201
self._style._fmt = ''
202+
# apply origin attributes
203+
record.msg, record.args = _msg, _args
201204

202205
return json.dumps(result, skipkeys=self.skipkeys, ensure_ascii=self.ensure_ascii, check_circular=self.check_circular, allow_nan=self.allow_nan, cls=self.cls, indent=self.indent, separators=self.separators, default=self.default, sort_keys=self.sort_keys, **self.kw)
203-

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
setup(
1515
name='jsonformatter',
16-
version='0.1.2',
16+
version='0.1.3',
1717
description=(
1818
'Python log in json format.'
1919
),
@@ -36,4 +36,3 @@
3636
license='BSD License',
3737
packages=['jsonformatter']
3838
)
39-

0 commit comments

Comments
 (0)