Skip to content

Commit

Permalink
make wrapper not crash if logger setup fails
Browse files Browse the repository at this point in the history
  • Loading branch information
nzbr committed Jul 5, 2024
1 parent 269411c commit ae1ed75
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions utils/src/shell_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,22 @@ fn real_main() -> anyhow::Result<()> {
}

fn main() {
JournalLog::new()
if let Err(err) = JournalLog::new()
.context("When initializing journal logger")
.unwrap()
.with_syslog_identifier("shell-wrapper".to_string())
.install()
.unwrap();
.and_then(|logger| {
logger
.with_syslog_identifier("shell-wrapper".to_string())
.install()
.context("When installing journal logger")
})
{
warn!("Error while setting up journal logger: {:?}", err);
}

log::set_max_level(LevelFilter::Info);

let result = real_main();

env::set_var("RUST_BACKTRACE", "1");
let err = result.unwrap_err();

eprintln!("{:?}", &err);
Expand Down

0 comments on commit ae1ed75

Please sign in to comment.