diff options
-rw-r--r-- | mitmproxy/addons/save.py | 2 | ||||
-rw-r--r-- | mitmproxy/log.py | 11 | ||||
-rw-r--r-- | mitmproxy/tools/console/master.py | 5 |
3 files changed, 17 insertions, 1 deletions
diff --git a/mitmproxy/addons/save.py b/mitmproxy/addons/save.py index 37dc6021..92b7c5be 100644 --- a/mitmproxy/addons/save.py +++ b/mitmproxy/addons/save.py @@ -56,6 +56,8 @@ class Save: stream = io.FlowWriter(f) for i in flows: stream.add(i) + f.close() + ctx.log.alert("Saved %s flows." % len(flows)) def load(self, l): l.add_command("save.file", self.save) diff --git a/mitmproxy/log.py b/mitmproxy/log.py index c2456cf1..a2e7ea99 100644 --- a/mitmproxy/log.py +++ b/mitmproxy/log.py @@ -24,6 +24,15 @@ class Log: """ self(txt, "info") + def alert(self, txt): + """ + Log with level alert. Alerts have the same urgency as info, but + signals to interctive tools that the user's attention should be + drawn to the output even if they're not currently looking at the + event log. + """ + self(txt, "alert") + def warn(self, txt): """ Log with level warn. @@ -41,4 +50,4 @@ class Log: def log_tier(level): - return dict(error=0, warn=1, info=2, debug=3).get(level) + return dict(error=0, warn=1, info=2, alert=2, debug=3).get(level) diff --git a/mitmproxy/tools/console/master.py b/mitmproxy/tools/console/master.py index 8727d175..8c5376bd 100644 --- a/mitmproxy/tools/console/master.py +++ b/mitmproxy/tools/console/master.py @@ -39,6 +39,11 @@ EVENTLOG_SIZE = 10000 class Logger: def log(self, evt): signals.add_log(evt.msg, evt.level) + if evt.level == "alert": + signals.status_message.send( + message=str(evt.msg), + expire=2 + ) class UnsupportedLog: |