Changing println to proper log macros and small fixes.
This commit is contained in:
+29
-32
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
use iced::widget;
|
||||
use log;
|
||||
use std::process::ExitCode;
|
||||
|
||||
use iced::{Element, Task};
|
||||
@@ -32,12 +33,13 @@ use crate::stages::welcome;
|
||||
use crate::stages::welcome::WelcomeStage;
|
||||
|
||||
rust_i18n::i18n!("src/locales", fallback = "en");
|
||||
mod kira_theming;
|
||||
mod kira_scroll_list;
|
||||
mod kira_color_bar;
|
||||
mod kira_disk_layout;
|
||||
mod kira_logger;
|
||||
mod kira_scroll_list;
|
||||
mod kira_size;
|
||||
mod kira_sysinfo;
|
||||
mod kira_theming;
|
||||
mod stage;
|
||||
mod stages;
|
||||
|
||||
@@ -80,7 +82,7 @@ fn load_kira_config(config_path: &str) -> Result<toml::Table, Box<dyn std::error
|
||||
// 2. Parse the string into a Table
|
||||
let table: Table = content.parse()?;
|
||||
|
||||
println!("{:?}", table);
|
||||
log::info!("{:?}", table);
|
||||
Ok(table)
|
||||
}
|
||||
|
||||
@@ -99,7 +101,6 @@ impl KiraState {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn view(k_state: &KiraState) -> Element<'_, Message> {
|
||||
match &k_state.current_view {
|
||||
Views::Start => Element::new(widget::space()),
|
||||
@@ -117,13 +118,13 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
||||
match message {
|
||||
Message::Start => match load_kira_config(CONFIG_PATH_STR) {
|
||||
Ok(conf) => {
|
||||
println!("Config loaded!");
|
||||
log::info!("Config loaded!");
|
||||
k_state.toml_config = conf;
|
||||
k_state.current_view = Views::Welcome(WelcomeStage::new());
|
||||
Task::none()
|
||||
}
|
||||
Err(ex) => {
|
||||
println!("Error reading config {}: {}", CONFIG_PATH_STR, ex);
|
||||
log::error!("Error reading config {}: {}", CONFIG_PATH_STR, ex);
|
||||
iced::exit()
|
||||
}
|
||||
},
|
||||
@@ -141,7 +142,7 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
||||
} else {
|
||||
Task::none()
|
||||
}
|
||||
},
|
||||
}
|
||||
Message::License(license_message) => {
|
||||
if let Views::License(license_view) = &mut k_state.current_view {
|
||||
let action = license_view.update(license_message);
|
||||
@@ -163,7 +164,7 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
||||
} else {
|
||||
Task::none()
|
||||
}
|
||||
},
|
||||
}
|
||||
Message::Network(network_message) => {
|
||||
if let Views::Network(network_view) = &mut k_state.current_view {
|
||||
let update_result = network_view.update(network_message);
|
||||
@@ -187,14 +188,15 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
||||
} else {
|
||||
Task::none()
|
||||
}
|
||||
},
|
||||
}
|
||||
Message::TimeZone(timezone_message) => {
|
||||
if let Views::TimeZone(timezone_view) = &mut k_state.current_view {
|
||||
let action = timezone_view.update(timezone_message);
|
||||
match action {
|
||||
StageAction::Next(tz_res) => {
|
||||
k_state.config.config_trail.push(tz_res);
|
||||
k_state.current_view = Views::Locale(stages::locale::LocaleStage::new(&k_state.config));
|
||||
k_state.current_view =
|
||||
Views::Locale(stages::locale::LocaleStage::new(&k_state.config));
|
||||
Task::none()
|
||||
}
|
||||
StageAction::Abort => iced::exit(),
|
||||
@@ -209,19 +211,20 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
||||
} else {
|
||||
Task::none()
|
||||
}
|
||||
},
|
||||
}
|
||||
Message::Locale(locale_msg) => {
|
||||
if let Views::Locale(locale_view) = &mut k_state.current_view {
|
||||
match locale_view.update(locale_msg) {
|
||||
StageAction::Next(locale_res) => {
|
||||
k_state.config.config_trail.push(locale_res);
|
||||
k_state.current_view = Views::Keyboard(stages::keyboard::KeyboardStage::new());
|
||||
k_state.current_view =
|
||||
Views::Keyboard(stages::keyboard::KeyboardStage::new());
|
||||
Task::none()
|
||||
}
|
||||
StageAction::Back => {
|
||||
k_state.config.config_trail.pop();
|
||||
k_state.current_view =
|
||||
Views::TimeZone(stages::timezone::TimeZoneStage::new());
|
||||
Views::TimeZone(stages::timezone::TimeZoneStage::new());
|
||||
Task::none()
|
||||
}
|
||||
_ => Task::none(),
|
||||
@@ -229,7 +232,7 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
||||
} else {
|
||||
Task::none()
|
||||
}
|
||||
},
|
||||
}
|
||||
Message::Keyboard(keyboard_msg) => {
|
||||
if let Views::Keyboard(keyboard_view) = &mut k_state.current_view {
|
||||
match keyboard_view.update(keyboard_msg) {
|
||||
@@ -238,17 +241,17 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
||||
Ok(part_stage) => {
|
||||
k_state.config.config_trail.push(keyboard_res);
|
||||
k_state.current_view = Views::Partition(part_stage);
|
||||
},
|
||||
Err(ex) => {
|
||||
println!("Error, cannot init partition stage: {}", ex);
|
||||
}
|
||||
|
||||
Err(ex) => {
|
||||
log::error!("Error, cannot init partition stage: {}", ex);
|
||||
}
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
StageAction::Back => {
|
||||
k_state.config.config_trail.pop();
|
||||
k_state.current_view = Views::Locale(stages::locale::LocaleStage::new(&k_state.config));
|
||||
k_state.current_view =
|
||||
Views::Locale(stages::locale::LocaleStage::new(&k_state.config));
|
||||
Task::none()
|
||||
}
|
||||
_ => Task::none(),
|
||||
@@ -256,7 +259,7 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
||||
} else {
|
||||
Task::none()
|
||||
}
|
||||
},
|
||||
}
|
||||
Message::Partition(partition_msg) => {
|
||||
if let Views::Partition(partition_view) = &mut k_state.current_view {
|
||||
match partition_view.update(partition_msg) {
|
||||
@@ -266,7 +269,8 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
||||
}
|
||||
StageAction::Back => {
|
||||
k_state.config.config_trail.pop();
|
||||
k_state.current_view = Views::Keyboard(stages::keyboard::KeyboardStage::new());
|
||||
k_state.current_view =
|
||||
Views::Keyboard(stages::keyboard::KeyboardStage::new());
|
||||
Task::none()
|
||||
}
|
||||
_ => Task::none(),
|
||||
@@ -278,8 +282,9 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn main() -> ExitCode {
|
||||
// Init logger
|
||||
kira_logger::init().unwrap();
|
||||
|
||||
let iced_result = iced::application(KiraState::boot, update, view)
|
||||
.window(iced::window::Settings {
|
||||
@@ -297,16 +302,8 @@ pub fn main() -> ExitCode {
|
||||
match iced_result {
|
||||
Ok(()) => ExitCode::SUCCESS,
|
||||
Err(ex) => {
|
||||
println!("ICED Error: {}", ex);
|
||||
log::error!("ICED Error: {}", ex);
|
||||
ExitCode::from(42)
|
||||
}, // Custom error code
|
||||
} // Custom error code
|
||||
}
|
||||
}
|
||||
|
||||
// fn main() {
|
||||
// println!("Hello, world!");
|
||||
// println!("{}", t!("wellcome.text"));
|
||||
// // Initialize the state
|
||||
// let _res = main_interface();
|
||||
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user