diff --git a/Cargo.toml b/Cargo.toml index 4d8bed7..c334859 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +egui = {version = "0.32.3", features = ["log"]} eframe = { version = "0.32.3" } +log = "0.4.28" +colog = "1.4.0" rfd = "*" json = "*" serde = { version = "*", features = ["derive"] } diff --git a/src/main.rs b/src/main.rs index 4eeaf40..0c905d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,10 +2,12 @@ use std::path::PathBuf; use eframe::egui; use eframe::egui::KeyboardShortcut; +use log::{info, warn, error}; use billy_sheet::gui::SheetGui; fn main() -> eframe::Result { + colog::init(); let options = eframe::NativeOptions { viewport: egui::ViewportBuilder::default().with_drag_and_drop(true), ..Default::default() @@ -54,7 +56,7 @@ impl eframe::App for Gui { if ui.button("Save in json").clicked() { let path = std::path::Path::new("./sheet.json"); if let Err(error) = billy_sheet::sheet::write_sheet(path, &self.sheet) { - println!("{error}"); + error!("{error}"); } } }); @@ -99,7 +101,19 @@ impl eframe::App for Gui { } }); if let Some(file_path) = &self.picked_path { - println!("{}", file_path.to_str().unwrap_or_default()); + if let Some(extension) = file_path.extension() { + info!("File selected : {}", file_path.display()); + if extension == "json" { + info!("File has json extension"); + } else { + warn!( + "File has not .json: {}", + extension.to_str().unwrap_or_default() + ); + } + } else { + error!("No extension for the file."); + } self.picked_path = None; } }