-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Copy link
Description
Summary
Remove manual prefixes like [Gzip], [HtmlRewriter], proxy: from log messages and update the logger format to automatically include the module name via record.target().
Current State
Log messages use inconsistent manual prefixes:
// streaming_processor.rs - manual prefix
log::info!("[Gzip] Decompressed size: {} bytes", decompressed.len());
// proxy.rs - different manual prefix
log::debug!("proxy: no synthetic_id to forward to origin");
// backend.rs - no prefix
log::info!("enable ssl for backend: {}", backend_name);The logger format in crates/fastly/src/main.rs:132-138 currently outputs:
2026-01-21T10:00:00.000Z INFO message here
It does not include record.target() which would provide the module path automatically.
Target State
Update logger to include module name automatically, then remove manual prefixes:
// Logger format includes module automatically
// streaming_processor.rs
log::info!("Decompressed size: {} bytes", decompressed.len());
// Output: 2026-01-21T10:00:00.000Z INFO [streaming_processor] Decompressed size: 1024 bytes
// proxy.rs
log::debug!("no synthetic_id to forward to origin");
// Output: 2026-01-21T10:00:00.000Z DEBUG [proxy] no synthetic_id to forward to originChanges Required
1. Update logger format in crates/fastly/src/main.rs:132-138
.format(|out, message, record| {
out.finish(format_args!(
"{} {} [{}] {}",
chrono::Local::now().to_rfc3339_opts(chrono::SecondsFormat::Millis, true),
record.level(),
record.target().split("::").last().unwrap_or(record.target()),
message
))
})2. Remove manual prefixes from crates/common/src/streaming_processor.rs
| Line | Current | New |
|---|---|---|
| 188 | "[Gzip] Decompressed size: {} bytes" |
"Decompressed size: {} bytes" |
| 198 | "[Gzip] Processed size: {} bytes" |
"Processed size: {} bytes" |
| 231-232 | "[Gzip->None] Decompressed size: {} bytes" |
"Gzip->None decompressed size: {} bytes" |
| 244 | "[Gzip->None] Processed size: {} bytes" |
"Gzip->None processed size: {} bytes" |
| 289-290 | "[Deflate->None] Decompressed size: {} bytes" |
"Deflate->None decompressed size: {} bytes" |
| 302 | "[Deflate->None] Processed size: {} bytes" |
"Deflate->None processed size: {} bytes" |
| 352-353 | "[Brotli->None] Decompressed size: {} bytes" |
"Brotli->None decompressed size: {} bytes" |
| 365 | "[Brotli->None] Processed size: {} bytes" |
"Brotli->None processed size: {} bytes" |
| 464-465 | "[HtmlRewriter] Buffering chunk..." |
"Buffering chunk..." |
| 473-474 | "[HtmlRewriter] Processing complete document..." |
"Processing complete document..." |
| 491 | "[HtmlRewriter] Failed to process HTML..." |
"Failed to process HTML..." |
| 497 | "[HtmlRewriter] Failed to finalize..." |
"Failed to finalize..." |
| 501 | "[HtmlRewriter] Output size..." |
"Output size..." |
3. Remove manual prefix from crates/common/src/proxy.rs
| Line | Current | New |
|---|---|---|
| 375 | "proxy: no synthetic_id to forward to origin" |
"no synthetic_id to forward to origin" |
Testing
- Run locally with
fastly compute serve - Trigger various code paths and verify log output includes module names in brackets
- Verify no duplicate prefixes appear
Complexity
Low - straightforward string replacements and one logger format change
Labels
good first issuetech-debtlogging