Issue
What is the issue?
Every module in the application independently calls logging.basicConfig() with no arguments and hardcodes logger.setLevel(logging.INFO). There are 25 such occurrences across the codebase.
This pattern has two concrete problems:
logging.basicConfig() is a no-op after the first call. Whichever module happens to be imported first claims the root logger; every subsequent call is silently ignored. Log format and handler behaviour are therefore undefined for most of the application.
- There is no way to change the log level or output format at runtime without editing source files.
There is also no structured (machine-readable) log output, which makes it difficult to aggregate or query logs in production or CI environments.
Expected Behaviour
Logger configuration should be centralised in one place. The log level and format should be controllable via environment variables (LOG_LEVEL, LOG_FORMAT) without any code changes. Setting LOG_FORMAT=json should produce one JSON object per line, suitable for log aggregation tools.
Actual Behaviour
25 modules each call logging.basicConfig() with no arguments. Only the first call has any effect. All modules hardcode INFO level. No structured output is available.
grep -rn "logging.basicConfig" application/ --include="*.py" | wc -l
# 25
Steps to reproduce
- Import any two application modules that both call
logging.basicConfig().
- Observe that log format is whatever Python's default is, with no way to override it at runtime.
- Note that changing
LOG_LEVEL or LOG_FORMAT environment variables has no effect.
Issue
What is the issue?
Every module in the application independently calls
logging.basicConfig()with no arguments and hardcodeslogger.setLevel(logging.INFO). There are 25 such occurrences across the codebase.This pattern has two concrete problems:
logging.basicConfig()is a no-op after the first call. Whichever module happens to be imported first claims the root logger; every subsequent call is silently ignored. Log format and handler behaviour are therefore undefined for most of the application.There is also no structured (machine-readable) log output, which makes it difficult to aggregate or query logs in production or CI environments.
Expected Behaviour
Logger configuration should be centralised in one place. The log level and format should be controllable via environment variables (
LOG_LEVEL,LOG_FORMAT) without any code changes. SettingLOG_FORMAT=jsonshould produce one JSON object per line, suitable for log aggregation tools.Actual Behaviour
25 modules each call
logging.basicConfig()with no arguments. Only the first call has any effect. All modules hardcode INFO level. No structured output is available.Steps to reproduce
logging.basicConfig().LOG_LEVELorLOG_FORMATenvironment variables has no effect.