Bug Report
Version
│ ├── tracing v0.1.44
│ │ ├── tracing-attributes v0.1.31 (proc-macro)
│ │ └── tracing-core v0.1.36
│ ├── tracing-appender v0.2.5
│ │ └── tracing-subscriber v0.3.23
│ │ ├── tracing-core v0.1.36 (*)
│ │ └── tracing-log v0.2.0
│ │ └── tracing-core v0.1.36 (*)
│ └── tracing-subscriber v0.3.23 (*)
└── tracing v0.1.44 (*)
Platform
Linux 7.1.8-1-cachyos SMP PREEMPT_DYNAMIC x86_64 GNU/Linux
Crates
tracing-appender v0.2.5
Description
When using the latest_symlink feature added in #3447, if a relative path is specified to Builder::build, the symlink also uses the relative path. This results in broken symlinks when a relative path to a directory is specified.
For example, this code:
let appender = RollingFileAppender::builder()
.rotation(Rotation::DAILY)
.filename_prefix("myapp.log")
.latest_symlink("latest.log")
.build("./logs")
.expect("failed to initialize rolling file appender");
Results in the symlink latest.log to point to ./logs/myapp.log.2019-01-01 while itself already inside of the logs directory, so it actually points to ./logs/./logs/myapp.log.2019-01-01, which is invalid.
The workaround is to always specify an absolute path to Builder::build. But this should be fixed by providing the correct path to symlink::symlink_file (either absolute, or fixing the relative path so it's correct):
|
if let Some(symlink_name) = latest_symlink_name { |
|
let symlink_path = directory.join(symlink_name); |
|
let _ = symlink::remove_symlink_file(&symlink_path); |
|
symlink::symlink_file(path, symlink_path).map_err(InitError::ctx( |
|
"failed to create symlink to latest log file", |
|
))?; |
|
} |
Bug Report
Version
Platform
Linux 7.1.8-1-cachyos SMP PREEMPT_DYNAMIC x86_64 GNU/Linux
Crates
tracing-appender v0.2.5
Description
When using the
latest_symlinkfeature added in #3447, if a relative path is specified toBuilder::build, the symlink also uses the relative path. This results in broken symlinks when a relative path to a directory is specified.For example, this code:
Results in the symlink
latest.logto point to./logs/myapp.log.2019-01-01while itself already inside of thelogsdirectory, so it actually points to./logs/./logs/myapp.log.2019-01-01, which is invalid.The workaround is to always specify an absolute path to
Builder::build. But this should be fixed by providing the correctpathtosymlink::symlink_file(either absolute, or fixing the relative path so it's correct):tracing/tracing-appender/src/rolling.rs
Lines 802 to 808 in d9d4c54