Use `log` crate & macros instead of prints.

This commit is contained in:
Tangent Wantwight 2019-11-19 01:52:52 -05:00
parent 2f129d6986
commit ba1d921a7e
5 changed files with 10 additions and 6 deletions

1
Cargo.lock generated
View File

@ -1718,6 +1718,7 @@ dependencies = [
"http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.13.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"odds 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -13,6 +13,7 @@ futures3 = { package = "futures-preview", version="0.3.0-alpha", features = ["co
http = "^0.1.18"
hyper = "^0.12.35"
hyper13 = { package = "hyper", version="0.13.0-alpha.4", features = ["unstable-stream"] }
log = "^0.4.8"
matches = "^0.1.8"
odds = { version = "^0.3.1", features = ["std-vec"] }
tokio2 = { package = "tokio", version="0.2.0-alpha.6" }

View File

@ -76,7 +76,7 @@ fn post_stream(channel: Handle, stream: impl Stream<Item = impl Buf, Error = war
.into_stream()
.map(|_| empty())
.map_err(|err| {
println!("[Warning] {}", err);
warn!("{}", err);
err
})
.flatten()
@ -114,19 +114,19 @@ pub fn run(args: &ArgMatches) -> Result<(), WebmetroError> {
let head = channel.clone().and(warp::head())
.map(|(_, name)| {
println!("[Info] HEAD Request For Channel {}", name);
info!("HEAD Request For Channel {}", name);
media_response(Body::empty())
});
let get = channel.clone().and(warp::get2())
.map(|(channel, name)| {
println!("[Info] Listener Connected On Channel {}", name);
info!("Listener Connected On Channel {}", name);
media_response(Body::wrap_stream(get_stream(channel)))
});
let post_put = channel.clone().and(warp::post2().or(warp::put2()).unify())
.and(warp::body::stream()).map(|(channel, name), stream| {
println!("[Info] Source Connected On Channel {}", name);
info!("Source Connected On Channel {}", name);
Response::new(Body::wrap_stream(post_stream(channel, stream)))
});

View File

@ -51,7 +51,7 @@ pub fn run(args: &ArgMatches) -> Result<(), WebmetroError> {
let chunk_stream = chunk_stream
.map_ok(|webm_chunk| webm_chunk.into_bytes())
.map_err(|err| {
eprintln!("{}", &err);
warn!("{}", &err);
err
});

View File

@ -1,4 +1,6 @@
#[macro_use] extern crate log;
mod commands;
use clap::{App, AppSettings, crate_version};
@ -36,6 +38,6 @@ fn main() {
Ok(())
}
}.unwrap_or_else(|err| {
eprintln!("Error: {}", err);
error!("{}", err);
});
}