default log level to logger::Level

This commit is contained in:
mbecker20
2024-03-20 16:04:55 -07:00
parent 873d9c2df6
commit 9d5550bf5f
4 changed files with 25 additions and 17 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ fn default_frontend_path() -> String {
pub fn core_config() -> &'static CoreConfig {
static CORE_CONFIG: OnceLock<CoreConfig> = OnceLock::new();
CORE_CONFIG.get_or_init(|| {
let env = &env();
let env = env();
let config_path = &env.config_path;
let mut config =
parse_config_file::<CoreConfig>(config_path.as_str())
+1 -5
View File
@@ -95,7 +95,7 @@ pub struct PeripheryConfig {
pub port: u16,
/// Configure the logging level: error, warn, info, debug, trace
#[serde(default = "default_log_level")]
#[serde(default)]
pub log_level: logger::LogLevel,
/// The system directory where monitor managed repos will be cloned
@@ -131,10 +131,6 @@ fn default_periphery_port() -> u16 {
8000
}
fn default_log_level() -> logger::LogLevel {
logger::LogLevel::Info
}
fn default_repo_dir() -> PathBuf {
"/repos".parse().unwrap()
}
+12 -10
View File
@@ -7,47 +7,49 @@ pub struct CoreConfig {
#[serde(default = "default_title")]
pub title: String,
// the host to use with oauth redirect url, whatever host the user hits to access monitor. eg 'https://monitor.mogh.tech'
/// The host to use with oauth redirect url, whatever host the user hits to access monitor. eg 'https://monitor.mogh.tech'
#[serde(default)]
pub host: String,
// port the core web server runs on
/// Port the core web server runs on
#[serde(default = "default_core_port")]
pub port: u16,
// sent in auth header with req to periphery
/// Sent in auth header with req to periphery
pub passkey: String,
/// Configure custom log level: trace | debug | info | warn | error. default: info
#[serde(default)]
pub log_level: LogLevel,
/// Control how long distributed JWT remain valid for. Default is 1-day
#[serde(default = "default_jwt_valid_for")]
pub jwt_valid_for: Timelength,
// interval at which to collect server stats and send any alerts
/// interval at which to collect server stats and send any alerts
#[serde(default = "default_monitoring_interval")]
pub monitoring_interval: Timelength,
// number of days to keep stats, or 0 to disable pruning. stats older than this number of days are deleted on a daily cycle
/// number of days to keep stats, or 0 to disable pruning. stats older than this number of days are deleted on a daily cycle
#[serde(default)]
pub keep_stats_for_days: u64,
// number of days to keep alerts, or 0 to disable pruning. alerts older than this number of days are deleted on a daily cycle
/// number of days to keep alerts, or 0 to disable pruning. alerts older than this number of days are deleted on a daily cycle
#[serde(default)]
pub keep_alerts_for_days: u64,
// used to verify validity from github webhooks
/// used to verify validity from github webhooks
#[serde(default)]
pub github_webhook_secret: String,
// used to form the frontend listener url, if None will use 'host'.
/// used to form the frontend listener url, if None will use 'host'.
pub github_webhook_base_url: Option<String>,
// allowed docker orgs used with monitor. first in this list will be default for build
/// allowed docker orgs used with monitor. first in this list will be default for build
#[serde(default)]
pub docker_organizations: Vec<String>,
// enable login with local auth
/// enable login with local auth
#[serde(default)]
pub local_auth: bool,
+11 -1
View File
@@ -9,11 +9,21 @@ pub fn init(log_level: impl Into<tracing::Level>) {
}
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize,
Debug,
Clone,
Copy,
Default,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize,
)]
#[serde(rename_all = "lowercase")]
pub enum LogLevel {
Trace,
Debug,
#[default]
Info,
Warn,
Error,