Skip to main content

Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }
Expand description

Collects configuration for the logging system. Create one with builder, then call Builder::build.

Implementations§

Source§

impl Builder

Source

pub fn sink<S: LogSink>(self, sink: S) -> Self

Overrides the output sink. Defaults to a ConsoleSink on stderr.

Source

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

Sets the maximum log level. More verbose records are discarded on the calling thread before they cost anything. Default: Level::Info.

Source

pub fn backpressure(self, policy: Backpressure) -> Self

Sets what happens when a logging thread’s buffer is full. Default: Backpressure::Drop.

Source

pub fn timezone_offset(self, seconds: i32) -> Self

Sets the timezone offset in seconds east of UTC, applied to timestamp formatting only. Default: 0 (UTC).

Source

pub fn drain_affinity(self, cores: &[usize]) -> Self

Pins the drain thread to the given set of logical CPUs.

An empty slice is a no-op. On Linux every core in the set is included in the CPU affinity mask; on macOS only the first core is used (as a Mach affinity tag). Default: no affinity (the OS migrates the drain freely).

When multiple drain threads are supported (in the future) all of them will share this affinity set.

Source

pub fn build(self) -> Result<Guard, TicklogError>

Initializes the logging system and returns a Guard. Dropping the guard shuts logging down. May be called only once per process.

§Errors

Returns TicklogError::InvalidTimezoneOffset if the configured offset is outside [-43200, 50400] seconds, TicklogError::AlreadyInitialized if build() has already run in this process, or TicklogError::DrainSpawnFailed if the drain thread cannot be spawned.

Trait Implementations§

Source§

impl Default for Builder

Source§

fn default() -> Self

Same as builder.

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.