Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module is logging warnings on import #210

Closed
FlorianVeaux opened this issue Feb 24, 2020 · 0 comments · Fixed by #212
Closed

Module is logging warnings on import #210

FlorianVeaux opened this issue Feb 24, 2020 · 0 comments · Fixed by #212

Comments

@FlorianVeaux
Copy link
Contributor

Hello 👋

Description of issue or feature request:

When securesystemslib is installed without the colors extra, warnings/error logs are shown.

Current behavior:

On Python3, it complains about the colorama module not being found here

On Python2, it tries to complain for the same thing but is failing with the No handlers could be found for logger "securesystemslib_interface".

Expected behavior:
The library should not complain about colorama as it is an optional dependency (and should also initialize the logger correctly on Python2)

How to reproduce:

Python2: docker run -it python:2 bash -c "pip install securesystemslib[crypto,pynacl] && python -c 'import securesystemslib.interface'"

Python3: docker run -it python:3 bash -c "pip install securesystemslib[crypto,pynacl] && python -c 'import securesystemslib.interface'"

lukpueh added a commit to lukpueh/securesystemslib that referenced this issue Feb 25, 2020
As pointed out by @FlorianVeaux in secure-systems-lab#210, securesystemslib does not
correctly initialize its loggers. As a consequence the logging
module logs a one-off "No handler could be found ..." warning when
used for the first time (only on Python 2).

The logging module then calls basicConfig, which attaches a
basic StreamHandler to the root logger, to which securesystemslib's
log messages are propagated.

This commit adds the configuration of a simple securesystemslib
top-level logger, with an attached StreamHandler and log level
WARNING, to which all other securesystemslib loggers default.
lukpueh added a commit to lukpueh/securesystemslib that referenced this issue Feb 25, 2020
As pointed out by @FlorianVeaux in secure-systems-lab#210, securesystemslib does not
correctly initialize its loggers. As a consequence the logging
module logs a one-off "No handler could be found ..." warning when
used for the first time (only on Python 2).

The logging module then calls basicConfig, which attaches a
basic StreamHandler to the root logger, to which securesystemslib's
log messages are propagated.

This commit adds the configuration of a simple securesystemslib
top-level logger, with an attached StreamHandler and log level
WARNING, to which all other securesystemslib loggers default.

This removes the one-off warning, while providing a similar logging
behavior as before and clear instructions (see added comments) on
how to customize (format, silence, etc...) securesystemslib's logging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant