Skip to content

Commit

Permalink
why does check_config::check_config() should be declared init_logger(…
Browse files Browse the repository at this point in the history
…) lol
  • Loading branch information
shorekeeper committed Jun 3, 2023
1 parent ea0ca3b commit 99da029
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/check_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::path::Path;
use std::thread;
use std::time::Duration;

use crate::{log_info}; // macro imports
use crate::log::{info};
use crate::log_info; // macro imports
use crate::log::info;
use crate::time::current_time;

const DEFAULT_CONFIG: &str =
Expand Down Expand Up @@ -43,7 +43,7 @@ pub fn check_config() {
match updated {
true => {
fs::write(env_path, config).expect("Failed to update .env file");
log_info!(&now, "Updated .env file with missing values. Please configure them before running the program again.");
log_info!(&now, "\x1B[1m\x1b[32mUpdated .env file with missing values. Please configure them before running the program again.\x1B[0m");
thread::sleep(Duration::from_secs(10));
std::process::exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub async fn create_server(server_ip: &str) -> std::io::Result<()> {
server
}
Err(e) => { // if NOT ok
log_error!(&now, "Failed to bind server to \x1B[4m'{}': \x1b[33m{}\x1b[0m ", server_ip, e); // print the error
log_error!(&now, "!!! FAILED TO BIND A SERVER !!!\n\x1b[33mIP: \x1b[31m'{}'\n\x1b[33m |\n\x1b[33m v\n\x1b[33mERROR_CODE: \x1b[31m{}\x1b[0m", server_ip, e);
return Err(e);
}
};
Expand Down
1 change: 0 additions & 1 deletion src/log.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use colored::Colorize;


pub fn error(now: &str, message: &str) {
eprintln!("{} {} {}", now.bold().dimmed(), "[ERROR]".bold().red(), message.red());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::init::{create_server, init_logger};

#[actix_web::main]
async fn main() -> std::io::Result<()> {
init_logger();
check_config::check_config(); // call check_config function
dotenv().ok(); // load the .env file

Expand All @@ -29,7 +30,6 @@ async fn main() -> std::io::Result<()> {
Err(_) => "NO_IP_CONFIGURED".to_string(),
};

init_logger();
let _server = create_server(&server_ip).await?; // pass the server_ip to the create_server function
Ok(())
}

0 comments on commit 99da029

Please sign in to comment.