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
impl Builder
Sourcepub fn sink<S: LogSink>(self, sink: S) -> Self
pub fn sink<S: LogSink>(self, sink: S) -> Self
Overrides the output sink. Defaults to a ConsoleSink on stderr.
Sourcepub fn max_level(self, level: Level) -> Self
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.
Sourcepub fn backpressure(self, policy: Backpressure) -> Self
pub fn backpressure(self, policy: Backpressure) -> Self
Sets what happens when a logging thread’s buffer is full. Default:
Backpressure::Drop.
Sourcepub fn timezone_offset(self, seconds: i32) -> Self
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).
Sourcepub fn drain_affinity(self, cores: &[usize]) -> Self
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.
Sourcepub fn build(self) -> Result<Guard, TicklogError>
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.