mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
console: display errors that happened during startup
This commit is contained in:
parent
18f34fe88e
commit
a5fd4bdb82
@ -9,6 +9,7 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import traceback
|
||||
import typing # noqa
|
||||
|
||||
import urwid
|
||||
|
||||
@ -32,6 +33,8 @@ class ConsoleMaster(master.Master):
|
||||
def __init__(self, opts):
|
||||
super().__init__(opts)
|
||||
|
||||
self.start_err = None # type: typing.Optional[log.LogEntry]
|
||||
|
||||
self.view = view.View() # type: view.View
|
||||
self.events = eventstore.EventStore()
|
||||
self.events.sig_add.connect(self.sig_add_log)
|
||||
@ -86,8 +89,12 @@ class ConsoleMaster(master.Master):
|
||||
if log.log_tier(self.options.verbosity) < log.log_tier(entry.level):
|
||||
return
|
||||
if entry.level in ("error", "warn"):
|
||||
if self.first_tick:
|
||||
self.start_err = entry
|
||||
else:
|
||||
signals.status_message.send(
|
||||
message="{}: {}".format(entry.level.title(), entry.msg)
|
||||
message=(entry.level, "{}: {}".format(entry.level.title(), entry.msg)),
|
||||
expire=5
|
||||
)
|
||||
|
||||
def sig_call_in(self, sender, seconds, callback, args=()):
|
||||
@ -198,6 +205,12 @@ class ConsoleMaster(master.Master):
|
||||
|
||||
self.loop.set_alarm_in(0.01, self.ticker)
|
||||
|
||||
if self.start_err:
|
||||
def display_err(*_):
|
||||
self.sig_add_log(None, self.start_err)
|
||||
self.start_err = None
|
||||
self.loop.set_alarm_in(0.01, display_err)
|
||||
|
||||
self.start()
|
||||
try:
|
||||
self.loop.run()
|
||||
|
Loading…
Reference in New Issue
Block a user