Skip to content

Commit

Permalink
Fix logger per pubtools conventions
Browse files Browse the repository at this point in the history
We now have documented at [1] the preferred logger setup for
projects in the pubtools family. Tweak logger to be consistent with
that, which means:

- our logger should be named "pubtools.iib"
- we should not set the level by default (but basicConfig is OK)

This helps to ensure loggers are configurable consistently across
the projects.

[1] https://release-engineering.github.io/pubtools/devguide.html
  • Loading branch information
rohanpm committed Jun 28, 2021
1 parent 5fadb70 commit bb346eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/source/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ChangeLog

Unreleased
-----------
* Use pubtools.iib logger rather than root logger

0.20.0 (2021-06-10)
-------------------
Expand Down
8 changes: 6 additions & 2 deletions pubtools/iib/iib_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from pubtools import pulplib
import pushcollector

LOG = logging.getLogger()
LOG.setLevel(logging.INFO)
LOG = logging.getLogger("pubtools.iib")


CMD_ARGS = {
("--pulp-url",): {
Expand Down Expand Up @@ -314,6 +314,8 @@ def make_rm_operators_parser():


def add_bundles_main(sysargs=None):
logging.basicConfig(level=logging.INFO)

parser = make_add_bundles_parser()
if sysargs:
args = parser.parse_args(sysargs[1:])
Expand All @@ -325,6 +327,8 @@ def add_bundles_main(sysargs=None):


def remove_operators_main(sysargs=None):
logging.basicConfig(level=logging.INFO)

parser = make_rm_operators_parser()
if sysargs:
args = parser.parse_args(sysargs[1:])
Expand Down
2 changes: 2 additions & 0 deletions tests/test_iib_ops.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import contextlib
import logging
import mock
import pkg_resources
import pytest
Expand Down Expand Up @@ -421,6 +422,7 @@ def test_add_bundles_py(
fixture_container_image_repo,
fixture_common_iib_op_args,
):
caplog.set_level(logging.INFO)
repo = fixture_container_image_repo
fixture_pulp_client.return_value.search_repository.return_value = [repo]
fixture_pulp_client.return_value.get_repository.return_value = repo
Expand Down

0 comments on commit bb346eb

Please sign in to comment.