deepgram-python-sdk icon indicating copy to clipboard operation
deepgram-python-sdk copied to clipboard

Logger handlers should not be allocated

Open sagb opened this issue 4 months ago • 0 comments

What is the current behavior?

Deepgram SDK modules allocate logger handlers randomly:

deepgram-python-sdk (main)$ grep -r logger.addHandler * | wc
     40      80    3855

When trying to configure the logging, the user gets duplicates, the format of the loggers can't be changed, etc.

Steps to reproduce

Import deepgram, and then, for example, use the standard logger initialization:

logging.basicConfig(level=LOGLEVEL)

Then you get duplicated records: one record in the desired format, plus one record in the format hardcoded in SDK.

Expected behavior

Python modules generally should not add their own handlers, the log records should propagate to the root logger, the only one with handlers, which is configured once per app.

Please tell us about your environment

deepgram-sdk 4.5.0

Other information

I tried to cleanup your handlers, as mentioned here: https://stackoverflow.com/questions/72722134/how-to-prevent-imported-packages-modules-from-adding-logging-handlers but you configure the loggers in too many places at runtime, so it's futile.

sagb avatar Jul 05 '25 10:07 sagb