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]
name = "rmenu"
version = "0.0.0"
version = "0.0.1"
edition = "2021"
# 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 => {}
_ => {
let path = cache_file(name);
println!("write! {:?}", path);
let data = bincode::serialize(entries)?;
let mut f = fs::File::create(path)?;
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>) {
log::info!("executing: {} {:?}", action.name, action.exec);
log::info!("executing: {:?} {:?}", action.name, action.exec);
let args = match &action.exec {
Method::Run(exec) => parse_args(&exec),
Method::Terminal(exec) => {

View File

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