Skip to content

Commit 3c06c91

Browse files
committed
fix: escape newlines in logged bodies
1 parent 4cf2edf commit 3c06c91

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[package]
44
name = "prodzilla"
5-
version = "0.0.3-rc.3"
5+
version = "0.0.3-rc.4"
66
edition = "2021"
77

88
[dependencies]

src/alerts/outbound_webhook.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ pub async fn alert_if_failure(
3737
Some(_) => Some("Redacted".to_owned()),
3838
None => None,
3939
};
40+
let log_body = truncated_body
41+
.as_ref()
42+
.unwrap_or(&"N/A".to_owned())
43+
.replace('\n', "\\n");
4044
warn!(
4145
"Probe {probe_name} failed at {failure_timestamp} with trace ID {}. Status code: {}. Error: {error_message}. Body: {}",
4246
trace_id.as_ref().unwrap_or(&"N/A".to_owned()),
4347
status_code.map_or("N/A".to_owned(), |code| code.to_string()),
44-
truncated_body.as_ref().unwrap_or(&"N/A".to_owned()),
48+
log_body,
4549
);
4650
let mut errors = Vec::new();
4751
if let Some(alerts_vec) = alerts {

0 commit comments

Comments
 (0)