Repository navigation
Conversation
The CSSUTILS logger was created with a StreamHandler and the INFO level every time an ErrorHandler was instantiated, overriding a logging setup the application had already done, and adding a second handler when one was already configured. Install the default handler only when the logger has no handlers at all, and apply the default level only when neither the logger nor the root logger has one, so that a level chosen by the application is preserved. An unconfigured logger keeps the previous behaviour.
Author
|
The The change is small, and here is the local verification:
The regression is reproducible on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13.
cssutilscreates theCSSUTILSlogger at import time, adds aStreamHandlerto it and forces the level toINFO. When an application configured logging before importingcssutils, that configuration was overridden, and a secondErrorHandleradded a second handler.This change:
StreamHandleronly when the logger has no handlers at all, so an application handler is left alone and no duplicate handler is added,CSSUTILSlogger nor the root logger has an explicit level, so a level chosen by the application is preserved.For an unconfigured logger the behaviour is unchanged (handler on
stderr, levelINFO).One limit worth stating: the root logger's default level (
WARNING) cannot be told apart from a level an application chose explicitly, so an application that sets exactlyWARNINGon the root logger and installs no handler of its own still gets theINFOdefault.Verified locally:
pytest: 629 passed, 43 xfailedruff checkandruff format --check(ruff 0.17.1): cleanmypy --config-file mypy.ini cssutils: no new findings (the 40 reported errors are pre-existing onmain)🤖 This contribution was drafted with AI assistance; the analysis, the change and the tests are described above so that they can be reviewed.