@@ -628,6 +628,7 @@ impl NodeBuilder {
628628 /// Builds a [`Node`] instance with a [`SqliteStore`] backend and according to the options
629629 /// previously configured.
630630 pub fn build ( & self , node_entropy : NodeEntropy ) -> Result < Node , BuildError > {
631+ let logger = setup_logger ( & self . log_writer_config , & self . config ) ?;
631632 let storage_dir_path = self . config . storage_dir_path . clone ( ) ;
632633 fs:: create_dir_all ( storage_dir_path. clone ( ) )
633634 . map_err ( |_| BuildError :: StoragePathAccessFailed ) ?;
@@ -636,20 +637,26 @@ impl NodeBuilder {
636637 Some ( io:: sqlite_store:: SQLITE_DB_FILE_NAME . to_string ( ) ) ,
637638 Some ( io:: sqlite_store:: KV_TABLE_NAME . to_string ( ) ) ,
638639 )
639- . map_err ( |_| BuildError :: KVStoreSetupFailed ) ?;
640- self . build_with_store ( node_entropy, kv_store)
640+ . map_err ( |e| {
641+ log_error ! ( logger, "Failed to setup Sqlite store: {}" , e) ;
642+ BuildError :: KVStoreSetupFailed
643+ } ) ?;
644+ self . build_with_store_and_logger ( node_entropy, kv_store, logger)
641645 }
642646
643647 /// Builds a [`Node`] instance with a [`FilesystemStore`] backend and according to the options
644648 /// previously configured.
645649 pub fn build_with_fs_store ( & self , node_entropy : NodeEntropy ) -> Result < Node , BuildError > {
650+ let logger = setup_logger ( & self . log_writer_config , & self . config ) ?;
646651 let mut storage_dir_path: PathBuf = self . config . storage_dir_path . clone ( ) . into ( ) ;
647652 storage_dir_path. push ( "fs_store" ) ;
648653
649- fs:: create_dir_all ( storage_dir_path. clone ( ) )
650- . map_err ( |_| BuildError :: StoragePathAccessFailed ) ?;
654+ fs:: create_dir_all ( storage_dir_path. clone ( ) ) . map_err ( |e| {
655+ log_error ! ( logger, "Failed to setup Filesystem store: {}" , e) ;
656+ BuildError :: StoragePathAccessFailed
657+ } ) ?;
651658 let kv_store = FilesystemStore :: new ( storage_dir_path) ;
652- self . build_with_store ( node_entropy, kv_store)
659+ self . build_with_store_and_logger ( node_entropy, kv_store, logger )
653660 }
654661
655662 /// Builds a [`Node`] instance with a [VSS] backend and according to the options
@@ -680,7 +687,7 @@ impl NodeBuilder {
680687 BuildError :: KVStoreSetupFailed
681688 } ) ?;
682689
683- self . build_with_store ( node_entropy, vss_store)
690+ self . build_with_store_and_logger ( node_entropy, vss_store, logger )
684691 }
685692
686693 /// Builds a [`Node`] instance with a [VSS] backend and according to the options
@@ -717,7 +724,7 @@ impl NodeBuilder {
717724 BuildError :: KVStoreSetupFailed
718725 } ) ?;
719726
720- self . build_with_store ( node_entropy, vss_store)
727+ self . build_with_store_and_logger ( node_entropy, vss_store, logger )
721728 }
722729
723730 /// Builds a [`Node`] instance with a [VSS] backend and according to the options
@@ -744,7 +751,7 @@ impl NodeBuilder {
744751 BuildError :: KVStoreSetupFailed
745752 } ) ?;
746753
747- self . build_with_store ( node_entropy, vss_store)
754+ self . build_with_store_and_logger ( node_entropy, vss_store, logger )
748755 }
749756
750757 /// Builds a [`Node`] instance with a [VSS] backend and according to the options
@@ -769,7 +776,7 @@ impl NodeBuilder {
769776 BuildError :: KVStoreSetupFailed
770777 } ) ?;
771778
772- self . build_with_store ( node_entropy, vss_store)
779+ self . build_with_store_and_logger ( node_entropy, vss_store, logger )
773780 }
774781
775782 /// Builds a [`Node`] instance according to the options previously configured.
@@ -778,6 +785,12 @@ impl NodeBuilder {
778785 ) -> Result < Node , BuildError > {
779786 let logger = setup_logger ( & self . log_writer_config , & self . config ) ?;
780787
788+ self . build_with_store_and_logger ( node_entropy, kv_store, logger)
789+ }
790+
791+ fn build_with_store_and_logger < S : SyncAndAsyncKVStore + Send + Sync + ' static > (
792+ & self , node_entropy : NodeEntropy , kv_store : S , logger : Arc < Logger > ,
793+ ) -> Result < Node , BuildError > {
781794 let runtime = if let Some ( handle) = self . runtime_handle . as_ref ( ) {
782795 Arc :: new ( Runtime :: with_handle ( handle. clone ( ) , Arc :: clone ( & logger) ) )
783796 } else {
0 commit comments