add log level option, don't use logger
Some checks failed
Build empanada images for imagefactory / buildx (push) Failing after 4s
Build empanada container images for lorax / buildx (push) Successful in 1s

This commit is contained in:
Louis Abel 2023-12-23 15:13:20 -07:00
parent 62d8d6a233
commit cdcf7e4c87
Signed by: 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 # I am aware this is confusing, I want podman to be the default option
parser.add_argument('--simple', action='store_false') parser.add_argument('--simple', action='store_false')
parser.add_argument('--logger', type=str) 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-gpg-check', action='store_false')
parser.add_argument('--disable-repo-gpg-check', action='store_false') parser.add_argument('--disable-repo-gpg-check', action='store_false')
parser.add_argument('--clean-old-packages', action='store_true') parser.add_argument('--clean-old-packages', action='store_true')
@ -60,6 +61,7 @@ a = SigRepoSync(
nofail=results.no_fail, nofail=results.no_fail,
refresh_extra_files=results.refresh_extra_files, refresh_extra_files=results.refresh_extra_files,
logger=results.logger, logger=results.logger,
log_level=results.log_level,
gpg_check=results.disable_gpg_check, gpg_check=results.disable_gpg_check,
repo_gpg_check=results.disable_repo_gpg_check, repo_gpg_check=results.disable_repo_gpg_check,
reposync_clean_old=results.clean_old_packages, reposync_clean_old=results.clean_old_packages,

View File

@ -64,7 +64,8 @@ class RepoSync:
extra_dnf_args=None, extra_dnf_args=None,
reposync_clean_old: bool = False, reposync_clean_old: bool = False,
fpsync: bool = False, fpsync: bool = False,
logger=None logger=None,
log_level='INFO',
): ):
self.nofail = nofail self.nofail = nofail
self.dryrun = dryrun self.dryrun = dryrun
@ -1702,7 +1703,8 @@ class SigRepoSync:
repo_gpg_check: bool = True, repo_gpg_check: bool = True,
extra_dnf_args=None, extra_dnf_args=None,
reposync_clean_old: bool = False, reposync_clean_old: bool = False,
logger=None logger=None,
log_level='INFO',
): ):
self.nofail = nofail self.nofail = nofail
self.dryrun = dryrun self.dryrun = dryrun
@ -1806,17 +1808,16 @@ class SigRepoSync:
) )
# This is temporary for now. # This is temporary for now.
if logger is None: self.log = logging.getLogger("sigreposync")
self.log = logging.getLogger("sigreposync") self.log.setLevel(getattr(logging, log_level.upper(), 'INFO'))
self.log.setLevel(getattr(logging, logger.upper(), 'INFO')) handler = logging.StreamHandler(sys.stdout)
handler = logging.StreamHandler(sys.stdout) handler.setLevel(logging.INFO)
handler.setLevel(logging.INFO) formatter = logging.Formatter(
formatter = logging.Formatter( '%(asctime)s :: %(name)s :: %(message)s',
'%(asctime)s :: %(name)s :: %(message)s', '%Y-%m-%d %H:%M:%S'
'%Y-%m-%d %H:%M:%S' )
) handler.setFormatter(formatter)
handler.setFormatter(formatter) self.log.addHandler(handler)
self.log.addHandler(handler)
self.log.info('sig reposync init') self.log.info('sig reposync init')
self.log.info(self.profile + ' ' + self.major_version) self.log.info(self.profile + ' ' + self.major_version)