Skip to main content

FlashLogBuilder

Struct FlashLogBuilder 

Source
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 flushes

Implementations§

Source§

impl FlashLogBuilder

Source

pub fn new() -> Self

Creates a new builder with default settings.

Source

pub fn level(self, level: Level) -> Self

Set the minimum log level.

Source

pub fn flush_delay(self, delay: Duration) -> Self

Set the flush delay duration.

Source

pub fn flush_buffer_size(self, bytes: u32) -> Self

Set the flush buffer size in bytes.

Source

pub fn flush_on(self, level: Level) -> Self

Set the level at or above which an immediate flush is triggered.

Source

pub fn queue_full_policy(self, policy: QueueFullPolicy) -> Self

Set the queue-full policy.

Source

pub fn queue_full_callback(self, callback: QueueFullCallback) -> Self

Set the queue-full callback.

Source

pub fn log_file(self, path: impl Into<String>) -> Self

Set the log output file path.

Source

pub fn rotation(self, config: RotationConfig) -> Self

Set the log file rotation config. Requires log_file to be set.

Source

pub fn header_pattern(self, pattern: impl Into<String>) -> Self

Set a custom header pattern string.

Source

pub fn poller_interval(self, interval: Duration) -> Self

Set the poller thread interval.

Source

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).

Source

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§

Source§

impl Default for FlashLogBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.