[logging] ensure isEnabledFor implements the right semantics #2292
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
We are guarding logging statements inside a check for
_LOGGER.isEnabledFor(LEVEL)
whereLEVEL
is typically (for now)std_logging.DEBUG
, though we may use other levels, such asINFO
,WARNING
, in some messages.As per the official docs,
isEnabledFor
and a function it calls,getEffectiveLevel
, check whether a certain severity is handled by the current logger, and only traverse up the hierarchy if the logger's severity isNOTSET
.This does not seem to be the semantics we intend. If the current
_LOGGER
is set to levelINFO
, say, but propagation is on, and the parent logger is set to levelDEBUG
, we want_LOGGER.debug()
statements to not be handled by_LOGGER
but to be handled by its parent. This means the logging statements should execute, which means the guard statements should evaluate to true, which means we need a different function thanisEnabledFor
.This is also relevant to the internal issue b/382299158 for logging encapsulation.
The text was updated successfully, but these errors were encountered: