pub trait LoggingConfigTrait {
// Required method
fn logging_config_mut(&mut self) -> &mut LoggingConfig;
// Provided methods
fn logging_enabled(self, enabled: bool) -> Self
where Self: Sized { ... }
fn logger_name<S>(self, logger_name: S) -> Self
where S: Into<String>,
Self: Sized { ... }
fn log_path<P>(self, path: P) -> Self
where P: AsRef<Path>,
Self: Sized { ... }
fn log_level_trace(self) -> Self
where Self: Sized { ... }
fn log_level_debug(self) -> Self
where Self: Sized { ... }
fn log_level_info(self) -> Self
where Self: Sized { ... }
fn log_level_warn(self) -> Self
where Self: Sized { ... }
fn log_level_error(self) -> Self
where Self: Sized { ... }
}
Expand description
Trait for configuring logging behavior.
Provides a fluent interface for configuring logging settings.
Required Methods§
fn logging_config_mut(&mut self) -> &mut LoggingConfig
Provided Methods§
Sourcefn logging_enabled(self, enabled: bool) -> Selfwhere
Self: Sized,
fn logging_enabled(self, enabled: bool) -> Selfwhere
Self: Sized,
Sourcefn logger_name<S>(self, logger_name: S) -> Self
fn logger_name<S>(self, logger_name: S) -> Self
Sets the name of the logger.
This method allows you to specify a custom name for the logger, which can be useful for identifying the source of log messages in applications with multiple components or services.
§Arguments
logger_name
- A string-like value that can be converted into aString
. This will be used as the name for the logger.
§Returns
Returns Self
to allow for method chaining.
Sourcefn log_level_trace(self) -> Selfwhere
Self: Sized,
fn log_level_trace(self) -> Selfwhere
Self: Sized,
Sets the log level to TRACE.
Use TRACE for purely “I am here!” logs. They indicate the flow of execution without additional context.
TRACE logs should not be used to log variables or decisions.
Sourcefn log_level_debug(self) -> Selfwhere
Self: Sized,
fn log_level_debug(self) -> Selfwhere
Self: Sized,
Sets the log level to DEBUG.
Use DEBUG to log variables or decisions. This level is appropriate for information that is useful for debugging but not necessary for normal operation.
§Examples
DEBUG logs should focus on logging specific data points or choices made in the code.
Sourcefn log_level_info(self) -> Selfwhere
Self: Sized,
fn log_level_info(self) -> Selfwhere
Self: Sized,
Sets the log level to INFO.
Use INFO for important runtime events that don’t prevent the application from working but are significant milestones or status updates.
INFO logs should provide a high-level overview of the application’s operation.
Sourcefn log_level_warn(self) -> Selfwhere
Self: Sized,
fn log_level_warn(self) -> Selfwhere
Self: Sized,
Sets the log level to WARN.
Use WARN for errors that were recovered from or potential issues that don’t prevent the application from working but might lead to problems if not addressed.
WARN logs often indicate situations that should be monitored or addressed soon.
Sourcefn log_level_error(self) -> Selfwhere
Self: Sized,
fn log_level_error(self) -> Selfwhere
Self: Sized,
Sets the log level to ERROR.
Use ERROR to log errors within specific tasks that cause the task to fail but don’t crash the entire application.
ERROR logs indicate serious issues that need immediate attention but don’t necessarily stop the application.