aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-07-22 23:18:25 +0800
committerAaron LI <aly@aaronly.me>2017-07-22 23:18:25 +0800
commitc586b6f0ce141b99abe90bf621fc05918860a285 (patch)
tree035aecc85c1457dea4bae8c0e9068c876871d7e3
parent7459867f5fef8cf8ac02619ef3761e7a3d1cf3b1 (diff)
downloadfg21sim-c586b6f0ce141b99abe90bf621fc05918860a285.tar.bz2
configs/manager.py: Add formatter for handlers
Signed-off-by: Aaron LI <aly@aaronly.me>
-rw-r--r--fg21sim/configs/manager.py9
1 files changed, 8 insertions, 1 deletions
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"],