Struct LoggerConfigBuilder

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

Builder for creating logger configurations.

Implementations§

Source§

impl LoggerConfigBuilder

Source

pub fn new() -> Self

Create a new builder with default configuration.

Source

pub fn level(self, level: LogLevel) -> Self

Set the minimum log level.

Source

pub fn add_handler(self, handler: HandlerRef) -> Self

Add a handler to the configuration.

Source

pub fn capture_source(self, capture: bool) -> Self

Set whether to capture source location information.

Source

pub fn use_colors(self, use_colors: bool) -> Self

Set whether to use colors in console output.

Source

pub fn format(self, format: String) -> Self

Set the format string for log messages.

Source

pub fn with_env_overrides(self) -> Self

Apply environment variable overrides to the configuration.

Supported environment variables:

  • LOGURU_LEVEL (e.g., “Debug”, “Info”, “Warn”, “Error”)
  • LOGURU_CAPTURE_SOURCE (“true”/“false”)
  • LOGURU_USE_COLORS (“true”/“false”)
  • LOGURU_FORMAT (format string)
Source

pub fn build(self) -> LoggerConfig

Build the final configuration.

Source

pub fn from_toml_str(self, toml_str: &str) -> Result<Self, Error>

Load configuration from a TOML string. Builder/env overrides take precedence.

Supported TOML keys:

  • level (e.g., “Debug”, “Info”, “Warn”, “Error”)
  • capture_source (bool)
  • use_colors (bool)
  • format (string)
Source

pub fn from_toml_file<P: AsRef<Path>>(self, path: P) -> Result<Self, Error>

Load configuration from a TOML file. Builder/env overrides take precedence.

Trait Implementations§

Source§

impl Debug for LoggerConfigBuilder

Source§

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

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

impl Default for LoggerConfigBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.

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.