mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Improve verbosity options.
This commit is contained in:
parent
35d16a4bca
commit
ad04f4ea68
@ -20,7 +20,7 @@ class TermLog:
|
||||
else:
|
||||
outfile = self.outfile or realstdout
|
||||
|
||||
if ctx.options.verbosity >= log.log_tier(e.level):
|
||||
if log.log_tier(ctx.options.verbosity) >= log.log_tier(e.level):
|
||||
click.secho(
|
||||
e.msg,
|
||||
file=outfile,
|
||||
|
@ -27,6 +27,14 @@ console_layouts = [
|
||||
"horizontal",
|
||||
]
|
||||
|
||||
log_verbosity = [
|
||||
"error",
|
||||
"warn",
|
||||
"info",
|
||||
"alert",
|
||||
"debug",
|
||||
]
|
||||
|
||||
APP_HOST = "mitm.it"
|
||||
APP_PORT = 80
|
||||
CA_DIR = "~/.mitmproxy"
|
||||
@ -162,8 +170,9 @@ class Options(optmanager.OptManager):
|
||||
"""
|
||||
)
|
||||
self.add_option(
|
||||
"verbosity", int, 2,
|
||||
"Log verbosity."
|
||||
"verbosity", str, 'info',
|
||||
"Log verbosity.",
|
||||
choices=log_verbosity
|
||||
)
|
||||
self.add_option(
|
||||
"default_contentview", str, "auto",
|
||||
|
@ -1,6 +1,8 @@
|
||||
import urwid
|
||||
from mitmproxy.tools.console import signals
|
||||
from mitmproxy.tools.console import layoutwidget
|
||||
from mitmproxy import ctx
|
||||
from mitmproxy import log
|
||||
|
||||
EVENTLOG_SIZE = 10000
|
||||
|
||||
@ -32,6 +34,8 @@ class EventLog(urwid.ListBox, layoutwidget.LayoutWidget):
|
||||
return urwid.ListBox.keypress(self, size, key)
|
||||
|
||||
def sig_add_log(self, sender, e, level):
|
||||
if log.log_tier(ctx.options.verbosity) < log.log_tier(level):
|
||||
return
|
||||
txt = "%s: %s" % (level, str(e))
|
||||
if level in ("error", "warn"):
|
||||
e = urwid.Text((level, txt))
|
||||
|
@ -87,7 +87,7 @@ class ConsoleMaster(master.Master):
|
||||
)
|
||||
|
||||
def sig_add_log(self, sender, e, level):
|
||||
if self.options.verbosity < log.log_tier(level):
|
||||
if log.log_tier(self.options.verbosity) < log.log_tier(level):
|
||||
return
|
||||
if level in ("error", "warn"):
|
||||
signals.status_message.send(
|
||||
|
@ -16,6 +16,7 @@ from mitmproxy import exceptions # noqa
|
||||
from mitmproxy import options # noqa
|
||||
from mitmproxy import optmanager # noqa
|
||||
from mitmproxy import proxy # noqa
|
||||
from mitmproxy import log
|
||||
from mitmproxy.utils import debug # noqa
|
||||
|
||||
|
||||
@ -40,7 +41,7 @@ def process_options(parser, opts, args):
|
||||
print(debug.dump_system_info())
|
||||
sys.exit(0)
|
||||
if args.quiet or args.options or args.commands:
|
||||
args.verbosity = 0
|
||||
args.verbosity = 'error'
|
||||
args.flow_detail = 0
|
||||
|
||||
adict = {}
|
||||
@ -79,7 +80,7 @@ def run(MasterKlass, args, extra=None): # pragma: no cover
|
||||
master.addons.trigger("configure", opts.keys())
|
||||
master.addons.trigger("tick")
|
||||
remaining = opts.update_known(**unknown)
|
||||
if remaining and opts.verbosity > 1:
|
||||
if remaining and log.log_tier(opts.verbosity) > 1:
|
||||
print("Ignored options: %s" % remaining)
|
||||
if args.options:
|
||||
print(optmanager.dump_defaults(opts))
|
||||
|
Loading…
Reference in New Issue
Block a user