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:
parent
3ad52908e6
commit
23817b5b95
16 changed files with 252 additions and 148 deletions
|
@ -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()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue