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 02de5ac
Showing 1 changed file with 2 additions and 11 deletions.
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 02de5ac

Please sign in to comment.