Skip to content

Commit

Permalink
feat: simplify log file output by removing bunyan layer (#2747)
Browse files Browse the repository at this point in the history
Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia authored Nov 14, 2023
1 parent 3dffc7b commit 5b97826
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
19 changes: 0 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/common/telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 2 additions & 5 deletions src/common/telemetry/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -140,16 +139,15 @@ 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.
let err_rolling_appender =
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:
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 5b97826

Please sign in to comment.