diff --git a/src/builder.rs b/src/builder.rs index c14ffcf5a..3a34a8a01 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1231,6 +1231,8 @@ fn build_with_store_internal( }) } +/// Sets up the node logger, creating a new log file if it does not exist, or utilizing +/// the existing log file. fn setup_logger(config: &Config) -> Result, BuildError> { let log_dir = match &config.log_dir_path { Some(log_dir) => String::from(log_dir), diff --git a/src/logger.rs b/src/logger.rs index 19df24367..ea2effb74 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -14,8 +14,6 @@ use chrono::Utc; use std::fs; use std::io::Write; -#[cfg(not(target_os = "windows"))] -use std::os::unix::fs::symlink; use std::path::Path; pub(crate) struct FilesystemLogger { @@ -24,33 +22,20 @@ pub(crate) struct FilesystemLogger { } impl FilesystemLogger { + /// Creates a new filesystem logger given the path to the log file directory and the log level. pub(crate) fn new(log_dir: String, level: Level) -> Result { - let log_file_name = - format!("ldk_node_{}.log", chrono::offset::Local::now().format("%Y_%m_%d")); + let log_file_name = "ldk_node.log"; let log_file_path = format!("{}/{}", log_dir, log_file_name); if let Some(parent_dir) = Path::new(&log_file_path).parent() { fs::create_dir_all(parent_dir).expect("Failed to create log parent directory"); - // make sure the file exists, so that the symlink has something to point to. + // make sure the file exists. fs::OpenOptions::new() .create(true) .append(true) .open(log_file_path.clone()) .map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?; - - #[cfg(not(target_os = "windows"))] - { - // Create a symlink to the current log file, with prior cleanup - let log_file_symlink = parent_dir.join("ldk_node_latest.log"); - if log_file_symlink.as_path().is_symlink() { - fs::remove_file(&log_file_symlink).map_err(|e| { - eprintln!("ERROR: Failed to remove log file symlink: {}", e) - })?; - } - symlink(&log_file_name, &log_file_symlink) - .map_err(|e| eprintln!("ERROR: Failed to create log file symlink: {}", e))?; - } } Ok(Self { file_path: log_file_path, level }) diff --git a/tests/integration_tests_rust.rs b/tests/integration_tests_rust.rs index dc5c4b818..85174bec7 100644 --- a/tests/integration_tests_rust.rs +++ b/tests/integration_tests_rust.rs @@ -232,8 +232,8 @@ fn start_stop_reinit() { node.sync_wallets().unwrap(); assert_eq!(node.list_balances().spendable_onchain_balance_sats, expected_amount.to_sat()); - let log_file_symlink = format!("{}/logs/ldk_node_latest.log", config.clone().storage_dir_path); - assert!(std::path::Path::new(&log_file_symlink).is_symlink()); + let log_file = format!("{}/logs/ldk_node.log", config.clone().storage_dir_path); + assert!(std::path::Path::new(&log_file).exists()); node.stop().unwrap(); assert_eq!(node.stop(), Err(NodeError::NotRunning));