add log level option, don't use logger

This commit is contained in:
Louis Abel 2023-12-23 15:13:20 -07:00
parent 62d8d6a233
commit cdcf7e4c87
Signed by untrusted user: label
GPG Key ID: B37E62D143879B36
2 changed files with 16 additions and 13 deletions

View File

@ -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,

View File

@ -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)