diff --git a/Cargo.lock b/Cargo.lock index ea034a8..0322ddb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,6 +27,17 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi 0.3.9", +] + [[package]] name = "autocfg" version = "1.0.1" @@ -193,6 +204,19 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "fnv" version = "1.0.7" @@ -322,6 +346,15 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + [[package]] name = "idna" version = "0.2.0" @@ -424,6 +457,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" dependencies = [ "cfg-if", + "serde 1.0.116", ] [[package]] @@ -590,6 +624,7 @@ name = "odyssey-server" version = "0.1.0" dependencies = [ "config", + "env_logger", "futures-util", "log", "serde 1.0.116", @@ -729,6 +764,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quote" version = "1.0.7" @@ -1047,6 +1088,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "termcolor" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +dependencies = [ + "winapi-util", +] + [[package]] name = "thread_local" version = "1.0.1" @@ -1252,6 +1302,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index c7e2557..3b38fff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,5 +13,6 @@ serde_derive = "1" tokio = { version = "0.2", features = ["full"] } tokio-tungstenite = "0.11" futures-util = { version = "0.3", default-features = false, features = ["async-await", "sink", "std"] } -log = "0.4" -ultraviolet = { version = "0.7", features = [ "f64", "int", "serde" ] } \ No newline at end of file +log = { version = "0.4", features = ["std", "serde"] } +ultraviolet = { version = "0.7", features = [ "f64", "int", "serde" ] } +env_logger = "0.7" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 3adc3f4..13bfdc7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ mod config; mod systems; use crate::config::Settings; +use env_logger::Env; use futures_util::StreamExt; use log::info; use shipyard::World; @@ -11,6 +12,9 @@ use tokio::net::{TcpListener, TcpStream}; #[tokio::main] async fn main() -> Result<(), Error> { + let env = Env::default().filter_or("LOG_LEVEL", "trace"); + env_logger::init_from_env(env); + let settings = Settings::new().unwrap(); // Create world @@ -19,15 +23,9 @@ async fn main() -> Result<(), Error> { // Create workload world.add_workload("update").build(); - tokio::spawn(update_loop(world)); - // Create the event loop and TCP listener we'll accept connections on. - tokio::spawn(listen_websocket(settings.bind)).await.unwrap(); + tokio::spawn(listen_websocket(settings.bind)); - Ok(()) -} - -async fn update_loop(world: World) { loop { world.run_workload("update"); }