feat(server): configure tracing
This commit is contained in:
parent
5428025431
commit
a2faec3473
3 changed files with 75 additions and 3 deletions
|
|
@ -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