Move logging initialization into Fastly adapter (PR 10)#610
Conversation
aram356
left a comment
There was a problem hiding this comment.
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 frommain.rs— the suppression is incorrect and would mask a real warning if the call is removed (logging.rs:8)
🤔 thinking
_messagevsmessage: The original used themessageparameter directly (idiomatic fern). The rename to_message+record.args()is semantically identical but gratuitous (logging.rs:18)
🌱 seedling
rsplit_oncealternative: More explicit thansplit("::").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-fastlycorrectly 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 ::.
aram356
left a comment
There was a problem hiding this comment.
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_labelempty-result fallback:rsplit_onceon"trailing::"returns"", producing log output likeINFO [] 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-corestill depends onfastlydirectly: Removinglog-fastlyis a step toward backend-agnostic core, butfastly = { 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_labelandinit_logger: Both arepub(crate)and lack///comments.init_loggeris a key startup function andtarget_labelhas 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 usesrsplit_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
aram356
left a comment
There was a problem hiding this comment.
Summary
Second-pass review. Prior CHANGES_REQUESTED findings from 2026-04-10 are all resolved in commit dd6929c: #[allow(dead_code)] removed, idiomatic fern message parameter restored, rsplit_once with empty-segment fallback in place, and target_label tests cover the no-separator, empty-string, and trailing-:: cases. The core ↔ adapter boundary move is clean — log-fastly is gone from trusted-server-core and lives only in trusted-server-adapter-fastly. CI is green. Approving with a few non-blocking suggestions inline.
Non-blocking
⛏ nitpick
target_labelvisibility: could be private instead ofpub(crate)(logging.rs:9)- Trailing-
::fallback still contains the separator: cosmetic only; real log targets never hit this (logging.rs:13) - Plan doc drift: plan file still references the pre-
rsplit_oncesnippet per the prior review
🌱 seedling
- Hardcoded
LevelFilter::Info: natural follow-up to wire throughSettingsnow that logging owns its own module (logging.rs:29) chrono::Local::now()under WASI: effectively resolves to UTC via fallback; consider switching tochrono::Utc::now()explicitly (logging.rs:37)
👍 praise
- Clean boundary move: minimal surface, focused tests, prior feedback fully addressed (logging.rs)
CI Status
- browser integration tests: PASS
- integration tests: PASS
- prepare integration artifacts: PASS
Summary
main.rs.log-fastlyfromtrusted-server-coreso core remains backend-agnostic and future Edgezero adapters can rely on the sharedlogfacade only.Changes
crates/trusted-server-adapter-fastly/src/logging.rscrates/trusted-server-adapter-fastly/src/main.rslogging::init_logger()and remove the inline Fastly logger implementation.crates/trusted-server-core/Cargo.tomllog-fastlydependency from core.Cargo.locklog-fastlydependency edge.docs/superpowers/specs/2026-04-02-pr10-logging-initialization-design.mddocs/superpowers/plans/2026-04-02-pr10-logging-initialization.mdCloses
Closes #491
Test plan
cargo test --workspacecargo clippy --workspace --all-targets --all-features -- -D warningscargo fmt --all -- --checkcd crates/js/lib && npx vitest runcd crates/js/lib && npm run formatcd docs && npm run formatcargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1fastly compute serveHardening note
Not applicable. This PR does not touch config-derived regex or pattern compilation.
Checklist
unwrap()in production code — useexpect("should ...")logmacros (notprintln!)