From 5a60f32c5510610935af1549022b3f7948002721 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sat, 16 Jul 2016 09:23:52 +1200 Subject: [PATCH] Fix log level handling We have 4: error, warn, info and debug. --- mitmproxy/cmdline.py | 2 +- mitmproxy/console/palettes.py | 6 +++++- mitmproxy/controller.py | 5 +++++ mitmproxy/dump.py | 2 +- mitmproxy/flow/master.py | 5 ----- mitmproxy/flow/options.py | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/mitmproxy/cmdline.py b/mitmproxy/cmdline.py index 551fffa07..a29f58c66 100644 --- a/mitmproxy/cmdline.py +++ b/mitmproxy/cmdline.py @@ -284,7 +284,7 @@ def basic_options(parser): ) parser.add_argument( "-v", "--verbose", - action="store_const", dest="verbose", default=1, const=2, + action="store_const", dest="verbose", default=2, const=3, help="Increase event log verbosity." ) outfile = parser.add_mutually_exclusive_group() diff --git a/mitmproxy/console/palettes.py b/mitmproxy/console/palettes.py index 36cc3ac0a..2e12338f9 100644 --- a/mitmproxy/console/palettes.py +++ b/mitmproxy/console/palettes.py @@ -24,7 +24,7 @@ class Palette: # List and Connections 'method', 'focus', 'code_200', 'code_300', 'code_400', 'code_500', 'code_other', - 'error', + 'error', "warn", 'header', 'highlight', 'intercept', 'replay', 'mark', # Hex view @@ -100,6 +100,7 @@ class LowDark(Palette): code_500 = ('light red', 'default'), code_other = ('dark red', 'default'), + warn = ('brown', 'default'), error = ('light red', 'default'), header = ('dark cyan', 'default'), @@ -166,6 +167,7 @@ class LowLight(Palette): code_other = ('light red', 'default'), error = ('light red', 'default'), + warn = ('brown', 'default'), header = ('dark blue', 'default'), highlight = ('black,bold', 'default'), @@ -250,6 +252,7 @@ class SolarizedLight(LowLight): code_other = (sol_magenta, 'default'), error = (sol_red, 'default'), + warn = (sol_orange, 'default'), header = (sol_blue, 'default'), highlight = (sol_base01, 'default'), @@ -299,6 +302,7 @@ class SolarizedDark(LowDark): code_other = (sol_magenta, 'default'), error = (sol_red, 'default'), + warn = (sol_orange, 'default'), header = (sol_blue, 'default'), highlight = (sol_base01, 'default'), diff --git a/mitmproxy/controller.py b/mitmproxy/controller.py index 503cdcd3c..129691bb1 100644 --- a/mitmproxy/controller.py +++ b/mitmproxy/controller.py @@ -89,6 +89,11 @@ class Master(object): mitmproxy_ctx.master = None mitmproxy_ctx.log = None + def add_event(self, e, level="info"): + """ + level: debug, info, warn, error + """ + def add_server(self, server): # We give a Channel to the server which can be used to communicate with the master channel = Channel(self.event_queue, self.should_exit) diff --git a/mitmproxy/dump.py b/mitmproxy/dump.py index 999a709ae..6a9bb951c 100644 --- a/mitmproxy/dump.py +++ b/mitmproxy/dump.py @@ -114,7 +114,7 @@ class DumpMaster(flow.FlowMaster): raise DumpError(str(e)) def add_event(self, e, level="info"): - needed = dict(error=0, info=1, debug=2).get(level, 1) + needed = dict(error=0, warn=1, info=2, debug=3).get(level, 2) if self.options.verbosity >= needed: self.echo( e, diff --git a/mitmproxy/flow/master.py b/mitmproxy/flow/master.py index aa09e1097..fe51c6041 100644 --- a/mitmproxy/flow/master.py +++ b/mitmproxy/flow/master.py @@ -52,11 +52,6 @@ class FlowMaster(controller.Master): port ) - def add_event(self, e, level="info"): - """ - level: debug, info, error - """ - def get_ignore_filter(self): return self.server.config.check_ignore.patterns diff --git a/mitmproxy/flow/options.py b/mitmproxy/flow/options.py index eccba5b13..6c2e39336 100644 --- a/mitmproxy/flow/options.py +++ b/mitmproxy/flow/options.py @@ -30,7 +30,7 @@ class Options(options.Options): stickycookie=None, # type: Optional[str] stickyauth=None, # type: Optional[str] stream_large_bodies=None, # type: Optional[str] - verbosity=1, # type: int + verbosity=2, # type: int outfile=None, # type: Tuple[str, str] replay_ignore_content=False, # type: bool replay_ignore_params=(), # type: Sequence[str]