pub struct Config {
pub version: String,
pub profile: String,
pub log_file_path: PathBuf,
pub log_level: LogLevel,
pub log_rotation: Option<LogRotation>,
pub log_format: String,
pub logging_destinations: Vec<LoggingDestination>,
pub env_vars: HashMap<String, String>,
}Expand description
Configuration structure for the logging system.
Fields§
§version: StringVersion of the configuration.
profile: StringProfile name for the configuration.
log_file_path: PathBufPath to the log file.
log_level: LogLevelLog level for the system.
log_rotation: Option<LogRotation>Log rotation settings.
log_format: StringLog format string.
logging_destinations: Vec<LoggingDestination>Logging destinations for the system.
env_vars: HashMap<String, String>Environment variables for the system.
Implementations§
Source§impl Config
impl Config
Sourcepub fn load<P: AsRef<Path>>(
config_path: Option<P>,
) -> Result<Arc<RwLock<Self>>, ConfigError>
pub fn load<P: AsRef<Path>>( config_path: Option<P>, ) -> Result<Arc<RwLock<Self>>, ConfigError>
Loads configuration from a file or falls back to defaults.
This is the synchronous variant. See Config::load_async for the
async equivalent (requires the tokio feature).
§Errors
Returns an error if the configuration file cannot be read, parsed, or if the version is unsupported.
Sourcepub async fn load_async<P: AsRef<Path>>(
config_path: Option<P>,
) -> Result<Arc<RwLock<Self>>, ConfigError>
pub async fn load_async<P: AsRef<Path>>( config_path: Option<P>, ) -> Result<Arc<RwLock<Self>>, ConfigError>
Loads configuration from a file or environment variables (async).
Requires the tokio feature.
§Errors
This function returns an error if the configuration file cannot be read, parsed, or if the version is unsupported.
Sourcepub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), ConfigError>
pub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), ConfigError>
Saves the current configuration to a file in TOML format.
This matches the TOML format expected by Config::load.
§Errors
This function returns an error if the file cannot be written or if serialization fails.
Sourcepub fn set<T: Serialize>(
&mut self,
key: &str,
value: T,
) -> Result<(), ConfigError>
pub fn set<T: Serialize>( &mut self, key: &str, value: T, ) -> Result<(), ConfigError>
Sets a value in the configuration based on the specified key.
§Errors
This function returns an error if the value cannot be serialized or if the key is unknown.
Sourcepub fn validate(&self) -> Result<(), ConfigError>
pub fn validate(&self) -> Result<(), ConfigError>
Validates the configuration settings.
§Errors
This function returns an error if any configuration setting is invalid.
Sourcepub fn ensure_paths(&self) -> Result<(), ConfigError>
pub fn ensure_paths(&self) -> Result<(), ConfigError>
Creates directories and log files required by the configuration.
§Errors
This function returns an error if the directories or files cannot be created.
Sourcepub fn expand_env_vars(&self) -> Self
pub fn expand_env_vars(&self) -> Self
Expands environment variables in the configuration values.
Sourcepub fn hot_reload_async(
config_path: &str,
config: &Arc<RwLock<Self>>,
) -> Result<Sender<()>, ConfigError>
pub fn hot_reload_async( config_path: &str, config: &Arc<RwLock<Self>>, ) -> Result<Sender<()>, ConfigError>
Hot-reloads configuration on file change.
Requires the tokio feature.
§Errors
This function returns an error if the watcher cannot be initialized.
Sourcepub fn diff(config1: &Self, config2: &Self) -> HashMap<String, String>
pub fn diff(config1: &Self, config2: &Self) -> HashMap<String, String>
Compares two configurations and returns the differences.
Sourcepub fn override_with(&self, other: &Self) -> Self
pub fn override_with(&self, other: &Self) -> Self
Overrides the current configuration with values from another configuration.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more