feat: cleanup and improve logging

This commit is contained in:
imgurbot12 2023-08-07 16:06:58 -07:00
parent 72267fb029
commit 5cc40a564a
4 changed files with 7 additions and 6 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "rmenu" name = "rmenu"
version = "0.0.0" version = "0.0.1"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -80,7 +80,6 @@ pub fn write_cache(name: &str, cfg: &PluginConfig, entries: &Vec<Entry>) -> Resu
CacheSetting::NoCache => {} CacheSetting::NoCache => {}
_ => { _ => {
let path = cache_file(name); let path = cache_file(name);
println!("write! {:?}", path);
let data = bincode::serialize(entries)?; let data = bincode::serialize(entries)?;
let mut f = fs::File::create(path)?; let mut f = fs::File::create(path)?;
f.write_all(&data)?; f.write_all(&data)?;

View file

@ -41,7 +41,7 @@ fn parse_args(exec: &str) -> Vec<String> {
} }
pub fn execute(action: &Action, term: Option<String>) { pub fn execute(action: &Action, term: Option<String>) {
log::info!("executing: {} {:?}", action.name, action.exec); log::info!("executing: {:?} {:?}", action.name, action.exec);
let args = match &action.exec { let args = match &action.exec {
Method::Run(exec) => parse_args(&exec), Method::Run(exec) => parse_args(&exec),
Method::Terminal(exec) => { Method::Terminal(exec) => {

View file

@ -128,6 +128,7 @@ impl Args {
"-" => "/dev/stdin", "-" => "/dev/stdin",
_ => &self.input, _ => &self.input,
}; };
log::info!("reading from {fpath:?}");
let file = File::open(fpath).map_err(|e| RMenuError::FileError(e))?; let file = File::open(fpath).map_err(|e| RMenuError::FileError(e))?;
let reader = BufReader::new(file); let reader = BufReader::new(file);
let mut entries = vec![]; let mut entries = vec![];
@ -236,10 +237,11 @@ impl Args {
//TODO: improve looks and css //TODO: improve looks and css
fn main() -> Result<(), RMenuError> { fn main() -> Result<(), RMenuError> {
// enable log if env-var is present // enable log and set default level
if std::env::var("RUST_LOG").is_ok() { if std::env::var("RUST_LOG").is_err() {
env_logger::init(); std::env::set_var("RUST_LOG", "info");
} }
env_logger::init();
// parse cli / config / application-settings // parse cli / config / application-settings
let app = Args::parse_app()?; let app = Args::parse_app()?;
// change directory to configuration dir // change directory to configuration dir