One function

LoggerFactory in hynek/structlog

The author described this change as Fix stdlib's logger name guessing. It counts as a record because the check below fails on the code as it stood at cfdf19383 and passes on 27cb2ab77, with nothing else changed between the two runs.

Fix saved2013-09-27
Sharing licenceMIT · LICENSE-MIT
Change size+8 3

What the code was meant to do, written into the code itself as a docstring

Build a standard library logger when an *instance* is called.

The change

1212
1313 :rtype: `logging.Logger`
1414 """
15- return logging.getLogger(
16- sys._getframe().f_back.f_back.f_globals['__name__']
17- )
15+ f = sys._getframe()
16+ name = f.f_globals['__name__']
17+
18+ # We skip all frames that originate from within structlog.
19+ while name.startswith('structlog.'):
20+ f = f.f_back
21+ name = f.f_globals['__name__']
22+ return logging.getLogger(name)

The check that tells the two apart

failpass·tests/test_stdlib.py::TestLoggerFactory::test_deduces_correct_name

Check file tests/test_stdlib.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itcfdf19383e04e2db70f122cf962afee546dda7fb
Broken version dated2013-09-26
Modulestructlog.stdlib
Units changedLoggerFactory
Fingerprinta29800d90d9c88ac
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in hynek/structlog