Skip to content

Conversation

@opspawn
Copy link
Contributor

@opspawn opspawn commented Feb 11, 2026

Adds support for configuring the uvicorn server log level via UVICORN_LOG_LEVEL env var. Falls back to LOG_LEVEL, then info. Fixes #1269

Copilot AI review requested due to automatic review settings February 11, 2026 07:41
Copy link
Contributor

Copilot AI left a 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 to LOG_LEVEL, default info) and normalize it.
  • Pass the resolved log level into both uvicorn.run() call sites (static and run commands).

💡 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()
Copy link

Copilot AI Feb 11, 2026

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.

Suggested change
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"

Copilot uses AI. Check for mistakes.
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>
@opspawn opspawn force-pushed the fix/1269-uvicorn-log-level branch from e2861db to a96ccca Compare February 11, 2026 23:51
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.

[FEATURE] Allow changing uvicorn log level

2 participants