From dbad0a16c4eb305c4192f4954b1dea09dc00af4e Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Fri, 21 Sep 2018 18:00:41 -0700 Subject: [PATCH] Comment out roblox_studio mechanisms for now, start using env_logger --- server/Cargo.lock | 49 ++++++++++++++++++++++++++++++++++++ server/Cargo.toml | 2 ++ server/src/bin.rs | 10 ++++++-- server/src/commands/init.rs | 2 +- server/src/commands/serve.rs | 12 +++++---- server/src/lib.rs | 3 ++- server/src/roblox_studio.rs | 7 +++--- server/src/session.rs | 5 ++-- server/src/web.rs | 3 ++- 9 files changed, 77 insertions(+), 16 deletions(-) diff --git a/server/Cargo.lock b/server/Cargo.lock index 3e0dfd05..caedd382 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -234,6 +234,18 @@ dependencies = [ "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "env_logger" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "filetime" version = "0.1.15" @@ -295,6 +307,14 @@ name = "httparse" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "humantime" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "idna" version = "0.1.5" @@ -571,6 +591,11 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "quick-error" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "quote" version = "0.6.8" @@ -662,7 +687,9 @@ name = "rojo" version = "0.5.0" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "notify 4.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -806,6 +833,14 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "termcolor" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "termion" version = "1.5.1" @@ -998,6 +1033,15 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "wincolor" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -1039,6 +1083,7 @@ dependencies = [ "checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" "checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" "checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180" +"checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "714653f3e34871534de23771ac7b26e999651a0a228f47beb324dfdf1dd4b10f" "checksum fsevent 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c4bbbf71584aeed076100b5665ac14e3d85eeb31fdbb45fbd41ef9a682b5ec05" "checksum fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a772d36c338d07a032d5375a36f15f9a7043bf0cb8ce7cee658e037c6032874" @@ -1047,6 +1092,7 @@ dependencies = [ "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" "checksum gzip-header 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0a9fcfe1c9ee125342355b2467bc29b9dfcb2124fcae27edb9cee6f4cc5ecd40" "checksum httparse 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b6288d7db100340ca12873fd4d08ad1b8f206a9457798dfb17c018a33fee540" +"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum inotify 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887fcc180136e77a85e6a6128579a719027b1bab9b1c38ea4444244fe262c20c" "checksum itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606" @@ -1078,6 +1124,7 @@ dependencies = [ "checksum phf_generator 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)" = "05a079dd052e7b674d21cb31cbb6c05efd56a2cd2827db7692e2f1a507ebd998" "checksum phf_shared 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)" = "c2261d544c2bb6aa3b10022b0be371b9c7c64f762ef28c6f5d4f1ef6d97b5930" "checksum proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "ee5697238f0d893c7f0ecc59c0999f18d2af85e424de441178bcacc9f9e6cf67" +"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" "checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" "checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" @@ -1104,6 +1151,7 @@ dependencies = [ "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum tempfile 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c4b103c6d08d323b92ff42c8ce62abcd83ca8efa7fd5bf7927efefec75f58c76" "checksum term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "f2077e54d38055cf1ca0fd7933a2e00cd3ec8f6fed352b2a377f06dcdaaf3281" +"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" @@ -1130,4 +1178,5 @@ dependencies = [ "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/server/Cargo.toml b/server/Cargo.toml index 69c9bfe1..c773efd1 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -28,6 +28,8 @@ notify = "4.0" rand = "0.4" regex = "1.0" lazy_static = "1.0" +log = "0.4" +env_logger = "0.5" [dev-dependencies] tempfile = "3.0" diff --git a/server/src/bin.rs b/server/src/bin.rs index 86232c92..da27fcbc 100644 --- a/server/src/bin.rs +++ b/server/src/bin.rs @@ -1,4 +1,6 @@ #[macro_use] extern crate clap; +#[macro_use] extern crate log; +extern crate env_logger; extern crate librojo; @@ -8,6 +10,10 @@ use std::process; use librojo::pathext::canonicalish; fn main() { + env_logger::Builder::from_default_env() + .default_format_timestamp(false) + .init(); + let matches = clap_app!(rojo => (version: env!("CARGO_PKG_VERSION")) (author: env!("CARGO_PKG_AUTHORS")) @@ -45,8 +51,8 @@ fn main() { librojo::commands::serve(&project_path); }, _ => { - eprintln!("Please specify a subcommand!"); - eprintln!("Try 'rojo help' for information."); + error!("Please specify a subcommand!"); + error!("Try 'rojo help' for information."); process::exit(1); }, } diff --git a/server/src/commands/init.rs b/server/src/commands/init.rs index 9050e072..05407f14 100644 --- a/server/src/commands/init.rs +++ b/server/src/commands/init.rs @@ -9,7 +9,7 @@ pub fn init(project_path: &PathBuf) { println!("Created new empty project at {}", project_path.display()); }, Err(e) => { - eprintln!("Failed to create new project.\n{}", e); + error!("Failed to create new project.\n{}", e); process::exit(1); }, } diff --git a/server/src/commands/serve.rs b/server/src/commands/serve.rs index 7233c872..4164026d 100644 --- a/server/src/commands/serve.rs +++ b/server/src/commands/serve.rs @@ -8,22 +8,24 @@ use ::{ project::Project, web::Server, session::Session, - roblox_studio, + // roblox_studio, }; pub fn serve(fuzzy_project_location: &Path) { + info!("Looking for project at {}", fuzzy_project_location.display()); + let project = match Project::load_fuzzy(fuzzy_project_location) { Ok(project) => project, Err(error) => { - eprintln!("Fatal: {}", error); + error!("{}", error); process::exit(1); }, }; - println!("Found project at {}", project.file_location.display()); - println!("Using project {:#?}", project); + info!("Found project at {}", project.file_location.display()); + info!("Using project {:#?}", project); - roblox_studio::install_bundled_plugin().unwrap(); + // roblox_studio::install_bundled_plugin().unwrap(); let session = Arc::new({ let mut session = Session::new(project); diff --git a/server/src/lib.rs b/server/src/lib.rs index 315d266c..41d3fd7e 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -1,6 +1,7 @@ #[macro_use] extern crate serde_derive; #[macro_use] extern crate rouille; #[macro_use] extern crate lazy_static; +#[macro_use] extern crate log; extern crate notify; extern crate rand; extern crate serde; @@ -16,7 +17,7 @@ pub mod message_queue; pub mod pathext; pub mod project; pub mod rbx; -pub mod roblox_studio; +// pub mod roblox_studio; pub mod session; pub mod vfs; pub mod web; diff --git a/server/src/roblox_studio.rs b/server/src/roblox_studio.rs index ee90a0b5..195e86be 100644 --- a/server/src/roblox_studio.rs +++ b/server/src/roblox_studio.rs @@ -4,7 +4,6 @@ #![allow(dead_code)] use std::path::PathBuf; -use std::env; #[cfg(all(not(debug_assertions), not(feature = "bundle-plugin")))] compile_error!("`bundle-plugin` feature must be set for release builds."); @@ -14,6 +13,8 @@ static PLUGIN_RBXM: &'static [u8] = include_bytes!("../target/plugin.rbxmx"); #[cfg(target_os = "windows")] pub fn get_install_location() -> Option { + use std::env; + let local_app_data = env::var("LocalAppData").ok()?; let mut location = PathBuf::from(local_app_data); @@ -46,7 +47,7 @@ pub fn install_bundled_plugin() -> Option<()> { use std::fs::File; use std::io::Write; - println!("Installing plugin..."); + info!("Installing plugin..."); let mut file = File::create(get_plugin_location()?).ok()?; file.write_all(PLUGIN_RBXM).ok()?; @@ -56,7 +57,7 @@ pub fn install_bundled_plugin() -> Option<()> { #[cfg(not(feature = "bundle-plugin"))] pub fn install_bundled_plugin() -> Option<()> { - println!("Skipping plugin installation, bundle-plugin not set."); + info!("Skipping plugin installation, bundle-plugin not set."); Some(()) } \ No newline at end of file diff --git a/server/src/session.rs b/server/src/session.rs index b1e9c7c8..7a69bed9 100644 --- a/server/src/session.rs +++ b/server/src/session.rs @@ -71,7 +71,7 @@ impl Session { } for root in vfs.get_roots() { - println!("Watching {}", root.display()); + info!("Watching {}", root.display()); let (watch_tx, watch_rx) = mpsc::channel(); @@ -83,7 +83,6 @@ impl Session { let vfs = Arc::clone(&self.vfs); thread::spawn(move || { - println!("Thread started"); loop { match watch_rx.recv() { Ok(event) => { @@ -107,7 +106,7 @@ impl Session { Err(_) => break, }; } - println!("Thread stopped"); + info!("Watcher thread stopped"); }); } } diff --git a/server/src/web.rs b/server/src/web.rs index 5d312aa4..8ec85213 100644 --- a/server/src/web.rs +++ b/server/src/web.rs @@ -9,7 +9,6 @@ use rouille::{self, Request, Response}; use ::{ id::Id, message_queue::Message, - project::Project, rbx::RbxInstance, session::Session, }; @@ -54,6 +53,8 @@ impl Server { #[allow(unreachable_code)] pub fn handle_request(&self, request: &Request) -> Response { + trace!("Request {} {}", request.method(), request.url()); + router!(request, (GET) (/) => { Response::text("Rojo is up and running!")