pub struct LogConfig {
pub default_level: LogLevel,
pub with_timestamps: bool,
pub with_target: bool,
pub with_file_line: bool,
pub with_ansi: bool,
}Expand description
Configuration for logging initialization.
§Why This Struct
Logging configuration often needs to vary between development and production:
- Development: verbose, colored output to terminal
- Production: JSON structured logs to file/stdout
- Testing: minimal output, captured by test harness
This struct captures these variations.
Fields§
§default_level: LogLevelDefault log level when RUST_LOG is not set.
with_timestamps: boolInclude timestamps in log output.
with_target: boolInclude target (module path) in log output.
with_file_line: boolInclude source file and line numbers.
with_ansi: boolUse ANSI colors (disable for file output).
Implementations§
Source§impl LogConfig
impl LogConfig
Sourcepub fn with_level(self, level: LogLevel) -> Self
pub fn with_level(self, level: LogLevel) -> Self
Set the default log level.
Sourcepub fn with_timestamps(self, enable: bool) -> Self
pub fn with_timestamps(self, enable: bool) -> Self
Enable or disable timestamps.
Sourcepub fn development() -> Self
pub fn development() -> Self
Configuration preset for development.
Verbose output with colors, file/line info for debugging.
Sourcepub fn production() -> Self
pub fn production() -> Self
Configuration preset for production.
Clean output without colors (for structured log ingestion).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LogConfig
impl RefUnwindSafe for LogConfig
impl Send for LogConfig
impl Sync for LogConfig
impl Unpin for LogConfig
impl UnwindSafe for LogConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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