Skip to content

Commit

Permalink
add log level option, don't use logger
Browse files Browse the repository at this point in the history
  • Loading branch information
nazunalika committed Dec 23, 2023
1 parent 62d8d6a commit cdcf7e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 2 additions & 0 deletions iso/empanadas/empanadas/scripts/sync_sig.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# 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')
Expand Down Expand Up @@ -60,6 +61,7 @@
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,
Expand Down
27 changes: 14 additions & 13 deletions iso/empanadas/empanadas/util/dnf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def __init__(
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
Expand Down Expand Up @@ -1702,7 +1703,8 @@ def __init__(
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
Expand Down Expand Up @@ -1806,17 +1808,16 @@ def __init__(
)

# 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)
Expand Down

0 comments on commit cdcf7e4

Please sign in to comment.