/rust/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-subscriber-0.3.23/src/layer/layered.rs
Line | Count | Source |
1 | | use tracing_core::{metadata::Metadata, span, Dispatch, Event, Interest, LevelFilter, Subscriber}; |
2 | | |
3 | | use crate::{ |
4 | | filter, |
5 | | layer::{Context, Layer}, |
6 | | registry::LookupSpan, |
7 | | }; |
8 | | #[cfg(all(feature = "registry", feature = "std"))] |
9 | | use crate::{filter::FilterId, registry::Registry}; |
10 | | use core::{ |
11 | | any::{Any, TypeId}, |
12 | | cmp, fmt, |
13 | | marker::PhantomData, |
14 | | }; |
15 | | |
16 | | /// A [`Subscriber`] composed of a `Subscriber` wrapped by one or more |
17 | | /// [`Layer`]s. |
18 | | /// |
19 | | /// [`Layer`]: crate::Layer |
20 | | /// [`Subscriber`]: tracing_core::Subscriber |
21 | | #[derive(Clone)] |
22 | | pub struct Layered<L, I, S = I> { |
23 | | /// The layer. |
24 | | layer: L, |
25 | | |
26 | | /// The inner value that `self.layer` was layered onto. |
27 | | /// |
28 | | /// If this is also a `Layer`, then this `Layered` will implement `Layer`. |
29 | | /// If this is a `Subscriber`, then this `Layered` will implement |
30 | | /// `Subscriber` instead. |
31 | | inner: I, |
32 | | |
33 | | // These booleans are used to determine how to combine `Interest`s and max |
34 | | // level hints when per-layer filters are in use. |
35 | | /// Is `self.inner` a `Registry`? |
36 | | /// |
37 | | /// If so, when combining `Interest`s, we want to "bubble up" its |
38 | | /// `Interest`. |
39 | | inner_is_registry: bool, |
40 | | |
41 | | /// Does `self.layer` have per-layer filters? |
42 | | /// |
43 | | /// This will be true if: |
44 | | /// - `self.inner` is a `Filtered`. |
45 | | /// - `self.inner` is a tree of `Layered`s where _all_ arms of those |
46 | | /// `Layered`s have per-layer filters. |
47 | | /// |
48 | | /// Otherwise, if it's a `Layered` with one per-layer filter in one branch, |
49 | | /// but a non-per-layer-filtered layer in the other branch, this will be |
50 | | /// _false_, because the `Layered` is already handling the combining of |
51 | | /// per-layer filter `Interest`s and max level hints with its non-filtered |
52 | | /// `Layer`. |
53 | | has_layer_filter: bool, |
54 | | |
55 | | /// Does `self.inner` have per-layer filters? |
56 | | /// |
57 | | /// This is determined according to the same rules as |
58 | | /// `has_layer_filter` above. |
59 | | inner_has_layer_filter: bool, |
60 | | _s: PhantomData<fn(S)>, |
61 | | } |
62 | | |
63 | | // === impl Layered === |
64 | | |
65 | | impl<L, S> Layered<L, S> |
66 | | where |
67 | | L: Layer<S>, |
68 | | S: Subscriber, |
69 | | { |
70 | | /// Returns `true` if this [`Subscriber`] is the same type as `T`. |
71 | 0 | pub fn is<T: Any>(&self) -> bool { |
72 | 0 | self.downcast_ref::<T>().is_some() |
73 | 0 | } |
74 | | |
75 | | /// Returns some reference to this [`Subscriber`] value if it is of type `T`, |
76 | | /// or `None` if it isn't. |
77 | 0 | pub fn downcast_ref<T: Any>(&self) -> Option<&T> { |
78 | | unsafe { |
79 | 0 | let raw = self.downcast_raw(TypeId::of::<T>())?; |
80 | 0 | if raw.is_null() { |
81 | 0 | None |
82 | | } else { |
83 | 0 | Some(&*(raw as *const T)) |
84 | | } |
85 | | } |
86 | 0 | } |
87 | | } |
88 | | |
89 | | impl<L, S> Subscriber for Layered<L, S> |
90 | | where |
91 | | L: Layer<S>, |
92 | | S: Subscriber, |
93 | | { |
94 | 0 | fn on_register_dispatch(&self, subscriber: &Dispatch) { |
95 | 0 | self.inner.on_register_dispatch(subscriber); |
96 | 0 | self.layer.on_register_dispatch(subscriber); |
97 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::on_register_dispatch Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::on_register_dispatch Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::on_register_dispatch |
98 | | |
99 | 0 | fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest { |
100 | 0 | self.pick_interest(self.layer.register_callsite(metadata), || { |
101 | 0 | self.inner.register_callsite(metadata) |
102 | 0 | }) Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::register_callsite::{closure#0}Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::register_callsite::{closure#0}Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::register_callsite::{closure#0}Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::register_callsite::{closure#0} |
103 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::register_callsite Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::register_callsite Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::register_callsite Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::register_callsite |
104 | | |
105 | 0 | fn enabled(&self, metadata: &Metadata<'_>) -> bool { |
106 | 0 | if self.layer.enabled(metadata, self.ctx()) { |
107 | | // if the outer layer enables the callsite metadata, ask the subscriber. |
108 | 0 | self.inner.enabled(metadata) |
109 | | } else { |
110 | | // otherwise, the callsite is disabled by the layer |
111 | | |
112 | | // If per-layer filters are in use, and we are short-circuiting |
113 | | // (rather than calling into the inner type), clear the current |
114 | | // per-layer filter `enabled` state. |
115 | | #[cfg(feature = "registry")] |
116 | 0 | filter::FilterState::clear_enabled(); |
117 | | |
118 | 0 | false |
119 | | } |
120 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::enabled Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::enabled Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::enabled Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::enabled |
121 | | |
122 | 0 | fn max_level_hint(&self) -> Option<LevelFilter> { |
123 | 0 | self.pick_level_hint( |
124 | 0 | self.layer.max_level_hint(), |
125 | 0 | self.inner.max_level_hint(), |
126 | 0 | super::subscriber_is_none(&self.inner), |
127 | | ) |
128 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::max_level_hint Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::max_level_hint Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::max_level_hint Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::max_level_hint |
129 | | |
130 | 0 | fn new_span(&self, span: &span::Attributes<'_>) -> span::Id { |
131 | 0 | let id = self.inner.new_span(span); |
132 | 0 | self.layer.on_new_span(span, &id, self.ctx()); |
133 | 0 | id |
134 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::new_span Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::new_span Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::new_span Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::new_span |
135 | | |
136 | 0 | fn record(&self, span: &span::Id, values: &span::Record<'_>) { |
137 | 0 | self.inner.record(span, values); |
138 | 0 | self.layer.on_record(span, values, self.ctx()); |
139 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::record Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::record Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::record Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::record |
140 | | |
141 | 0 | fn record_follows_from(&self, span: &span::Id, follows: &span::Id) { |
142 | 0 | self.inner.record_follows_from(span, follows); |
143 | 0 | self.layer.on_follows_from(span, follows, self.ctx()); |
144 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::record_follows_from Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::record_follows_from Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::record_follows_from Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::record_follows_from |
145 | | |
146 | 0 | fn event_enabled(&self, event: &Event<'_>) -> bool { |
147 | 0 | if self.layer.event_enabled(event, self.ctx()) { |
148 | | // if the outer layer enables the event, ask the inner subscriber. |
149 | 0 | self.inner.event_enabled(event) |
150 | | } else { |
151 | | // otherwise, the event is disabled by this layer |
152 | 0 | false |
153 | | } |
154 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::event_enabled Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::event_enabled Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::event_enabled Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::event_enabled |
155 | | |
156 | 0 | fn event(&self, event: &Event<'_>) { |
157 | 0 | self.inner.event(event); |
158 | 0 | self.layer.on_event(event, self.ctx()); |
159 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::event Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::event Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::event Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::event |
160 | | |
161 | 0 | fn enter(&self, span: &span::Id) { |
162 | 0 | self.inner.enter(span); |
163 | 0 | self.layer.on_enter(span, self.ctx()); |
164 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::enter Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::enter Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::enter Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::enter |
165 | | |
166 | 0 | fn exit(&self, span: &span::Id) { |
167 | 0 | self.inner.exit(span); |
168 | 0 | self.layer.on_exit(span, self.ctx()); |
169 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::exit Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::exit Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::exit Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::exit |
170 | | |
171 | 0 | fn clone_span(&self, old: &span::Id) -> span::Id { |
172 | 0 | let new = self.inner.clone_span(old); |
173 | 0 | if &new != old { |
174 | 0 | self.layer.on_id_change(old, &new, self.ctx()) |
175 | 0 | }; |
176 | 0 | new |
177 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::clone_span Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::clone_span Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::clone_span Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::clone_span |
178 | | |
179 | | #[inline] |
180 | 0 | fn drop_span(&self, id: span::Id) { |
181 | 0 | self.try_close(id); |
182 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::drop_span Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::drop_span Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::drop_span |
183 | | |
184 | 0 | fn try_close(&self, id: span::Id) -> bool { |
185 | | #[cfg(all(feature = "registry", feature = "std"))] |
186 | 0 | let subscriber = &self.inner as &dyn Subscriber; |
187 | | #[cfg(all(feature = "registry", feature = "std"))] |
188 | 0 | let mut guard = subscriber |
189 | 0 | .downcast_ref::<Registry>() |
190 | 0 | .map(|registry| registry.start_close(id.clone())); Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::try_close::{closure#0}Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::try_close::{closure#0}Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::try_close::{closure#0}Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::try_close::{closure#0} |
191 | 0 | if self.inner.try_close(id.clone()) { |
192 | | // If we have a registry's close guard, indicate that the span is |
193 | | // closing. |
194 | | #[cfg(all(feature = "registry", feature = "std"))] |
195 | | { |
196 | 0 | if let Some(g) = guard.as_mut() { |
197 | 0 | g.set_closing() |
198 | 0 | }; |
199 | | } |
200 | | |
201 | 0 | self.layer.on_close(id, self.ctx()); |
202 | 0 | true |
203 | | } else { |
204 | 0 | false |
205 | | } |
206 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::try_close Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::try_close Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::try_close Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::try_close |
207 | | |
208 | | #[inline] |
209 | 0 | fn current_span(&self) -> span::Current { |
210 | 0 | self.inner.current_span() |
211 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::current_span Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::current_span Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::current_span Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::current_span |
212 | | |
213 | | #[doc(hidden)] |
214 | 0 | unsafe fn downcast_raw(&self, id: TypeId) -> Option<*const ()> { |
215 | | // Unlike the implementation of `Layer` for `Layered`, we don't have to |
216 | | // handle the "magic PLF downcast marker" here. If a `Layered` |
217 | | // implements `Subscriber`, we already know that the `inner` branch is |
218 | | // going to contain something that doesn't have per-layer filters (the |
219 | | // actual root `Subscriber`). Thus, a `Layered` that implements |
220 | | // `Subscriber` will always be propagating the root subscriber's |
221 | | // `Interest`/level hint, even if it includes a `Layer` that has |
222 | | // per-layer filters, because it will only ever contain layers where |
223 | | // _one_ child has per-layer filters. |
224 | | // |
225 | | // The complex per-layer filter detection logic is only relevant to |
226 | | // *trees* of layers, which involve the `Layer` implementation for |
227 | | // `Layered`, not *lists* of layers, where every `Layered` implements |
228 | | // `Subscriber`. Of course, a linked list can be thought of as a |
229 | | // degenerate tree...but luckily, we are able to make a type-level |
230 | | // distinction between individual `Layered`s that are definitely |
231 | | // list-shaped (their inner child implements `Subscriber`), and |
232 | | // `Layered`s that might be tree-shaped (the inner child is also a |
233 | | // `Layer`). |
234 | | |
235 | | // If downcasting to `Self`, return a pointer to `self`. |
236 | 0 | if id == TypeId::of::<Self>() { |
237 | 0 | return Some(self as *const _ as *const ()); |
238 | 0 | } |
239 | | |
240 | 0 | unsafe { self.layer.downcast_raw(id) }.or_else(|| unsafe { self.inner.downcast_raw(id) })Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::downcast_raw::{closure#0}Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::downcast_raw::{closure#0}Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::downcast_raw::{closure#0}Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::downcast_raw::{closure#0} |
241 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::downcast_raw Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::downcast_raw Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::downcast_raw Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::downcast_raw |
242 | | } |
243 | | |
244 | | impl<S, A, B> Layer<S> for Layered<A, B, S> |
245 | | where |
246 | | A: Layer<S>, |
247 | | B: Layer<S>, |
248 | | S: Subscriber, |
249 | | { |
250 | 0 | fn on_register_dispatch(&self, subscriber: &Dispatch) { |
251 | 0 | self.layer.on_register_dispatch(subscriber); |
252 | 0 | self.inner.on_register_dispatch(subscriber); |
253 | 0 | } |
254 | | |
255 | 0 | fn on_layer(&mut self, subscriber: &mut S) { |
256 | 0 | self.layer.on_layer(subscriber); |
257 | 0 | self.inner.on_layer(subscriber); |
258 | 0 | } |
259 | | |
260 | 0 | fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest { |
261 | 0 | self.pick_interest(self.layer.register_callsite(metadata), || { |
262 | 0 | self.inner.register_callsite(metadata) |
263 | 0 | }) |
264 | 0 | } |
265 | | |
266 | 0 | fn enabled(&self, metadata: &Metadata<'_>, ctx: Context<'_, S>) -> bool { |
267 | 0 | if self.layer.enabled(metadata, ctx.clone()) { |
268 | | // if the outer subscriber enables the callsite metadata, ask the inner layer. |
269 | 0 | self.inner.enabled(metadata, ctx) |
270 | | } else { |
271 | | // otherwise, the callsite is disabled by this layer |
272 | 0 | false |
273 | | } |
274 | 0 | } |
275 | | |
276 | 0 | fn max_level_hint(&self) -> Option<LevelFilter> { |
277 | 0 | self.pick_level_hint( |
278 | 0 | self.layer.max_level_hint(), |
279 | 0 | self.inner.max_level_hint(), |
280 | 0 | super::layer_is_none(&self.inner), |
281 | | ) |
282 | 0 | } |
283 | | |
284 | | #[inline] |
285 | 0 | fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) { |
286 | 0 | self.inner.on_new_span(attrs, id, ctx.clone()); |
287 | 0 | self.layer.on_new_span(attrs, id, ctx); |
288 | 0 | } |
289 | | |
290 | | #[inline] |
291 | 0 | fn on_record(&self, span: &span::Id, values: &span::Record<'_>, ctx: Context<'_, S>) { |
292 | 0 | self.inner.on_record(span, values, ctx.clone()); |
293 | 0 | self.layer.on_record(span, values, ctx); |
294 | 0 | } |
295 | | |
296 | | #[inline] |
297 | 0 | fn on_follows_from(&self, span: &span::Id, follows: &span::Id, ctx: Context<'_, S>) { |
298 | 0 | self.inner.on_follows_from(span, follows, ctx.clone()); |
299 | 0 | self.layer.on_follows_from(span, follows, ctx); |
300 | 0 | } |
301 | | |
302 | | #[inline] |
303 | 0 | fn event_enabled(&self, event: &Event<'_>, ctx: Context<'_, S>) -> bool { |
304 | 0 | if self.layer.event_enabled(event, ctx.clone()) { |
305 | | // if the outer layer enables the event, ask the inner subscriber. |
306 | 0 | self.inner.event_enabled(event, ctx) |
307 | | } else { |
308 | | // otherwise, the event is disabled by this layer |
309 | 0 | false |
310 | | } |
311 | 0 | } |
312 | | |
313 | | #[inline] |
314 | 0 | fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>) { |
315 | 0 | self.inner.on_event(event, ctx.clone()); |
316 | 0 | self.layer.on_event(event, ctx); |
317 | 0 | } |
318 | | |
319 | | #[inline] |
320 | 0 | fn on_enter(&self, id: &span::Id, ctx: Context<'_, S>) { |
321 | 0 | self.inner.on_enter(id, ctx.clone()); |
322 | 0 | self.layer.on_enter(id, ctx); |
323 | 0 | } |
324 | | |
325 | | #[inline] |
326 | 0 | fn on_exit(&self, id: &span::Id, ctx: Context<'_, S>) { |
327 | 0 | self.inner.on_exit(id, ctx.clone()); |
328 | 0 | self.layer.on_exit(id, ctx); |
329 | 0 | } |
330 | | |
331 | | #[inline] |
332 | 0 | fn on_close(&self, id: span::Id, ctx: Context<'_, S>) { |
333 | 0 | self.inner.on_close(id.clone(), ctx.clone()); |
334 | 0 | self.layer.on_close(id, ctx); |
335 | 0 | } |
336 | | |
337 | | #[inline] |
338 | 0 | fn on_id_change(&self, old: &span::Id, new: &span::Id, ctx: Context<'_, S>) { |
339 | 0 | self.inner.on_id_change(old, new, ctx.clone()); |
340 | 0 | self.layer.on_id_change(old, new, ctx); |
341 | 0 | } |
342 | | |
343 | | #[doc(hidden)] |
344 | 0 | unsafe fn downcast_raw(&self, id: TypeId) -> Option<*const ()> { |
345 | 0 | match id { |
346 | | // If downcasting to `Self`, return a pointer to `self`. |
347 | 0 | id if id == TypeId::of::<Self>() => Some(self as *const _ as *const ()), |
348 | | |
349 | | // Oh, we're looking for per-layer filters! |
350 | | // |
351 | | // This should only happen if we are inside of another `Layered`, |
352 | | // and it's trying to determine how it should combine `Interest`s |
353 | | // and max level hints. |
354 | | // |
355 | | // In that case, this `Layered` should be considered to be |
356 | | // "per-layer filtered" if *both* the outer layer and the inner |
357 | | // layer/subscriber have per-layer filters. Otherwise, this `Layered |
358 | | // should *not* be considered per-layer filtered (even if one or the |
359 | | // other has per layer filters). If only one `Layer` is per-layer |
360 | | // filtered, *this* `Layered` will handle aggregating the `Interest` |
361 | | // and level hints on behalf of its children, returning the |
362 | | // aggregate (which is the value from the &non-per-layer-filtered* |
363 | | // child). |
364 | | // |
365 | | // Yes, this rule *is* slightly counter-intuitive, but it's |
366 | | // necessary due to a weird edge case that can occur when two |
367 | | // `Layered`s where one side is per-layer filtered and the other |
368 | | // isn't are `Layered` together to form a tree. If we didn't have |
369 | | // this rule, we would actually end up *ignoring* `Interest`s from |
370 | | // the non-per-layer-filtered layers, since both branches would |
371 | | // claim to have PLF. |
372 | | // |
373 | | // If you don't understand this...that's fine, just don't mess with |
374 | | // it. :) |
375 | 0 | id if filter::is_plf_downcast_marker(id) => { |
376 | 0 | unsafe { self.layer.downcast_raw(id) }.and(unsafe { self.inner.downcast_raw(id) }) |
377 | | } |
378 | | |
379 | | // Otherwise, try to downcast both branches normally... |
380 | 0 | _ => unsafe { self.layer.downcast_raw(id) } |
381 | 0 | .or_else(|| unsafe { self.inner.downcast_raw(id) }), |
382 | | } |
383 | 0 | } |
384 | | } |
385 | | |
386 | | impl<'a, L, S> LookupSpan<'a> for Layered<L, S> |
387 | | where |
388 | | S: Subscriber + LookupSpan<'a>, |
389 | | { |
390 | | type Data = S::Data; |
391 | | |
392 | 0 | fn span_data(&'a self, id: &span::Id) -> Option<Self::Data> { |
393 | 0 | self.inner.span_data(id) |
394 | 0 | } |
395 | | |
396 | | #[cfg(all(feature = "registry", feature = "std"))] |
397 | 0 | fn register_filter(&mut self) -> FilterId { |
398 | 0 | self.inner.register_filter() |
399 | 0 | } |
400 | | } |
401 | | |
402 | | impl<L, S> Layered<L, S> |
403 | | where |
404 | | S: Subscriber, |
405 | | { |
406 | 0 | fn ctx(&self) -> Context<'_, S> { |
407 | 0 | Context::new(&self.inner) |
408 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry>>::ctx Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>>::ctx Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>>>::ctx Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber>>::ctx |
409 | | } |
410 | | |
411 | | impl<A, B, S> Layered<A, B, S> |
412 | | where |
413 | | A: Layer<S>, |
414 | | S: Subscriber, |
415 | | { |
416 | 0 | pub(super) fn new(layer: A, inner: B, inner_has_layer_filter: bool) -> Self { |
417 | | #[cfg(all(feature = "registry", feature = "std"))] |
418 | 0 | let inner_is_registry = TypeId::of::<S>() == TypeId::of::<crate::registry::Registry>(); |
419 | | |
420 | | #[cfg(not(all(feature = "registry", feature = "std")))] |
421 | | let inner_is_registry = false; |
422 | | |
423 | 0 | let inner_has_layer_filter = inner_has_layer_filter || inner_is_registry; |
424 | 0 | let has_layer_filter = filter::layer_has_plf(&layer); |
425 | 0 | Self { |
426 | 0 | layer, |
427 | 0 | inner, |
428 | 0 | has_layer_filter, |
429 | 0 | inner_has_layer_filter, |
430 | 0 | inner_is_registry, |
431 | 0 | _s: PhantomData, |
432 | 0 | } |
433 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry>>::new Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>>::new Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>>>::new Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber>>::new |
434 | | |
435 | 0 | fn pick_interest(&self, outer: Interest, inner: impl FnOnce() -> Interest) -> Interest { |
436 | 0 | if self.has_layer_filter { |
437 | 0 | return inner(); |
438 | 0 | } |
439 | | |
440 | | // If the outer layer has disabled the callsite, return now so that |
441 | | // the inner layer/subscriber doesn't get its hopes up. |
442 | 0 | if outer.is_never() { |
443 | | // If per-layer filters are in use, and we are short-circuiting |
444 | | // (rather than calling into the inner type), clear the current |
445 | | // per-layer filter interest state. |
446 | | #[cfg(feature = "registry")] |
447 | 0 | filter::FilterState::take_interest(); |
448 | | |
449 | 0 | return outer; |
450 | 0 | } |
451 | | |
452 | | // The `inner` closure will call `inner.register_callsite()`. We do this |
453 | | // before the `if` statement to ensure that the inner subscriber is |
454 | | // informed that the callsite exists regardless of the outer layer's |
455 | | // filtering decision. |
456 | 0 | let inner = inner(); |
457 | 0 | if outer.is_sometimes() { |
458 | | // if this interest is "sometimes", return "sometimes" to ensure that |
459 | | // filters are reevaluated. |
460 | 0 | return outer; |
461 | 0 | } |
462 | | |
463 | | // If there is a per-layer filter in the `inner` stack, and it returns |
464 | | // `never`, change the interest to `sometimes`, because the `outer` |
465 | | // layer didn't return `never`. This means that _some_ layer still wants |
466 | | // to see that callsite, even though the inner stack's per-layer filter |
467 | | // didn't want it. Therefore, returning `sometimes` will ensure |
468 | | // `enabled` is called so that the per-layer filter can skip that |
469 | | // span/event, while the `outer` layer still gets to see it. |
470 | 0 | if inner.is_never() && self.inner_has_layer_filter { |
471 | 0 | return Interest::sometimes(); |
472 | 0 | } |
473 | | |
474 | | // otherwise, allow the inner subscriber or subscriber to weigh in. |
475 | 0 | inner |
476 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry>>::pick_interest::<<tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::register_callsite::{closure#0}>Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>>::pick_interest::<<tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry> as tracing_core::subscriber::Subscriber>::register_callsite::{closure#0}>Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>>>::pick_interest::<<tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>> as tracing_core::subscriber::Subscriber>::register_callsite::{closure#0}>Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber>>::pick_interest::<<tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber> as tracing_core::subscriber::Subscriber>::register_callsite::{closure#0}> |
477 | | |
478 | 0 | fn pick_level_hint( |
479 | 0 | &self, |
480 | 0 | outer_hint: Option<LevelFilter>, |
481 | 0 | inner_hint: Option<LevelFilter>, |
482 | 0 | inner_is_none: bool, |
483 | 0 | ) -> Option<LevelFilter> { |
484 | 0 | if self.inner_is_registry { |
485 | 0 | return outer_hint; |
486 | 0 | } |
487 | | |
488 | 0 | if self.has_layer_filter && self.inner_has_layer_filter { |
489 | 0 | return Some(cmp::max(outer_hint?, inner_hint?)); |
490 | 0 | } |
491 | | |
492 | 0 | if self.has_layer_filter && inner_hint.is_none() { |
493 | 0 | return None; |
494 | 0 | } |
495 | | |
496 | 0 | if self.inner_has_layer_filter && outer_hint.is_none() { |
497 | 0 | return None; |
498 | 0 | } |
499 | | |
500 | | // If the layer is `Option::None`, then we |
501 | | // want to short-circuit the layer underneath, if it |
502 | | // returns `None`, to override the `None` layer returning |
503 | | // `Some(OFF)`, which should ONLY apply when there are |
504 | | // no other layers that return `None`. Note this |
505 | | // `None` does not == `Some(TRACE)`, it means |
506 | | // something more like: "whatever all the other |
507 | | // layers agree on, default to `TRACE` if none |
508 | | // have an opinion". We also choose do this AFTER |
509 | | // we check for per-layer filters, which |
510 | | // have their own logic. |
511 | | // |
512 | | // Also note that this does come at some perf cost, but |
513 | | // this function is only called on initialization and |
514 | | // subscriber reloading. |
515 | 0 | if super::layer_is_none(&self.layer) { |
516 | 0 | return cmp::max(outer_hint, Some(inner_hint?)); |
517 | 0 | } |
518 | | |
519 | | // Similarly, if the layer on the inside is `None` and it returned an |
520 | | // `Off` hint, we want to override that with the outer hint. |
521 | 0 | if inner_is_none && inner_hint == Some(LevelFilter::OFF) { |
522 | 0 | return outer_hint; |
523 | 0 | } |
524 | | |
525 | 0 | cmp::max(outer_hint, inner_hint) |
526 | 0 | } Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_tree::HierarchicalLayer<tracing_subscriber::fmt::writer::TestWriter>, tracing_subscriber::registry::sharded::Registry>>::pick_level_hint Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>>::pick_level_hint Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_core::metadata::LevelFilter, tracing_subscriber::layer::layered::Layered<tracing_subscriber::fmt::fmt_layer::Layer<tracing_subscriber::registry::sharded::Registry>, tracing_subscriber::registry::sharded::Registry>>>::pick_level_hint Unexecuted instantiation: <tracing_subscriber::layer::layered::Layered<tracing_subscriber::filter::targets::Targets, tracing_subscriber::fmt::Subscriber>>::pick_level_hint |
527 | | } |
528 | | |
529 | | impl<A, B, S> fmt::Debug for Layered<A, B, S> |
530 | | where |
531 | | A: fmt::Debug, |
532 | | B: fmt::Debug, |
533 | | { |
534 | 0 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
535 | | #[cfg(all(feature = "registry", feature = "std"))] |
536 | 0 | let alt = f.alternate(); |
537 | 0 | let mut s = f.debug_struct("Layered"); |
538 | | // These additional fields are more verbose and usually only necessary |
539 | | // for internal debugging purposes, so only print them if alternate mode |
540 | | // is enabled. |
541 | | |
542 | | #[cfg(all(feature = "registry", feature = "std"))] |
543 | | { |
544 | 0 | if alt { |
545 | 0 | s.field("inner_is_registry", &self.inner_is_registry) |
546 | 0 | .field("has_layer_filter", &self.has_layer_filter) |
547 | 0 | .field("inner_has_layer_filter", &self.inner_has_layer_filter); |
548 | 0 | } |
549 | | } |
550 | | |
551 | 0 | s.field("layer", &self.layer) |
552 | 0 | .field("inner", &self.inner) |
553 | 0 | .finish() |
554 | 0 | } |
555 | | } |