Skip to content

Commit

Permalink
chore: remove env_logger from hyper example
Browse files Browse the repository at this point in the history
Currently, the `hyper_echo` example uses the `tracing-log` env logger
support for some weird reason. I believe this is due to Hyper previously
using `log` rather than `tracing`. However, `hyper` now emits native
`tracing` diagnostics, so all the `env_logger` nonsense can just be
removed from the example.

This branch does that.
  • Loading branch information
hawkw committed Oct 12, 2023
1 parent 6cb6c27 commit 84f0a60
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
3 changes: 0 additions & 3 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ serde_json = "1.0.82"
futures = "0.3.21"
tokio = { version = "1.20.0", features = ["full"] }

# env-logger example
env_logger = "0.8.4"

# tower examples
tower = { version = "0.4.13", features = ["full"] }
http = "0.2.8"
Expand Down
13 changes: 2 additions & 11 deletions examples/examples/hyper-echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,9 @@ async fn echo(req: Request<Body>) -> Result<Response<Body>, hyper::Error> {

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
use tracing_log::env_logger::BuilderExt;

let collector = tracing_subscriber::fmt()
tracing_subscriber::fmt()
.with_max_level(Level::TRACE)
.finish();
let mut builder = env_logger::Builder::new();
builder
.filter(Some("hyper_echo"), log::LevelFilter::Off)
.filter(Some("hyper"), log::LevelFilter::Trace)
.emit_traces() // from `tracing_log::env_logger::BuilderExt`
.try_init()?;
tracing::collect::set_global_default(collector)?;
.init();

let local_addr: std::net::SocketAddr = ([127, 0, 0, 1], 3000).into();
let server_span = span!(Level::TRACE, "server", %local_addr);
Expand Down

0 comments on commit 84f0a60

Please sign in to comment.