File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 33// Use of this source code is governed by an MIT-style license that can be found
44// in the LICENSE file or at https://opensource.org/licenses/MIT.
55
6- use log:: info;
6+ use log:: { error , info} ;
77
88fn main ( ) {
99 let args = rrg:: args:: from_env_args ( ) ;
1010 rrg:: log:: init ( & args) ;
1111
12+ // TODO: https://github.com/rust-lang/rust/issues/92649
13+ //
14+ // Refactor once `panic_update_hook` is stable.
15+
16+ // Because Fleetspeak does not necessarily capture RRG's standard error, it
17+ // might be difficult to find reason behind a crash. Thus, we extend the
18+ // standard panic hook to also log the panic message.
19+ let panic_hook = std:: panic:: take_hook ( ) ;
20+ std:: panic:: set_hook ( Box :: new ( move |info| {
21+ // Note that logging is an I/O operation and it itself might panic. In
22+ // case of the logging failure it does not end in an endless cycle (of
23+ // trying to log, which panics, which tries to log and so on) but it
24+ // triggers an abort which is fine.
25+ error ! ( "thread panicked: {info}" ) ;
26+ panic_hook ( info)
27+ } ) ) ;
28+
1229 info ! ( "sending Fleetspeak startup information" ) ;
1330 fleetspeak:: startup ( env ! ( "CARGO_PKG_VERSION" ) ) ;
1431
You can’t perform that action at this time.
0 commit comments