diff options
author | emkael <emkael@tlen.pl> | 2019-07-30 14:31:21 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-07-30 14:31:21 +0200 |
commit | c4b1705710d268f17b21c9547c510272a2acaba4 (patch) | |
tree | 0c8c6b7c98b1c6147caf4ae622aed830b518e1c6 /jfr_playoff/gui | |
parent | b4bf2e464dc3f01f2ced9189f0ba22748574bfe1 (diff) |
Adding debug log handler for testing purposes
Diffstat (limited to 'jfr_playoff/gui')
-rw-r--r-- | jfr_playoff/gui/logframe.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/jfr_playoff/gui/logframe.py b/jfr_playoff/gui/logframe.py index 1711d52..74ffca1 100644 --- a/jfr_playoff/gui/logframe.py +++ b/jfr_playoff/gui/logframe.py @@ -43,11 +43,21 @@ class LogWindow(tk.Toplevel): btnFrame, text='Wyczyść dziennik', command=self.resetRecords)).pack(side=tk.LEFT) + def _getGUIHandler(self): + return LogHandler(log.INFO, window=self) + + def _getConsoleHandler(self): + consoleHandler = log.StreamHandler() + consoleHandler.setFormatter( + log.Formatter( + '%(asctime)s - %(name)s - %(levelname)s - %(message)s')) + return consoleHandler + def _registerLogging(self): - logHandler = LogHandler(log.INFO, window=self) logger = log.getLogger() logger.setLevel(log.INFO) - logger.addHandler(logHandler) + for handler in [self._getConsoleHandler, self._getGUIHandler]: + logger.addHandler(handler()) def addRecord(self, record): self._counter += 1 |