From e0872b331f946d535dadaddf8133740f064eea78 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Sun, 12 Feb 2023 21:31:21 +0100 Subject: [PATCH] ignore io errors on server --- kubi-logging/src/lib.rs | 10 ++++++++-- kubi-udp/src/server.rs | 3 ++- kubi/src/main.rs | 3 +++ kubi/src/networking.rs | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/kubi-logging/src/lib.rs b/kubi-logging/src/lib.rs index 84505f0..7a4c922 100644 --- a/kubi-logging/src/lib.rs +++ b/kubi-logging/src/lib.rs @@ -20,6 +20,9 @@ pub fn init() { _ => Color::Blue }).set_bold(true); + let mut bold_style = buf.style(); + bold_style.set_bold(true); + let mut location_style = buf.style(); location_style.set_bold(true); location_style.set_dimmed(true); @@ -27,9 +30,11 @@ pub fn init() { let mut location_line_style = buf.style(); location_line_style.set_dimmed(true); + let text = format!("{}", record.args()); + writeln!( buf, - "{} {:<50}\t{}{}{}", + "{} {:<50}\t{}{}{}{}", level_style.value(match record.level() { Level::Error => "[e]", Level::Warn => "[w]", @@ -37,7 +42,8 @@ pub fn init() { Level::Debug => "[d]", Level::Trace => "[t]", }), - format!("{}", record.args()), + text, + bold_style.value((text.len() > 50).then_some("\n ╰─ ").unwrap_or_default()), location_style.value(record.target()), location_line_style.value(" :"), location_line_style.value(record.line().unwrap_or(0)) diff --git a/kubi-udp/src/server.rs b/kubi-udp/src/server.rs index 5d135a0..05cd01e 100644 --- a/kubi-udp/src/server.rs +++ b/kubi-udp/src/server.rs @@ -189,7 +189,8 @@ impl Server where S: Encode + Decode, R: Encode + Decode { } }, Err(error) if error.kind() != ErrorKind::WouldBlock => { - return Err(error.into()); + log::warn!("IO error {}", error); + // return Err(error.into()); }, _ => break, } diff --git a/kubi/src/main.rs b/kubi/src/main.rs index 3ddf83d..64de54c 100644 --- a/kubi/src/main.rs +++ b/kubi/src/main.rs @@ -152,6 +152,9 @@ fn attach_console() { fn main() { //Attach console on release builds on windows #[cfg(all(windows, not(debug_assertions)))] attach_console(); + + //Print version + println!("{:─^54}", format!("[ ▄▀ Kubi client v. {} ]", env!("CARGO_PKG_VERSION"))); //Init env_logger kubi_logging::init(); diff --git a/kubi/src/networking.rs b/kubi/src/networking.rs index 3254bc4..4b5a8ff 100644 --- a/kubi/src/networking.rs +++ b/kubi/src/networking.rs @@ -66,7 +66,7 @@ pub fn update_networking() -> Workload { connect_client.run_if(client_needs_connect_call), update_client, insert_client_events, - ).into_workload().run_if(is_multiplayer) + ).into_workload() } fn client_needs_connect_call(