From ea54648b4374d72303482ff4822cca1877bd2451 Mon Sep 17 00:00:00 2001 From: Avril Date: Tue, 4 Aug 2020 01:35:10 +0100 Subject: [PATCH] option for date format default --- build/config.toml | 6 +++++- src/config/build_cfg.rs | 10 ++++++++++ src/config/mod.rs | 7 +++++++ src/log.rs | 5 ++++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/build/config.toml b/build/config.toml index 0734a4d..4be8ca8 100644 --- a/build/config.toml +++ b/build/config.toml @@ -1,4 +1,8 @@ # Compilation time options for hotreload module. [hot] backlog = 100 -timeout = 5 \ No newline at end of file +timeout = 5 + +# Logging options +[log] +default_time_local = false \ No newline at end of file diff --git a/src/config/build_cfg.rs b/src/config/build_cfg.rs index 3523ba0..a442de7 100644 --- a/src/config/build_cfg.rs +++ b/src/config/build_cfg.rs @@ -7,6 +7,7 @@ use std::borrow::Cow; #[allow(non_camel_case_types)] pub struct Config { pub hot: _Config__hot, + pub log: _Config__log, } #[derive(Debug, Clone)] @@ -16,9 +17,18 @@ pub struct _Config__hot { pub timeout: i64, } +#[derive(Debug, Clone)] +#[allow(non_camel_case_types)] +pub struct _Config__log { + pub default_time_local: bool, +} + pub const CONFIG: Config = Config { hot: _Config__hot { backlog: 100, timeout: 5, }, + log: _Config__log { + default_time_local: false, + }, }; diff --git a/src/config/mod.rs b/src/config/mod.rs index e882e7e..c663352 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -54,6 +54,13 @@ pub mod build static_assert!(TIMEOUT > 0); } + pub mod log + { + pub use super::*; + + pub const DEFAULT_LOCAL_TIME: bool = CONFIG.log.default_time_local; + } + /// Print the status of `build.toml` vars #[cfg(any(debug_assertions,feature="debug_logger"))] pub fn stat() diff --git a/src/log.rs b/src/log.rs index def40b7..ea77d65 100644 --- a/src/log.rs +++ b/src/log.rs @@ -15,6 +15,9 @@ use std::{ }; use once_cell::sync::OnceCell; +/// Print local time by default +const DEFAULT_USE_LOCAL_TIME: bool = crate::config::build::log::DEFAULT_LOCAL_TIME; + /// Logging level #[derive(PartialEq,Copy,Eq,Debug,Clone,Hash,Ord,PartialOrd)] pub enum Level @@ -220,7 +223,7 @@ impl Logger Self { level, title: String::new(), - use_local_time: false, + use_local_time: DEFAULT_USE_LOCAL_TIME, } }