mirror of
https://github.com/MeexReay/bRAC.git
synced 2025-06-24 19:02:58 +03:00
add debug logs setting
This commit is contained in:
parent
b206f18829
commit
9ef7560963
@ -29,6 +29,7 @@ pub struct Config {
|
|||||||
#[serde(default)] pub wrac_enabled: bool,
|
#[serde(default)] pub wrac_enabled: bool,
|
||||||
#[serde(default)] pub proxy: Option<String>,
|
#[serde(default)] pub proxy: Option<String>,
|
||||||
#[serde(default = "default_true")] pub notifications_enabled: bool,
|
#[serde(default = "default_true")] pub notifications_enabled: bool,
|
||||||
|
#[serde(default)] pub debug_logs: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_config_path() -> PathBuf {
|
pub fn get_config_path() -> PathBuf {
|
||||||
@ -120,6 +121,7 @@ pub struct Args {
|
|||||||
#[arg(long)] pub notifications_enabled: Option<bool>,
|
#[arg(long)] pub notifications_enabled: Option<bool>,
|
||||||
#[arg(long)] pub wrac_enabled: Option<bool>,
|
#[arg(long)] pub wrac_enabled: Option<bool>,
|
||||||
#[arg(long)] pub proxy: Option<String>,
|
#[arg(long)] pub proxy: Option<String>,
|
||||||
|
#[arg(long)] pub debug_logs: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Args {
|
impl Args {
|
||||||
@ -139,5 +141,6 @@ impl Args {
|
|||||||
if let Some(v) = self.commands_enabled { config.commands_enabled = v }
|
if let Some(v) = self.commands_enabled { config.commands_enabled = v }
|
||||||
if let Some(v) = self.notifications_enabled { config.notifications_enabled = v }
|
if let Some(v) = self.notifications_enabled { config.notifications_enabled = v }
|
||||||
if let Some(v) = self.wrac_enabled { config.wrac_enabled = v }
|
if let Some(v) = self.wrac_enabled { config.wrac_enabled = v }
|
||||||
|
if self.debug_logs { config.debug_logs = true }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -173,6 +173,7 @@ fn open_settings(ctx: Arc<Context>, app: &Application) {
|
|||||||
let formatting_enabled_entry = gui_checkbox_setting!("Formatting Enabled", formatting_enabled, ctx, vbox);
|
let formatting_enabled_entry = gui_checkbox_setting!("Formatting Enabled", formatting_enabled, ctx, vbox);
|
||||||
let commands_enabled_entry = gui_checkbox_setting!("Commands Enabled", commands_enabled, ctx, vbox);
|
let commands_enabled_entry = gui_checkbox_setting!("Commands Enabled", commands_enabled, ctx, vbox);
|
||||||
let notifications_enabled_entry = gui_checkbox_setting!("Notifications Enabled", notifications_enabled, ctx, vbox);
|
let notifications_enabled_entry = gui_checkbox_setting!("Notifications Enabled", notifications_enabled, ctx, vbox);
|
||||||
|
let debug_logs_entry = gui_checkbox_setting!("Debug Logs", debug_logs, ctx, vbox);
|
||||||
|
|
||||||
let save_button = Button::builder()
|
let save_button = Button::builder()
|
||||||
.label("Save")
|
.label("Save")
|
||||||
@ -197,6 +198,7 @@ fn open_settings(ctx: Arc<Context>, app: &Application) {
|
|||||||
#[weak] notifications_enabled_entry,
|
#[weak] notifications_enabled_entry,
|
||||||
#[weak] wrac_enabled_entry,
|
#[weak] wrac_enabled_entry,
|
||||||
#[weak] proxy_entry,
|
#[weak] proxy_entry,
|
||||||
|
#[weak] debug_logs_entry,
|
||||||
move |_| {
|
move |_| {
|
||||||
let config = Config {
|
let config = Config {
|
||||||
host: host_entry.text().to_string(),
|
host: host_entry.text().to_string(),
|
||||||
@ -241,6 +243,7 @@ fn open_settings(ctx: Arc<Context>, app: &Application) {
|
|||||||
formatting_enabled: formatting_enabled_entry.is_active(),
|
formatting_enabled: formatting_enabled_entry.is_active(),
|
||||||
commands_enabled: commands_enabled_entry.is_active(),
|
commands_enabled: commands_enabled_entry.is_active(),
|
||||||
notifications_enabled: notifications_enabled_entry.is_active(),
|
notifications_enabled: notifications_enabled_entry.is_active(),
|
||||||
|
debug_logs: debug_logs_entry.is_active(),
|
||||||
proxy: {
|
proxy: {
|
||||||
let proxy = proxy_entry.text().to_string();
|
let proxy = proxy_entry.text().to_string();
|
||||||
|
|
||||||
@ -554,10 +557,12 @@ fn build_ui(ctx: Arc<Context>, app: &Application) -> UiModel {
|
|||||||
));
|
));
|
||||||
|
|
||||||
if let Err(e) = on_send_message(ctx.clone(), &text_entry.text()) {
|
if let Err(e) = on_send_message(ctx.clone(), &text_entry.text()) {
|
||||||
|
if ctx.config(|o| o.debug_logs) {
|
||||||
let msg = format!("Send message error: {}", e.to_string()).to_string();
|
let msg = format!("Send message error: {}", e.to_string()).to_string();
|
||||||
add_chat_message(ctx.clone(), msg);
|
add_chat_message(ctx.clone(), msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
text_entry.connect_activate(clone!(
|
text_entry.connect_activate(clone!(
|
||||||
@ -573,10 +578,12 @@ fn build_ui(ctx: Arc<Context>, app: &Application) -> UiModel {
|
|||||||
));
|
));
|
||||||
|
|
||||||
if let Err(e) = on_send_message(ctx.clone(), &text_entry.text()) {
|
if let Err(e) = on_send_message(ctx.clone(), &text_entry.text()) {
|
||||||
|
if ctx.config(|o| o.debug_logs) {
|
||||||
let msg = format!("Send message error: {}", e.to_string()).to_string();
|
let msg = format!("Send message error: {}", e.to_string()).to_string();
|
||||||
add_chat_message(ctx.clone(), msg);
|
add_chat_message(ctx.clone(), msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
send_box.append(&send_btn);
|
send_box.append(&send_btn);
|
||||||
@ -873,7 +880,9 @@ fn run_recv_loop(ctx: Arc<Context>) {
|
|||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
loop {
|
loop {
|
||||||
if let Err(e) = recv_tick(ctx.clone()) {
|
if let Err(e) = recv_tick(ctx.clone()) {
|
||||||
|
if ctx.config(|o| o.debug_logs) {
|
||||||
let _ = print_message(ctx.clone(), format!("Print messages error: {}", e.to_string()).to_string());
|
let _ = print_message(ctx.clone(), format!("Print messages error: {}", e.to_string()).to_string());
|
||||||
|
}
|
||||||
thread::sleep(Duration::from_secs(1));
|
thread::sleep(Duration::from_secs(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,9 @@ pub fn recv_tick(ctx: Arc<Context>) -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Read messages error: {}", e.to_string())
|
if ctx.config(|o| o.debug_logs) {
|
||||||
|
add_chat_message(ctx.clone(), format!("Read messages error: {}", e.to_string()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user