pub struct LoggerOptions {
pub levels: Option<LoggerLevels>,
pub format: Option<Arc<dyn Format<Input = LogInfo> + Send + Sync>>,
pub level: Option<String>,
pub transports: Option<Vec<(TransportHandle, LoggerTransport<LogInfo>)>>,
pub channel_capacity: Option<usize>,
pub backpressure_strategy: Option<BackpressureStrategy>,
}Fields§
§levels: Option<LoggerLevels>§format: Option<Arc<dyn Format<Input = LogInfo> + Send + Sync>>§level: Option<String>§transports: Option<Vec<(TransportHandle, LoggerTransport<LogInfo>)>>§channel_capacity: Option<usize>§backpressure_strategy: Option<BackpressureStrategy>Implementations§
Source§impl LoggerOptions
impl LoggerOptions
Sourcepub fn level<T: Into<String>>(self, level: T) -> Self
pub fn level<T: Into<String>>(self, level: T) -> Self
Sets the logging level for the logger.
§Arguments
level- A string slice that represents the logging level.
Sourcepub fn transport(self, transport: impl IntoLoggerTransport) -> Self
pub fn transport(self, transport: impl IntoLoggerTransport) -> Self
Adds a single transport to the existing list of transports.
This method is additive — it appends the provided transport to any
previously added transports. Each transport is automatically wrapped in
an Arc and assigned a unique [TransportHandle].
This method accepts either a raw transport or a pre-configured
LoggerTransport.
§Example
use winston_rs::LoggerOptions;
// Raw transport
let options = LoggerOptions::new()
.transport(stdout())
.transport(FileTransport::new("app.log"));
// Pre-configured transport
let options = LoggerOptions::new()
.transport(
LoggerTransport::new(FileTransport::new("app.log"))
.with_level("debug")
.with_format(json())
);Each call to transport appends a new transport,
allowing multiple outputs (e.g. console + file + network) to be used simultaneously.
Sourcepub fn transports<I>(self, transports: I) -> Selfwhere
I: IntoIterator,
I::Item: IntoLoggerTransport,
pub fn transports<I>(self, transports: I) -> Selfwhere
I: IntoIterator,
I::Item: IntoLoggerTransport,
Replaces all transports with the provided collection.
This method is not additive — it replaces any previously configured
transports. Each transport must already be wrapped in an Arc and will
be assigned a unique [TransportHandle].
§Example
use winston_rs::LoggerOptions;
use std::sync::Arc;
let transports = vec![
Arc::new(stdout()),
Arc::new(FileTransport::new("app.log")),
];
let options = LoggerOptions::new().transports(transports);Use this method when you want to replace all existing transports
instead of appending new ones. Multiple calls to .transports() will
override the previous collection.
Sourcepub fn levels(self, levels: HashMap<String, u8>) -> Self
pub fn levels(self, levels: HashMap<String, u8>) -> Self
Sets custom logging levels for the logger.
§Arguments
levels- AHashMapwhere the key is the level name and the value is its severity.
Sourcepub fn channel_capacity(self, capacity: usize) -> Self
pub fn channel_capacity(self, capacity: usize) -> Self
Sets the channel capacity for the logger.
§Arguments
capacity- Anusizethat defines the capacity of the channel.
Sourcepub fn backpressure_strategy(self, strategy: BackpressureStrategy) -> Self
pub fn backpressure_strategy(self, strategy: BackpressureStrategy) -> Self
Sets the backpressure strategy for the logger.
§Arguments
strategy- The backpressure strategy to apply when the channel is full.
Trait Implementations§
Source§impl Clone for LoggerOptions
impl Clone for LoggerOptions
Source§fn clone(&self) -> LoggerOptions
fn clone(&self) -> LoggerOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LoggerOptions
impl Debug for LoggerOptions
Source§impl Default for LoggerOptions
impl Default for LoggerOptions
Source§fn default() -> Self
fn default() -> Self
Provides the default configuration for LoggerOptions.
The default configuration includes:
- A default set of logging levels.
- The logging level set to “info”.
- No default transports.
- The JSON format for log entries.
- A channel capacity of 1024.
- A backpressure strategy set to
BackpressureStrategy::Block, meaning the logger will block on overflow until space is available.