From 9832aef9eeaeff8979354d5de04b8706ff79a233 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Mon, 6 Jul 2020 21:30:41 -0400 Subject: [PATCH] feat(lib): Move from `log` to `tracing` in a backwards-compatible way (#2204) I've moved Hyper from `log` to `tracing`. Existing `log`-based users shouldn't notice a difference, but `tracing` users will see higher performance when filtering data. This isn't the _end_ of the `tracing` integration that can happen in `Hyper` (e.g., Hyper can start using spans, typed fields, etc.), but _something_ is better than nothing. I'd rather address those points, including examples, in followups. I've attached a screenshot of the `hello` example working, but the logged information is pulled from `tracing`, not `log`. Screen Shot 2020-05-16 at 1 23 19 PM --- Cargo.toml | 4 ++-- src/client/mod.rs | 12 +++++------- src/lib.rs | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cebbfc3b23..98264a761e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ http-body = "0.3.1" httparse = "1.0" h2 = "0.2.2" itoa = "0.4.1" -log = "0.4" +tracing = { version = "0.1", default-features = false, features = ["log", "std"] } pin-project = "0.4.20" time = "0.1" tower-service = "0.3" @@ -58,7 +58,7 @@ url = "1.0" [features] default = [ "runtime", - "stream", + "stream" ] runtime = [ "tcp", diff --git a/src/client/mod.rs b/src/client/mod.rs index a64970fe99..b4105bcb3c 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -793,13 +793,11 @@ fn absolute_form(uri: &mut Uri) { } fn authority_form(uri: &mut Uri) { - if log_enabled!(::log::Level::Warn) { - if let Some(path) = uri.path_and_query() { - // `https://hyper.rs` would parse with `/` path, don't - // annoy people about that... - if path != "/" { - warn!("HTTP/1.1 CONNECT request stripping path: {:?}", path); - } + if let Some(path) = uri.path_and_query() { + // `https://hyper.rs` would parse with `/` path, don't + // annoy people about that... + if path != "/" { + warn!("HTTP/1.1 CONNECT request stripping path: {:?}", path); } } *uri = match uri.authority() { diff --git a/src/lib.rs b/src/lib.rs index 068b9bae18..03d5cf3f64 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,7 +43,7 @@ #[doc(hidden)] pub use http; #[macro_use] -extern crate log; +extern crate tracing; #[cfg(all(test, feature = "nightly"))] extern crate test;