Log every panic to the logfile (#1602)

* Add unified panic logging

* Remove redundant logging in client

* Add to changelog

* Improve changelog
This commit is contained in:
raphCode 2022-07-26 17:47:25 +02:00 committed by GitHub
parent 9dc392e75b
commit 408f520e4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View file

@ -65,6 +65,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* fix: avoid sending mouse click events on pane frames to applications (https://github.com/zellij-org/zellij/pull/1584)
* feat: search through terminal scrollback (https://github.com/zellij-org/zellij/pull/1521)
* feat: support themes directory (https://github.com/zellij-org/zellij/pull/1577)
* feat: Improve logging by writing server panics into the logfile (https://github.com/zellij-org/zellij/pull/1602)
## [0.30.0] - 2022-06-07
* fix: right and middle clicks creating selection (https://github.com/zellij-org/zellij/pull/1372)

View file

@ -7,7 +7,6 @@ mod sessions;
mod stdin_ansi_parser;
mod stdin_handler;
use log::error;
use log::info;
use std::env::current_exe;
use std::io::{self, Write};
@ -210,7 +209,6 @@ pub fn start_client(
let send_client_instructions = send_client_instructions.clone();
let os_input = os_input.clone();
Box::new(move |info| {
error!("Panic occurred in client:\n{:?}", info);
if let Ok(()) = os_input.unset_raw_mode(0) {
handle_panic(info, &send_client_instructions);
}

View file

@ -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