You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CSSUTILS logger overrides existing config on import #13
This can lead to issues if your import of cssutils happens later than your main logging config setup, since it will override whatever is already configured. To avoid it, you must pre-emptively import cssutils before your own logging config.
It would be easier if cssutils detected if the logger has already been set up, and didn't add it's own default config in that case. At the very least, if it preserved the loglevel the user has selected that would help.
Hi @strokirk — thanks for the report, and sorry for the slow reply. You are right: cssutils creates the CSSUTILS logger at import time, adds its own StreamHandler to it and forces the level to INFO, which overrides a logging setup that ran earlier.
I would like to fix this. My plan:
install the default StreamHandler only when the CSSUTILS logger has no handlers at all, so an application handler is left alone and a second ErrorHandler does not add a duplicate handler,
apply the default level only when the logger has no level of its own and the root logger still has the default level, so a level chosen for CSSUTILS or for the root is preserved.
For an unconfigured logger the behaviour stays exactly as it is today (handler on stderr, level INFO).
Activity
jaraco commentedon Jun 3, 2022
Sounds reasonable to me. Can you draft a fix?
Madin-H23 commentedon Oct 21, 2026
Hi @strokirk — thanks for the report, and sorry for the slow reply. You are right:
cssutilscreates theCSSUTILSlogger at import time, adds its ownStreamHandlerto it and forces the level toINFO, which overrides a logging setup that ran earlier.I would like to fix this. My plan:
StreamHandleronly when theCSSUTILSlogger has no handlers at all, so an application handler is left alone and a secondErrorHandlerdoes not add a duplicate handler,CSSUTILSor for the root is preserved.For an unconfigured logger the behaviour stays exactly as it is today (handler on
stderr, levelINFO).I will open a PR with the change and the tests.