Skip to content

Commit

Permalink
fix: escape newlines in logged bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
stevensdavid committed Jun 27, 2024
1 parent 4cf2edf commit 7c88d2e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "prodzilla"
version = "0.0.3-rc.3"
version = "0.0.3-rc.4"
edition = "2021"

[dependencies]
Expand Down
6 changes: 5 additions & 1 deletion src/alerts/outbound_webhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ pub async fn alert_if_failure(
Some(_) => Some("Redacted".to_owned()),
None => None,
};
let log_body = truncated_body
.as_ref()
.unwrap_or(&"N/A".to_owned())
.replace("\n", "\\n");
warn!(
"Probe {probe_name} failed at {failure_timestamp} with trace ID {}. Status code: {}. Error: {error_message}. Body: {}",
trace_id.as_ref().unwrap_or(&"N/A".to_owned()),
status_code.map_or("N/A".to_owned(), |code| code.to_string()),
truncated_body.as_ref().unwrap_or(&"N/A".to_owned()),
log_body,
);
let mut errors = Vec::new();
if let Some(alerts_vec) = alerts {
Expand Down

0 comments on commit 7c88d2e

Please sign in to comment.