@@ -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 ;
@@ -238,17 +238,21 @@ pub fn run_node(matches: &ArgMatches) -> Result<(), String> {
238238 . expect ( "Current time should be later than unix epoch" )
239239 . subsec_nanos ( ) as usize ,
240240 ) ;
241- let email_alarm_config = if !config. email_alarm . disable . unwrap ( ) {
242- match ( & config. email_alarm . to , & config. email_alarm . sendgrid_key ) {
241+ let email_alarm = if !config. email_alarm . disable . unwrap ( ) {
242+ let config = match ( & config. email_alarm . to , & config. email_alarm . sendgrid_key ) {
243243 ( Some ( to) , Some ( sendgrid_key) ) => Some ( EmailAlarmConfig :: new ( to. to_string ( ) , sendgrid_key. to_string ( ) ) ) ,
244244 ( None , _) => return Err ( "email-alarm-to is not specified" . to_string ( ) ) ,
245245 ( _, None ) => return Err ( "email-alarm-sendgrid-key is not specified" . to_string ( ) ) ,
246- }
246+ } ;
247+ config. as_ref ( ) . map ( EmailAlarm :: new)
247248 } else {
248249 None
249250 } ;
250- clogger:: init ( & LoggerConfig :: new ( instance_id) , & email_alarm_config )
251+ clogger:: init ( & LoggerConfig :: new ( instance_id) , email_alarm . clone ( ) )
251252 . expect ( "Logger must be successfully initialized" ) ;
253+ if let Some ( email_alarm) = email_alarm {
254+ panic_hook:: set_with_email_alarm ( email_alarm) ;
255+ }
252256
253257 let pf = load_password_file ( & config. operating . password_path ) ?;
254258 let base_path = config. operating . base_path . as_ref ( ) . unwrap ( ) . clone ( ) ;
0 commit comments