cki-lib initalizes the root logger

I'm really not sure how I didn't notice this before, but logging.basicConfig() doesn't work when cki-lib is imported first.

The path to this is as follow

File "src/seqe/beaker/dw_upload.py", line 10, in <module>
    import kernel_qe_tools.kcidb_tool.bkr.parser


  File "venv/lib64/python3.14/site-packages/kernel_qe_tools/kcidb_tool/bkr/parser.py", line 7, in <module>
    from . import utils as bkr_utils

  File "venv/lib64/python3.14/site-packages/kernel_qe_tools/kcidb_tool/bkr/utils.py", line 8, in <module>
    from cki_lib.kcidb.validate import sanitize_kcidb_status

  File "venv/lib64/python3.14/site-packages/cki_lib/kcidb/__init__.py", line 3, in <module>
    from ..yaml import ValidationError

  File "venv/lib64/python3.14/site-packages/cki_lib/yaml.py", line 18, in <module>
    from . import config_tree

  File "venv/lib64/python3.14/site-packages/cki_lib/config_tree.py", line 5, in <module>
    from . import misc

  File "venv/lib64/python3.14/site-packages/cki_lib/misc.py", line 31, in <module>
    LOGGER = get_logger(__name__)
  File "venv/lib64/python3.14/site-packages/cki_lib/logger.py", line 111, in get_logger
    root_logger = logging.getLogger()
  File "/usr/lib64/python3.14/logging/__init__.py", line 2138, in getLogger

Because https://gitlab.com/cki-project/cki-lib/-/blob/main/cki_lib/logger.py?ref_type=heads#L109 is adding a handler to the root logger as part of the import process, tools that import cki_lib can not use standard logging.basicConfig(level=logging.DEBUG) when they start.

I'll admit, I can't see that this has changed recently. We've had logging.basicConfig(level=DEBUG if args.debug else WARNING) in our CLI tool forever. It may be that I've not had reason to use --debug on a tool that has this imported until I tried debugging a related issue infrastructure#1271 (closed) - or possibly kcidb_tool changed imports causing this to now come in, I didn't keep digging TBH.

I would suggest this is a rather unexpected side-effect of what started out as from cki_lib.kcidb.validate import sanitize_kcidb_status. If I want cki_lib to manage my logging I should have to ask it explicitly 😄

Jira: CKI-6522

Edited by CKI Bot