Skip to content

Commit 24cf565

Browse files
committed
revert: removes date from & symlink to log files (PR #116)
This commit reverts the changes introduce by PR #116 which added the date to log files when the node is started & a symlink to track the latest log file. This reversal is necessary to simplify the work required to integrate with OS-level log tools.
1 parent 9e00f35 commit 24cf565

File tree

3 files changed

+7
-20
lines changed

3 files changed

+7
-20
lines changed

src/builder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,8 @@ fn build_with_store_internal(
12311231
})
12321232
}
12331233

1234+
/// Sets up the node logger, creating a new log file if it does not exist, or utilizing
1235+
/// the existing log file.
12341236
fn setup_logger(config: &Config) -> Result<Arc<FilesystemLogger>, BuildError> {
12351237
let log_dir = match &config.log_dir_path {
12361238
Some(log_dir) => String::from(log_dir),

src/logger.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ use chrono::Utc;
1414

1515
use std::fs;
1616
use std::io::Write;
17-
#[cfg(not(target_os = "windows"))]
18-
use std::os::unix::fs::symlink;
1917
use std::path::Path;
2018

2119
pub(crate) struct FilesystemLogger {
@@ -24,33 +22,20 @@ pub(crate) struct FilesystemLogger {
2422
}
2523

2624
impl FilesystemLogger {
25+
/// Creates a new filesystem logger given the path to the log file directory and the log level.
2726
pub(crate) fn new(log_dir: String, level: Level) -> Result<Self, ()> {
28-
let log_file_name =
29-
format!("ldk_node_{}.log", chrono::offset::Local::now().format("%Y_%m_%d"));
27+
let log_file_name = "ldk_node.log";
3028
let log_file_path = format!("{}/{}", log_dir, log_file_name);
3129

3230
if let Some(parent_dir) = Path::new(&log_file_path).parent() {
3331
fs::create_dir_all(parent_dir).expect("Failed to create log parent directory");
3432

35-
// make sure the file exists, so that the symlink has something to point to.
33+
// make sure the file exists.
3634
fs::OpenOptions::new()
3735
.create(true)
3836
.append(true)
3937
.open(log_file_path.clone())
4038
.map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?;
41-
42-
#[cfg(not(target_os = "windows"))]
43-
{
44-
// Create a symlink to the current log file, with prior cleanup
45-
let log_file_symlink = parent_dir.join("ldk_node_latest.log");
46-
if log_file_symlink.as_path().is_symlink() {
47-
fs::remove_file(&log_file_symlink).map_err(|e| {
48-
eprintln!("ERROR: Failed to remove log file symlink: {}", e)
49-
})?;
50-
}
51-
symlink(&log_file_name, &log_file_symlink)
52-
.map_err(|e| eprintln!("ERROR: Failed to create log file symlink: {}", e))?;
53-
}
5439
}
5540

5641
Ok(Self { file_path: log_file_path, level })

tests/integration_tests_rust.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ fn start_stop_reinit() {
232232
node.sync_wallets().unwrap();
233233
assert_eq!(node.list_balances().spendable_onchain_balance_sats, expected_amount.to_sat());
234234

235-
let log_file_symlink = format!("{}/logs/ldk_node_latest.log", config.clone().storage_dir_path);
236-
assert!(std::path::Path::new(&log_file_symlink).is_symlink());
235+
let log_file = format!("{}/logs/ldk_node.log", config.clone().storage_dir_path);
236+
assert!(std::path::Path::new(&log_file).exists());
237237

238238
node.stop().unwrap();
239239
assert_eq!(node.stop(), Err(NodeError::NotRunning));

0 commit comments

Comments
 (0)