From f1377e6eba2b3d93425e740e03232e498eb13b99 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 29 Aug 2022 15:19:28 -0400 Subject: [PATCH] clean up client ui --- veilid-cli/src/command_processor.rs | 20 ++++++++++++-------- veilid-cli/src/ui.rs | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/veilid-cli/src/command_processor.rs b/veilid-cli/src/command_processor.rs index 81d0bb0b..a4872d82 100644 --- a/veilid-cli/src/command_processor.rs +++ b/veilid-cli/src/command_processor.rs @@ -111,7 +111,8 @@ attach - attach the server to the Veilid network detach - detach the server from the Veilid network debug - send a debugging command to the Veilid server change_log_level - change the log level for a tracing layer -"#, +"# + .to_owned(), ); let ui = self.ui(); ui.send_callback(callback); @@ -202,7 +203,7 @@ change_log_level - change the log level for a tracing layer let log_level = match convert_loglevel(&rest.unwrap_or_default()) { Ok(v) => v, Err(e) => { - error!("failed to change log level: {}", e); + ui.add_node_event(format!("Failed to change log level: {}", e)); ui.send_callback(callback); return; } @@ -210,12 +211,14 @@ change_log_level - change the log level for a tracing layer match capi.server_change_log_level(layer, log_level).await { Ok(()) => { - info!("Log level changed"); - ui.send_callback(callback); + ui.display_string_dialog("Success", "Log level changed", callback); } Err(e) => { - error!("Server command 'change_log_level' failed: {}", e); - ui.send_callback(callback); + ui.display_string_dialog( + "Server command 'change_log_level' failed", + e.to_string(), + callback, + ); } } }); @@ -326,8 +329,9 @@ change_log_level - change the log level for a tracing layer } pub fn update_log(&mut self, log: veilid_core::VeilidStateLog) { - let message = format!("{}: {}", log.log_level, log.message); - self.inner().ui.add_node_event(&message); + self.inner() + .ui + .add_node_event(format!("{}: {}", log.log_level, log.message)); } pub fn update_shutdown(&mut self) { diff --git a/veilid-cli/src/ui.rs b/veilid-cli/src/ui.rs index 686e3eaf..ecd780ed 100644 --- a/veilid-cli/src/ui.rs +++ b/veilid-cli/src/ui.rs @@ -790,7 +790,7 @@ impl UI { inner.ui_state.connection_state.set(state); let _ = inner.cb_sink.send(Box::new(UI::update_cb)); } - pub fn add_node_event(&self, event: &str) { + pub fn add_node_event(&self, event: String) { let inner = self.inner.borrow(); let color = *inner.log_colors.get(&Level::Info).unwrap(); for line in event.lines() {