Skip to content

Honor RUST_LOG in the Axum adapter logger - #1227

Open
dhruv8sh wants to merge 2 commits into
mainfrom
fix/axum-rust-log
Open

dhruv8sh wants to merge 2 commits into
mainfrom
fix/axum-rust-log

Conversation

@dhruv8sh

@dhruv8sh dhruv8sh commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • The Axum dev server ignored RUST_LOG and always logged at trace, which floods stdout and writes full OpenRTB bid request bodies and TCF consent strings during routine local runs. It now reads the maximum level from RUST_LOG.
  • When RUST_LOG is unset, the default is now info (matching the Fastly adapter) instead of trace. Nothing in the repo relies on Axum trace output: the integration harness discards Axum stdout, CI and scripts already set RUST_LOG=info, and the smoke script only checks error-level lines.
  • Only a single level is supported (trace, debug, info, warn, error, off). Per-module filter syntax such as trace,hyper=info is not supported; it falls back to info and prints a startup warning to stderr.

Changes

File Change
crates/trusted-server-adapter-axum/src/main.rs Add resolve_max_level (parses RUST_LOG, defaults to info) and unrecognized_log_level (detects set-but-ignored values); pass the level to SimpleLogger::with_level; warn on stderr for unrecognized values; add unit tests for both helpers.
docs/guide/axum-dev.md Add a Logging section covering the default level, supported values, the fallback warning, and the sensitivity of trace output.

The warning uses eprintln! only because the logger is not initialized yet at that point. This matches the existing PORT and logger-init warnings in main, which already sit under #[allow(clippy::print_stderr)].

Closes

Closes #1129

Test plan

  • cargo test-fastly && cargo test-axum
  • cargo clippy-fastly && cargo clippy-axum
  • cargo fmt --all -- --check
  • JS tests: cd crates/trusted-server-js/lib && npx vitest run
  • JS format: cd crates/trusted-server-js/lib && npm run format
  • Docs format: cd docs && npm run format
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1
  • Manual testing via fastly compute serve
  • Other: cargo clippy-cloudflare && cargo clippy-cloudflare-wasm && cargo clippy-spin-native && cargo clippy-spin-wasm && cargo clippy-cli && cargo clippy-codegen, cargo test-cloudflare && cargo test-spin, and the parity test (cargo test --manifest-path crates/trusted-server-integration-tests/Cargo.toml --test parity)

Checklist

  • Changes follow AGENTS.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses log macros (not println!); the startup eprintln! runs before the logger exists
  • New code has tests
  • No secrets or credentials committed

The Axum adapter initialized simple_logger without reading RUST_LOG, so
it always logged at trace, including OpenRTB bid request bodies and TCF
consent strings. Resolve the level from RUST_LOG and default to info
when it is unset or unrecognized, matching the Fastly adapter. Warn on
standard error when a set value is ignored, and document the setting in
the Axum guide.

Closes #1129

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
@dhruv8sh dhruv8sh self-assigned this Oct 1, 2026
@dhruv8sh
dhruv8sh requested review from aram356 and prk-Jr and removed request for aram356 October 1, 2026 15:33
@aram356 aram356 added this to the 202610 milestone Oct 1, 2026

@ChristianPavilonis ChristianPavilonis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary

Reviewed 0b149636304e0e7f184a9f3298f56f9b10d669a8 against cb945254521ed6dab365072f7caec10c524e323b. Both changed files were reviewed, including logger initialization, pinned dependency behavior, request handlers, and scripts consuming Axum output. No actionable issues introduced by this PR were found.

Safety proof

Runtime verification confirmed that the configured level controls actual output without changing HTTP behavior. A live-binary probe passed 12 cases covering every supported level, unset and blank values, whitespace and case normalization, and invalid filters. An actual EC trace record appeared only at trace; off suppressed all logs. Invalid filters warned on stderr. Every case retained /health HTTP 200 and malformed /auction HTTP 400.

Validation and review context

  • cargo test-axum: 48 tests passed; one documentation example ignored.
  • cargo fmt --all -- --check, cargo clippy-axum, and cargo build-axum: passed.
  • In-memory Python live-binary logging matrix: all 12 cases passed after correcting a fixture rejected for known placeholder domains.
  • cd docs && npm run format: blocked locally because prettier is unavailable. The CI docs check passed.
  • All reported CI checks passed, including Axum tests, target-matched linting, docs formatting/build, parity, and integration tests.
  • No existing reviews, inline comments, review threads, or PR issue comments were found.
  • Residual risk: APS payload-specific trace output was not reproduced; the shared logging filter was verified through a real EC trace record.

The revision remained unchanged and the worktree stayed clean. No files were edited and no review work was delegated.

@prk-Jr prk-Jr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The Axum logger now honors a single-level RUST_LOG setting and defaults to info. The startup warning, parser tests, and documentation agree with the selected behavior. No blocking or non-blocking findings.

Reviewed commit: 0b149636304e0e7f184a9f3298f56f9b10d669a8.

Validation

Read both changed files and compared the removed startup code, checked the pinned simple_logger and log implementations, and checked the EdgeZero startup path for competing logger initialization. Validation relies on GitHub CI; no local test suite was rerun.

CI Status

This branch has not been deployed

No deployments
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.

RUST_LOG has no effect on the Axum adapter, which always logs at trace

4 participants