Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion crates/rrg/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,29 @@
// Use of this source code is governed by an MIT-style license that can be found
// in the LICENSE file or at https://opensource.org/licenses/MIT.

use log::info;
use log::{error, info};

fn main() {
let args = rrg::args::from_env_args();
rrg::log::init(&args);

// TODO: https://github.com/rust-lang/rust/issues/92649
//
// Refactor once `panic_update_hook` is stable.

// Because Fleetspeak does not necessarily capture RRG's standard error, it
// might be difficult to find reason behind a crash. Thus, we extend the
// standard panic hook to also log the panic message.
let panic_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
// Note that logging is an I/O operation and it itself might panic. In
// case of the logging failure it does not end in an endless cycle (of
// trying to log, which panics, which tries to log and so on) but it
// triggers an abort which is fine.
error!("thread panicked: {info}");
panic_hook(info)
}));

info!("sending Fleetspeak startup information");
fleetspeak::startup(env!("CARGO_PKG_VERSION"));

Expand Down
Loading