@@ -28,7 +28,7 @@ use ckey::{Address, NetworkId, PlatformAddress};
2828use ckeystore:: accounts_dir:: RootDiskDirectory ;
2929use ckeystore:: KeyStore ;
3030use clap:: ArgMatches ;
31- use clogger:: { self , EmailAlarmConfig , LoggerConfig } ;
31+ use clogger:: { self , EmailAlarm , EmailAlarmConfig , LoggerConfig } ;
3232use cnetwork:: { Filters , NetworkConfig , NetworkControl , NetworkService , RoutingTable , SocketAddr } ;
3333use csync:: { BlockSyncExtension , BlockSyncSender , SnapshotService , TransactionSyncExtension } ;
3434use ctimer:: TimerLoop ;
@@ -236,17 +236,21 @@ pub fn run_node(matches: &ArgMatches) -> Result<(), String> {
236236 . expect ( "Current time should be later than unix epoch" )
237237 . subsec_nanos ( ) as usize ,
238238 ) ;
239- let email_alarm_config = if !config. email_alarm . disable . unwrap ( ) {
240- match ( & config. email_alarm . to , & config. email_alarm . sendgrid_key ) {
239+ let email_alarm = if !config. email_alarm . disable . unwrap ( ) {
240+ let config = match ( & config. email_alarm . to , & config. email_alarm . sendgrid_key ) {
241241 ( Some ( to) , Some ( sendgrid_key) ) => Some ( EmailAlarmConfig :: new ( to. to_string ( ) , sendgrid_key. to_string ( ) ) ) ,
242242 ( None , _) => return Err ( "email-alarm-to is not specified" . to_string ( ) ) ,
243243 ( _, None ) => return Err ( "email-alarm-sendgrid-key is not specified" . to_string ( ) ) ,
244- }
244+ } ;
245+ config. as_ref ( ) . map ( EmailAlarm :: new)
245246 } else {
246247 None
247248 } ;
248- clogger:: init ( & LoggerConfig :: new ( instance_id) , & email_alarm_config )
249+ clogger:: init ( & LoggerConfig :: new ( instance_id) , email_alarm . clone ( ) )
249250 . expect ( "Logger must be successfully initialized" ) ;
251+ if let Some ( email_alarm) = email_alarm {
252+ panic_hook:: set_with_email_alarm ( email_alarm) ;
253+ }
250254
251255 let pf = load_password_file ( & config. operating . password_path ) ?;
252256 let base_path = config. operating . base_path . as_ref ( ) . unwrap ( ) . clone ( ) ;
0 commit comments