From c03db3205d60f6e74991254ca72825bca3f2b9e0 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sat, 29 Sep 2018 15:10:34 +0200 Subject: [PATCH] Updated formatting of debug logging. --- nw/__init__.py | 12 ++++++------ nw/gui/winmain.py | 2 ++ nw/main.py | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/nw/__init__.py b/nw/__init__.py index b53c2915..5f7d6a68 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -117,8 +117,8 @@ def main(sysArgs): # Defaults debugLevel = logging.WARN - debugStr = "%(levelname)-8s %(message)s" - timeStr = "[%(asctime)s] " + debugStr = "{levelname:8} {message:}" + timeStr = "[{asctime:}] " logFile = "" toFile = False toStd = True @@ -149,7 +149,7 @@ def main(sysArgs): debugLevel = logging.INFO elif inArg == "DEBUG": debugLevel = logging.DEBUG - debugStr = "%(lineno)4d:%(name)-20s %(levelname)-8s %(message)s" + debugStr = "{name:>20}:{lineno:<4d} {levelname:8} {message:}" else: print("Invalid debug level") exit(2) @@ -160,10 +160,10 @@ def main(sysArgs): toStd = False elif inOpt in ("--verbose"): debugLevel = VERBOSE - timeStr = "[%(asctime)s.%(msecs)03d] " + timeStr = "[{asctime:}.{msecs:03.0f}] " elif inOpt in ("--vverbose"): debugLevel = VVERBOSE - timeStr = "[%(asctime)s.%(msecs)03d] " + timeStr = "[{asctime:}.{msecs:03.0f}] " elif inOpt in ("-t","--time"): showTime = True elif inOpt in ("--config"): @@ -173,7 +173,7 @@ def main(sysArgs): # Set Logging if showTime: debugStr = timeStr+debugStr - logFmt = logging.Formatter(fmt=debugStr,datefmt="%Y-%m-%d %H:%M:%S") + logFmt = logging.Formatter(fmt=debugStr,datefmt="%Y-%m-%d %H:%M:%S",style="{") if not logFile == "" and toFile: if path.isfile(logFile+".bak"): diff --git a/nw/gui/winmain.py b/nw/gui/winmain.py index 2b1f0a87..219d569f 100644 --- a/nw/gui/winmain.py +++ b/nw/gui/winmain.py @@ -25,6 +25,7 @@ class GuiMain(QMainWindow): def __init__(self): QWidget.__init__(self) + logger.debug("Initialising GUI ...") self.mainConf = nw.CONFIG self.resize(900,600) @@ -59,6 +60,7 @@ class GuiMain(QMainWindow): self._buildMenu() self.show() + logger.debug("GUI initialisation complete") return diff --git a/nw/main.py b/nw/main.py index b3d4c440..8b190087 100644 --- a/nw/main.py +++ b/nw/main.py @@ -25,4 +25,5 @@ class NovelWriter(): self.winMain = GuiMain() return + # END Class NovelWriter