pub struct FlashLogBuilder { /* private fields */ }Expand description
Builder for configuring and starting the ferrilog logger.
§Example
ⓘ
let _guard = ferrilog::builder()
.level(ferrilog::INFO)
.log_file("/var/log/app.log")
.rotation(RotationConfig::by_size(100_000_000, 5))
.flush_delay(Duration::from_secs(3))
.flush_buffer_size(8192)
.flush_on(ferrilog::ERR)
.poller_interval(Duration::from_millis(1))
.poller_core_affinity(3)
.start()?;
// guard drop automatically stops poller and flushesImplementations§
Source§impl FlashLogBuilder
impl FlashLogBuilder
Sourcepub fn flush_delay(self, delay: Duration) -> Self
pub fn flush_delay(self, delay: Duration) -> Self
Set the flush delay duration.
Sourcepub fn flush_buffer_size(self, bytes: u32) -> Self
pub fn flush_buffer_size(self, bytes: u32) -> Self
Set the flush buffer size in bytes.
Sourcepub fn flush_on(self, level: Level) -> Self
pub fn flush_on(self, level: Level) -> Self
Set the level at or above which an immediate flush is triggered.
Sourcepub fn queue_full_policy(self, policy: QueueFullPolicy) -> Self
pub fn queue_full_policy(self, policy: QueueFullPolicy) -> Self
Set the queue-full policy.
Sourcepub fn queue_full_callback(self, callback: QueueFullCallback) -> Self
pub fn queue_full_callback(self, callback: QueueFullCallback) -> Self
Set the queue-full callback.
Sourcepub fn rotation(self, config: RotationConfig) -> Self
pub fn rotation(self, config: RotationConfig) -> Self
Set the log file rotation config. Requires log_file to be set.
Sourcepub fn header_pattern(self, pattern: impl Into<String>) -> Self
pub fn header_pattern(self, pattern: impl Into<String>) -> Self
Set a custom header pattern string.
Sourcepub fn poller_interval(self, interval: Duration) -> Self
pub fn poller_interval(self, interval: Duration) -> Self
Set the poller thread interval.
Sourcepub fn poller_core_affinity(self, core_id: usize) -> Self
pub fn poller_core_affinity(self, core_id: usize) -> Self
Pin the poller thread to the given CPU core (Linux only; ignored on other platforms).
Sourcepub fn start(self) -> Result<FlashLogGuard>
pub fn start(self) -> Result<FlashLogGuard>
Apply all configuration and start the background polling thread.
Returns a FlashLogGuard that stops the poller and flushes when
dropped.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FlashLogBuilder
impl RefUnwindSafe for FlashLogBuilder
impl Send for FlashLogBuilder
impl Sync for FlashLogBuilder
impl Unpin for FlashLogBuilder
impl UnsafeUnpin for FlashLogBuilder
impl UnwindSafe for FlashLogBuilder
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