mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-08-07 19:49:07 +00:00
refactor: replace panic with a graceful exit
This commit is contained in:
parent
d0c22b9fc9
commit
96e27328ad
1 changed files with 13 additions and 1 deletions
14
src/main.rs
14
src/main.rs
|
@ -65,7 +65,19 @@ async fn main() -> Result<(), Error> {
|
||||||
launch_info();
|
launch_info();
|
||||||
|
|
||||||
use log::LevelFilter as LF;
|
use log::LevelFilter as LF;
|
||||||
let level = LF::from_str(&CONFIG.log_level()).expect("Valid log level");
|
let level = LF::from_str(&CONFIG.log_level()).unwrap_or_else(|_| {
|
||||||
|
let mut valid_log_levels = "".to_string();
|
||||||
|
LF::iter().fold(true, |first, elem| {
|
||||||
|
let mut joinstr = ", ".to_string();
|
||||||
|
if first {
|
||||||
|
joinstr = "".to_string();
|
||||||
|
}
|
||||||
|
valid_log_levels = format!("{}{}{}", valid_log_levels, joinstr, elem.as_str().to_lowercase());
|
||||||
|
false
|
||||||
|
});
|
||||||
|
println!("Log level must be oe of the following: {valid_log_levels}");
|
||||||
|
exit(1);
|
||||||
|
});
|
||||||
init_logging(level).ok();
|
init_logging(level).ok();
|
||||||
|
|
||||||
let extra_debug = matches!(level, LF::Trace | LF::Debug);
|
let extra_debug = matches!(level, LF::Trace | LF::Debug);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue