Force set --log-level for all modules (and/or allow configuring per module) #10266
Labels
plugin: logging
related to the logging builtin plugin
type: proposal
proposal for a new feature, often to gather opinions or design the API around the new feature
What's the problem this feature will solve?
--log-level
is nice. However, certain modules (like SQLAlchemy) default to certain log level, which doesn't get set/adjusted/overwritten via--log-level
which only sets the level forroot
. From SQLAlchemy docs:You have to manually
logging.getLogger("sqlalchemy").setLevel(logging.DEBUG)
etc if you want to enable the logging.Describe the solution you'd like
Add some flag, that will wipe the existing loggers/handlers/levels so it'll use the same level for everything?
Alternative Solutions
Do the same but also allow setting log level per module. This is maybe for flexible (but less simple). Something like:
Additional context
It looks like SQLAlchemy sets the logging level when the module is loaded (so during the test discovery?):
Apparently
pytest
has not configured the logger at this point, because indeed thelogging.WARNING
gets set forsqlalchemy
namespace. Rises a question of at what point doespytest
configure the logging?Looks like
logging.root.manager.loggerDict
allows to iterate (and clear/override) the configured loggers. For me, in a random environment, it shows as:Could iterate over everything and wipe them out, leaving just the root logger?
A couple of SO questions about per-module configuration:
The text was updated successfully, but these errors were encountered: