XFFXFF commited on
Commit
5cb53c7
2 Parent(s): 67287c3 680ffd1

Merge pull request #70 from neon-mmd/feat-add-logging-option

Browse files
src/bin/websurfx.rs CHANGED
@@ -5,7 +5,6 @@
5
 
6
  use std::net::TcpListener;
7
 
8
- use env_logger::Env;
9
  use websurfx::{config_parser::parser::Config, run};
10
 
11
  /// The function that launches the main server and registers all the routes of the website.
@@ -20,7 +19,10 @@ async fn main() -> std::io::Result<()> {
20
  let config = Config::parse().unwrap();
21
 
22
  // Initializing logging middleware with level set to default or info.
23
- env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
 
 
 
24
 
25
  log::info!("started server on port {}", config.port);
26
 
 
5
 
6
  use std::net::TcpListener;
7
 
 
8
  use websurfx::{config_parser::parser::Config, run};
9
 
10
  /// The function that launches the main server and registers all the routes of the website.
 
19
  let config = Config::parse().unwrap();
20
 
21
  // Initializing logging middleware with level set to default or info.
22
+ if config.logging {
23
+ use env_logger::Env;
24
+ env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
25
+ }
26
 
27
  log::info!("started server on port {}", config.port);
28
 
src/config_parser/parser.rs CHANGED
@@ -25,6 +25,7 @@ pub struct Config {
25
  pub style: Style,
26
  pub redis_connection_url: String,
27
  pub aggregator: AggreatorConfig,
 
28
  }
29
 
30
  /// Configuration options for the aggregator.
@@ -71,6 +72,7 @@ impl Config {
71
  ),
72
  redis_connection_url: globals.get::<_, String>("redis_connection_url")?,
73
  aggregator: aggregator_config,
 
74
  })
75
  })
76
  }
 
25
  pub style: Style,
26
  pub redis_connection_url: String,
27
  pub aggregator: AggreatorConfig,
28
+ pub logging: bool,
29
  }
30
 
31
  /// Configuration options for the aggregator.
 
72
  ),
73
  redis_connection_url: globals.get::<_, String>("redis_connection_url")?,
74
  aggregator: aggregator_config,
75
+ logging: globals.get::<_, bool>("logging")?,
76
  })
77
  })
78
  }
websurfx/config.lua CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  -- ### Server ###
2
  port = "8080" -- port on which server should be launched
3
  binding_ip_addr = "127.0.0.1" --ip address on the which server should be launched.
 
1
+ -- ### General ###
2
+ logging = true -- an option to enable or disable logs.
3
+
4
  -- ### Server ###
5
  port = "8080" -- port on which server should be launched
6
  binding_ip_addr = "127.0.0.1" --ip address on the which server should be launched.