Struct Logger

Source
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: LoggerConfig

Configuration for logging levels and behavior.

Implementations§

Source§

impl Logger

Source

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.

Source

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§

Source§

impl Debug for Logger

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Log for Logger

Source§

fn enabled(&self, metadata: &Metadata<'_>) -> bool

Determines if a log message with the specified metadata would be logged. Read more
Source§

fn log(&self, record: &Record<'_>)

Logs the Record. Read more
Source§

fn flush(&self)

Flushes any buffered records. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> Ungil for T
where T: Send,