Skip to main content

LoggerConfig

Struct LoggerConfig 

Source
pub struct LoggerConfig { /* private fields */ }
Expand description

The configuration of the logger.

Implementations§

Source§

impl LoggerConfig

Inherent implementation of LoggerConfig.

Source

pub fn new(level: LevelFilter) -> Self

Creates a new LoggerConfig with the specified maximum log level.

§Arguments
  • LevelFilter - Maximum severity level written by the logger.
§Returns
  • Self - Constructed configuration.
Source

pub fn get_level(&self) -> LevelFilter

Returns the configured maximum LevelFilter.

§Returns
  • LevelFilter - Active maximum log level.
Source

pub fn get_file(&self) -> Option<&str>

Returns the optional log file path.

§Returns
  • Option<&str> - Configured log file path, if any.
Source

pub fn get_console(&self) -> bool

Returns whether standard output console logging is enabled.

§Returns
  • bool - true when console logging is enabled.
Source

pub fn get_format(&self) -> LogFormat

Returns the active LogFormat.

§Returns
  • LogFormat - Plain or JSON output format.
Source

pub fn get_channel_capacity(&self) -> usize

Returns the bounded non-blocking background writer channel capacity.

§Returns
  • usize - Maximum queued log records before dropping.
Source

pub fn set_level(&mut self, level: LevelFilter) -> &mut Self

Sets the maximum LevelFilter in place.

§Arguments
  • LevelFilter - Desired maximum severity level.
§Returns
  • &mut Self - Mutable reference for fluent chaining.
Source

pub fn set_file(&mut self, file: Option<String>) -> &mut Self

Sets the optional log file path in place.

§Arguments
  • Option<String> - Optional destination file path.
§Returns
  • &mut Self - Mutable reference for fluent chaining.
Source

pub fn set_console(&mut self, enabled: bool) -> &mut Self

Enables or disables standard output console printing in place.

§Arguments
  • bool - true to write to stdout, false to skip console output.
§Returns
  • &mut Self - Mutable reference for fluent chaining.
Source

pub fn set_format(&mut self, format: LogFormat) -> &mut Self

Selects the LogFormat in place.

§Arguments
  • LogFormat - Desired record wire format.
§Returns
  • &mut Self - Mutable reference for fluent chaining.
Source

pub fn set_channel_capacity(&mut self, capacity: usize) -> &mut Self

Sets the bounded background channel capacity in place.

§Arguments
  • usize - Channel capacity (clamped to >= 1).
§Returns
  • &mut Self - Mutable reference for fluent chaining.
Source

pub fn set_sink(&mut self, sink: Option<Arc<dyn LogSink>>) -> &mut Self

Sets the custom extensible LogSink in place.

§Arguments
  • Option<Arc<dyn LogSink>> - Optional custom sink implementation.
§Returns
  • &mut Self - Mutable reference for fluent chaining.
Source

pub fn with_level(self, level: LevelFilter) -> Self

Updates the maximum LevelFilter.

§Arguments
  • LevelFilter - Desired maximum severity level.
§Returns
  • Self - Updated configuration.
Source

pub fn with_file<P>(self, path: P) -> Self
where P: Into<String>,

Configures a file path for non-blocking buffered append logging.

§Arguments
  • P - Destination file path convertible into String.
§Returns
  • Self - Updated configuration.
Source

pub fn with_console(self, enabled: bool) -> Self

Enables or disables standard output console printing.

§Arguments
  • bool - true to write to stdout, false to skip console output.
§Returns
  • Self - Updated configuration.
Source

pub fn with_format(self, format: LogFormat) -> Self

Selects the LogFormat emitted by the logger.

§Arguments
  • LogFormat - Desired record wire format.
§Returns
  • Self - Updated configuration.
Source

pub fn with_channel_capacity(self, capacity: usize) -> Self

Sets the bounded background channel capacity for non-blocking file I/O.

§Arguments
  • usize - Channel capacity (clamped to >= 1).
§Returns
  • Self - Updated configuration.
Source

pub fn with_sink(self, sink: Arc<dyn LogSink>) -> Self

Attaches a custom extensible LogSink to receive every formatted log record.

§Arguments
  • Arc<dyn LogSink> - Custom sink implementation.
§Returns
  • Self - Updated configuration.

Trait Implementations§

Source§

impl Clone for LoggerConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LoggerConfig

Formatting / debug-printing for LoggerConfig.

Source§

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

Formats the LoggerConfig without requiring LogSink to implement Debug.

§Arguments
  • &mut Formatter<'_> - The formatter receiving the formatted output.
§Returns
  • fmt::Result - Formatting status.
Source§

impl Default for LoggerConfig

Default construction for LoggerConfig.

Source§

fn default() -> Self

Builds the configuration the logger uses when none is given.

§Returns
  • Self - The default configuration.

Auto Trait Implementations§

§

impl !RefUnwindSafe for LoggerConfig

§

impl !UnwindSafe for LoggerConfig

§

impl Forget for LoggerConfig

§

impl Freeze for LoggerConfig
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<dyn LogSink> is !null: Freeze, PhantomData<ArcInner<dyn LogSink>>: Freeze,

§

impl Move for LoggerConfig

§

impl Send for LoggerConfig
where RawVecInner: Send, Arc<dyn LogSink>: Send,

§

impl Sync for LoggerConfig
where RawVecInner: Sync, Arc<dyn LogSink>: Sync,

§

impl Unpin for LoggerConfig
where *const u8 is !null: Unpin, Arc<dyn LogSink>: Unpin,

§

impl UnsafeUnpin for LoggerConfig
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<dyn LogSink> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn LogSink>>: UnsafeUnpin,

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> AnySend for T
where T: Any + Send,

Source§

impl<T> AnySendClone for T
where T: Any + Send + Clone,

Source§

impl<T> AnySendSync for T
where T: Any + Send + Sync,

Source§

impl<T> AnySendSyncClone for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> AnySync for T
where T: Any + Sync,

Source§

impl<T> AnySyncClone for T
where T: Any + Sync + Clone,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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