mirror of
https://github.com/Tribufu/TribufuRust
synced 2026-08-10 05:11:07 +00:00
Add utils crates
This commit is contained in:
parent
f5d3e86eb2
commit
738f9c947b
18 changed files with 412 additions and 1 deletions
22
src/log/log_config.rs
Normal file
22
src/log/log_config.rs
Normal 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(),
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue