mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 22:07:58 +00:00
Add logger configuration hook (#10440)
* Initial poc Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Make config available to logger hook Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fmt Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Fix tests Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fmt Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Add metric prefix option in sc_cli::RunCmd Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Remove print Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Review fixes Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fmt Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix docs Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
This commit is contained in:
@@ -193,6 +193,7 @@ where
|
||||
pub struct LoggerBuilder {
|
||||
directives: String,
|
||||
profiling: Option<(crate::TracingReceiver, String)>,
|
||||
custom_profiler: Option<Box<dyn crate::TraceHandler>>,
|
||||
log_reloading: bool,
|
||||
force_colors: Option<bool>,
|
||||
detailed_output: bool,
|
||||
@@ -204,6 +205,7 @@ impl LoggerBuilder {
|
||||
Self {
|
||||
directives: directives.into(),
|
||||
profiling: None,
|
||||
custom_profiler: None,
|
||||
log_reloading: false,
|
||||
force_colors: None,
|
||||
detailed_output: false,
|
||||
@@ -220,6 +222,15 @@ impl LoggerBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
/// Add a custom profiler.
|
||||
pub fn with_custom_profiling(
|
||||
&mut self,
|
||||
custom_profiler: Box<dyn crate::TraceHandler>,
|
||||
) -> &mut Self {
|
||||
self.custom_profiler = Some(custom_profiler);
|
||||
self
|
||||
}
|
||||
|
||||
/// Wether or not to disable log reloading.
|
||||
pub fn with_log_reloading(&mut self, enabled: bool) -> &mut Self {
|
||||
self.log_reloading = enabled;
|
||||
@@ -256,7 +267,12 @@ impl LoggerBuilder {
|
||||
self.detailed_output,
|
||||
|builder| enable_log_reloading!(builder),
|
||||
)?;
|
||||
let profiling = crate::ProfilingLayer::new(tracing_receiver, &profiling_targets);
|
||||
let mut profiling =
|
||||
crate::ProfilingLayer::new(tracing_receiver, &profiling_targets);
|
||||
|
||||
self.custom_profiler
|
||||
.into_iter()
|
||||
.for_each(|profiler| profiling.add_handler(profiler));
|
||||
|
||||
tracing::subscriber::set_global_default(subscriber.with(profiling))?;
|
||||
|
||||
@@ -269,7 +285,12 @@ impl LoggerBuilder {
|
||||
self.detailed_output,
|
||||
|builder| builder,
|
||||
)?;
|
||||
let profiling = crate::ProfilingLayer::new(tracing_receiver, &profiling_targets);
|
||||
let mut profiling =
|
||||
crate::ProfilingLayer::new(tracing_receiver, &profiling_targets);
|
||||
|
||||
self.custom_profiler
|
||||
.into_iter()
|
||||
.for_each(|profiler| profiling.add_handler(profiler));
|
||||
|
||||
tracing::subscriber::set_global_default(subscriber.with(profiling))?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user