mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-28 23:38:20 +01:00
Set RUST_LOG environment var for all examples using tracing (#123)
* Set RUST_LOG environment var for all examples using tracing Signed-off-by: Spencer Gilbert <spencer.gilbert@gmail.com> * Update examples/multipart_form.rs Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
This commit is contained in:
parent
a8eb26b672
commit
3cd0c0fd45
17 changed files with 120 additions and 18 deletions
|
@ -14,7 +14,13 @@ use tower::util::MapResponseLayer;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
// build our application with a route
|
||||
let app = route("/", get(handler))
|
||||
|
|
|
@ -24,7 +24,13 @@ use uuid::Uuid;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
// Inject a `UserRepo` into our handlers via a trait object. This could be
|
||||
// the live implementation or just a mock for testing.
|
||||
|
|
|
@ -10,7 +10,13 @@ use std::net::SocketAddr;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
// build our application with some routes
|
||||
let app = route("/", get(show_form).post(accept_form));
|
||||
|
|
|
@ -9,7 +9,13 @@ use std::net::SocketAddr;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
// build our application with a route
|
||||
let app = route("/", get(handler));
|
||||
|
|
|
@ -31,7 +31,13 @@ use tower_http::{
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
// Build our application by composing routes
|
||||
let app = route(
|
||||
|
|
|
@ -12,7 +12,13 @@ use std::net::SocketAddr;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
// build our application with some routes
|
||||
let app = route("/", get(show_form).post(accept_form))
|
||||
|
|
|
@ -20,7 +20,13 @@ use uuid::Uuid;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
// `MemoryStore` just used as an example. Don't use this in production.
|
||||
let store = MemoryStore::new();
|
||||
|
|
|
@ -13,7 +13,13 @@ use tower_http::{services::ServeDir, trace::TraceLayer};
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
// build our application with a route
|
||||
let app = nest(
|
||||
|
|
|
@ -11,7 +11,13 @@ use tower_http::{services::ServeDir, trace::TraceLayer};
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
let app = nest(
|
||||
"/static",
|
||||
|
|
|
@ -11,7 +11,13 @@ use std::net::SocketAddr;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
// build our application with some routes
|
||||
let app = route("/greet/:name", get(greet));
|
||||
|
|
|
@ -9,7 +9,13 @@ use tower_http::trace::TraceLayer;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 3000));
|
||||
|
||||
|
|
|
@ -17,7 +17,13 @@ use tokio_rustls::{
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
let rustls_config = rustls_server_config(
|
||||
"examples/self_signed_certs/key.pem",
|
||||
|
|
|
@ -34,7 +34,13 @@ use uuid::Uuid;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
let db = Db::default();
|
||||
|
||||
|
|
|
@ -13,7 +13,13 @@ use tokio_postgres::NoTls;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
// setup connection pool
|
||||
let manager =
|
||||
|
|
|
@ -36,7 +36,13 @@ fn main() {
|
|||
#[cfg(unix)]
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
let path = PathBuf::from("/tmp/axum/helloworld");
|
||||
|
||||
|
|
|
@ -16,7 +16,13 @@ use std::net::SocketAddr;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
// build our application with some routes
|
||||
let app = route("/:version/foo", get(handler));
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//! Run with
|
||||
//!
|
||||
//! ```not_rust
|
||||
//! RUST_LOG=tower_http=debug,key_value_store=trace cargo run --features=ws,headers --example websocket
|
||||
//! cargo run --features=ws,headers --example websocket
|
||||
//! ```
|
||||
|
||||
use axum::{
|
||||
|
@ -22,7 +22,13 @@ use tower_http::{
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
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();
|
||||
|
||||
// build our application with some routes
|
||||
let app = nest(
|
||||
|
|
Loading…
Reference in a new issue