Skip to content

Commit 9832aef

Browse files
authored
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`. <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">
1 parent 77c3b5b commit 9832aef

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ http-body = "0.3.1"
2929
httparse = "1.0"
3030
h2 = "0.2.2"
3131
itoa = "0.4.1"
32-
log = "0.4"
32+
tracing = { version = "0.1", default-features = false, features = ["log", "std"] }
3333
pin-project = "0.4.20"
3434
time = "0.1"
3535
tower-service = "0.3"
@@ -58,7 +58,7 @@ url = "1.0"
5858
[features]
5959
default = [
6060
"runtime",
61-
"stream",
61+
"stream"
6262
]
6363
runtime = [
6464
"tcp",

src/client/mod.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -793,13 +793,11 @@ fn absolute_form(uri: &mut Uri) {
793793
}
794794

795795
fn authority_form(uri: &mut Uri) {
796-
if log_enabled!(::log::Level::Warn) {
797-
if let Some(path) = uri.path_and_query() {
798-
// `https://hyper.rs` would parse with `/` path, don't
799-
// annoy people about that...
800-
if path != "/" {
801-
warn!("HTTP/1.1 CONNECT request stripping path: {:?}", path);
802-
}
796+
if let Some(path) = uri.path_and_query() {
797+
// `https://hyper.rs` would parse with `/` path, don't
798+
// annoy people about that...
799+
if path != "/" {
800+
warn!("HTTP/1.1 CONNECT request stripping path: {:?}", path);
803801
}
804802
}
805803
*uri = match uri.authority() {

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#[doc(hidden)]
4444
pub use http;
4545
#[macro_use]
46-
extern crate log;
46+
extern crate tracing;
4747

4848
#[cfg(all(test, feature = "nightly"))]
4949
extern crate test;

0 commit comments

Comments
 (0)