Fix getting loggers.

This commit is contained in:
Darko Poljak 2018-09-23 21:38:03 +02:00
parent 6acf6f64dc
commit 0c57b3083e
3 changed files with 10 additions and 16 deletions

View file

@ -165,25 +165,20 @@ class Config(object):
def commandline(cls, args): def commandline(cls, args):
"""Configure remote system""" """Configure remote system"""
# FIXME: Refactor relict - remove later if (args.parallel and args.parallel != 1) or args.jobs:
log = logging.getLogger("cdist") 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. # No new child process if only one host at a time.
if args.parallel == 1: if args.parallel == 1:
log.debug("Only 1 parallel process, doing it sequentially") log.debug("Only 1 parallel process, doing it sequentially")
args.parallel = 0 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: if args.parallel:
import signal import signal

View file

@ -47,7 +47,7 @@ class CdistType(object):
""" """
log = logging.getLogger("cdist") log = logging.getLogger("cdist-type")
def __init__(self, base_path, name): def __init__(self, base_path, name):
self.base_path = base_path self.base_path = base_path

View file

@ -69,8 +69,6 @@ if __name__ == "__main__":
import re import re
import os import os
log = logging.getLogger("cdist")
if re.match("__", os.path.basename(sys.argv[0])): if re.match("__", os.path.basename(sys.argv[0])):
import cdist.emulator import cdist.emulator
emulator = cdist.emulator.Emulator(sys.argv) emulator = cdist.emulator.Emulator(sys.argv)
@ -82,6 +80,7 @@ if __name__ == "__main__":
exit_code = 2 exit_code = 2
except cdist.Error as e: except cdist.Error as e:
log = logging.getLogger("cdist")
log.error(e) log.error(e)
exit_code = 1 exit_code = 1