-
Notifications
You must be signed in to change notification settings - Fork 319
Description
Describe the bug
There are two related issues with logger configuration in the Confluent Kafka components:
-
Late Logger Setup in AsyncConfluentProducer
In faststream/confluent/helpers/client.py at line 46, the Producer object is created before the _setup() method is called for loger_state. This results in the Producer receiving a NoSetLoggerObject instead of the intended logger passed during initialization.
-
Missing Logger in AdminClient
The AdminClient in AdminService does not accept a logger parameter, even though it should. Currently, only the configuration is passed, leaving the AdminClient without proper logging.
How to reproduce
Include source code:
import logging
import uvicorn
from fastapi import FastAPI
from faststream.confluent.fastapi import KafkaRouter
logger = logging.getLogger("faststream")
router = KafkaRouter(
bootstrap_servers="kafka:9092",
enable_idempotence=True,
allow_auto_create_topics=False,
schema_url="/asyncapi",
include_in_schema=True,
logger=logger,
)
app = FastAPI()
app.include_router(router)
uvicorn.run(app, host="0.0.0.0", port=8000)Expected behavior
- The Producer in AsyncConfluentProducer should use the logger passed to KafkaRouter.
- The AdminClient should inherit the same logger as other components.
Observed behavior
- The Producer uses NoSetLoggerObject instead of the provided logger.
- The AdminClient lacks logger configuration, leading to potential silent failures or inadequate logging.
Environment
Running FastStream 0.6.3 with CPython 3.13.1 on Linux