aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simple
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2018-05-08 11:23:52 +1200
committerAldo Cortesi <aldo@nullcube.com>2018-05-08 14:26:41 +1200
commitaf1a4ffdcd4c98afefd4228bbc2bc276cfd8436f (patch)
treedacb5e2dae27aabb550b93b181cac0197072707e /examples/simple
parent717fbaa99076545d11f554187759005dce1aa67b (diff)
downloadmitmproxy-af1a4ffdcd4c98afefd4228bbc2bc276cfd8436f.tar.gz
mitmproxy-af1a4ffdcd4c98afefd4228bbc2bc276cfd8436f.tar.bz2
mitmproxy-af1a4ffdcd4c98afefd4228bbc2bc276cfd8436f.zip
Ditch the addon stdout wrapper
This results in a 30% improvement in our core request throughput. Fixes #3102
Diffstat (limited to 'examples/simple')
-rw-r--r--examples/simple/filter_flows.py4
-rw-r--r--examples/simple/log_events.py5
2 files changed, 3 insertions, 6 deletions
diff --git a/examples/simple/filter_flows.py b/examples/simple/filter_flows.py
index d252089c..aba240de 100644
--- a/examples/simple/filter_flows.py
+++ b/examples/simple/filter_flows.py
@@ -19,8 +19,8 @@ class Filter:
def response(self, flow: http.HTTPFlow) -> None:
if flowfilter.match(self.filter, flow):
- print("Flow matches filter:")
- print(flow)
+ ctx.log.info("Flow matches filter:")
+ ctx.log.info(flow)
addons = [Filter()]
diff --git a/examples/simple/log_events.py b/examples/simple/log_events.py
index b9aa2c1f..4f70e340 100644
--- a/examples/simple/log_events.py
+++ b/examples/simple/log_events.py
@@ -1,10 +1,7 @@
-"""
-It is recommended to use `ctx.log` for logging within a script.
-print() statements are equivalent to ctx.log.warn().
-"""
from mitmproxy import ctx
def load(l):
ctx.log.info("This is some informative text.")
+ ctx.log.warn("This is a warning.")
ctx.log.error("This is an error.")