diff options
author | Aldo Cortesi <aldo@corte.si> | 2016-07-16 11:46:01 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-16 11:46:01 +1200 |
commit | 50c76ac4ff4dbc8442f60d5887ffbff5f96ecf20 (patch) | |
tree | a4ec369f03b6fbd66b3363a93b6fec62cd7b0da1 /mitmproxy/dump.py | |
parent | c4fb489a96c58932609cced96d5b0d3c2687f15f (diff) | |
parent | 50f1495f29adee2d3eda011693518ca5ba938037 (diff) | |
download | mitmproxy-50c76ac4ff4dbc8442f60d5887ffbff5f96ecf20.tar.gz mitmproxy-50c76ac4ff4dbc8442f60d5887ffbff5f96ecf20.tar.bz2 mitmproxy-50c76ac4ff4dbc8442f60d5887ffbff5f96ecf20.zip |
Merge pull request #1362 from cortesi/errors
Some work on errors and logs
Diffstat (limited to 'mitmproxy/dump.py')
-rw-r--r-- | mitmproxy/dump.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/mitmproxy/dump.py b/mitmproxy/dump.py index 999a709a..18c24d61 100644 --- a/mitmproxy/dump.py +++ b/mitmproxy/dump.py @@ -15,6 +15,7 @@ from mitmproxy import exceptions from mitmproxy import filt from mitmproxy import flow from mitmproxy import builtins +from mitmproxy import utils from netlib import human from netlib import tcp from netlib import strutils @@ -44,6 +45,7 @@ class DumpMaster(flow.FlowMaster): def __init__(self, server, options): flow.FlowMaster.__init__(self, options, server, flow.State()) + self.has_errored = False self.addons.add(*builtins.default_addons()) # This line is just for type hinting self.options = self.options # type: Options @@ -97,7 +99,7 @@ class DumpMaster(flow.FlowMaster): try: self.load_flows_file(options.rfile) except exceptions.FlowReadException as v: - self.add_event("Flow file corrupted.", "error") + self.add_log("Flow file corrupted.", "error") raise DumpError(v) if self.options.app: @@ -113,9 +115,10 @@ class DumpMaster(flow.FlowMaster): except exceptions.FlowReadException as e: raise DumpError(str(e)) - def add_event(self, e, level="info"): - needed = dict(error=0, info=1, debug=2).get(level, 1) - if self.options.verbosity >= needed: + def add_log(self, e, level="info"): + if level == "error": + self.has_errored = True + if self.options.verbosity >= utils.log_tier(level): self.echo( e, fg="red" if level == "error" else None, @@ -157,7 +160,7 @@ class DumpMaster(flow.FlowMaster): ) except exceptions.ContentViewException: s = "Content viewer failed: \n" + traceback.format_exc() - self.add_event(s, "debug") + self.add_log(s, "debug") type, lines = contentviews.get_content_view( contentviews.get("Raw"), message.content, |