Fix gateway launchd log growth#922
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces changes to suppress console logging during the gateway server boot and allows configuring the uvicorn log level. It also reduces log noise in the WeChat connector by logging update requests at the debug level instead of info. The feedback suggests respecting existing environment variables in _suppress_gateway_console_logging to allow users to explicitly enable console logging, and wrapping the configure_gateway_logging call in the finally block of serve_gateway in a try...except block to prevent potential logging errors from masking other runtime exceptions.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| def _suppress_gateway_console_logging() -> None: | ||
| os.environ["AWORLD_DISABLE_CONSOLE_LOG"] = "true" | ||
| os.environ[GATEWAY_CONSOLE_LOG_ENV] = "false" | ||
|
|
There was a problem hiding this comment.
The _suppress_gateway_console_logging function unconditionally overwrites the AWORLD_DISABLE_CONSOLE_LOG and AWORLD_GATEWAY_CONSOLE_LOG environment variables. This prevents users from explicitly enabling console logging (e.g., for debugging or local development) via environment variables when running the gateway server.
Consider only setting these environment variables if they are not already set, and respecting the user's explicit settings.
Note: If you apply this suggestion, you will also need to update the test test_suppress_gateway_console_logging_reconfigures_enabled_logger in tests/gateway/test_gateway_status_command.py because it sets AWORLD_DISABLE_CONSOLE_LOG to "false" before calling _suppress_gateway_console_logging(), which would now correctly bypass suppression.
| def _suppress_gateway_console_logging() -> None: | |
| os.environ["AWORLD_DISABLE_CONSOLE_LOG"] = "true" | |
| os.environ[GATEWAY_CONSOLE_LOG_ENV] = "false" | |
| def _suppress_gateway_console_logging() -> None: | |
| if "AWORLD_DISABLE_CONSOLE_LOG" not in os.environ: | |
| os.environ["AWORLD_DISABLE_CONSOLE_LOG"] = "true" | |
| if GATEWAY_CONSOLE_LOG_ENV not in os.environ: | |
| os.environ[GATEWAY_CONSOLE_LOG_ENV] = "false" | |
| if os.environ.get("AWORLD_DISABLE_CONSOLE_LOG") == "false": | |
| return |
| if gateway_log_path is not None: | ||
| configure_gateway_logging(log_path=gateway_log_path) |
There was a problem hiding this comment.
Calling configure_gateway_logging in the finally block could potentially raise an OSError (e.g., due to file system or permission issues) and mask the original exception that caused the gateway server to stop or fail to boot.
It is safer to wrap this call in a try...except block to ensure that any logging configuration errors during restoration do not suppress the actual runtime exception.
| if gateway_log_path is not None: | |
| configure_gateway_logging(log_path=gateway_log_path) | |
| if gateway_log_path is not None: | |
| try: | |
| configure_gateway_logging(log_path=gateway_log_path) | |
| except Exception: | |
| pass |
Summary
Test Plan