0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-22 05:58:21 -05:00

Merge branch 'rolling' into readme-revision

This commit is contained in:
alamin655 2023-08-06 11:07:20 +05:30 committed by GitHub
commit f3aedb1ffd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 19 deletions

View File

@ -24,8 +24,8 @@ async fn main() -> std::io::Result<()> {
);
log::info!(
"Open http://{}:{}/ in your browser",
config.binding_ip,
config.port,
config.binding_ip
);
let listener = TcpListener::bind((config.binding_ip.clone(), config.port))?;

View File

@ -4,7 +4,7 @@
use super::parser_models::Style;
use log::LevelFilter;
use rlua::Lua;
use std::{collections::HashMap, format, fs, io::Write, path::Path, thread::available_parallelism};
use std::{collections::HashMap, format, fs, path::Path, thread::available_parallelism};
// ------- Constants --------
static COMMON_DIRECTORY_NAME: &str = "websurfx";
@ -79,26 +79,26 @@ impl Config {
// Check whether logging has not been initialized before.
if logging_initialized {
// Initializing logging middleware with level set to default or info.
let mut log_level: LevelFilter = LevelFilter::Off;
if logging && debug == false {
log_level = LevelFilter::Info;
} else if debug {
log_level = LevelFilter::Trace;
};
env_logger::Builder::new().filter(None, log_level).init();
if let Ok(pkg_env_var) = std::env::var("PKG_ENV"){
if pkg_env_var.to_lowercase() == "dev" {
env_logger::Builder::new().filter(None, LevelFilter::Trace).init();
}
} else {
// Initializing logging middleware with level set to default or info.
let mut log_level: LevelFilter = LevelFilter::Error;
if logging && debug == false {
log_level = LevelFilter::Info;
} else if debug {
log_level = LevelFilter::Debug;
};
env_logger::Builder::new().filter(None, log_level).init();
}
}
let threads: u8 = if parsed_threads == 0 {
let total_num_of_threads:usize = available_parallelism()?.get() /2;
if debug || logging {
log::error!("Config Error: The value of `threads` option should be a non zero positive integer");
log::info!("Falling back to using {} threads", total_num_of_threads)
} else {
std::io::stdout()
.lock()
.write_all(&format!("Config Error: The value of `threads` option should be a non zero positive integer\nFalling back to using {} threads\n", total_num_of_threads).into_bytes())?;
};
let total_num_of_threads: usize = available_parallelism()?.get() / 2;
log::error!("Config Error: The value of `threads` option should be a non zero positive integer");
log::error!("Falling back to using {} threads", total_num_of_threads);
total_num_of_threads as u8
} else {
parsed_threads

View File

@ -144,6 +144,7 @@ pub async fn aggregate(
initial = false
}
Err(error_type) => {
log::error!("Engine Error: {:?}", error_type);
engine_errors_info.push(EngineErrorInfo::new(
error_type.downcast_ref::<EngineError>().unwrap(),
upstream_search_engines[counter].clone(),
@ -172,6 +173,7 @@ pub async fn aggregate(
counter += 1
}
Err(error_type) => {
log::error!("Engine Error: {:?}", error_type);
engine_errors_info.push(EngineErrorInfo::new(
error_type.downcast_ref::<EngineError>().unwrap(),
upstream_search_engines[counter].clone(),