mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-29 15:49:16 +01:00
Simplify tracing-subscriber initialization (#128)
This commit is contained in:
parent
f18e423fb0
commit
68f826ef3b
17 changed files with 17 additions and 51 deletions
|
@ -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))
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue