add backreference to layer in capture data struct
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
db288b169e
commit
d9054f5364
2 changed files with 8 additions and 5 deletions
|
@ -1,9 +1,10 @@
|
||||||
use tracing::Level;
|
use tracing::Level;
|
||||||
use tracing_core::{span::Current, Event};
|
use tracing_core::{span::Current, Event};
|
||||||
|
|
||||||
use super::layer::Value;
|
use super::{layer::Value, Layer};
|
||||||
|
|
||||||
pub struct Data<'a> {
|
pub struct Data<'a> {
|
||||||
|
pub layer: &'a Layer,
|
||||||
pub event: &'a Event<'a>,
|
pub event: &'a Event<'a>,
|
||||||
pub current: &'a Current,
|
pub current: &'a Current,
|
||||||
pub values: Option<&'a mut [Value]>,
|
pub values: Option<&'a mut [Value]>,
|
||||||
|
|
|
@ -40,12 +40,12 @@ where
|
||||||
.read()
|
.read()
|
||||||
.expect("shared lock")
|
.expect("shared lock")
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|capture| filter(capture, event, &ctx))
|
.filter(|capture| filter(self, capture, event, &ctx))
|
||||||
.for_each(|capture| handle(capture, event, &ctx));
|
.for_each(|capture| handle(self, capture, event, &ctx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle<S>(capture: &Capture, event: &Event<'_>, ctx: &Context<'_, S>)
|
fn handle<S>(layer: &Layer, capture: &Capture, event: &Event<'_>, ctx: &Context<'_, S>)
|
||||||
where
|
where
|
||||||
S: Subscriber + for<'a> LookupSpan<'a>,
|
S: Subscriber + for<'a> LookupSpan<'a>,
|
||||||
{
|
{
|
||||||
|
@ -56,18 +56,20 @@ where
|
||||||
|
|
||||||
let mut closure = capture.closure.lock().expect("exclusive lock");
|
let mut closure = capture.closure.lock().expect("exclusive lock");
|
||||||
closure(Data {
|
closure(Data {
|
||||||
|
layer,
|
||||||
event,
|
event,
|
||||||
current: &ctx.current_span(),
|
current: &ctx.current_span(),
|
||||||
values: Some(&mut visitor.values),
|
values: Some(&mut visitor.values),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn filter<S>(capture: &Capture, event: &Event<'_>, ctx: &Context<'_, S>) -> bool
|
fn filter<S>(layer: &Layer, capture: &Capture, event: &Event<'_>, ctx: &Context<'_, S>) -> bool
|
||||||
where
|
where
|
||||||
S: Subscriber + for<'a> LookupSpan<'a>,
|
S: Subscriber + for<'a> LookupSpan<'a>,
|
||||||
{
|
{
|
||||||
capture.filter.as_ref().map_or(true, |filter| {
|
capture.filter.as_ref().map_or(true, |filter| {
|
||||||
filter(Data {
|
filter(Data {
|
||||||
|
layer,
|
||||||
event,
|
event,
|
||||||
current: &ctx.current_span(),
|
current: &ctx.current_span(),
|
||||||
values: None,
|
values: None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue