feat(server): configure tracing
This commit is contained in:
parent
5428025431
commit
a2faec3473
3 changed files with 75 additions and 3 deletions
|
|
@ -14,5 +14,5 @@ tokio = { version = "1.29.1", features = ["full"] }
|
|||
tokio-util = { version = "0.7.8", features = ["io"] }
|
||||
tower = { version = "0.4.13", features = ["make"] }
|
||||
tower-http = { version = "0.4.1", features = ["fs", "trace"] }
|
||||
tracing-subscriber = "0.3.17"
|
||||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||
uuid = { version = "1.4.0", features = ["v4"] }
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use repo::RepoGroupManager;
|
|||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use tower_http::trace::TraceLayer;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Config {
|
||||
|
|
@ -31,6 +32,13 @@ impl FromRef<Global> for Arc<RwLock<RepoGroupManager>> {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::EnvFilter::new(
|
||||
std::env::var("RUST_LOG").unwrap_or_else(|_| "tower_http=debug".into()),
|
||||
))
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
.init();
|
||||
|
||||
let config = Config {
|
||||
data_dir: "./data".into(),
|
||||
repo_dir: "./data/repos".into(),
|
||||
|
|
@ -43,8 +51,6 @@ async fn main() {
|
|||
repo_manager: Arc::new(RwLock::new(repo_manager)),
|
||||
};
|
||||
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
// build our application with a single route
|
||||
let app = Router::new()
|
||||
.merge(repo::router(&global))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue