<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="A composable handler for `tracing` events."><title>Layer in tracing_subscriber::layer - Rust</title><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><linkrel="preload"as="font"type="font/woff2"crossoriginhref="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><linkrel="stylesheet"href="../../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet"href="../../static.files/rustdoc-ac92e1bbe349e143.css"><metaname="rustdoc-vars"data-root-path="../../"data-static-root-path="../../static.files/"data-current-crate="tracing_subscriber"data-themes=""data-resource-suffix=""data-rustdoc-version="1.76.0 (07dca489a 2024-02-04)"data-channel="1.76.0"data-search-js="search-2b6ce74ff89ae146.js"data-settings-js="settings-4313503d2e1961c2.js"><scriptsrc="../../static.files/storage-f2adc0d6ca4d09fb.js"></script><scriptdefersrc="sidebar-items.js"></script><scriptdefersrc="../../static.files/main-305769736d49e732.js"></script><noscript><linkrel="stylesheet"href="../../static.files/noscript-feafe1bb7466e4bd.css"></noscript><linkrel="alternate icon"type="image/png"href="../../static.files/favicon-16x16-8b506e7a72182f1c.png"><linkrel="alternate icon"type="image/png"href="../../static.files/favicon-32x32-422f7d1d52889060.png"><linkrel="icon"type="image/svg+xml"href="../../static.files/favicon-2c020d218678b618.svg"></head><bodyclass="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="mobile-topbar"><buttonclass="sidebar-menu-toggle">☰</button><aclass="logo-container"href="../../tracing_subscriber/index.html"><imgsrc="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png"alt=""></a></nav><navclass="sidebar"><divclass="sidebar-crate"><aclass="logo-container"href="../../tracing_subscriber/index.html"><imgsrc="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png"alt="logo"></a><h2><ahref="../../tracing_subscriber/index.html">tracing_subscriber</a><spanclass="version">0.3.18</span></h2></div><h2class="location"><ahref="#">Layer</a></h2><divclass="sidebar-elems"><section><h3><ahref="#provided-methods">Provided Methods</a></h3><ulclass="block"><li><ahref="#method.and_then">and_then</a></li><li><ahref="#method.boxed">boxed</a></li><li><ahref="#method.enabled">enabled</a></li><li><ahref="#method.event_enabled">event_enabled</a></li><li><ahref="#method.on_close">on_close</a></li><li><ahref="#method.on_enter">on_enter</a></li><li><ahref="#method.on_event">on_event</a></li><li><ahref="#method.on_exit">on_exit</a></li><li><ahref="#method.on_follows_from">on_follows_from</a></li><li><ahref="#method.on_id_change">on_id_change</a></li><li><ahref="#method.on_layer">on_layer</a></li><li><ahref="#method.on_new_span">on_new_span</a></li><li><ahref="#method.on_record">on_record</a></li><li><ahref="#method.on_register_dispatch">on_register_dispatch</a></li><li><ahref="#method.register_callsite">register_callsite</a></li><li><ahref="#method.with_filter">with_filter</a></li><li><ahref="#method.with_subscriber">with_subscriber</a></li></ul><h3><ahref="#foreign-impls">Implementations on Foreign Types</a></h3><ulclass="block"><li><ahref="#impl-Layer%3CS%3E-for-Box%3CL%3E">Box<L></a></li><li><ahref="#impl-Layer%3CS%3E-for-Box%3Cdyn+Layer%3C
<main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><divid="sidebar-button"tabindex="-1"><ahref="../../tracing_subscriber/all.html"title="show sidebar"></a></div><inputclass="search-input"name="search"aria-label="Run search in the documentation"autocomplete="off"spellcheck="false"placeholder="Click or press ‘S’ to search, ‘?’ for more options…"type="search"><divid="help-button"tabindex="-1"><ahref="../../help.html"title="help">?</a></div><divid="settings-menu"tabindex="-1"><ahref="../../settings.html"title="settings"><imgwidth="22"height="22"alt="Change settings"src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><sectionid="main-content"class="content"><divclass="main-heading"><h1>Trait <ahref="../index.html">tracing_subscriber</a>::<wbr><ahref="index.html">layer</a>::<wbr><aclass="trait"href="#">Layer</a><buttonid="copy-path"title="Copy item path to clipboard"><imgsrc="../../static.files/clipboard-7571035ce49a181d.svg"width="19"height="18"alt="Copy item path"></button></h1><spanclass="out-of-band"><aclass="src"href="../../src/tracing_subscriber/layer/mod.rs.html#727-1251">source</a> · <buttonid="toggle-all-docs"title="collapse all docs">[<span>−</span>]</button></span></div><preclass="rust item-decl"><code>pub trait Layer<S><divclass="where">where
</details>}</code></pre><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>A composable handler for <code>tracing</code> events.</p>
<p>A <code>Layer</code> implements a behavior for recording or collecting traces that can
be composed together with other <code>Layer</code>s to build a <ahref="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a>. See the
<ahref="index.html"title="mod tracing_subscriber::layer">module-level documentation</a> for details.</p>
</div></details><h2id="provided-methods"class="section-header">Provided Methods<ahref="#provided-methods"class="anchor">§</a></h2><divclass="methods"><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_register_dispatch"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#753-755">source</a><h4class="code-header">fn <ahref="#method.on_register_dispatch"class="fn">on_register_dispatch</a>(&self, subscriber: &<aclass="struct"href="../../tracing_core/dispatcher/struct.Dispatch.html"title="struct tracing_core::dispatcher::Dispatch">Dispatch</a>)</h4></section></summary><divclass="docblock"><p>Performs late initialization when installing this layer as a
<p><code>Layer</code>s should not store the <ahref="../../tracing_core/dispatcher/struct.Dispatch.html"title="struct tracing_core::dispatcher::Dispatch"><code>Dispatch</code></a> pointing to the <ahref="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a>
that they are a part of. Because the <code>Dispatch</code> owns the <code>Subscriber</code>,
storing the <code>Dispatch</code> within the <code>Subscriber</code> will create a reference
count cycle, preventing the <code>Dispatch</code> from ever being dropped.</p>
<p>Instead, when it is necessary to store a cyclical reference to the
<code>Dispatch</code> within a <code>Layer</code>, use <ahref="../../tracing_core/dispatcher/struct.Dispatch.html#method.downgrade"title="method tracing_core::dispatcher::Dispatch::downgrade"><code>Dispatch::downgrade</code></a> to convert a
<code>Dispatch</code> into a <ahref="../../tracing_core/dispatcher/struct.WeakDispatch.html"title="struct tracing_core::dispatcher::WeakDispatch"><code>WeakDispatch</code></a>. This type is analogous to
<ahref="https://doc.rust-lang.org/1.76.0/alloc/sync/struct.Weak.html"title="struct alloc::sync::Weak"><code>std::sync::Weak</code></a>, and does not create a reference count cycle. A
<ahref="../../tracing_core/dispatcher/struct.WeakDispatch.html"title="struct tracing_core::dispatcher::WeakDispatch"><code>WeakDispatch</code></a> can be stored within a subscriber without causing a
memory leak, and can be <ahref="../../tracing_core/dispatcher/struct.WeakDispatch.html#method.upgrade"title="method tracing_core::dispatcher::WeakDispatch::upgrade">upgraded</a> into a <code>Dispatch</code> temporarily when
the <code>Dispatch</code> must be accessed by the subscriber.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_layer"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#784-786">source</a><h4class="code-header">fn <ahref="#method.on_layer"class="fn">on_layer</a>(&mut self, subscriber: <aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&mut S</a>)</h4></section></summary><divclass="docblock"><p>Performs late initialization when attaching a <code>Layer</code> to a
<p>This is a callback that is called when the <code>Layer</code> is added to a
<ahref="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a> (e.g. in <ahref="trait.Layer.html#method.with_subscriber"title="method tracing_subscriber::layer::Layer::with_subscriber"><code>Layer::with_subscriber</code></a> and
<ahref="trait.SubscriberExt.html#method.with"title="method tracing_subscriber::layer::SubscriberExt::with"><code>SubscriberExt::with</code></a>). Since this can only occur before the
<ahref="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a> has been set as the default, both the <code>Layer</code> and
<ahref="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a> are passed to this method <em>mutably</em>. This gives the
<code>Layer</code> the opportunity to set any of its own fields with values
recieved by method calls on the <ahref="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a>.</p>
<p>For example, <ahref="../filter/struct.Filtered.html"title="struct tracing_subscriber::filter::Filtered"><code>Filtered</code></a> layers implement <code>on_layer</code> to call the
<ahref="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a>’s <ahref="../registry/trait.LookupSpan.html#method.register_filter"title="method tracing_subscriber::registry::LookupSpan::register_filter"><code>register_filter</code></a> method, and store the returned
<ahref="../filter/struct.FilterId.html"title="struct tracing_subscriber::filter::FilterId"><code>FilterId</code></a> as a field.</p>
<p><strong>Note</strong> In most cases, <code>Layer</code> implementations will not need to
implement this method. However, in cases where a type implementing
<code>Layer</code> wraps one or more other types that implement <code>Layer</code>, like the
<ahref="struct.Layered.html"title="struct tracing_subscriber::layer::Layered"><code>Layered</code></a> and <ahref="../filter/struct.Filtered.html"title="struct tracing_subscriber::filter::Filtered"><code>Filtered</code></a> types in this crate, that type MUST ensure
that the inner <code>Layer</code>s’<code>on_layer</code> methods are called. Otherwise,
functionality that relies on <code>on_layer</code>, such as <ahref="#per-layer-filtering">per-layer filtering</a>,
may not work correctly.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.register_callsite"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#828-834">source</a><h4class="code-header">fn <ahref="#method.register_callsite"class="fn">register_callsite</a>(&self, metadata: &'static <aclass="struct"href="../../tracing_core/metadata/struct.Metadata.html"title="struct tracing_core::metadata::Metadata">Metadata</a><'static>) -><aclass="struct"href="../../tracing_core/subscriber/struct.Interest.html"title="struct tracing_core::subscriber::Interest">Interest</a></h4></section></summary><divclass="docblock"><p>Registers a new callsite with this layer, returning whether or not
the layer is interested in being notified about the callsite, similarly
to <ahref="../../tracing_core/subscriber/trait.Subscriber.html#method.register_callsite"title="method tracing_core::subscriber::Subscriber::register_callsite"><code>Subscriber::register_callsite</code></a>.</p>
<p>By default, this returns <ahref="../../tracing_core/subscriber/struct.Interest.html#method.always"title="associated function tracing_core::subscriber::Interest::always"><code>Interest::always()</code></a> if <ahref="trait.Layer.html#method.enabled"title="method tracing_subscriber::layer::Layer::enabled"><code>self.enabled</code></a> returns
true, or <ahref="../../tracing_core/subscriber/struct.Interest.html#method.never"title="associated function tracing_core::subscriber::Interest::never"><code>Interest::never()</code></a> if it returns false.</p>
<ahref="#method.on_exit"><code>on_exit</code></a>, and other notification
methods.
</pre>
<p>See <ahref="#filtering-with-layers">the trait-level documentation</a> for more information on filtering
with <code>Layer</code>s.</p>
<p>Layers may also implement this method to perform any behaviour that
should be run once per callsite. If the layer wishes to use
<code>register_callsite</code> for per-callsite behaviour, but does not want to
globally enable or disable those callsites, it should always return
<ahref="../../tracing_core/subscriber/struct.Interest.html#method.always"title="associated function tracing_core::subscriber::Interest::always"><code>Interest::always()</code></a>.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.enabled"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#868-871">source</a><h4class="code-header">fn <ahref="#method.enabled"class="fn">enabled</a>(&self, metadata: &<aclass="struct"href="../../tracing_core/metadata/struct.Metadata.html"title="struct tracing_core::metadata::Metadata">Metadata</a><'_>, ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>) -><aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><divclass="docblock"><p>Returns <code>true</code> if this layer is interested in a span or event with the
given <code>metadata</code> in the current <ahref="struct.Context.html"title="struct tracing_subscriber::layer::Context"><code>Context</code></a>, similarly to
<ahref="#method.on_exit"><code>on_exit</code></a>, and other notification
methods.
</pre>
<p>See <ahref="#filtering-with-layers">the trait-level documentation</a> for more information on filtering
with <code>Layer</code>s.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_new_span"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#875-877">source</a><h4class="code-header">fn <ahref="#method.on_new_span"class="fn">on_new_span</a>(&self, attrs: &<aclass="struct"href="../../tracing_core/span/struct.Attributes.html"title="struct tracing_core::span::Attributes">Attributes</a><'_>, id: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass="docblock"><p>Notifies this layer that a new span was constructed with the given
<code>Attributes</code> and <code>Id</code>.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_record"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#892">source</a><h4class="code-header">fn <ahref="#method.on_record"class="fn">on_record</a>(&self, _span: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, _values: &<aclass="struct"href="../../tracing_core/span/struct.Record.html"title="struct tracing_core::span::Record">Record</a><'_>, _ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass="docblock"><p>Notifies this layer that a span with the given <code>Id</code> recorded the given
<code>values</code>.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_follows_from"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#899">source</a><h4class="code-header">fn <ahref="#method.on_follows_from"class="fn">on_follows_from</a>(&self, _span: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, _follows: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, _ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass="docblock"><p>Notifies this layer that a span with the ID <code>span</code> recorded that it
follows from the span with the ID <code>follows</code>.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.event_enabled"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#922-924">source</a><h4class="code-header">fn <ahref="#method.event_enabled"class="fn">event_enabled</a>(&self, _event: &<aclass="struct"href="../../tracing_core/event/struct.Event.html"title="struct tracing_core::event::Event">Event</a><'_>, _ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>) -><aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><divclass="docblock"><p>Called before <ahref="trait.Layer.html#method.on_event"><code>on_event</code></a>, to determine if <code>on_event</code> should be called.</p>
<p><strong>Note</strong>: This method determines whether an event is globally enabled,
<em>not</em> whether the individual <code>Layer</code> will be notified about the
event. This is intended to be used by <code>Layer</code>s that implement
filtering for the entire stack. <code>Layer</code>s which do not wish to be
notified about certain events but do not wish to globally disable them
should ignore those events in their <ahref="trait.Layer.html#method.on_event">on_event</a>.</p>
<p></pre></div></p>
<p>See <ahref="#filtering-with-layers">the trait-level documentation</a> for more information on filtering
with <code>Layer</code>s.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_event"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#927">source</a><h4class="code-header">fn <ahref="#method.on_event"class="fn">on_event</a>(&self, _event: &<aclass="struct"href="../../tracing_core/event/struct.Event.html"title="struct tracing_core::event::Event">Event</a><'_>, _ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass="docblock"><p>Notifies this layer that an event has occurred.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_enter"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#930">source</a><h4class="code-header">fn <ahref="#method.on_enter"class="fn">on_enter</a>(&self, _id: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, _ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass="docblock"><p>Notifies this layer that a span with the given ID was entered.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_exit"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#933">source</a><h4class="code-header">fn <ahref="#method.on_exit"class="fn">on_exit</a>(&self, _id: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, _ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass="docblock"><p>Notifies this layer that the span with the given ID was exited.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_close"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#936">source</a><h4class="code-header">fn <ahref="#method.on_close"class="fn">on_close</a>(&self, _id: <aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, _ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass="docblock"><p>Notifies this layer that the span with the given ID has been closed.</p>
</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_id_change"class="method"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#940">source</a><h4class="code-header">fn <ahref="#method.on_id_change"class="fn">on_id_change</a>(&self, _old: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, _new: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, _ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass="docblock"><p>Notifies this layer that a span ID has been cloned, and that the
Self: <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html"title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><divclass="docblock"><p>Composes this layer around the given <code>Layer</code>, returning a <code>Layered</code>
struct implementing <code>Layer</code>.</p>
<p>The returned <code>Layer</code> will call the methods on this <code>Layer</code> and then
those of the new <code>Layer</code>, before calling the methods on the subscriber
Self: <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html"title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><divclass="docblock"><p>Composes this <code>Layer</code> with the given <ahref="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a>, returning a
<code>Layered</code> struct that implements <ahref="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a>.</p>
<p>The returned <code>Layered</code> subscriber will call the methods on this <code>Layer</code>
F: <aclass="trait"href="trait.Filter.html"title="trait tracing_subscriber::layer::Filter">Filter</a><S>,</div></h4></section></summary><divclass="docblock"><p>Combines <code>self</code> with a <ahref="trait.Filter.html"title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a>, returning a <ahref="../filter/struct.Filtered.html"title="struct tracing_subscriber::filter::Filtered"><code>Filtered</code></a> layer.</p>
<p>The <ahref="trait.Filter.html"title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a> will control which spans and events are enabled for
this layer. See <ahref="index.html#per-layer-filtering"title="mod tracing_subscriber::layer">the trait-level documentation</a> for details on
S: <aclass="trait"href="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber">Subscriber</a>,</div></h4></section></summary><divclass="docblock"><p>Erases the type of this <ahref="trait.Layer.html"title="trait tracing_subscriber::layer::Layer"><code>Layer</code></a>, returning a <ahref="https://doc.rust-lang.org/1.76.0/alloc/boxed/struct.Box.html"title="struct alloc::boxed::Box"><code>Box</code></a>ed <code>dyn Layer</code> trait object.</p>
<p>This can be used when a function returns a <code>Layer</code> which may be of
one of several types, or when a <code>Layer</code> subscriber has a very long type
S: <aclass="trait"href="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber">Subscriber</a>,</div></h3></section></summary><divclass="impl-items"><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_register_dispatch-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1772">source</a><ahref="#method.on_register_dispatch-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.on_register_dispatch"class="fn">on_register_dispatch</a>(&self, subscriber: &<aclass="struct"href="../../tracing_core/dispatcher/struct.Dispatch.html"title="struct tracing_core::dispatcher::Dispatch">Dispatch</a>)</h4></section></summary><divclass='docblock'>Performs late initialization when installing this layer as a
<ahref="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a>. <ahref="trait.Layer.html#method.on_register_dispatch">Read more</a></div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_layer-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1772">source</a><ahref="#method.on_layer-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.on_layer"class="fn">on_layer</a>(&mut self, subscriber: <aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&mut S</a>)</h4></section></summary><divclass='docblock'>Performs late initialization when attaching a <code>Layer</code> to a
<ahref="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a>. <ahref="trait.Layer.html#method.on_layer">Read more</a></div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_new_span-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1772">source</a><ahref="#method.on_new_span-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.on_new_span"class="fn">on_new_span</a>(&self, attrs: &<aclass="struct"href="../../tracing_core/span/struct.Attributes.html"title="struct tracing_core::span::Attributes">Attributes</a><'_>, id: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass='docblock'>Notifies this layer that a new span was constructed with the given
<code>Attributes</code> and <code>Id</code>.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.register_callsite-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1772">source</a><ahref="#method.register_callsite-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.register_callsite"class="fn">register_callsite</a>(&self, metadata: &'static <aclass="struct"href="../../tracing_core/metadata/struct.Metadata.html"title="struct tracing_core::metadata::Metadata">Metadata</a><'static>) -><aclass="struct"href="../../tracing_core/subscriber/struct.Interest.html"title="struct tracing_core::subscriber::Interest">Interest</a></h4></section></summary><divclass='docblock'>Registers a new callsite with this layer, returning whether or not
the layer is interested in being notified about the callsite, similarly
to <ahref="../../tracing_core/subscriber/trait.Subscriber.html#method.register_callsite"title="method tracing_core::subscriber::Subscriber::register_callsite"><code>Subscriber::register_callsite</code></a>. <ahref="trait.Layer.html#method.register_callsite">Read more</a></div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.enabled-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1772">source</a><ahref="#method.enabled-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.enabled"class="fn">enabled</a>(&self, metadata: &<aclass="struct"href="../../tracing_core/metadata/struct.Metadata.html"title="struct tracing_core::metadata::Metadata">Metadata</a><'_>, ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>) -><aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><divclass='docblock'>Returns <code>true</code> if this layer is interested in a span or event with the
given <code>metadata</code> in the current <ahref="struct.Context.html"title="struct tracing_subscriber::layer::Context"><code>Context</code></a>, similarly to
<ahref="../../tracing_core/subscriber/trait.Subscriber.html#tymethod.enabled"title="method tracing_core::subscriber::Subscriber::enabled"><code>Subscriber::enabled</code></a>. <ahref="trait.Layer.html#method.enabled">Read more</a></div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_record-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1772">source</a><ahref="#method.on_record-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.on_record"class="fn">on_record</a>(&self, span: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, values: &<aclass="struct"href="../../tracing_core/span/struct.Record.html"title="struct tracing_core::span::Record">Record</a><'_>, ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass='docblock'>Notifies this layer that a span with the given <code>Id</code> recorded the given
<code>values</code>.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_follows_from-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1772">source</a><ahref="#method.on_follows_from-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.on_follows_from"class="fn">on_follows_from</a>(&self, span: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, follows: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass='docblock'>Notifies this layer that a span with the ID <code>span</code> recorded that it
follows from the span with the ID <code>follows</code>.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.event_enabled-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1772">source</a><ahref="#method.event_enabled-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.event_enabled"class="fn">event_enabled</a>(&self, event: &<aclass="struct"href="../../tracing_core/event/struct.Event.html"title="struct tracing_core::event::Event">Event</a><'_>, ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>) -><aclass="primitive"href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><divclass='docblock'>Called before <ahref="trait.Layer.html#method.on_event"><code>on_event</code></a>, to determine if <code>on_event</code> should be called.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_event-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1772">source</a><ahref="#method.on_event-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.on_event"class="fn">on_event</a>(&self, event: &<aclass="struct"href="../../tracing_core/event/struct.Event.html"title="struct tracing_core::event::Event">Event</a><'_>, ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass='docblock'>Notifies this layer that an event has occurred.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_enter-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1772">source</a><ahref="#method.on_enter-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.on_enter"class="fn">on_enter</a>(&self, id: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass='docblock'>Notifies this layer that a span with the given ID was entered.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_exit-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1772">source</a><ahref="#method.on_exit-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.on_exit"class="fn">on_exit</a>(&self, id: &<aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass='docblock'>Notifies this layer that the span with the given ID was exited.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_close-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1772">source</a><ahref="#method.on_close-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.on_close"class="fn">on_close</a>(&self, id: <aclass="struct"href="../../tracing_core/span/struct.Id.html"title="struct tracing_core::span::Id">Id</a>, ctx: <aclass="struct"href="struct.Context.html"title="struct tracing_subscriber::layer::Context">Context</a><'_, S>)</h4></section></summary><divclass='docblock'>Notifies this layer that the span with the given ID has been closed.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.on_id_change-1"class="method trait-impl"><aclass="src rightside"href="../../src/t
subscriber returned a different ID.</div></details><detailsclass="toggle method-toggle"open><summary><sectionid="method.and_then-1"class="method trait-impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1039-1046">source</a><ahref="#method.and_then-1"class="anchor">§</a><h4class="code-header">fn <ahref="trait.Layer.html#method.and_then"class="fn">and_then</a><L>(self, layer: L) -><aclass="struct"href="struct.Layered.html"title="struct tracing_subscriber::layer::Layered">Layered</a><L, Self, S><divclass="where">where
Self: <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html"title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><divclass='docblock'>Composes this layer around the given <code>Layer</code>, returning a <code>Layered</code>
Self: <aclass="trait"href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html"title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><divclass='docblock'>Composes this <code>Layer</code> with the given <ahref="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a>, returning a
S: <aclass="trait"href="../../tracing_core/subscriber/trait.Subscriber.html"title="trait tracing_core::subscriber::Subscriber">Subscriber</a>,</div></h4></section></summary><divclass='docblock'>Erases the type of this <ahref="trait.Layer.html"title="trait tracing_subscriber::layer::Layer"><code>Layer</code></a>, returning a <ahref="https://doc.rust-lang.org/1.76.0/alloc/boxed/struct.Box.html"title="struct alloc::boxed::Box"><code>Box</code></a>ed <code>dyn Layer</code> trait object. <ahref="trait.Layer.html#method.boxed">Read more</a></div></details></div></details></div><h2id="foreign-impls"class="section-header">Implementations on Foreign Types<ahref="#foreign-impls"class="anchor">§</a></h2><detailsclass="toggle implementors-toggle"><summary><sectionid="impl-Layer%3CS%3E-for-Option%3CL%3E"class="impl"><aclass="src rightside"href="../../src/tracing_subscriber/layer/mod.rs.html#1559-1673">source</a><ahref="#impl-Layer%3CS%3E-for-Option%3CL%3E"class="anchor">§</a><h3class="code-header">impl<L, S><aclass="trait"href="trait.Layer.html"title="trait tracing_subscriber::layer::Layer">Layer</a><S> for <aclass="enum"href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><L><divclass="where">where
L: <aclass="trait"href="trait.Layer.html"title="trait tracing_subscriber::layer::Layer">Layer</a><S>,</div></h3></section><sectionid="impl-Layer%3CS%3E-for-Layer%3CS,+N,+E,+W%3E"class="impl"><aclass="src rightside"href="../../src/tracing_subscriber/fmt/fmt_layer.rs.html#804-1008">source</a><ahref="#impl-Layer%3CS%3E-for-Layer%3CS,+N,+E,+W%3E"class="anchor">§</a><h3class="code-header">impl<S, N, E, W><aclass="trait"href="trait.Layer.html"title="trait tracing_subscriber::layer::Layer">Layer</a><S> for tracing_subscriber::fmt::<aclass="struct"href="../fmt/struct.Layer.html"title="struct tracing_subscriber::fmt::Layer">Layer</a><S, N, E, W><divclass="where">where