Refactor logging system to switch between stdout and file logging

* Refactor logging to switch between stdout and file logging

* Use "clear" instead of "tput reset" for unix

* Remove redundant comments
This commit is contained in:
Jason Spalti 2024-12-02 11:51:39 -06:00 committed by BitSyndicate
parent b36fd151b5
commit cfe961ab71
Signed by: bitsyndicate
GPG key ID: 443E4198D6BBA6DE
16 changed files with 252 additions and 148 deletions

View file

@ -1,30 +1,28 @@
use super::COMMAND_LIST;
use std::process::Command;
use log2::{debug, info};
use log::debug;
pub(crate) fn say_hello() {
println!("Hello, World!");
}
pub(crate) fn echo(args: Vec<String>) {
debug!("{}", args.join(" "));
println!("{}", args.join(" "))
}
pub(crate) fn exit() {
debug!("Exiting...");
println!("Exiting...");
std::process::exit(0)
}
pub(crate) fn clear() {
info!("Clearing screen..., running command");
println!("Clearing screen..., running command");
let _result = if cfg!(target_os = "windows") {
debug!("target_os is windows");
Command::new("cmd").args(["/c", "cls"]).spawn()
} else {
debug!("target_os is unix");
// "clear" or "tput reset"
Command::new("tput").arg("reset").spawn()
Command::new("clear").spawn()
};
}