diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 14 |
2 files changed, 10 insertions, 6 deletions
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(()) } |