mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-28 00:00:20 +02:00
Replace set_var usage in examples (#829)
* examples: Fix inconsistent toml formatting * examples: Replace set_var usage
This commit is contained in:
@@ -18,18 +18,18 @@ use axum::{
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
use std::{net::SocketAddr, sync::Arc};
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// Set the RUST_LOG, if it hasn't been explicitly defined
|
||||
if std::env::var_os("RUST_LOG").is_none() {
|
||||
std::env::set_var(
|
||||
"RUST_LOG",
|
||||
"example_error_handling_and_dependency_injection=debug",
|
||||
)
|
||||
}
|
||||
tracing_subscriber::fmt::init();
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::EnvFilter::new(
|
||||
std::env::var("RUST_LOG")
|
||||
.unwrap_or_else(|_| "example_error_handling_and_dependency_injection=debug".into()),
|
||||
))
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
.init();
|
||||
|
||||
// Inject a `UserRepo` into our handlers via a trait object. This could be
|
||||
// the live implementation or just a mock for testing.
|
||||
|
||||
Reference in New Issue
Block a user