Simplify tracing-subscriber initialization (#128)

This commit is contained in:
Laurențiu Nicola 2021-08-05 20:43:03 +03:00 committed by GitHub
parent f18e423fb0
commit 68f826ef3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 17 additions and 51 deletions

View file

@ -18,9 +18,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "404=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
// build our application with a route
let app = route("/", get(handler))

View file

@ -28,9 +28,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "error_handling_and_dependency_injection=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
// Inject a `UserRepo` into our handlers via a trait object. This could be
// the live implementation or just a mock for testing.

View file

@ -14,9 +14,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "form=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
// build our application with some routes
let app = route("/", get(show_form).post(accept_form));

View file

@ -13,9 +13,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "hello_world=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
// build our application with a route
let app = route("/", get(handler));

View file

@ -35,9 +35,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "key_value_store=debug,tower_http=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
// Build our application by composing routes
let app = route(

View file

@ -16,9 +16,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "multipart_form=debug,tower_http=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
// build our application with some routes
let app = route("/", get(show_form).post(accept_form))

View file

@ -24,9 +24,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "sessions=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
// `MemoryStore` just used as an example. Don't use this in production.
let store = MemoryStore::new();

View file

@ -17,9 +17,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "sse=debug,tower_http=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
// build our application with a route
let app = nest(

View file

@ -15,9 +15,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "static_file_server=debug,tower_http=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
let app = nest(
"/static",

View file

@ -15,9 +15,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "templates=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
// build our application with some routes
let app = route("/greet/:name", get(greet));

View file

@ -13,9 +13,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "testing=debug,tower_http=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 3000));

View file

@ -21,9 +21,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "rustls=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
let rustls_config = rustls_server_config(
"examples/self_signed_certs/key.pem",

View file

@ -38,9 +38,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "todos=debug,tower_http=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
let db = Db::default();

View file

@ -17,9 +17,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "tokio_postgres=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
// setup connection pool
let manager =

View file

@ -40,9 +40,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
let path = PathBuf::from("/tmp/axum/helloworld");

View file

@ -20,9 +20,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "versioning=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
// build our application with some routes
let app = route("/:version/foo", get(handler));

View file

@ -26,9 +26,7 @@ async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "websocket=debug,tower_http=debug")
}
tracing_subscriber::fmt::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing_subscriber::fmt::init();
// build our application with some routes
let app = nest(