Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Unexpected side-effect to calling LoggerFactory()

Open
#230 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start by reading structlog.stdlib.LoggerFactory and the logger class setup it performs; the issue provides a minimal reproduction using logging.getLogger. Check the relevant tests for logger factory behavior and reproduce whether constructing LoggerFactory changes the type returned by later calls. Done means the behavior is understood and covered by a regression test.

Written by the indexing model from the issue text.

Description

I'm using structlog package 19.2.0 but I've validated the behavior to be the same in version 19.1.0.
Instantiating LoggerFactory causes all subsequent calls to logging.getLogger to be of type
structlog.stdlib._FixedFindCallerLogger.

import logging
from structlog.stdlib import BoundLogger, LoggerFactory
from structlog import wrap_logger

print (logging.getLogger('foo'))
print(wrap_logger(logging.getLogger('bar'), 
	logger_factory=LoggerFactory(), wrapper_class=BoundLogger))

print(logging.getLogger('jazz'))  # would expect this to be a logging.Logger instance

prints

logging.Logger object at 0x10169bf90>
<BoundLoggerLazyProxy(logger=<logging.Logger object at 0x101732990>, wrapper_class=<class 'structlog.stdlib.BoundLogger'>, processors=None, context_class=None, initial_values={'logger_factory': <structlog.stdlib.LoggerFactory object at 0x1017dbad0>}, logger_factory_args=())>
<structlog.stdlib._FixedFindCallerLogger object at 0x1017db8d0>

A minimal example (May not be appropriate usage. Only to illustrate)

import logging
from structlog.stdlib import LoggerFactory

print(logging.getLogger('foo'))
LoggerFactory()
print(logging.getLogger('jazz'))  # would expect this to be a logging.Logger instance

prints

<logging.Logger object at 0x1085b9f90>
<structlog.stdlib._FixedFindCallerLogger object at 0x108650990>

This is a rather unexpected side-effect and causes client's code to return an unexpected type for logging.getLogger calls if structlog LoggerFactory is ever instantiated in a parent application. Is this something that can be addressed?

Dominant language
Python
Stars
5k
Forks
302
Avg merge
17m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hynek/structlog

All issues in hynek/structlog

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.