Skip to content

Commit

Permalink
Don't show port number in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
j-chmielewski committed Mar 27, 2024
1 parent 1948fe6 commit 079a67b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ where
let split: Vec<&str> = log.split(['=', ' ']).collect();
let method = split.get(1).unwrap_or(&"unknown");
let path = split.get(3).unwrap_or(&"unknown");
let ip = split.get(5).unwrap_or(&"unknown").replace('"', "");

let addr = split.get(5).and_then(|s| Some(s.replace('"', "")));
let ip = addr
.and_then(|s| s.split(":").next().map(|s| s.to_string()))
.unwrap_or("unknown".to_string());
write!(writer, "{ip} {method} {path} ")?;
}

Expand Down

0 comments on commit 079a67b

Please sign in to comment.