From 0f525af2ac15c28865b09a5fe831f2df74d37a4c Mon Sep 17 00:00:00 2001 From: ReCore-sys Date: Tue, 17 Sep 2024 07:20:44 +0930 Subject: [PATCH] Should be done --- src/utils/logging/Cargo.toml | 2 ++ src/utils/logging/src/lib.rs | 14 ++++++++++++-- src/utils/profiling/Cargo.toml | 3 +-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/utils/logging/Cargo.toml b/src/utils/logging/Cargo.toml index bfc556b4..6f75963e 100644 --- a/src/utils/logging/Cargo.toml +++ b/src/utils/logging/Cargo.toml @@ -7,3 +7,5 @@ edition = "2021" tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } tokio = "1.40.0" + +profiling = { path = "../profiling" } diff --git a/src/utils/logging/src/lib.rs b/src/utils/logging/src/lib.rs index 754e05d2..f2625e37 100644 --- a/src/utils/logging/src/lib.rs +++ b/src/utils/logging/src/lib.rs @@ -1,10 +1,20 @@ +use profiling::ProfilerTracingLayer; use tracing::Level; +use tracing_subscriber::layer::SubscriberExt; +use tracing_subscriber::util::SubscriberInitExt; static LOG_LEVEL: Level = Level::INFO; -pub async fn init_logging() { +pub fn init_logging() { let env_filter = tracing_subscriber::EnvFilter::from_default_env().add_directive(LOG_LEVEL.into()); - tracing_subscriber::fmt().with_env_filter(env_filter).init(); + let fmt_layer = tracing_subscriber::fmt::Layer::default(); + + let profiler_layer = ProfilerTracingLayer::default(); + tracing_subscriber::registry() + .with(env_filter) + .with(profiler_layer) + .with(fmt_layer) + .init(); } diff --git a/src/utils/profiling/Cargo.toml b/src/utils/profiling/Cargo.toml index 5504c7e1..e35937d9 100644 --- a/src/utils/profiling/Cargo.toml +++ b/src/utils/profiling/Cargo.toml @@ -9,14 +9,13 @@ lazy_static = "1.5.0" hashbrown = "0.14.5" dashmap = "6.1.0" parking_lot = "0.12.3" -tracing-subscriber = "0.3.18" +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } tracing = "0.1.40" tinyvec = "1.8.0" serde = "1.0.210" serde_json = "1.0.128" serde_derive = "1.0.210" -logging = { path = "../logging" } log = "0.4.22" tokio = { version = "1.40.0", features = ["full"] } derive_macros = { path = "../../derive_macros" }