geforkt von mirrored/vaultwarden
Remove unneccessary shim for backtrace
Dieser Commit ist enthalten in:
Ursprung
29c6b145ca
Commit
93b7ded1e6
1 geänderte Dateien mit 8 neuen und 19 gelöschten Zeilen
27
src/main.rs
27
src/main.rs
|
@ -17,7 +17,6 @@ extern crate diesel;
|
||||||
extern crate diesel_migrations;
|
extern crate diesel_migrations;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fmt, // For panic logging
|
|
||||||
fs::create_dir_all,
|
fs::create_dir_all,
|
||||||
panic,
|
panic,
|
||||||
path::Path,
|
path::Path,
|
||||||
|
@ -26,6 +25,8 @@ use std::{
|
||||||
thread,
|
thread,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use structopt::StructOpt;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod error;
|
mod error;
|
||||||
mod api;
|
mod api;
|
||||||
|
@ -39,18 +40,6 @@ mod util;
|
||||||
pub use config::CONFIG;
|
pub use config::CONFIG;
|
||||||
pub use error::{Error, MapResult};
|
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)]
|
#[derive(Debug, StructOpt)]
|
||||||
#[structopt(name = "bitwarden_rs", about = "A Bitwarden API server written in Rust")]
|
#[structopt(name = "bitwarden_rs", about = "A Bitwarden API server written in Rust")]
|
||||||
struct Opt {
|
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
|
// Catch panics and log them instead of default output to StdErr
|
||||||
panic::set_hook(Box::new(|info| {
|
panic::set_hook(Box::new(|info| {
|
||||||
let backtrace = Backtrace::new();
|
|
||||||
|
|
||||||
let thread = thread::current();
|
let thread = thread::current();
|
||||||
let thread = thread.name().unwrap_or("unnamed");
|
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() {
|
match info.location() {
|
||||||
Some(location) => {
|
Some(location) => {
|
||||||
error!(
|
error!(
|
||||||
target: "panic", "thread '{}' panicked at '{}': {}:{}{:?}",
|
target: "panic", "thread '{}' panicked at '{}': {}:{}\n{:?}",
|
||||||
thread,
|
thread,
|
||||||
msg,
|
msg,
|
||||||
location.file(),
|
location.file(),
|
||||||
location.line(),
|
location.line(),
|
||||||
Shim(backtrace)
|
backtrace
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
None => error!(
|
None => error!(
|
||||||
target: "panic",
|
target: "panic",
|
||||||
"thread '{}' panicked at '{}'{:?}",
|
"thread '{}' panicked at '{}'\n{:?}",
|
||||||
thread,
|
thread,
|
||||||
msg,
|
msg,
|
||||||
Shim(backtrace)
|
backtrace
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
Laden …
In neuem Issue referenzieren