set log level from config
authorGeoffrey Allott <geoffrey@allott.email>
Sat, 6 Mar 2021 22:32:52 +0000 (22:32 +0000)
committerGeoffrey Allott <geoffrey@allott.email>
Sat, 6 Mar 2021 22:32:52 +0000 (22:32 +0000)
src/config.rs
src/main.rs

index 86604fe1471421135ad6a893bb56ef0cc9956531..bef5394508dfd235cb096efb049bed7e0d3cda57 100644 (file)
@@ -11,7 +11,7 @@ pub struct Config {
 }
 
 fn default_filter() -> String {
-    "warn".to_string()
+    "info".to_string()
 }
 
 fn default_style() -> String {
index 6ddfbc2a1aa1898b1d28c5db44677c6d23666c58..57b62ae53493032a920f0dbf112ac9ceee215567 100644 (file)
@@ -54,7 +54,6 @@ async fn serve_404(response: Response) -> Result<Response, tide::Error> {
 
 #[async_std::main]
 async fn main() -> Result<(), tide::Error> {
-    env_logger::init();
     let matches = app_from_crate!()
         .arg(
             Arg::with_name("config")
@@ -78,11 +77,16 @@ async fn main() -> Result<(), tide::Error> {
         )
         .subcommand(SubCommand::with_name("all").about("Serve the website, websocket connections and start a dealer for each game (default)"))
         .get_matches();
+
     let config = match matches.value_of_os("config") {
         Some(path) => toml::from_str(&read_to_string(path)?)?,
         None => Config::default(),
     };
 
+    env_logger::Builder::from_env(env_logger::Env::default().default_filter_or(config.log.filter).default_write_style_or(config.log.style))
+        .format_timestamp_millis()
+        .init();
+
     let mut run_server = true;
     let mut run_dealer = true;
     let mut partition = Partition::default();