-
Notifications
You must be signed in to change notification settings - Fork 402
feat: allow configuring uvicorn log level via env var #1281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds configurability for the Uvicorn server log level in the ADK CLI via UVICORN_LOG_LEVEL, with fallback to LOG_LEVEL and default info, addressing #1269.
Changes:
- Read
UVICORN_LOG_LEVEL(fallback toLOG_LEVEL, defaultinfo) and normalize it. - Pass the resolved log level into both
uvicorn.run()call sites (staticandruncommands).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| kagent_url_override = os.getenv("KAGENT_URL") | ||
| sts_well_known_uri = os.getenv("STS_WELL_KNOWN_URI") | ||
| propagate_token = os.getenv("KAGENT_PROPAGATE_TOKEN") | ||
| uvicorn_log_level = os.getenv("UVICORN_LOG_LEVEL", os.getenv("LOG_LEVEL", "info")).lower() |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uvicorn_log_level is derived from LOG_LEVEL/UVICORN_LOG_LEVEL without sanitizing/normalizing beyond .lower(). If LOG_LEVEL is set to a numeric value (which Python logging accepts) or either env var is set but empty/whitespace, this will pass an invalid log_level through to uvicorn.run(). Consider .strip() plus handling numeric levels (e.g., map 20→"info") and falling back to "info" when the value is empty/invalid.
| uvicorn_log_level = os.getenv("UVICORN_LOG_LEVEL", os.getenv("LOG_LEVEL", "info")).lower() | |
| _raw_uvicorn_log_level = os.getenv("UVICORN_LOG_LEVEL") | |
| if _raw_uvicorn_log_level is None: | |
| _raw_uvicorn_log_level = os.getenv("LOG_LEVEL") | |
| if _raw_uvicorn_log_level is None: | |
| _raw_uvicorn_log_level = "info" | |
| _raw_uvicorn_log_level = _raw_uvicorn_log_level.strip() | |
| allowed_uvicorn_levels = {"critical", "error", "warning", "info", "debug", "trace"} | |
| if not _raw_uvicorn_log_level: | |
| uvicorn_log_level = "info" | |
| elif _raw_uvicorn_log_level.isdigit(): | |
| # Map numeric logging levels (e.g., 20) to their textual names (e.g., "info") | |
| numeric_level = int(_raw_uvicorn_log_level) | |
| level_name = logging.getLevelName(numeric_level) | |
| if isinstance(level_name, str): | |
| level_name = level_name.lower() | |
| uvicorn_log_level = level_name if level_name in allowed_uvicorn_levels else "info" | |
| else: | |
| uvicorn_log_level = "info" | |
| else: | |
| level_name = _raw_uvicorn_log_level.lower() | |
| uvicorn_log_level = level_name if level_name in allowed_uvicorn_levels else "info" |
Read the UVICORN_LOG_LEVEL environment variable (falling back to LOG_LEVEL, then 'info') and pass it to uvicorn.run() in both the 'static' and 'run' commands. This allows users to control uvicorn's log verbosity at deployment time without code changes. Fixes kagent-dev#1269 Signed-off-by: OpSpawn <opspawn@users.noreply.github.com>
e2861db to
a96ccca
Compare
Adds support for configuring the uvicorn server log level via UVICORN_LOG_LEVEL env var. Falls back to LOG_LEVEL, then info. Fixes #1269