⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Standardize logging: Remove manual prefixes, add module target to logger format #184

@aram356

Description

@aram356

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 origin

Changes 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

  1. Run locally with fastly compute serve
  2. Trigger various code paths and verify log output includes module names in brackets
  3. Verify no duplicate prefixes appear

Complexity

Low - straightforward string replacements and one logger format change

Labels

  • good first issue
  • tech-debt
  • logging

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions