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:
Spencer Gilbert 2021-08-05 05:25:03 -04:00 committed by GitHub
parent a8eb26b672
commit 3cd0c0fd45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 120 additions and 18 deletions

View file

@ -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))

View file

@ -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.

View file

@ -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));

View file

@ -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));

View file

@ -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(

View file

@ -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))

View file

@ -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();

View file

@ -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(

View file

@ -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",

View file

@ -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));

View file

@ -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));

View file

@ -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",

View file

@ -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();

View file

@ -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 =

View file

@ -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");

View file

@ -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));

View file

@ -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(