From c586b6f0ce141b99abe90bf621fc05918860a285 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 22 Jul 2017 23:18:25 +0800 Subject: configs/manager.py: Add formatter for handlers Signed-off-by: Aaron LI --- fg21sim/configs/manager.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'fg21sim') diff --git a/fg21sim/configs/manager.py b/fg21sim/configs/manager.py index 3f773a5..59e364f 100644 --- a/fg21sim/configs/manager.py +++ b/fg21sim/configs/manager.py @@ -525,6 +525,7 @@ class ConfigManager: if os.environ.get("DEBUG_FG21SIM"): print("DEBUG: Force 'DEBUG' logging level", file=sys.stderr) level = "DEBUG" + # logging handlers handlers = [] stream = conf["stream"] @@ -534,7 +535,13 @@ class ConfigManager: filemode = "a" if conf["appendmode"] else "w" if logfile: handlers.append(FileHandler(logfile, mode=filemode)) - # + + # Explicitly add formatter to each handler + formatter = logging.Formatter(fmt=conf["format"], + datefmt=conf["datefmt"]) + for handler in handlers: + handler.setFormatter(formatter) + logconf = { "level": getattr(logging, level), "format": conf["format"], -- cgit v1.2.2