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: LoggerConfigConfiguration 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more