From 0c57b3083ec4f43ff6fc56345a3007cfbd4dc3f6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 23 Sep 2018 21:38:03 +0200 Subject: [PATCH] Fix getting loggers. --- cdist/config.py | 21 ++++++++------------- cdist/core/cdist_type.py | 2 +- scripts/cdist | 3 +-- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/cdist/config.py b/cdist/config.py index bfb89419..e8fd5384 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -165,25 +165,20 @@ class Config(object): def commandline(cls, args): """Configure remote system""" - # FIXME: Refactor relict - remove later - log = logging.getLogger("cdist") + if (args.parallel and args.parallel != 1) or args.jobs: + if args.timestamp: + cdist.log.setupTimestampingParallelLogging() + else: + cdist.log.setupParallelLogging() + elif args.timestamp: + cdist.log.setupTimestampingLogging() + log = logging.getLogger("config") # No new child process if only one host at a time. if args.parallel == 1: log.debug("Only 1 parallel process, doing it sequentially") args.parallel = 0 - if args.parallel or args.jobs: - # If parallel execution then also log process id - if args.timestamp: - cdist.log.setupTimestampingParallelLogging() - else: - cdist.log.setupParallelLogging() - log = logging.getLogger("cdist") - elif args.timestamp: - cdist.log.setupTimestampingLogging() - log = logging.getLogger("cdist") - if args.parallel: import signal diff --git a/cdist/core/cdist_type.py b/cdist/core/cdist_type.py index 40194f94..99e40e70 100644 --- a/cdist/core/cdist_type.py +++ b/cdist/core/cdist_type.py @@ -47,7 +47,7 @@ class CdistType(object): """ - log = logging.getLogger("cdist") + log = logging.getLogger("cdist-type") def __init__(self, base_path, name): self.base_path = base_path diff --git a/scripts/cdist b/scripts/cdist index 088e4dc2..3110e657 100755 --- a/scripts/cdist +++ b/scripts/cdist @@ -69,8 +69,6 @@ if __name__ == "__main__": import re import os - log = logging.getLogger("cdist") - if re.match("__", os.path.basename(sys.argv[0])): import cdist.emulator emulator = cdist.emulator.Emulator(sys.argv) @@ -82,6 +80,7 @@ if __name__ == "__main__": exit_code = 2 except cdist.Error as e: + log = logging.getLogger("cdist") log.error(e) exit_code = 1