split: server foundation (Cargo, config, errors, utils, main)
Cargo.{toml,lock} bumps, build.rs, config-e2e.yml, rust-toolchain.toml,
src/config/* (database/logging/server/user configs), src/consts.rs,
src/errors.rs, src/main.rs, and src/utils/* (dedup_paths,
find_first_available_path, rotating_file_writer, sanitize_path).
This commit is contained in:
parent
70f97c4b16
commit
a9ce09b59d
17 changed files with 535 additions and 99 deletions
|
|
@ -1,10 +1,13 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use anyhow::{Result, ensure};
|
||||
use log::debug;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
consts::{DEFAULT_LOG_DIRECTORY, DEFAULT_LOG_LEVEL, DEFAULT_LOG_ROTATION_INTERVAL},
|
||||
consts::{
|
||||
DEFAULT_LOG_DIRECTORY, DEFAULT_LOG_LEVEL, DEFAULT_LOG_ROTATION_INTERVAL, DURATION_ZERO,
|
||||
},
|
||||
utils::log_level::LogLevel,
|
||||
};
|
||||
|
||||
|
|
@ -20,6 +23,20 @@ pub struct LoggingConfig {
|
|||
pub log_level: LogLevel,
|
||||
}
|
||||
|
||||
impl LoggingConfig {
|
||||
pub fn validate(&self) -> Result<()> {
|
||||
ensure!(
|
||||
!self.log_directory.is_empty(),
|
||||
"log_directory must not be an empty string"
|
||||
);
|
||||
ensure!(
|
||||
self.log_rotation > DURATION_ZERO,
|
||||
"log_rotation must be greater than 0"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for LoggingConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue