From cdcf7e4c87b7bb54ab945d053bc0b1e950744445 Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Sat, 23 Dec 2023 15:13:20 -0700 Subject: [PATCH] add log level option, don't use logger --- iso/empanadas/empanadas/scripts/sync_sig.py | 2 ++ iso/empanadas/empanadas/util/dnf_utils.py | 27 +++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/iso/empanadas/empanadas/scripts/sync_sig.py b/iso/empanadas/empanadas/scripts/sync_sig.py index 70731a0..2c901e4 100755 --- a/iso/empanadas/empanadas/scripts/sync_sig.py +++ b/iso/empanadas/empanadas/scripts/sync_sig.py @@ -29,6 +29,7 @@ parser.add_argument('--refresh-extra-files', action='store_true') # I am aware this is confusing, I want podman to be the default option parser.add_argument('--simple', action='store_false') parser.add_argument('--logger', type=str) +parser.add_argument('--log-level', type=str, default='INFO') parser.add_argument('--disable-gpg-check', action='store_false') parser.add_argument('--disable-repo-gpg-check', action='store_false') parser.add_argument('--clean-old-packages', action='store_true') @@ -60,6 +61,7 @@ a = SigRepoSync( nofail=results.no_fail, refresh_extra_files=results.refresh_extra_files, logger=results.logger, + log_level=results.log_level, gpg_check=results.disable_gpg_check, repo_gpg_check=results.disable_repo_gpg_check, reposync_clean_old=results.clean_old_packages, diff --git a/iso/empanadas/empanadas/util/dnf_utils.py b/iso/empanadas/empanadas/util/dnf_utils.py index 98d6062..86ddae2 100644 --- a/iso/empanadas/empanadas/util/dnf_utils.py +++ b/iso/empanadas/empanadas/util/dnf_utils.py @@ -64,7 +64,8 @@ class RepoSync: extra_dnf_args=None, reposync_clean_old: bool = False, fpsync: bool = False, - logger=None + logger=None, + log_level='INFO', ): self.nofail = nofail self.dryrun = dryrun @@ -1702,7 +1703,8 @@ class SigRepoSync: repo_gpg_check: bool = True, extra_dnf_args=None, reposync_clean_old: bool = False, - logger=None + logger=None, + log_level='INFO', ): self.nofail = nofail self.dryrun = dryrun @@ -1806,17 +1808,16 @@ class SigRepoSync: ) # This is temporary for now. - if logger is None: - self.log = logging.getLogger("sigreposync") - self.log.setLevel(getattr(logging, logger.upper(), 'INFO')) - handler = logging.StreamHandler(sys.stdout) - handler.setLevel(logging.INFO) - formatter = logging.Formatter( - '%(asctime)s :: %(name)s :: %(message)s', - '%Y-%m-%d %H:%M:%S' - ) - handler.setFormatter(formatter) - self.log.addHandler(handler) + self.log = logging.getLogger("sigreposync") + self.log.setLevel(getattr(logging, log_level.upper(), 'INFO')) + handler = logging.StreamHandler(sys.stdout) + handler.setLevel(logging.INFO) + formatter = logging.Formatter( + '%(asctime)s :: %(name)s :: %(message)s', + '%Y-%m-%d %H:%M:%S' + ) + handler.setFormatter(formatter) + self.log.addHandler(handler) self.log.info('sig reposync init') self.log.info(self.profile + ' ' + self.major_version)