From 5b978269cc10c2cf857ae664a321a45445714e0e Mon Sep 17 00:00:00 2001 From: Ruihang Xia Date: Tue, 14 Nov 2023 22:18:34 +0800 Subject: [PATCH] feat: simplify log file output by removing bunyan layer (#2747) Signed-off-by: Ruihang Xia --- Cargo.lock | 19 ------------------- src/common/telemetry/Cargo.toml | 1 - src/common/telemetry/src/logging.rs | 7 ++----- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f06de962603..622a3fafd4cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1936,7 +1936,6 @@ dependencies = [ "tokio", "tracing", "tracing-appender", - "tracing-bunyan-formatter", "tracing-futures", "tracing-log", "tracing-opentelemetry", @@ -9903,24 +9902,6 @@ dependencies = [ "syn 2.0.38", ] -[[package]] -name = "tracing-bunyan-formatter" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5c266b9ac83dedf0e0385ad78514949e6d89491269e7065bee51d2bb8ec7373" -dependencies = [ - "ahash 0.8.6", - "gethostname", - "log", - "serde", - "serde_json", - "time", - "tracing", - "tracing-core", - "tracing-log", - "tracing-subscriber", -] - [[package]] name = "tracing-core" version = "0.1.32" diff --git a/src/common/telemetry/Cargo.toml b/src/common/telemetry/Cargo.toml index 64f6f015bf65..cc5fe5423267 100644 --- a/src/common/telemetry/Cargo.toml +++ b/src/common/telemetry/Cargo.toml @@ -27,7 +27,6 @@ serde.workspace = true tokio.workspace = true tracing = "0.1" tracing-appender = "0.2" -tracing-bunyan-formatter = "0.3" tracing-futures = { version = "0.2", features = ["futures-03"] } tracing-log = "0.1" tracing-opentelemetry = "0.17" diff --git a/src/common/telemetry/src/logging.rs b/src/common/telemetry/src/logging.rs index 2d757ed596a2..8beaf88e0b88 100644 --- a/src/common/telemetry/src/logging.rs +++ b/src/common/telemetry/src/logging.rs @@ -23,7 +23,6 @@ use serde::{Deserialize, Serialize}; pub use tracing::{event, span, Level}; use tracing_appender::non_blocking::WorkerGuard; use tracing_appender::rolling::{RollingFileAppender, Rotation}; -use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer}; use tracing_log::LogTracer; use tracing_subscriber::fmt::Layer; use tracing_subscriber::layer::SubscriberExt; @@ -140,7 +139,7 @@ pub fn init_global_logging( // JSON log layer. let rolling_appender = RollingFileAppender::new(Rotation::HOURLY, dir, app_name); let (rolling_writer, rolling_writer_guard) = tracing_appender::non_blocking(rolling_appender); - let file_logging_layer = BunyanFormattingLayer::new(app_name.to_string(), rolling_writer); + let file_logging_layer = Layer::new().with_writer(rolling_writer); guards.push(rolling_writer_guard); // error JSON log layer. @@ -148,8 +147,7 @@ pub fn init_global_logging( RollingFileAppender::new(Rotation::HOURLY, dir, format!("{}-{}", app_name, "err")); let (err_rolling_writer, err_rolling_writer_guard) = tracing_appender::non_blocking(err_rolling_appender); - let err_file_logging_layer = - BunyanFormattingLayer::new(app_name.to_string(), err_rolling_writer); + let err_file_logging_layer = Layer::new().with_writer(err_rolling_writer); guards.push(err_rolling_writer_guard); // resolve log level settings from: @@ -203,7 +201,6 @@ pub fn init_global_logging( #[cfg(not(feature = "tokio-console"))] let subscriber = Registry::default() .with(filter) - .with(JsonStorageLayer) .with(stdout_logging_layer) .with(file_logging_layer) .with(err_file_logging_layer.with_filter(filter::LevelFilter::ERROR));