emabee / flexi_logger

A flexible logger for rust programs that can write to stderr, stdout, and/or to log files
Apache License 2.0
315 stars 55 forks source link

Rotated logs are not deleted when directory uses a UNC path on Windows #173

Closed mtkennerly closed 1 month ago

mtkennerly commented 1 month ago

Hi! On Windows, with something like .log_to_file(FileSpec::default().directory(r"\\?\C:\tmp")) with rotation, I see the following behavior:

For many paths, I can simplify the UNC style (\\?\C:\ -> C:\), but that's not always possible. In particular, I have a use case involving Windows network shares, which use paths like \\?\UNC\localhost\share-name.

For context, here's my full logging setup: https://github.com/mtkennerly/ludusavi/blob/0067872d697008252d22fb7452ce1f0353437557/src/main.rs#L24-L49

emabee commented 1 month ago

Might be caused by https://github.com/rust-lang/glob/issues/145.

emabee commented 1 month ago

Could you please try using method dunce::simplified on the path that you give to flexi_logger::FileSpec::directory()?

mtkennerly commented 1 month ago

That works for paths like r"\\?\C:\tmp" (which I simplify already), but not for paths like r"\\?\UNC\localhost\share-name", unfortunately. That kind of path can't be simplified.

emabee commented 1 month ago

With version 0.29.3 I removed the dependency to glob and implemented the necessary file searches explicitly. This should have the "side-effect" to also fix this issue here.

mtkennerly commented 4 weeks ago

I can confirm the new version works for me 🎉 Thanks!