commit 7439aeb63ef692510c121a0e9f090d58de8d87e2
parent 63459c5f7267f41fbec9aaab4bca131bbc72f162
Author: BlackDex <black.dex@gmail.com>
Date: Tue, 25 Feb 2020 14:10:52 +0100
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.
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git 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(())
}