Skip to content

Move logging initialization into Fastly adapter (PR 10)#610

Open
prk-Jr wants to merge 10 commits intofeature/edgezero-pr9-wire-signing-to-store-primitivesfrom
feature/edgezero-pr10-abstract-logging-initialization
Open

Move logging initialization into Fastly adapter (PR 10)#610
prk-Jr wants to merge 10 commits intofeature/edgezero-pr9-wire-signing-to-store-primitivesfrom
feature/edgezero-pr10-abstract-logging-initialization

Conversation

@prk-Jr
Copy link
Copy Markdown
Collaborator

@prk-Jr prk-Jr commented Apr 2, 2026

Summary

  • Move Fastly logging initialization into an adapter-local module so backend setup stays owned by the Fastly adapter instead of leaking through main.rs.
  • Remove log-fastly from trusted-server-core so core remains backend-agnostic and future Edgezero adapters can rely on the shared log facade only.
  • Capture the PR 10 design and implementation notes used to keep this stacked migration step scoped against the PR 9 base branch.

Changes

File Change
crates/trusted-server-adapter-fastly/src/logging.rs Add the adapter-local Fastly logger initializer, target-label helper, and unit test.
crates/trusted-server-adapter-fastly/src/main.rs Call logging::init_logger() and remove the inline Fastly logger implementation.
crates/trusted-server-core/Cargo.toml Remove the log-fastly dependency from core.
Cargo.lock Update the lockfile after removing core's log-fastly dependency edge.
docs/superpowers/specs/2026-04-02-pr10-logging-initialization-design.md Add the PR 10 design note and scope.
docs/superpowers/plans/2026-04-02-pr10-logging-initialization.md Add the implementation plan for the logging boundary change.

Closes

Closes #491

Test plan

  • cargo test --workspace
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • JS tests: cd crates/js/lib && npx vitest run
  • JS format: cd crates/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:

Hardening note

Not applicable. This PR does not touch config-derived regex or pattern compilation.

Checklist

  • Changes follow CLAUDE.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses log macros (not println!)
  • New code has tests
  • No secrets or credentials committed

@prk-Jr prk-Jr self-assigned this Apr 2, 2026
@aram356 aram356 marked this pull request as draft April 2, 2026 15:32
@prk-Jr prk-Jr marked this pull request as ready for review April 3, 2026 12:27
Copy link
Copy Markdown
Collaborator

@aram356 aram356 left a comment

Choose a reason for hiding this comment

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

Summary

Clean, well-scoped extraction that correctly moves Fastly logging initialization into the adapter, making trusted-server-core backend-agnostic. No behavioral changes.

Non-blocking

🔧 wrench

  • Unnecessary #[allow(dead_code)]: init_logger() is called from main.rs — the suppression is incorrect and would mask a real warning if the call is removed (logging.rs:8)

🤔 thinking

  • _message vs message: The original used the message parameter directly (idiomatic fern). The rename to _message + record.args() is semantically identical but gratuitous (logging.rs:18)

🌱 seedling

  • rsplit_once alternative: More explicit than split("::").last() for extracting the final segment (logging.rs:4)
  • Missing test edge cases: No coverage for inputs without ::, empty strings, or trailing :: (logging.rs:38)

👍 praise

  • Clean separation of concerns: log-fastly correctly removed from core, adapter owns its logging, pub(crate) visibility is correct
  • Thorough design and plan docs: Clear scope, out-of-scope boundaries, and reproducible implementation plan

- Reverted gratuitous _message rename and record.args() usage in logging.rs, returning to the idiomatic message parameter inside the fern format closure.
- Refactored target_label to use .rsplit_once("::") rather than .split("::").last(). This provides a more explicit and robust way to extract the final module segment.
- Expanded target_label test coverage to explicitly test edge cases such as inputs without :: separators, empty strings, and inputs with trailing ::.
@prk-Jr prk-Jr linked an issue Apr 8, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Collaborator

@aram356 aram356 left a comment

Choose a reason for hiding this comment

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

Summary

Clean extraction of Fastly logging initialization from trusted-server-core into trusted-server-adapter-fastly. The change is small, well-scoped, and achieves the stated goal of making core backend-agnostic for logging. CI passes.

Non-blocking

🤔 thinking

  • target_label empty-result fallback: rsplit_once on "trailing::" returns "", producing log output like INFO [] message. Consider falling back to the full target when the extracted segment is empty. (crates/trusted-server-adapter-fastly/src/logging.rs:5)

📌 out of scope

  • trusted-server-core still depends on fastly directly: Removing log-fastly is a step toward backend-agnostic core, but fastly = { workspace = true } remains in core's Cargo.toml. Worth tracking as a follow-up. (crates/trusted-server-core/Cargo.toml:25)

🌱 seedling

  • Missing doc comments on target_label and init_logger: Both are pub(crate) and lack /// comments. init_logger is a key startup function and target_label has non-obvious semantics — a brief doc comment would help. (crates/trusted-server-adapter-fastly/src/logging.rs:4,8)

⛏ nitpick

  • Plan/implementation mismatch: Plan shows split("::").last().unwrap_or(target) but implementation uses rsplit_once. Implementation is better, but the plan doc is now inaccurate. (docs/superpowers/plans/2026-04-02-pr10-logging-initialization.md:81)

CI Status

  • integration tests: PASS
  • browser integration tests: PASS
  • prepare integration artifacts: PASS

@prk-Jr prk-Jr requested a review from aram356 April 10, 2026 08:48
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.

Abstract logging initialization

3 participants