Skip to content

Commit bd44692

Browse files
committed
Fix logger symlink setup
Currently we check the for the existence of the log file the symlink is pointing to before removing the symlink. This could lead to weird issues when a log file was removed, as we'd then never remove and update the symlink. Here, we remove the superfluous check and just check that the path in question is indeed a symlink before removing it. While we're at it we introduce some logging to `stderr` that might help debug issues arising during logger setup.
1 parent ed6c529 commit bd44692

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/logger.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ impl FilesystemLogger {
2929
.create(true)
3030
.append(true)
3131
.open(log_file_path.clone())
32-
.map_err(|_| ())?;
32+
.map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?;
3333

3434
// Create a symlink to the current log file, with prior cleanup
3535
let log_file_symlink = parent_dir.join("ldk_node_latest.log");
36-
if log_file_symlink.as_path().exists() && log_file_symlink.as_path().is_symlink() {
37-
fs::remove_file(&log_file_symlink).map_err(|_| ())?;
36+
if log_file_symlink.as_path().is_symlink() {
37+
fs::remove_file(&log_file_symlink)
38+
.map_err(|e| eprintln!("ERROR: Failed to remove log file symlink: {}", e))?;
3839
}
39-
symlink(&log_file_name, &log_file_symlink).map_err(|_| ())?;
40+
symlink(&log_file_name, &log_file_symlink)
41+
.map_err(|e| eprintln!("ERROR: Failed to create log file symlink: {}", e))?;
4042
}
4143

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

0 commit comments

Comments
 (0)