pub struct LogConfig {
pub level: String,
pub format: LogFormat,
pub file_path: Option<PathBuf>,
pub targets: BTreeMap<String, String>,
pub with_target: bool,
pub with_thread_ids: bool,
pub with_file_line: bool,
pub use_stderr: bool,
}Expand description
Configuration for logging initialization.
Fields§
§level: StringBase log level (trace, debug, info, warn, error, off).
format: LogFormatOutput format.
file_path: Option<PathBuf>Optional file path for rotating logs.
targets: BTreeMap<String, String>Per-target log level overrides.
with_target: boolInclude target in log output.
with_thread_ids: boolInclude thread IDs in log output.
with_file_line: boolInclude file and line number in log output.
use_stderr: boolWrite console logs to stderr instead of stdout.
Implementations§
Source§impl LogConfig
impl LogConfig
Sourcepub fn from_env(default_level: &str) -> Self
pub fn from_env(default_level: &str) -> Self
Build a logging configuration from environment variables.
Supported environment variables:
- RCH_LOG_LEVEL
- RCH_LOG_FORMAT (pretty|json|compact)
- RCH_LOG_FILE (path to rotating log file)
- RCH_LOG_TARGETS (comma-separated target=level list)
Sourcepub fn with_level(self, level: impl Into<String>) -> Self
pub fn with_level(self, level: impl Into<String>) -> Self
Override the base log level.
Sourcepub fn with_stderr(self) -> Self
pub fn with_stderr(self) -> Self
Write console logs to stderr.
Sourcepub fn env_filter(&self) -> EnvFilter
pub fn env_filter(&self) -> EnvFilter
Build the effective EnvFilter, honoring RUST_LOG if set.
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 UnsafeUnpin 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