-
Notifications
You must be signed in to change notification settings - Fork 53
Configure basic top-level logger #212
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
Conversation
Replace hardcoded logger names with __name__. This also helps to enforce a logger hierarchy, i.e. "securesystemslib" overrules "securesystemslib.keys".
- remove obsolete comment (from when sslib was part of tuf) - reword docstring to disambiguate printing and logging
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.
@trishankatdatadog, @FlorianVeaux, please let me know if this works for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great set of changes, thanks @lukpueh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great for me, thanks 🙇
@FlorianVeaux, @trishankatdatadog: I just pushed v0.14.1 which includes the logging fixes. https://github.com/secure-systems-lab/securesystemslib/releases/tag/v0.14.1 |
Fixes issue #:
Closes #210
Description of the changes being introduced by the pull request:
As pointed out by @FlorianVeaux in #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 PR 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.
The PR further:
__name__
logger naming conventionPlease verify and check that the pull request fulfils the following
requirements: