Skip to content

Commit

Permalink
feat(lib): Move from log to tracing in a backwards-compatible way (
Browse files Browse the repository at this point in the history
…#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`.

<img width="514" alt="Screen Shot 2020-05-16 at 1 23 19 PM" src="https://user-images.githubusercontent.com/2067774/82126298-d8103800-9779-11ea-8f0b-57c632c684d6.png">
  • Loading branch information
davidbarsky authored Jul 7, 2020
1 parent 77c3b5b commit 9832aef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -58,7 +58,7 @@ url = "1.0"
[features]
default = [
"runtime",
"stream",
"stream"
]
runtime = [
"tcp",
Expand Down
12 changes: 5 additions & 7 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9832aef

Please sign in to comment.