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 LogEvent
s
sent via an MPSC channel.
Fields§
§config: LoggerConfig
Configuration for logging levels and behavior.
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.
§Examples
let config = LoggerConfig::from_spec("stdout=Info;fileout=Debug;RiskEngine=Error");
let file_config = FileWriterConfig::default();
let log_guard = Logger::init_with_config(trader_id, instance_id, config, file_config);
Initializes the logger with the given LoggerConfig
and FileWriterConfig
.
§Errors
Returns an error if the logger fails to register or initialize the background thread.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Logger
impl RefUnwindSafe for Logger
impl Send for Logger
impl Sync for Logger
impl Unpin for Logger
impl UnwindSafe for Logger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more