Fix problem with multiple loggers

This commit is contained in:
einarf 2023-03-09 02:08:25 +01:00
parent a9619e1cc8
commit 23649bc86e
2 changed files with 5 additions and 2 deletions

View File

@ -12,8 +12,8 @@ class BaseCommand:
self.cli_args = cli_args
self.log_level = cli_args.log_level
self.config = Config()
self.logger = logging.getLogger(__name__)
log.setup(level=self.log_level or self.config.log_level)
self.logger = log.logger
def get_containers(self):
"""Get running containers"""

View File

@ -25,4 +25,7 @@ def setup(level: str = 'warning'):
# ch.setFormatter(logging.Formatter('%(asctime)s - {HOSTNAME} - %(name)s - %(levelname)s - %(message)s'))
# ch.setFormatter(logging.Formatter('%(asctime)s - {HOSTNAME} - %(levelname)s - %(message)s'))
ch.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s: %(message)s'))
logger.addHandler(ch)
# Prevent duplicate handlers
if not logger.handlers:
logger.addHandler(ch)