From 7439aeb63ef692510c121a0e9f090d58de8d87e2 Mon Sep 17 00:00:00 2001 From: BlackDex Date: Tue, 25 Feb 2020 14:10:52 +0100 Subject: [PATCH] Make panics logable (as warn) panic!()'s only appear on stderr, this makes tracking down some strange issues harder with the usage of docker since stderr does not get logged into the bitwarden.log file. This change logs the message to stdout and the logfile when activated. --- src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.rs b/src/main.rs index 7c9d026..3e2a9e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,7 @@ use std::{ path::Path, process::{exit, Command}, str::FromStr, + panic, }; #[macro_use] @@ -121,6 +122,11 @@ fn init_logging(level: log::LevelFilter) -> Result<(), fern::InitError> { logger.apply()?; + // Catch panics and log them instead of default output to StdErr + panic::set_hook(Box::new(|info| { + warn!("[PANIC] {}", info); + })); + Ok(()) }