-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add propagate=False opt to basic_logger() #31
Conversation
435f231
to
859e7b2
Compare
859e7b2
to
6a0a46e
Compare
@javierggt - this PR is critical for ska3-prime.
|
I can confirm that using this branch, I do not get the log messages from I'm trying to understand what should be the behavior other than that. The PR does not say, and whenever we discuss logging, @taldcroft and I have different expectations. For example, I would expect that the following code
should give the following output:
but this is the actual output:
|
@javierggt - good catch, this script now gives the expected output:
Output:
|
As |
Good question @jeanconn but I've already spent too much time on this. Maybe another day. |
For the record, there is a pytest fixture to do exactly that (https://docs.pytest.org/en/7.1.x/how-to/logging.html) So a test can be something like (from their docs):
|
Description
This adds a keyword argument
propagate=False
to thelogging.basic_logger()
signature. The returnedlogger
haspropagate
set to the input value.Interface impacts
This changes the behavior of
basic_logger
, but in a way that is likely expected anyway. I checked all current uses ofbasic_logger
in Ska and none of them would expect to propagate messages to a root or parent logger.@javierggt - you should double-check
astromon
though.Testing
Unit tests
Independent check of unit tests by Jean
Functional tests
From this branch in the git repo:
Previously the
annie
andcheta
imports generated debug information fromget_version()
calls due toannie
creating a root logger on import. This was becauseget_version()
uses logging to catch debug information in anio.String()
object, and all of those messages then get passed up to the parent where they get emitted regardless of the parent log level. (The annie root logger is at CRITICAL, but only the level of the handlers (NOTSET) is evaluated).