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
This structure holds the configuration for logging, including log file paths, log rotation settings, logging format, and environment variables.
§Fields
version
: The version of the configuration.profile
: The profile name for the configuration.log_file_path
: The path to the log file.log_level
: The logging level.log_rotation
: Optional log rotation settings.log_format
: The format for log messages.logging_destinations
: List of destinations where logs will be sent.env_vars
: Environment variables that apply to the logging system.
Fields§
§version: String
Version of the configuration.
profile: String
Profile name for the configuration.
log_file_path: PathBuf
Path to the log file.
log_level: LogLevel
Log level for the system.
log_rotation: Option<LogRotation>
Log rotation settings.
log_format: String
Log 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 async fn load_async<P: AsRef<Path>>(
config_path: Option<P>,
) -> Result<Arc<RwLock<Config>>, ConfigError>
pub async fn load_async<P: AsRef<Path>>( config_path: Option<P>, ) -> Result<Arc<RwLock<Config>>, ConfigError>
Loads configuration from a file or environment variables.
Sourcepub fn get<T>(&self, key: &str) -> Option<T>where
T: DeserializeOwned,
pub fn get<T>(&self, key: &str) -> Option<T>where
T: DeserializeOwned,
Retrieves a value from the configuration based on the specified key.
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.
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.
Sourcepub fn validate(&self) -> Result<(), ConfigError>
pub fn validate(&self) -> Result<(), ConfigError>
Validates the configuration settings.
Sourcepub fn expand_env_vars(&self) -> Config
pub fn expand_env_vars(&self) -> Config
Expands environment variables in the configuration values.
Sourcepub async fn hot_reload_async(
config_path: &str,
config: Arc<RwLock<Config>>,
) -> Result<Sender<()>, ConfigError>
pub async fn hot_reload_async( config_path: &str, config: Arc<RwLock<Config>>, ) -> Result<Sender<()>, ConfigError>
Hot-reloads configuration on file change.
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin 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
Mutably borrows from an owned value. Read more