Log panics when not attached to a pty

Nathan Sobo created

Hopefully this will give us better forensics if we panic in production.

Change summary

Cargo.lock      | 11 +++++++++++
zed/Cargo.toml  |  1 +
zed/src/main.rs |  1 +
3 files changed, 13 insertions(+)

Detailed changes

Cargo.lock 🔗

@@ -2807,6 +2807,16 @@ dependencies = [
  "value-bag",
 ]
 
+[[package]]
+name = "log-panics"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae0136257df209261daa18d6c16394757c63e032e27aafd8b07788b051082bef"
+dependencies = [
+ "backtrace",
+ "log",
+]
+
 [[package]]
 name = "loom"
 version = "0.4.0"
@@ -5910,6 +5920,7 @@ dependencies = [
  "lazy_static",
  "libc",
  "log",
+ "log-panics",
  "num_cpus",
  "parking_lot",
  "postage",

zed/Cargo.toml 🔗

@@ -35,6 +35,7 @@ image = "0.23"
 lazy_static = "1.4.0"
 libc = "0.2"
 log = "0.4"
+log-panics = { version = "2.0", features = ["with-backtrace"] }
 num_cpus = "1.13.0"
 parking_lot = "0.11.1"
 postage = { version = "0.4.1", features = ["futures-traits"] }

zed/src/main.rs 🔗

@@ -90,6 +90,7 @@ fn init_logger() {
             .expect("could not open logfile");
         simplelog::WriteLogger::init(level, simplelog::Config::default(), log_file)
             .expect("could not initialize logger");
+        log_panics::init();
     }
 }