diff options
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/config.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 14 |
3 files changed, 11 insertions, 7 deletions
@@ -7,7 +7,7 @@ edition = "2018" [dependencies] bincode = "1" -env_logger = "0.8" +env_logger = { version = "0.8", default-features = false } handlebars = "3" hyper = { version = "0.14", default-features = false, features = ["server", "client", "http1", "http2"] } hyper-rustls = "0.22" diff --git a/src/config.rs b/src/config.rs index 4dd4433..c4396d4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -32,7 +32,7 @@ pub struct Config { parse(from_occurrences), help = "Increases log level" )] - pub verbose: u8, + pub verbose: usize, #[structopt( long, diff --git a/src/main.rs b/src/main.rs index c6a1110..a17e2b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,8 +3,7 @@ use hyper::{ service::{make_service_fn, service_fn}, Server, }; -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; -use structopt::StructOpt; +use log::LevelFilter; #[macro_use] extern crate lazy_static; @@ -19,7 +18,13 @@ mod templates; #[tokio::main] async fn main() -> Result<(), TwinHError> { - //env_logger::try_init_from_env; + // configure logger + let level = match config::INSTANCE.verbose { + 1 => LevelFilter::Info, + 2 => LevelFilter::Debug, + _ => LevelFilter::Warn, + }; + env_logger::builder().filter_level(level).init(); // create HTTP listener let make_svc = @@ -29,9 +34,8 @@ async fn main() -> Result<(), TwinHError> { let server = Server::bind(&config::INSTANCE.bind_addr.into()).serve(make_svc); let graceful = server.with_graceful_shutdown(shutdown_signal()); - // start and run + // start and wait for shutdown graceful.await?; - Ok(()) } |