Replace set_var usage in examples (#829)

* examples: Fix inconsistent toml formatting

* examples: Replace set_var usage
This commit is contained in:
Jonas Platte
2022-03-06 12:37:00 +01:00
committed by GitHub
parent 9470f5ae1d
commit 79b94b9bd6
55 changed files with 237 additions and 178 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ publish = false
axum = { path = "../../axum", features = ["headers"] }
tokio = { version = "1.0", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version="0.3", features = ["env-filter"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
serde = { version = "1.0", features = ["derive"] }
uuid = { version = "0.8", features = ["v4", "serde"] }
async-session = "3.0.0"
+7 -5
View File
@@ -21,17 +21,19 @@ use axum::{
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
use std::net::SocketAddr;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use uuid::Uuid;
const AXUM_SESSION_COOKIE_NAME: &str = "axum_session";
#[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_sessions=debug")
}
tracing_subscriber::fmt::init();
tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::new(
std::env::var("RUST_LOG").unwrap_or_else(|_| "example_sessions=debug".into()),
))
.with(tracing_subscriber::fmt::layer())
.init();
// `MemoryStore` just used as an example. Don't use this in production.
let store = MemoryStore::new();