Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 13 additions & 26 deletions crates/common/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn finalize_proxied_response(

let ct_for_log: &str = if ct_raw.is_empty() { "-" } else { &ct_raw };
log::info!(
"proxy: origin response status={} ct={} cl={} accept={} url={}",
"origin response status={} ct={} cl={} accept={} url={}",
status_code,
ct_for_log,
cl_raw,
Expand Down Expand Up @@ -199,11 +199,7 @@ fn finalize_proxied_response(
}

if is_pixel {
log::info!(
"proxy: likely pixel image fetched: {} ct={}",
target_url,
ct
);
log::info!("likely pixel image fetched: {} ct={}", target_url, ct);
}

return beresp;
Expand Down Expand Up @@ -235,7 +231,7 @@ fn finalize_proxied_response_streaming(

let ct_for_log: &str = if ct_raw.is_empty() { "-" } else { &ct_raw };
log::info!(
"proxy(stream): origin response status={} ct={} cl={} accept={} url={}",
"stream: origin response status={} ct={} cl={} accept={} url={}",
Copy link
Collaborator

Choose a reason for hiding this comment

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

⛏️ Remove stream:

status_code,
ct_for_log,
cl_raw,
Expand Down Expand Up @@ -280,7 +276,7 @@ fn finalize_proxied_response_streaming(

if is_pixel {
log::info!(
"proxy(stream): likely pixel image fetched: {} ct={}",
"stream: likely pixel image fetched: {} ct={}",
target_url,
ct
);
Expand Down Expand Up @@ -340,10 +336,7 @@ fn append_synthetic_id(req: &Request, target_url_parsed: &mut url::Url) {
let synthetic_id_param = match get_synthetic_id(req) {
Ok(id) => id,
Err(e) => {
log::warn!(
"proxy: failed to extract synthetic ID for forwarding: {:?}",
e
);
log::warn!("failed to extract synthetic ID for forwarding: {:?}", e);
None
}
};
Expand All @@ -368,11 +361,11 @@ fn append_synthetic_id(req: &Request, target_url_parsed: &mut url::Url) {
}

log::debug!(
"proxy: forwarding synthetic_id to origin url {}",
"forwarding synthetic_id to origin url {}",
target_url_parsed.as_str()
);
} else {
log::debug!("proxy: no synthetic_id to forward to origin");
log::debug!("no synthetic_id to forward to origin");
}
}

Expand Down Expand Up @@ -469,7 +462,7 @@ async fn proxy_with_redirects(

if redirect_attempt == MAX_REDIRECTS {
log::warn!(
"proxy: redirect limit reached for {}; returning redirect response",
"redirect limit reached for {}; returning redirect response",
current_url
);
return Ok(finalize_proxied_response(
Expand Down Expand Up @@ -498,7 +491,7 @@ async fn proxy_with_redirects(
}

log::info!(
"proxy: following redirect {} => {} (status {})",
"following redirect {} => {} (status {})",
current_url,
next_url,
status.as_u16()
Expand Down Expand Up @@ -569,10 +562,7 @@ pub async fn handle_first_party_click(
let synthetic_id = match get_synthetic_id(&req) {
Ok(id) => id,
Err(e) => {
log::warn!(
"click: failed to extract synthetic ID for forwarding: {:?}",
e
);
log::warn!("failed to extract synthetic ID for forwarding: {:?}", e);
None
}
};
Expand All @@ -599,15 +589,12 @@ pub async fn handle_first_party_click(
}

let final_target = url.to_string();
log::debug!(
"click: forwarding synthetic_id to target url {}",
final_target
);
log::debug!("forwarding synthetic_id to target url {}", final_target);
redirect_target = final_target;
}
Err(e) => {
log::warn!(
"click: failed to parse target url for synthetic forwarding: {:?}",
"failed to parse target url for synthetic forwarding: {:?}",
e
);
}
Expand All @@ -624,7 +611,7 @@ pub async fn handle_first_party_click(
.and_then(|h| h.to_str().ok())
.unwrap_or("");
log::info!(
"click: redirect tsurl={} params_present={} target={} referer={} ua={} synthetic_id={}",
"redirect tsurl={} params_present={} target={} referer={} ua={} synthetic_id={}",
tsurl,
had_params,
redirect_target,
Expand Down
29 changes: 13 additions & 16 deletions crates/common/src/streaming_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl<P: StreamProcessor> StreamingPipeline<P> {
message: "Failed to decompress gzip".to_string(),
})?;

log::info!("[Gzip] Decompressed size: {} bytes", decompressed.len());
log::info!("Decompressed size: {} bytes", decompressed.len());

// Process the decompressed content
let processed = self
Expand All @@ -195,7 +195,7 @@ impl<P: StreamProcessor> StreamingPipeline<P> {
message: "Failed to process content".to_string(),
})?;

log::info!("[Gzip] Processed size: {} bytes", processed.len());
log::info!("Processed size: {} bytes", processed.len());

// Recompress the output
let mut encoder = GzEncoder::new(output, Compression::default());
Expand Down Expand Up @@ -228,10 +228,7 @@ impl<P: StreamProcessor> StreamingPipeline<P> {
message: "Failed to decompress gzip".to_string(),
})?;

log::info!(
"[Gzip->None] Decompressed size: {} bytes",
decompressed.len()
);
log::info!("Gzip->None decompressed size: {} bytes", decompressed.len());
Copy link
Collaborator

Choose a reason for hiding this comment

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

⛏️ Change to Decompressed size


// Process the decompressed content
let processed = self
Expand All @@ -241,7 +238,7 @@ impl<P: StreamProcessor> StreamingPipeline<P> {
message: "Failed to process content".to_string(),
})?;

log::info!("[Gzip->None] Processed size: {} bytes", processed.len());
log::info!("Gzip->None processed size: {} bytes", processed.len());

// Write uncompressed output
output
Expand Down Expand Up @@ -287,7 +284,7 @@ impl<P: StreamProcessor> StreamingPipeline<P> {
})?;

log::info!(
"[Deflate->None] Decompressed size: {} bytes",
"Deflate->None decompressed size: {} bytes",
decompressed.len()
);

Expand All @@ -299,7 +296,7 @@ impl<P: StreamProcessor> StreamingPipeline<P> {
message: "Failed to process content".to_string(),
})?;

log::info!("[Deflate->None] Processed size: {} bytes", processed.len());
log::info!("Deflate->None processed size: {} bytes", processed.len());

// Write uncompressed output
output
Expand Down Expand Up @@ -350,7 +347,7 @@ impl<P: StreamProcessor> StreamingPipeline<P> {
})?;

log::info!(
"[Brotli->None] Decompressed size: {} bytes",
"Brotli->None decompressed size: {} bytes",
decompressed.len()
);

Expand All @@ -362,7 +359,7 @@ impl<P: StreamProcessor> StreamingPipeline<P> {
message: "Failed to process content".to_string(),
})?;

log::info!("[Brotli->None] Processed size: {} bytes", processed.len());
log::info!("Brotli->None processed size: {} bytes", processed.len());

// Write uncompressed output
output
Expand Down Expand Up @@ -462,7 +459,7 @@ impl StreamProcessor for HtmlRewriterAdapter {

if !chunk.is_empty() {
log::debug!(
"[HtmlRewriter] Buffering chunk: {} bytes, total buffered: {} bytes",
"Buffering chunk: {} bytes, total buffered: {} bytes",
chunk.len(),
self.accumulated_input.len()
);
Expand All @@ -471,7 +468,7 @@ impl StreamProcessor for HtmlRewriterAdapter {
// Only process when we have all the input
if is_last {
log::info!(
"[HtmlRewriter] Processing complete document: {} bytes",
"Processing complete document: {} bytes",
self.accumulated_input.len()
);

Expand All @@ -488,17 +485,17 @@ impl StreamProcessor for HtmlRewriterAdapter {

// Process the entire document
rewriter.write(&self.accumulated_input).map_err(|e| {
log::error!("[HtmlRewriter] Failed to process HTML: {}", e);
log::error!("Failed to process HTML: {}", e);
io::Error::other(format!("HTML processing failed: {}", e))
})?;

// Finalize the rewriter
rewriter.end().map_err(|e| {
log::error!("[HtmlRewriter] Failed to finalize: {}", e);
log::error!("Failed to finalize: {}", e);
io::Error::other(format!("HTML finalization failed: {}", e))
})?;

log::debug!("[HtmlRewriter] Output size: {} bytes", output.len());
log::debug!("Output size: {} bytes", output.len());
self.accumulated_input.clear();
Ok(output)
} else {
Expand Down
7 changes: 6 additions & 1 deletion crates/fastly/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,14 @@ fn init_logger() {
fern::Dispatch::new()
.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
))
})
Expand Down