Skip to content

fix: preserve exception tracebacks in logs#1261

Merged
zhongwen666 merged 5 commits into
alibaba:masterfrom
Timandes:fix/1260-logger-exception-traceback
Jul 20, 2026
Merged

fix: preserve exception tracebacks in logs#1261
zhongwen666 merged 5 commits into
alibaba:masterfrom
Timandes:fix/1260-logger-exception-traceback

Conversation

@Timandes

Copy link
Copy Markdown
Collaborator

Summary

  • preserve exception type and traceback output in StandardFormatter when logging with exc_info
  • add logging.exception_traceback_enabled YAML configuration and ROCK_LOGGING_EXCEPTION_TRACEBACK_ENABLE environment-variable override
  • apply YAML logging configuration to the shared admin/proxy lifespan while keeping rocklet on environment/default behavior
  • retain the current single-line log format when traceback output is disabled

Root cause

StandardFormatter.format() built the final message directly from record.getMessage() and did not append record.exc_info. Exceptions with an empty message, such as httpx.PoolTimeout(""), therefore produced only Error in http_proxy: with neither an exception type nor a traceback.

Impact

Exception tracebacks are enabled by default. Operators can restore the previous behavior with either:

logging:
  exception_traceback_enabled: false

or:

ROCK_LOGGING_EXCEPTION_TRACEBACK_ENABLE=false

An explicitly set environment variable takes precedence over YAML configuration.

Validation

  • uv run pytest tests/unit/test_logger.py tests/unit/test_config.py tests/unit/admin/test_logging_config.py -q — 83 passed
  • uv run ruff check rock/logger.py rock/env_vars.py rock/config.py rock/admin/main.py tests/unit/test_logger.py tests/unit/test_config.py tests/unit/admin/test_logging_config.py
  • uv run ruff format --check rock/logger.py rock/env_vars.py rock/config.py rock/admin/main.py tests/unit/test_logger.py tests/unit/test_config.py tests/unit/admin/test_logging_config.py
  • all three sample YAML files parsed and validated
  • project fast profile: 2088 passed; 13 failed and 33 errored in Docker/Testcontainers and shell temporary-output tests because of the local test environment

Fixes #1260

@Timandes
Timandes marked this pull request as ready for review July 20, 2026 05:01
@Timandes
Timandes requested a review from zhongwen666 July 20, 2026 05:01
@zhongwen666
zhongwen666 merged commit 406ec89 into alibaba:master Jul 20, 2026
7 checks passed
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.

[BUG] Preserve exception tracebacks in custom log formatter

2 participants