pub struct Logger {
pub config: LoggerConfig,
/* private fields */
}Expand description
A high-performance logger utilizing a MPSC channel under the hood.
A logger is initialized with a LoggerConfig to set up different logging levels for
stdout, file, and components. The logger spawns a thread that listens for LogEvents
sent via an MPSC channel.
Fields§
§config: LoggerConfigInitialization snapshot for logging levels and behavior.
Producer filters are derived into filter_policy at initialization; mutating this field
after registration does not reload component/module filters.
Implementations§
Source§impl Logger
impl Logger
Sourcepub fn init_with_env(
trader_id: TraderId,
instance_id: UUID4,
file_config: FileWriterConfig,
) -> Result<LogGuard>
pub fn init_with_env( trader_id: TraderId, instance_id: UUID4, file_config: FileWriterConfig, ) -> Result<LogGuard>
Initializes the logger based on the NAUTILUS_LOG environment variable.
§Errors
Returns an error if reading the environment variable or parsing the configuration fails.
Sourcepub fn init_with_config(
trader_id: TraderId,
instance_id: UUID4,
config: LoggerConfig,
file_config: FileWriterConfig,
) -> Result<LogGuard>
pub fn init_with_config( trader_id: TraderId, instance_id: UUID4, config: LoggerConfig, file_config: FileWriterConfig, ) -> Result<LogGuard>
Initializes the logger with the given configuration.
§Errors
Returns an error if the logger fails to register or initialize the background thread.