diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2018-04-04 07:28:43 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2018-04-07 09:02:10 +1200 |
commit | 80f2bac356dd8abc50a28e4c8d9951a60979d168 (patch) | |
tree | 1d60ebbf513b256bac0049253b6dd942c8bd9947 /mitmproxy/log.py | |
parent | 0fa1280daa94729defa8411d86266bd2b52ad0b6 (diff) | |
download | mitmproxy-80f2bac356dd8abc50a28e4c8d9951a60979d168.tar.gz mitmproxy-80f2bac356dd8abc50a28e4c8d9951a60979d168.tar.bz2 mitmproxy-80f2bac356dd8abc50a28e4c8d9951a60979d168.zip |
asyncio: move log mechanism onto the event loop
Logs are now asynchronous, with a log entry pushed onto the event loop for
handling. To support this, the test mechanism grows an await_log method that
waits for a log entry to appear.
Diffstat (limited to 'mitmproxy/log.py')
-rw-r--r-- | mitmproxy/log.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mitmproxy/log.py b/mitmproxy/log.py index d2988011..30dbb473 100644 --- a/mitmproxy/log.py +++ b/mitmproxy/log.py @@ -1,3 +1,5 @@ +import asyncio + class LogEntry: def __init__(self, msg, level): @@ -54,7 +56,9 @@ class Log: self(txt, "error") def __call__(self, text, level="info"): - self.master.add_log(text, level) + asyncio.get_event_loop().call_soon( + self.master.addons.trigger, "log", LogEntry(text, level) + ) LogTierOrder = [ |