fix(log): decrease log size

This commit is contained in:
2025-07-10 17:30:38 +03:00
parent b988880c41
commit b563c7ea24
7 changed files with 64 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
use derive_macro::FromFile;
use merge::{option::overwrite_none, Merge};
use merge::{Merge, option::overwrite_none};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize, Merge)]

View File

@@ -9,6 +9,7 @@ use log::{LogConfig, LogConfigFile};
use merge::{Merge, option::overwrite_none};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use tracing::{debug, info, warn};
#[derive(Debug, Clone, Default, Deserialize, Serialize, Merge)]
pub struct ConfigFile {
@@ -28,28 +29,39 @@ pub struct Config {
}
impl Config {
#[tracing::instrument(name = "Loading configuration")]
pub fn load() -> Result<Self> {
let mut config = ConfigFile::default();
// Load system-wide config
let system_config_path = PathBuf::from("/etc/xdg/traxor/config.toml");
if system_config_path.exists() {
info!("Loading system-wide config from: {:?}", system_config_path);
let config_str = std::fs::read_to_string(&system_config_path)?;
let system_config = toml::from_str::<ConfigFile>(&config_str)?;
config.merge(system_config);
info!("Successfully loaded system-wide config.");
} else {
warn!("System-wide config not found at: {:?}", system_config_path);
}
// Load user-specific config
let user_config_path = Self::get_config_path()?;
if user_config_path.exists() {
info!("Loading user-specific config from: {:?}", user_config_path);
let config_str = std::fs::read_to_string(&user_config_path)?;
let user_config = toml::from_str::<ConfigFile>(&config_str)?;
config.merge(user_config);
info!("Successfully loaded user-specific config.");
} else {
warn!("User-specific config not found at: {:?}", user_config_path);
}
debug!("Configuration loaded successfully.");
Ok(config.into())
}
#[tracing::instrument(name = "Getting config path")]
fn get_config_path() -> Result<PathBuf> {
let config_dir = std::env::var("XDG_CONFIG_HOME")
.map(PathBuf::from)