From 3f47be435dcc9e4063e54b832473eec3b48da34a Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Fri, 10 Feb 2023 20:44:34 +0100 Subject: [PATCH] separate logging into a library --- Cargo.toml | 2 +- kubi-logging/Cargo.toml | 8 ++++++++ kubi/src/logging.rs => kubi-logging/src/lib.rs | 6 +++++- kubi-server/Cargo.toml | 2 ++ kubi-server/src/main.rs | 1 + kubi/Cargo.toml | 4 ++-- kubi/src/main.rs | 3 +-- 7 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 kubi-logging/Cargo.toml rename kubi/src/logging.rs => kubi-logging/src/lib.rs (93%) diff --git a/Cargo.toml b/Cargo.toml index de197ad..ae1d7de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["kubi", "kubi-server", "kubi-shared", "kubi-udp"] +members = ["kubi", "kubi-server", "kubi-shared", "kubi-udp", "kubi-logging"] resolver = "2" [profile.release-with-debug] diff --git a/kubi-logging/Cargo.toml b/kubi-logging/Cargo.toml new file mode 100644 index 0000000..c88c172 --- /dev/null +++ b/kubi-logging/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "kubi-logging" +version = "0.1.0" +edition = "2021" + +[dependencies] +log = "0.4" +env_logger = "0.10" diff --git a/kubi/src/logging.rs b/kubi-logging/src/lib.rs similarity index 93% rename from kubi/src/logging.rs rename to kubi-logging/src/lib.rs index 14d12ce..84505f0 100644 --- a/kubi/src/logging.rs +++ b/kubi-logging/src/lib.rs @@ -1,9 +1,13 @@ -//! Custom env_logger options and styling +/// Custom env_logger options and styling use env_logger::{fmt::Color, Builder, Env}; use log::Level; use std::io::Write; +pub use log; +pub use env_logger; + +#[inline] pub fn init() { let env = Env::default() .filter_or("RUST_LOG", "trace,gilrs=warn,rusty_xinput=warn"); diff --git a/kubi-server/Cargo.toml b/kubi-server/Cargo.toml index 87c64dd..e9ff2ba 100644 --- a/kubi-server/Cargo.toml +++ b/kubi-server/Cargo.toml @@ -6,4 +6,6 @@ edition = "2021" [dependencies] kubi-shared = { path = "../kubi-shared" } kubi-udp = { path = "../kubi-udp" } +kubi-logging = { path = "../kubi-logging" } +log = "*" shipyard = "0.6" diff --git a/kubi-server/src/main.rs b/kubi-server/src/main.rs index b82c528..82bd08a 100644 --- a/kubi-server/src/main.rs +++ b/kubi-server/src/main.rs @@ -37,6 +37,7 @@ fn update() -> Workload { } fn main() { + kubi_logging::init(); let world = World::new(); world.add_workload(initialize); world.add_workload(update); diff --git a/kubi/Cargo.toml b/kubi/Cargo.toml index 536897f..50bf39a 100644 --- a/kubi/Cargo.toml +++ b/kubi/Cargo.toml @@ -6,11 +6,11 @@ edition = "2021" [dependencies] kubi-shared = { path = "../kubi-shared" } kubi-udp = { path = "../kubi-udp", optional = true } +kubi-logging = { path = "../kubi-logging" } +log = "*" glium = "0.32" glam = { version = "0.22", features = ["debug-glam-assert", "fast-math"] } image = { version = "0.24", default_features = false, features = ["png"] } -log = "0.4" -env_logger = "0.10" strum = { version = "0.24", features = ["derive"] } hashbrown = "0.13" rayon = "1.6" diff --git a/kubi/src/main.rs b/kubi/src/main.rs index c743c24..d683794 100644 --- a/kubi/src/main.rs +++ b/kubi/src/main.rs @@ -18,7 +18,6 @@ use glium::{ use glam::vec3; use std::time::Instant; -mod logging; pub(crate) mod rendering; pub(crate) mod world; pub(crate) mod player; @@ -148,7 +147,7 @@ fn main() { #[cfg(all(windows, not(debug_assertions)))] attach_console(); //Init env_logger - logging::init(); + kubi_logging::init(); //Create a shipyard world let mut world = World::new();