tracing-collector: mark default_collector return LookupSpan

Summary:
`LookupSpan` is needed to chain the fmt logger:

  impl<S, N, E, W> Layer<S> for tracing_subscriber::fmt::Layer<S, N, E, W>
  where
      S: Subscriber + for<'a> LookupSpan<'a>,
      N: for<'writer> FormatFields<'writer> + 'static,
      E: FormatEvent<S, N> + 'static,
      W: MakeWriter + 'static,

Reviewed By: sfilipco

Differential Revision: D26518020

fbshipit-source-id: fda996683e2c68cede4778e653845bd23a1fcb1c
This commit is contained in:
Jun Wu 2021-02-19 15:18:03 -08:00 committed by Facebook GitHub Bot
parent 3aba8d89b0
commit 568e0d2258

View File

@ -20,6 +20,7 @@ use tracing::span::{Attributes, Record};
use tracing::subscriber::SetGlobalDefaultError;
use tracing::{Event, Id, Level, Metadata, Subscriber};
use tracing_subscriber::layer::{Context, Layer, SubscriberExt};
use tracing_subscriber::registry::LookupSpan;
use tracing_subscriber::Registry;
pub fn init(data: Arc<Mutex<TracingData>>, level: Level) -> Result<(), SetGlobalDefaultError> {
@ -27,7 +28,10 @@ pub fn init(data: Arc<Mutex<TracingData>>, level: Level) -> Result<(), SetGlobal
tracing::subscriber::set_global_default(collector)
}
pub fn default_collector(data: Arc<Mutex<TracingData>>, level: Level) -> impl Subscriber {
pub fn default_collector(
data: Arc<Mutex<TracingData>>,
level: Level,
) -> impl Subscriber + for<'a> LookupSpan<'a> {
let tracing_data_subscriber = TracingCollector::new(data, level);
Registry::default().with(tracing_data_subscriber)
}