mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Add a helper to translate a log level to a tier
This is in utils for now - we'll find a better home down the track.
This commit is contained in:
parent
91e9016ce5
commit
49b65d2ea4
@ -22,6 +22,7 @@ from mitmproxy import controller
|
|||||||
from mitmproxy import exceptions
|
from mitmproxy import exceptions
|
||||||
from mitmproxy import flow
|
from mitmproxy import flow
|
||||||
from mitmproxy import script
|
from mitmproxy import script
|
||||||
|
from mitmproxy import utils
|
||||||
from mitmproxy.console import flowlist
|
from mitmproxy.console import flowlist
|
||||||
from mitmproxy.console import flowview
|
from mitmproxy.console import flowview
|
||||||
from mitmproxy.console import grideditor
|
from mitmproxy.console import grideditor
|
||||||
@ -271,8 +272,7 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
return super(ConsoleMaster, self).load_script(command, use_reloader)
|
return super(ConsoleMaster, self).load_script(command, use_reloader)
|
||||||
|
|
||||||
def sig_add_log(self, sender, e, level):
|
def sig_add_log(self, sender, e, level):
|
||||||
needed = dict(error=0, warn=1, info=2, debug=3).get(level, 2)
|
if self.options.verbosity < utils.log_tier(level):
|
||||||
if self.options.verbosity < needed:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if level == "error":
|
if level == "error":
|
||||||
|
@ -15,6 +15,7 @@ from mitmproxy import exceptions
|
|||||||
from mitmproxy import filt
|
from mitmproxy import filt
|
||||||
from mitmproxy import flow
|
from mitmproxy import flow
|
||||||
from mitmproxy import builtins
|
from mitmproxy import builtins
|
||||||
|
from mitmproxy import utils
|
||||||
from netlib import human
|
from netlib import human
|
||||||
from netlib import tcp
|
from netlib import tcp
|
||||||
from netlib import strutils
|
from netlib import strutils
|
||||||
@ -114,8 +115,7 @@ class DumpMaster(flow.FlowMaster):
|
|||||||
raise DumpError(str(e))
|
raise DumpError(str(e))
|
||||||
|
|
||||||
def add_log(self, e, level="info"):
|
def add_log(self, e, level="info"):
|
||||||
needed = dict(error=0, warn=1, info=2, debug=3).get(level, 2)
|
if self.options.verbosity >= utils.log_tier(level):
|
||||||
if self.options.verbosity >= needed:
|
|
||||||
self.echo(
|
self.echo(
|
||||||
e,
|
e,
|
||||||
fg="red" if level == "error" else None,
|
fg="red" if level == "error" else None,
|
||||||
|
@ -36,3 +36,7 @@ class LRUCache:
|
|||||||
d = self.cacheList.pop()
|
d = self.cacheList.pop()
|
||||||
self.cache.pop(d)
|
self.cache.pop(d)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
def log_tier(level):
|
||||||
|
return dict(error=0, warn=1, info=2, debug=3).get(level)
|
||||||
|
Loading…
Reference in New Issue
Block a user