summaryrefslogtreecommitdiffstats
path: root/zellij-utils
diff options
context:
space:
mode:
authorraphCode <15750438+raphCode@users.noreply.github.com>2022-07-26 17:47:25 +0200
committerGitHub <noreply@github.com>2022-07-26 17:47:25 +0200
commit408f520e4c1c30ed0f90aa80c0a02e3c6e70c511 (patch)
tree194d9b2bbc9cf0fb8aa0e23e8d4646d28ff6d0e9 /zellij-utils
parent9dc392e75b960f53b2b39bf40fca3eb912a91862 (diff)
Log every panic to the logfile (#1602)
* Add unified panic logging * Remove redundant logging in client * Add to changelog * Improve changelog
Diffstat (limited to 'zellij-utils')
-rw-r--r--zellij-utils/src/errors.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs
index 0e18bb9e5..bd2061227 100644
--- a/zellij-utils/src/errors.rs
+++ b/zellij-utils/src/errors.rs
@@ -3,6 +3,7 @@
use crate::channels::{SenderWithContext, ASYNCOPENCALLS, OPENCALLS};
use colored::*;
+use log::error;
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Error, Formatter};
use std::panic::PanicInfo;
@@ -70,13 +71,15 @@ where
let mut report: Report = Panic(format!("\u{1b}[0;31m{}\u{1b}[0;0m", msg)).into();
+ let mut location_string = String::new();
if let Some(location) = info.location() {
- report = report.wrap_err(format!(
+ location_string = format!(
"At {}:{}:{}",
location.file(),
location.line(),
location.column()
- ));
+ );
+ report = report.wrap_err(location_string.clone());
}
if !err_ctx.is_empty() {
@@ -88,6 +91,17 @@ where
thread
));
+ error!(
+ "{}",
+ format!(
+ "Panic occured:
+ thread: {}
+ location: {}
+ message: {}",
+ thread, location_string, msg
+ )
+ );
+
if thread == "main" {
// here we only show the first line because the backtrace is not readable otherwise
// a better solution would be to escape raw mode before we do this, but it's not trivial