mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-24 23:18:22 -05:00
feat: add an option to enable or disable logs
This commit is contained in:
parent
1d638ffeea
commit
8e7dc68d2d
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
use std::net::TcpListener;
|
use std::net::TcpListener;
|
||||||
|
|
||||||
use env_logger::Env;
|
|
||||||
use websurfx::{config_parser::parser::Config, run};
|
use websurfx::{config_parser::parser::Config, run};
|
||||||
|
|
||||||
/// The function that launches the main server and registers all the routes of the website.
|
/// 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<()> {
|
|||||||
let config = Config::parse().unwrap();
|
let config = Config::parse().unwrap();
|
||||||
|
|
||||||
// Initializing logging middleware with level set to default or info.
|
// Initializing logging middleware with level set to default or info.
|
||||||
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
|
if config.logging {
|
||||||
|
use env_logger::Env;
|
||||||
|
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
|
||||||
|
}
|
||||||
|
|
||||||
log::info!("started server on port {}", config.port);
|
log::info!("started server on port {}", config.port);
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ pub struct Config {
|
|||||||
pub style: Style,
|
pub style: Style,
|
||||||
pub redis_connection_url: String,
|
pub redis_connection_url: String,
|
||||||
pub aggregator: AggreatorConfig,
|
pub aggregator: AggreatorConfig,
|
||||||
|
pub logging: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration options for the aggregator.
|
/// Configuration options for the aggregator.
|
||||||
@ -71,6 +72,7 @@ impl Config {
|
|||||||
),
|
),
|
||||||
redis_connection_url: globals.get::<_, String>("redis_connection_url")?,
|
redis_connection_url: globals.get::<_, String>("redis_connection_url")?,
|
||||||
aggregator: aggregator_config,
|
aggregator: aggregator_config,
|
||||||
|
logging: globals.get::<_, bool>("logging")?,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
-- ### General ###
|
||||||
|
logging = true -- an option to enable or disable logs.
|
||||||
|
|
||||||
-- ### Server ###
|
-- ### Server ###
|
||||||
port = "8080" -- port on which server should be launched
|
port = "8080" -- port on which server should be launched
|
||||||
binding_ip_addr = "127.0.0.1" --ip address on the which server should be launched.
|
binding_ip_addr = "127.0.0.1" --ip address on the which server should be launched.
|
||||||
|
Loading…
Reference in New Issue
Block a user