@@ -73,11 +73,10 @@ def is_debug_set(logger):
7373 """
7474 if logger .manager .disable >= _DEBUG :
7575 return False
76- _level = logger .getEffectiveLevel ()
7776 # Filter out NOTSET and higher levels
78- return _NOTSET < _level <= _DEBUG
77+ return _NOTSET < logger . getEffectiveLevel () <= _DEBUG
7978
80- else :
79+ elif sys . version_info [: 3 ] < ( 3 , 13 , 4 ) :
8180 # This is inefficient (it indirectly checks effective level twice),
8281 # but is included for [as yet unknown] platforms that ONLY implement
8382 # the API documented in the logging library
@@ -86,6 +85,15 @@ def is_debug_set(logger):
8685 return False
8786 return logger .getEffectiveLevel () > _NOTSET
8887
88+ else :
89+ # Python 3.14 (and backported to python 3.13.4) changed the behavior
90+ # of isEnabledFor() so that it always returns False when called
91+ # while a log record is in flight (learned this from
92+ # https://github.com/hynek/structlog/pull/723). In newer versions
93+ # of Python, we will only rely on getEffectiveLevel().
94+ def is_debug_set (logger ):
95+ return _NOTSET < logger .getEffectiveLevel () <= _DEBUG
96+
8997
9098class WrappingFormatter (logging .Formatter ):
9199 _flag = "<<!MSG!>>"
@@ -262,7 +270,7 @@ def filter(self, record):
262270pyomo_logger = logging .getLogger ('pyomo' )
263271pyomo_handler = logging .StreamHandler (sys .stdout )
264272pyomo_formatter = LegacyPyomoFormatter (
265- base = PYOMO_ROOT_DIR , verbosity = lambda : pyomo_logger . isEnabledFor ( logging . DEBUG )
273+ base = PYOMO_ROOT_DIR , verbosity = lambda : is_debug_set ( pyomo_logger )
266274)
267275pyomo_handler .setFormatter (pyomo_formatter )
268276pyomo_handler .addFilter (_GlobalLogFilter ())
0 commit comments