Make root log level configurable via LOG_LEVEL in config - #105
Open
t0kubetsu wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #101
The root logger was hardcoded to
DEBUGunconditionally 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__.pybasicConfigafterapp.config.from_object("config")soLOG_LEVELis available from configapp.config.get("LOG_LEVEL", "WARNING")with a safe fallbackwebapp/config.py.templateLOG_LEVEL = "WARNING"with a comment explaining the valid valuesTest plan
config.py.template— verify only WARNING+ messages appear in logsLOG_LEVEL = "DEBUG"in config and restart — verify DEBUG messages appearLOG_LEVEL = "INVALID"— verify app falls back to WARNING without crashing