diff --git a/SWParser/gui/gui.py b/SWParser/gui/gui.py index 1a9217f..02d73d3 100644 --- a/SWParser/gui/gui.py +++ b/SWParser/gui/gui.py @@ -4,6 +4,7 @@ import SWProxy import threading import logging +import time logger = logging.getLogger("SWProxy") @@ -51,6 +52,10 @@ def openPCAP(self): def log(self, str): self.ui.logWindow.addItem(str) + # After a short delay, scroll to the bottom of the window. + # Cannot scroll immediately due to race condition with UI update + threading.Timer(0.1, self.ui.logWindow.scrollToBottom).start() + def startStopProxy(self): self.ui.proxyPort.setReadOnly(True) if self.proxy: diff --git a/SWProxy.py b/SWProxy.py index 3cee2bb..b56b8eb 100755 --- a/SWProxy.py +++ b/SWProxy.py @@ -233,7 +233,7 @@ def parse_pcap(filename): # Set up logger level = "DEBUG" if options.debug else "INFO" - logging.basicConfig(level=level, filename="proxy.log", format='%(asctime)s: %(name)s - %(levelname)s - %(message)s') + logging.basicConfig(level=level, filename="proxy.log", format="%(asctime)s: %(name)s - %(levelname)s - %(message)s") logger.setLevel(logging.INFO) print get_usage_text() @@ -264,6 +264,8 @@ def parse_pcap(filename): app_icon.addFile(icons_path + '256x256.png', QSize(256,256)) app.setWindowIcon(app_icon) win = gui.MainWindow(get_external_ip(), options.port) - logger.addHandler(gui.GuiLogHandler(win)) + guiLogHandler = gui.GuiLogHandler(win) + guiLogHandler.setFormatter(logging.Formatter(fmt="%(asctime)s %(message)s", datefmt="%X")) + logger.addHandler(guiLogHandler) win.show() sys.exit(app.exec_()) diff --git a/plugins/DemoPlugin.py b/plugins/DemoPlugin.py index 24a18ba..f42384a 100644 --- a/plugins/DemoPlugin.py +++ b/plugins/DemoPlugin.py @@ -5,4 +5,4 @@ class DemoPlugin(SWPlugin.SWPlugin): def process_request(self, req_json, resp_json): - logger.info("Found Summoners War API request : %s" % req_json['command']) + logger.info("Found Summoners War API request (wizard_id: %(wizard_id)s) : %(command)s " % req_json)