Skip to content

Commit 54cd575

Browse files
authored
Merge pull request #1818 from ehuss/response-log
Reduce response logging.
2 parents 2a42a20 + 0d0196a commit 54cd575

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,20 @@ async fn run_server(addr: SocketAddr) -> anyhow::Result<()> {
298298
Ok::<_, hyper::Error>(hyper::service::service_fn(move |req| {
299299
let uuid = uuid::Uuid::new_v4();
300300
let span = tracing::span!(tracing::Level::INFO, "request", ?uuid);
301+
// Only log the webhook responses at INFO level to avoid flooding the
302+
// logs with huge responses. Other responses are at DEBUG.
303+
let log_info_response = matches!(req.uri().path(), "/github-hook" | "/zulip-hook");
301304
serve_req(req, ctx.clone(), agenda.clone())
302305
.map(move |mut resp| {
303306
if let Ok(resp) = &mut resp {
304307
resp.headers_mut()
305308
.insert("X-Request-Id", uuid.to_string().parse().unwrap());
306309
}
307-
log::info!("response = {:?}", resp);
310+
if log_info_response {
311+
log::info!("response = {resp:?}");
312+
} else {
313+
log::debug!("response = {resp:?}");
314+
}
308315
resp
309316
})
310317
.instrument(span)

0 commit comments

Comments
 (0)