mirror of
https://github.com/vee1e/mitmproxy.git
synced 2026-09-01 18:27:18 +00:00
logging: don't pick up later mutations
This commit is contained in:
parent
d6975e0b80
commit
2fe4a49d8f
2 changed files with 10 additions and 1 deletions
|
|
@ -6,7 +6,9 @@ from mitmproxy import hooks
|
|||
|
||||
class LogEntry:
|
||||
def __init__(self, msg, level):
|
||||
self.msg = msg
|
||||
# it's important that we serialize to string here already so that we don't pick up changes
|
||||
# happening after this log statement.
|
||||
self.msg = str(msg)
|
||||
self.level = level
|
||||
|
||||
def __eq__(self, other):
|
||||
|
|
|
|||
|
|
@ -9,3 +9,10 @@ def test_logentry():
|
|||
assert e == e
|
||||
assert e != f
|
||||
assert e != 42
|
||||
|
||||
|
||||
def test_dont_pick_up_mutations():
|
||||
x = {"foo": "bar"}
|
||||
e = log.LogEntry(x, "info")
|
||||
x["foo"] = "baz" # this should not affect the log entry anymore.
|
||||
assert repr(e) == "LogEntry({'foo': 'bar'}, info)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue