Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging(fix): Use the proper log target for logging #4124

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions substrate/client/tracing/src/logging/event_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use ansi_term::Colour;
use regex::Regex;
use std::fmt::{self, Write};
use tracing::{Event, Level, Subscriber};
use tracing_log::NormalizeEvent;
use tracing_subscriber::{
fmt::{format, time::FormatTime, FmtContext, FormatEvent, FormatFields},
registry::LookupSpan,
Expand Down Expand Up @@ -60,10 +61,12 @@ where
N: for<'a> FormatFields<'a> + 'static,
{
let mut writer = &mut ControlCodeSanitizer::new(!self.enable_color, writer);
let normalized_meta = event.normalized_metadata();
let meta = normalized_meta.as_ref().unwrap_or_else(|| event.metadata());
time::write(&self.timer, &mut format::Writer::new(&mut writer), self.enable_color)?;

if self.display_level {
let fmt_level = FmtLevel::new(event.metadata().level(), self.enable_color);
let fmt_level = FmtLevel::new(meta.level(), self.enable_color);
write!(writer, "{} ", fmt_level)?;
}

Expand All @@ -81,7 +84,7 @@ where
}

if self.display_target {
write!(writer, "{}: ", event.metadata().target())?;
write!(writer, "{}: ", meta.target())?;
}

// Custom code to display node name
Expand Down
Loading