chore: change verbose to isize, only println if verbose > 0 (env WEB_SERVER_VERBOSE)
This commit is contained in:
parent
b5685bbe40
commit
ad0664c90b
5 changed files with 26 additions and 18 deletions
|
|
@ -29,7 +29,7 @@ pub struct AppData {
|
|||
impl AppData {
|
||||
/// Schema creation for `AppEnv`
|
||||
#[must_use]
|
||||
pub fn new(env: AppEnv) -> Self {
|
||||
pub fn new(env: AppEnv, verbose: isize) -> Self {
|
||||
let config = env.get_curr_websrvr_config();
|
||||
let templates_path = config.templates_path.to_owned();
|
||||
let default_module = config.default_module.to_owned();
|
||||
|
|
@ -40,7 +40,9 @@ impl AppData {
|
|||
let templates = format!("{}/**/*", &templates_path);
|
||||
tera = match tera::Tera::new(templates.as_str()) {
|
||||
Ok(t) => {
|
||||
println!("WebServices Templates loaded from: {}", &templates_path);
|
||||
if verbose > 0 {
|
||||
println!("WebServices Templates loaded from: {}", &templates_path);
|
||||
}
|
||||
t
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
@ -58,7 +60,9 @@ impl AppData {
|
|||
for (key, value) in &data_hash { //.iter() {
|
||||
ctx.insert(key, value);
|
||||
}
|
||||
println!("Default WebServices templates module loaded from: {}", &data_path);
|
||||
if verbose > 0 {
|
||||
println!("Default WebServices templates module loaded from: {}", &data_path);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
println!("Error parsing data {}:{}", &data_path, e);
|
||||
|
|
|
|||
|
|
@ -213,14 +213,14 @@ pub struct Config {
|
|||
}
|
||||
|
||||
impl Config {
|
||||
pub fn load_file_content(verbose: &str, cfg_path: &str) -> String {
|
||||
pub fn load_file_content(verbose: isize, cfg_path: &str) -> String {
|
||||
let config_path: String;
|
||||
if cfg_path.is_empty() {
|
||||
config_path = envmnt::get_or("APP_CONFIG_PATH", "config.toml");
|
||||
} else {
|
||||
config_path = cfg_path.to_string();
|
||||
}
|
||||
if verbose != "quiet" {
|
||||
if verbose > 0 {
|
||||
println!("Config path: {}", &config_path);
|
||||
}
|
||||
std::fs::read_to_string(&config_path)
|
||||
|
|
@ -229,10 +229,10 @@ impl Config {
|
|||
String::from("")
|
||||
})
|
||||
}
|
||||
pub fn new(content: String,verbose: &str) -> Self {
|
||||
pub fn new(content: String,verbose: isize) -> Self {
|
||||
match toml::from_str(&content) {
|
||||
Ok(cfg) => {
|
||||
if verbose != "quiet" {
|
||||
if verbose > 0 {
|
||||
println!("Config Loaded successfully");
|
||||
}
|
||||
let app_home=envmnt::get_or("APP_HOME", ".");
|
||||
|
|
|
|||
|
|
@ -47,12 +47,14 @@ impl Module {
|
|||
String::from("")
|
||||
})
|
||||
}
|
||||
pub fn new(content: String) -> Self {
|
||||
pub fn new(content: String, verbose: isize) -> Self {
|
||||
// let modul_def: toml::Value = toml::from_str(&content)?;
|
||||
// if let Some(name) = modul_def["name"].as_str() {
|
||||
match toml::from_str(&content) {
|
||||
Ok(cfg) => {
|
||||
println!("Module Loaded successfully");
|
||||
if verbose > 0 {
|
||||
println!("Module Loaded successfully");
|
||||
}
|
||||
cfg
|
||||
},
|
||||
Err(e) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue