@@ -161,6 +161,8 @@ use std::convert::TryInto;
161161use std:: default:: Default ;
162162use std:: fs;
163163use std:: net:: ToSocketAddrs ;
164+ use std:: os:: unix:: fs:: symlink;
165+ use std:: path:: Path ;
164166use std:: sync:: atomic:: { AtomicBool , Ordering } ;
165167use std:: sync:: { Arc , Mutex , RwLock } ;
166168use std:: time:: { Duration , Instant , SystemTime } ;
@@ -384,8 +386,19 @@ impl Builder {
384386 fs:: create_dir_all ( bdk_data_dir. clone ( ) ) . expect ( "Failed to create BDK data directory" ) ;
385387
386388 // Initialize the Logger
387- let log_file_path = format ! ( "{}/ldk_node.log" , config. storage_dir_path) ;
388- let logger = Arc :: new ( FilesystemLogger :: new ( log_file_path, config. log_level ) ) ;
389+ let log_file_path = format ! (
390+ "{}/logs/ldk_node_{}.log" ,
391+ config. storage_dir_path,
392+ chrono:: offset:: Local :: now( ) . format( "%Y_%m_%d" )
393+ ) ;
394+ let logger = Arc :: new ( FilesystemLogger :: new ( log_file_path. clone ( ) , config. log_level ) ) ;
395+ let log_file_symlink = format ! ( "{}/ldk_node.log" , config. storage_dir_path) ;
396+ if Path :: new ( & log_file_symlink) . exists ( ) {
397+ fs:: remove_file ( & log_file_symlink)
398+ . expect ( "Failed to remove an old symlink for the log file" ) ;
399+ }
400+ symlink ( & log_file_path, & log_file_symlink)
401+ . expect ( & format ! ( "Failed to create symlink for the log file: {}" , log_file_symlink) ) ;
389402
390403 // Initialize the on-chain wallet and chain access
391404 let seed_bytes = match & * self . entropy_source_config . read ( ) . unwrap ( ) {
@@ -1743,7 +1756,7 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
17431756 /// # use ldk_node::bitcoin::Network;
17441757 /// # let mut config = Config::default();
17451758 /// # config.network = Network::Regtest;
1746- /// # config.storage_dir_path = "/tmp/ldk_node_test/ ".to_string();
1759+ /// # config.storage_dir_path = "/tmp/ldk_node_test_list_payments ".to_string();
17471760 /// # let builder = Builder::from_config(config);
17481761 /// # let node = builder.build();
17491762 /// node.list_payments_with_filter(|p| p.direction == PaymentDirection::Outbound);
0 commit comments