set log levels

This commit is contained in:
Cappy Ishihara 2024-06-02 04:04:12 +07:00
parent e6f3a4f7a4
commit 92d2a0d906
No known key found for this signature in database
GPG key ID: 50862C285CB76906

View file

@ -4,9 +4,7 @@ use axum::{
routing::{delete, get, post, put}, routing::{delete, get, post, put},
Router, Router,
}; };
use chrono::prelude::*;
use dashmap::DashMap; use dashmap::DashMap;
use fern::colors::{Color, ColoredLevelConfig};
use log::info; use log::info;
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::{broadcast, Mutex}; use tokio::sync::{broadcast, Mutex};
@ -99,13 +97,15 @@ pub struct AppState {
#[tokio::main] #[tokio::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {
tracing_subscriber::fmt::fmt() tracing_subscriber::fmt::fmt()
.with_env_filter("trace") .with_env_filter("trace,axum=info,tower_http=info,tokio=info,tungstenite=info,tokio_tungstenite=info")
.pretty() .pretty()
.init(); .init();
let config_file = std::env::var("CONFIG_PATH").unwrap_or_else(|_| "Config.toml".into());
info!("The Sculptor MMSI edition v{}", env!("CARGO_PKG_VERSION")); info!("The Sculptor MMSI edition v{}", env!("CARGO_PKG_VERSION"));
// Config // Config
let config = config::Config::parse("Config.toml".into()); let config = config::Config::parse(config_file.clone().into());
let listen = config.listen.as_str(); let listen = config.listen.as_str();
// State // State
@ -122,7 +122,7 @@ async fn main() -> Result<()> {
loop { loop {
tokio::time::sleep(std::time::Duration::from_secs(10)).await; tokio::time::sleep(std::time::Duration::from_secs(10)).await;
let new_config = config::Config::parse("Config.toml".into()).advanced_users; let new_config = config::Config::parse(config_file.clone().into()).advanced_users;
let mut config = advanced_users.lock().await; let mut config = advanced_users.lock().await;
if new_config != *config { if new_config != *config {