pub struct FileBuilder { /* private fields */ }
Expand description
A builder to configure and create an File
appender.
Implementations§
Source§impl FileBuilder
impl FileBuilder
Sourcepub fn new(basedir: impl Into<PathBuf>, filename: impl Into<String>) -> Self
pub fn new(basedir: impl Into<PathBuf>, filename: impl Into<String>) -> Self
Create a new file appender builder.
Sourcepub fn layout(self, layout: impl Into<Box<dyn Layout>>) -> Self
pub fn layout(self, layout: impl Into<Box<dyn Layout>>) -> Self
Set the layout for the logs.
Default to PlainTextLayout
.
§Examples
use logforth_append_file::FileBuilder;
use logforth_layout_json::JsonLayout;
let builder = FileBuilder::new("my_service", "my_app");
builder.layout(JsonLayout::default());
Sourcepub fn trap(self, trap: impl Into<Box<dyn Trap>>) -> Self
pub fn trap(self, trap: impl Into<Box<dyn Trap>>) -> Self
Set the trap for the file writer.
Default to [DefaultTrap
].
§Examples
use logforth_append_file::FileBuilder;
use logforth_core::trap::DefaultTrap;
let builder = FileBuilder::new("my_service", "my_app");
builder.trap(DefaultTrap::default());
Sourcepub fn rollover_minutely(self) -> Self
pub fn rollover_minutely(self) -> Self
Set the rotation strategy to roll over log files minutely.
Sourcepub fn rollover_hourly(self) -> Self
pub fn rollover_hourly(self) -> Self
Set the rotation strategy to roll over log files hourly.
Sourcepub fn rollover_daily(self) -> Self
pub fn rollover_daily(self) -> Self
Set the rotation strategy to roll over log files daily at 00:00 in the local time zone.
Sourcepub fn rollover_size(self, n: NonZeroUsize) -> Self
pub fn rollover_size(self, n: NonZeroUsize) -> Self
Set the rotation strategy to roll over log files if the current log file exceeds the given size.
If any time-based rotation strategy is set, the size-based rotation will be checked on the current log file after the time-based rotation check.
Sourcepub fn filename_suffix(self, suffix: impl Into<String>) -> Self
pub fn filename_suffix(self, suffix: impl Into<String>) -> Self
Set the filename suffix.
Sourcepub fn max_log_files(self, n: NonZeroUsize) -> Self
pub fn max_log_files(self, n: NonZeroUsize) -> Self
Set the maximum number of log files to keep.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileBuilder
impl !RefUnwindSafe for FileBuilder
impl Send for FileBuilder
impl Sync for FileBuilder
impl Unpin for FileBuilder
impl !UnwindSafe for FileBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more