feat: Adding SingleFile appender#135
Conversation
SingleFile appenderSingleFile appender
SingleFile appenderSingleFile appender
| //! use logforth::append::single_file::SingleFileBuilder; | ||
| //! use logforth::layout::JsonLayout; | ||
| //! | ||
| //! let (file_writer, _guard) = SingleFileBuilder::new("/path/to/flile.log") |
There was a problem hiding this comment.
This doc test would fail because /path/to/file.log typically no permission to access and non-exist.
There was a problem hiding this comment.
Oops, I always forget to make sure I've run the doc tests because I use nextest. Think it's passing now, ran with cargo test --doc --features single-file,json.
tisonkun
left a comment
There was a problem hiding this comment.
Thanks for your contribution! Merging ...
|
I reviewed this patch today and noticed that if the RollingFile appender can set the full file name and doesn't always include Related to #143. |
|
Yes, I originally tried fulfilling my use case with I'm fine with switching over to RollingFile with Never if I can control the filename. I liked the suggestion of a pluggable file namer too. |
I'm trying to switch to logforth from log4rs and everything is looking good except for the ability to just write to a single file. My application is a short running commandline utility that can write its log to either stderr or a file. I tried using the
RollingFileappender with aRotation::Neverbut I have a requirement that the log file path must be able to be set explicitly andRollingFilealways includes thecnt. I've gated this behind asingle-filefeature similar torolling-file.This seemed like something that could be generally useful, hence the pull request.
Thanks for taking a look!