Add utils crates

This commit is contained in:
Guilherme Werner 2025-06-04 11:30:22 -03:00
parent f5d3e86eb2
commit 738f9c947b
18 changed files with 412 additions and 1 deletions

22
src/log/log_config.rs Normal file
View file

@ -0,0 +1,22 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
use crate::LogLevel;
use serde::{Deserialize, Serialize};
use std::env;
use tribufu_error::Result;
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct LogConfig {
pub level: LogLevel,
pub file: Option<String>,
}
impl LogConfig {
pub fn from_env() -> Result<Self> {
Ok(Self {
level: LogLevel::from_str(&env::var("LOG_LEVEL")?).unwrap_or_default(),
file: env::var("LOG_FILE").ok(),
})
}
}