vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

commit 93b7ded1e6d34c42e756fdc80a629f76db5f0c47
parent 29c6b145ca40e5bc125f2fb7f00b3ef5dca90d87
Author: Daniel GarcĂ­a <dani-garcia@users.noreply.github.com>
Date:   Wed, 12 Aug 2020 18:45:26 +0200

Remove unneccessary shim for backtrace

Diffstat:
Msrc/main.rs | 27++++++++-------------------
1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -17,7 +17,6 @@ extern crate diesel; extern crate diesel_migrations; use std::{ - fmt, // For panic logging fs::create_dir_all, panic, path::Path, @@ -26,6 +25,8 @@ use std::{ thread, }; +use structopt::StructOpt; + #[macro_use] mod error; mod api; @@ -39,18 +40,6 @@ mod util; pub use config::CONFIG; pub use error::{Error, MapResult}; -use structopt::StructOpt; - -// Used for catching panics and log them to file instead of stderr -use backtrace::Backtrace; -struct Shim(Backtrace); - -impl fmt::Debug for Shim { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "\n{:?}", self.0) - } -} - #[derive(Debug, StructOpt)] #[structopt(name = "bitwarden_rs", about = "A Bitwarden API server written in Rust")] struct Opt { @@ -156,8 +145,6 @@ fn init_logging(level: log::LevelFilter) -> Result<(), fern::InitError> { // Catch panics and log them instead of default output to StdErr panic::set_hook(Box::new(|info| { - let backtrace = Backtrace::new(); - let thread = thread::current(); let thread = thread.name().unwrap_or("unnamed"); @@ -169,23 +156,25 @@ fn init_logging(level: log::LevelFilter) -> Result<(), fern::InitError> { }, }; + let backtrace = backtrace::Backtrace::new(); + match info.location() { Some(location) => { error!( - target: "panic", "thread '{}' panicked at '{}': {}:{}{:?}", + target: "panic", "thread '{}' panicked at '{}': {}:{}\n{:?}", thread, msg, location.file(), location.line(), - Shim(backtrace) + backtrace ); } None => error!( target: "panic", - "thread '{}' panicked at '{}'{:?}", + "thread '{}' panicked at '{}'\n{:?}", thread, msg, - Shim(backtrace) + backtrace ), } }));