Skip to content

Make root log level configurable via LOG_LEVEL in config - #105

Open
t0kubetsu wants to merge 1 commit into
D4-project:mainfrom
t0kubetsu:fix/configurable-log-level
Open

Make root log level configurable via LOG_LEVEL in config#105
t0kubetsu wants to merge 1 commit into
D4-project:mainfrom
t0kubetsu:fix/configurable-log-level

Conversation

@t0kubetsu

Copy link
Copy Markdown
Contributor

Summary

Fixes #101

The root logger was hardcoded to DEBUG unconditionally at startup. Production deployments had no way to reduce log noise without patching source code. Debug output can also inadvertently log sensitive request payloads.

Changes

webapp/app/__init__.py

  • Move basicConfig after app.config.from_object("config") so LOG_LEVEL is available from config
  • Read the level name from app.config.get("LOG_LEVEL", "WARNING") with a safe fallback

webapp/config.py.template

  • Add LOG_LEVEL = "WARNING" with a comment explaining the valid values
# Before — hardcoded DEBUG always
logging.getLogger().setLevel(logging.DEBUG)

# After — driven by config, defaults to WARNING
_log_level_name = str(app.config.get("LOG_LEVEL", "WARNING")).upper()
_log_level = getattr(logging, _log_level_name, logging.WARNING)
logging.getLogger().setLevel(_log_level)

Test plan

  • Start app with default config.py.template — verify only WARNING+ messages appear in logs
  • Set LOG_LEVEL = "DEBUG" in config and restart — verify DEBUG messages appear
  • Set LOG_LEVEL = "INVALID" — verify app falls back to WARNING without crashing

Closes D4-project#101

The root logger was hardcoded to DEBUG on every startup. Production
deployments had no way to silence debug output without patching source.

Move basicConfig after app.config.from_object() so LOG_LEVEL from
config.py is available. Read the level name from config (defaulting to
WARNING) and apply it. Add LOG_LEVEL = "WARNING" to config.py.template.

To enable debug logging, set LOG_LEVEL = "DEBUG" in config.py.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LOW: Root logger forced to DEBUG level unconditionally at startup (__init__.py:15)

1 participant