adding log framework
This commit is contained in:
parent
8c4171ba14
commit
528d1edb7a
@ -6,7 +6,9 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
bytes = { version = "1.4.0", default-features = false, features = ["std"] }
|
bytes = { version = "1.4.0", default-features = false, features = ["std"] }
|
||||||
crossbeam-utils = { version = "0.8.14", default-features = false, features = ["std"] }
|
crossbeam-utils = { version = "0.8.14", default-features = false, features = ["std"] }
|
||||||
|
env_logger = { version = "0.10.0", default-features = false, features = ["humantime"] }
|
||||||
lexopt = { version = "0.3.0", default-features = false }
|
lexopt = { version = "0.3.0", default-features = false }
|
||||||
|
log = { version = "0.4.17", default-features = false, features = ["serde", "std"] }
|
||||||
parking_lot = { version = "0.12.1", default-features = false }
|
parking_lot = { version = "0.12.1", default-features = false }
|
||||||
quinn = { version = "0.9.3", default-features = false, features = ["futures-io", "runtime-tokio", "tls-rustls"] }
|
quinn = { version = "0.9.3", default-features = false, features = ["futures-io", "runtime-tokio", "tls-rustls"] }
|
||||||
register-count = { version = "0.1.0", default-features = false, features = ["std"] }
|
register-count = { version = "0.1.0", default-features = false, features = ["std"] }
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use crate::utils::CongestionControl;
|
use crate::utils::CongestionControl;
|
||||||
use lexopt::{Arg, Error as ArgumentError, Parser};
|
use lexopt::{Arg, Error as ArgumentError, Parser};
|
||||||
|
use log::LevelFilter;
|
||||||
use serde::{de::Error as DeError, Deserialize, Deserializer};
|
use serde::{de::Error as DeError, Deserialize, Deserializer};
|
||||||
use serde_json::Error as SerdeError;
|
use serde_json::Error as SerdeError;
|
||||||
use std::{
|
use std::{
|
||||||
@ -48,6 +49,8 @@ pub struct Config {
|
|||||||
pub gc_interval: Duration,
|
pub gc_interval: Duration,
|
||||||
#[serde(default = "default::gc_lifetime")]
|
#[serde(default = "default::gc_lifetime")]
|
||||||
pub gc_lifetime: Duration,
|
pub gc_lifetime: Duration,
|
||||||
|
#[serde(default = "default::log_level")]
|
||||||
|
pub log_level: LevelFilter,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
@ -83,6 +86,7 @@ impl Config {
|
|||||||
|
|
||||||
mod default {
|
mod default {
|
||||||
use crate::utils::CongestionControl;
|
use crate::utils::CongestionControl;
|
||||||
|
use log::LevelFilter;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
pub fn congestion_control() -> CongestionControl {
|
pub fn congestion_control() -> CongestionControl {
|
||||||
@ -120,6 +124,10 @@ mod default {
|
|||||||
pub fn gc_lifetime() -> Duration {
|
pub fn gc_lifetime() -> Duration {
|
||||||
Duration::from_secs(15)
|
Duration::from_secs(15)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn log_level() -> LevelFilter {
|
||||||
|
LevelFilter::Warn
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deserialize_from_str<'de, T, D>(deserializer: D) -> Result<T, D::Error>
|
pub fn deserialize_from_str<'de, T, D>(deserializer: D) -> Result<T, D::Error>
|
||||||
|
@ -2,6 +2,7 @@ use self::{
|
|||||||
config::{Config, ConfigError},
|
config::{Config, ConfigError},
|
||||||
server::Server,
|
server::Server,
|
||||||
};
|
};
|
||||||
|
use env_logger::Builder as LoggerBuilder;
|
||||||
use quinn::ConnectionError;
|
use quinn::ConnectionError;
|
||||||
use rustls::Error as RustlsError;
|
use rustls::Error as RustlsError;
|
||||||
use std::{env, io::Error as IoError, net::SocketAddr, process};
|
use std::{env, io::Error as IoError, net::SocketAddr, process};
|
||||||
@ -28,6 +29,8 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LoggerBuilder::new().filter_level(cfg.log_level).init();
|
||||||
|
|
||||||
match Server::init(cfg) {
|
match Server::init(cfg) {
|
||||||
Ok(server) => server.start().await,
|
Ok(server) => server.start().await,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user