mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +00:00
Speed up timestamp generation when logging (#9933)
* Speed up timestamp generation when logging * Align to review comments. * Correct a typo
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
mod directives;
|
||||
mod event_format;
|
||||
mod fast_local_time;
|
||||
mod layers;
|
||||
|
||||
pub use directives::*;
|
||||
@@ -34,8 +35,8 @@ use tracing::Subscriber;
|
||||
use tracing_subscriber::{
|
||||
filter::LevelFilter,
|
||||
fmt::{
|
||||
format, time::ChronoLocal, FormatEvent, FormatFields, Formatter, Layer as FmtLayer,
|
||||
MakeWriter, SubscriberBuilder,
|
||||
format, FormatEvent, FormatFields, Formatter, Layer as FmtLayer, MakeWriter,
|
||||
SubscriberBuilder,
|
||||
},
|
||||
layer::{self, SubscriberExt},
|
||||
registry::LookupSpan,
|
||||
@@ -43,6 +44,7 @@ use tracing_subscriber::{
|
||||
};
|
||||
|
||||
pub use event_format::*;
|
||||
pub use fast_local_time::FastLocalTime;
|
||||
pub use layers::*;
|
||||
|
||||
/// Logging Result typedef.
|
||||
@@ -89,12 +91,7 @@ fn prepare_subscriber<N, E, F, W>(
|
||||
profiling_targets: Option<&str>,
|
||||
force_colors: Option<bool>,
|
||||
builder_hook: impl Fn(
|
||||
SubscriberBuilder<
|
||||
format::DefaultFields,
|
||||
EventFormat<ChronoLocal>,
|
||||
EnvFilter,
|
||||
fn() -> std::io::Stderr,
|
||||
>,
|
||||
SubscriberBuilder<format::DefaultFields, EventFormat, EnvFilter, fn() -> std::io::Stderr>,
|
||||
) -> SubscriberBuilder<N, E, F, W>,
|
||||
) -> Result<impl Subscriber + for<'a> LookupSpan<'a>>
|
||||
where
|
||||
@@ -161,11 +158,7 @@ where
|
||||
};
|
||||
|
||||
let enable_color = force_colors.unwrap_or_else(|| atty::is(atty::Stream::Stderr));
|
||||
let timer = ChronoLocal::with_format(if simple {
|
||||
"%Y-%m-%d %H:%M:%S".to_string()
|
||||
} else {
|
||||
"%Y-%m-%d %H:%M:%S%.3f".to_string()
|
||||
});
|
||||
let timer = fast_local_time::FastLocalTime { with_fractional: !simple };
|
||||
|
||||
let event_format = EventFormat {
|
||||
timer,
|
||||
|
||||
Reference in New Issue
Block a user