Skip to content

Commit 6c77423

Browse files
authored
chore: don't log backtraces (#318)
The backtraces are huge and not readable with the default formatter, so there's no point in logging them.
1 parent c75251a commit 6c77423

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

cot/src/error_page.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ pub(super) fn handle_response_panic(
274274
log_panic(
275275
panic_payload,
276276
panic_location.as_deref(),
277-
backtrace.as_ref(),
278277
request_data.as_ref(),
279278
);
280279
build_response(
@@ -401,8 +400,7 @@ fn log_error(error: &Error, request_data: Option<&RequestData>) {
401400
let span = tracing::span!(Level::ERROR,
402401
"request_error",
403402
error_type = %error.inner,
404-
error_message = %error,
405-
backtrace = ?error.backtrace()
403+
error_message = %error
406404
);
407405
let _enter = span.enter();
408406
if let Some(req) = request_data {
@@ -415,15 +413,13 @@ fn log_error(error: &Error, request_data: Option<&RequestData>) {
415413
fn log_panic(
416414
panic_payload: &Box<dyn Any + Send>,
417415
panic_location: Option<&str>,
418-
backtrace: Option<&Backtrace>,
419416
request_data: Option<&RequestData>,
420417
) {
421418
let span = tracing::span!(
422419
Level::ERROR,
423420
"request_panic",
424421
panic_message = ?ErrorPageTemplateBuilder::get_panic_string(panic_payload),
425-
location = ?panic_location,
426-
backtrace = ?backtrace
422+
location = ?panic_location
427423
);
428424
let _enter = span.enter();
429425
if let Some(req) = request_data {
@@ -485,15 +481,9 @@ mod tests {
485481
fn test_log_panic() {
486482
let panic_payload: Box<dyn Any + Send> = Box::new("Test panic");
487483
let panic_location = Some("src/test.rs:10");
488-
let backtrace = Some(__cot_create_backtrace());
489484
let request_data = Some(create_test_request_data());
490485

491-
log_panic(
492-
&panic_payload,
493-
panic_location,
494-
backtrace.as_ref(),
495-
request_data.as_ref(),
496-
);
486+
log_panic(&panic_payload, panic_location, request_data.as_ref());
497487

498488
assert!(logs_contain("Request handler panicked"));
499489
assert!(logs_contain("Test panic"));

0 commit comments

Comments
 (0)