mirror of
https://github.com/NotAShelf/mpvrc.git
synced 2026-04-23 02:15:06 +00:00
deploy: de38ae62916547ad097c066f94a32e9ba7790eeb
This commit is contained in:
commit
9a86359447
28502 changed files with 1261284 additions and 0 deletions
4
tracing_subscriber/filter/combinator/index.html
Normal file
4
tracing_subscriber/filter/combinator/index.html
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Filter combinators"><title>tracing_subscriber::filter::combinator - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-42caa33d.css"><meta name="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.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../../tracing_subscriber/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../tracing_subscriber/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></a><h2><a href="../../../tracing_subscriber/index.html">tracing_<wbr>subscriber</a><span class="version">0.3.19</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module combinator</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In tracing_<wbr>subscriber::<wbr>filter</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../../index.html">tracing_subscriber</a>::<wbr><a href="../index.html">filter</a></span><h1>Module <span>combinator</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/tracing_subscriber/filter/layer_filters/combinator.rs.html#1-542">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Filter combinators</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.And.html" title="struct tracing_subscriber::filter::combinator::And">And</a></div><div class="desc docblock-short">Combines two <a href="../../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a>s so that spans and events are enabled if and only if
|
||||
<em>both</em> filters return <code>true</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.Not.html" title="struct tracing_subscriber::filter::combinator::Not">Not</a></div><div class="desc docblock-short">Inverts the result of a <a href="../../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.Or.html" title="struct tracing_subscriber::filter::combinator::Or">Or</a></div><div class="desc docblock-short">Combines two <a href="../../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a>s so that spans and events are enabled if <em>either</em> filter
|
||||
returns <code>true</code>.</div></li></ul></section></div></main></body></html>
|
||||
1
tracing_subscriber/filter/combinator/sidebar-items.js
Normal file
1
tracing_subscriber/filter/combinator/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"struct":["And","Not","Or"]};
|
||||
51
tracing_subscriber/filter/combinator/struct.And.html
Normal file
51
tracing_subscriber/filter/combinator/struct.And.html
Normal file
File diff suppressed because one or more lines are too long
43
tracing_subscriber/filter/combinator/struct.Not.html
Normal file
43
tracing_subscriber/filter/combinator/struct.Not.html
Normal file
File diff suppressed because one or more lines are too long
51
tracing_subscriber/filter/combinator/struct.Or.html
Normal file
51
tracing_subscriber/filter/combinator/struct.Or.html
Normal file
File diff suppressed because one or more lines are too long
11
tracing_subscriber/filter/directive/struct.ParseError.html
Normal file
11
tracing_subscriber/filter/directive/struct.ParseError.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/filter/struct.ParseError.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/filter/struct.ParseError.html">../../../tracing_subscriber/filter/struct.ParseError.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/filter/struct.ParseError.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/filter/fn.dynamic_filter_fn.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/filter/fn.dynamic_filter_fn.html">../../../tracing_subscriber/filter/fn.dynamic_filter_fn.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/filter/fn.dynamic_filter_fn.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tracing_subscriber/filter/filter_fn/fn.filter_fn.html
Normal file
11
tracing_subscriber/filter/filter_fn/fn.filter_fn.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/filter/fn.filter_fn.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/filter/fn.filter_fn.html">../../../tracing_subscriber/filter/fn.filter_fn.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/filter/fn.filter_fn.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tracing_subscriber/filter/filter_fn/struct.DynFilterFn.html
Normal file
11
tracing_subscriber/filter/filter_fn/struct.DynFilterFn.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/filter/struct.DynFilterFn.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/filter/struct.DynFilterFn.html">../../../tracing_subscriber/filter/struct.DynFilterFn.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/filter/struct.DynFilterFn.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tracing_subscriber/filter/filter_fn/struct.FilterFn.html
Normal file
11
tracing_subscriber/filter/filter_fn/struct.FilterFn.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/filter/struct.FilterFn.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/filter/struct.FilterFn.html">../../../tracing_subscriber/filter/struct.FilterFn.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/filter/struct.FilterFn.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
49
tracing_subscriber/filter/fn.dynamic_filter_fn.html
Normal file
49
tracing_subscriber/filter/fn.dynamic_filter_fn.html
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Constructs a `DynFilterFn` from a function or closure that returns `true` if a span or event should be enabled within a particular span context."><title>dynamic_filter_fn in tracing_subscriber::filter - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="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.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../tracing_subscriber/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing_subscriber/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing_subscriber/index.html">tracing_<wbr>subscriber</a><span class="version">0.3.19</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">dynamic_<wbr>filter_<wbr>fn</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>filter</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">tracing_subscriber</a>::<wbr><a href="index.html">filter</a></span><h1>Function <span class="fn">dynamic_filter_fn</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing_subscriber/filter/filter_fn.rs.html#175-180">Source</a> </span></div><pre class="rust item-decl"><code>pub fn dynamic_filter_fn<S, F>(f: F) -> <a class="struct" href="struct.DynFilterFn.html" title="struct tracing_subscriber::filter::DynFilterFn">DynFilterFn</a><S, F><div class="where">where
|
||||
F: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&<a class="struct" href="../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata">Metadata</a><'_>, &<a class="struct" href="../layer/struct.Context.html" title="struct tracing_subscriber::layer::Context">Context</a><'_, S>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.bool.html">bool</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs a <a href="struct.DynFilterFn.html" title="struct tracing_subscriber::filter::DynFilterFn"><code>DynFilterFn</code></a> from a function or closure that returns <code>true</code>
|
||||
if a span or event should be enabled within a particular <a href="../layer/struct.Context.html" title="struct tracing_subscriber::layer::Context">span context</a>.</p>
|
||||
<p>This is equivalent to calling <a href="struct.DynFilterFn.html#method.new" title="associated function tracing_subscriber::filter::DynFilterFn::new"><code>DynFilterFn::new</code></a>.</p>
|
||||
<p>Unlike <a href="fn.filter_fn.html" title="fn tracing_subscriber::filter::filter_fn"><code>filter_fn</code></a>, this function takes a closure or function pointer
|
||||
taking the <a href="../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata"><code>Metadata</code></a> for a span or event <em>and</em> the current <a href="../layer/struct.Context.html" title="struct tracing_subscriber::layer::Context"><code>Context</code></a>.
|
||||
This means that a <a href="struct.DynFilterFn.html" title="struct tracing_subscriber::filter::DynFilterFn"><code>DynFilterFn</code></a> can choose whether to enable spans or
|
||||
events based on information about the <em>current</em> span (or its parents).</p>
|
||||
<p>If this is <em>not</em> necessary, use <a href="fn.filter_fn.html" title="fn tracing_subscriber::filter::filter_fn"><code>filter_fn</code></a> instead.</p>
|
||||
<p>The returned <a href="struct.DynFilterFn.html" title="struct tracing_subscriber::filter::DynFilterFn"><code>DynFilterFn</code></a> can be used for both <a href="../layer/index.html#per-layer-filtering" title="mod tracing_subscriber::layer">per-layer filtering</a>
|
||||
(using its <a href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a> implementation) and <a href="../layer/index.html#global-filtering" title="mod tracing_subscriber::layer">global filtering</a> (using
|
||||
its <a href="../layer/trait.Layer.html" title="trait tracing_subscriber::layer::Layer"><code>Layer</code></a> implementation).</p>
|
||||
<p>See the <a href="../layer/index.html#filtering-with-layers" title="mod tracing_subscriber::layer">documentation on filtering with layers</a> for details.</p>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing_subscriber::{
|
||||
layer::{Layer, SubscriberExt},
|
||||
filter,
|
||||
util::SubscriberInitExt,
|
||||
};
|
||||
|
||||
<span class="comment">// Only enable spans or events within a span named "interesting_span".
|
||||
</span><span class="kw">let </span>my_filter = filter::dynamic_filter_fn(|metadata, cx| {
|
||||
<span class="comment">// If this *is* "interesting_span", make sure to enable it.
|
||||
</span><span class="kw">if </span>metadata.is_span() && metadata.name() == <span class="string">"interesting_span" </span>{
|
||||
<span class="kw">return </span><span class="bool-val">true</span>;
|
||||
}
|
||||
|
||||
<span class="comment">// Otherwise, are we in an interesting span?
|
||||
</span><span class="kw">if let </span><span class="prelude-val">Some</span>(current_span) = cx.lookup_current() {
|
||||
<span class="kw">return </span>current_span.name() == <span class="string">"interesting_span"</span>;
|
||||
}
|
||||
|
||||
<span class="bool-val">false
|
||||
</span>});
|
||||
|
||||
<span class="kw">let </span>my_layer = tracing_subscriber::fmt::layer();
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(my_layer.with_filter(my_filter))
|
||||
.init();
|
||||
|
||||
<span class="comment">// This event will not be enabled.
|
||||
</span><span class="macro">tracing::info!</span>(<span class="string">"something happened"</span>);
|
||||
|
||||
<span class="macro">tracing::info_span!</span>(<span class="string">"interesting_span"</span>).in_scope(|| {
|
||||
<span class="comment">// This event will be enabled.
|
||||
</span><span class="macro">tracing::debug!</span>(<span class="string">"something else happened"</span>);
|
||||
});</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
32
tracing_subscriber/filter/fn.filter_fn.html
Normal file
32
tracing_subscriber/filter/fn.filter_fn.html
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Constructs a `FilterFn`, from a function or closure that returns `true` if a span or event should be enabled, based on its `Metadata`."><title>filter_fn in tracing_subscriber::filter - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="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.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../tracing_subscriber/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing_subscriber/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing_subscriber/index.html">tracing_<wbr>subscriber</a><span class="version">0.3.19</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">filter_<wbr>fn</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>filter</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">tracing_subscriber</a>::<wbr><a href="index.html">filter</a></span><h1>Function <span class="fn">filter_fn</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing_subscriber/filter/filter_fn.rs.html#104-109">Source</a> </span></div><pre class="rust item-decl"><code>pub fn filter_fn<F>(f: F) -> <a class="struct" href="struct.FilterFn.html" title="struct tracing_subscriber::filter::FilterFn">FilterFn</a><F><div class="where">where
|
||||
F: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&<a class="struct" href="../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata">Metadata</a><'_>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.bool.html">bool</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs a <a href="struct.FilterFn.html" title="struct tracing_subscriber::filter::FilterFn"><code>FilterFn</code></a>, from a function or closure that returns <code>true</code> if
|
||||
a span or event should be enabled, based on its <a href="../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata"><code>Metadata</code></a>.</p>
|
||||
<p>The returned <a href="struct.FilterFn.html" title="struct tracing_subscriber::filter::FilterFn"><code>FilterFn</code></a> can be used for both <a href="../layer/index.html#per-layer-filtering" title="mod tracing_subscriber::layer">per-layer filtering</a>
|
||||
(using its <a href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a> implementation) and <a href="../layer/index.html#global-filtering" title="mod tracing_subscriber::layer">global filtering</a> (using
|
||||
its <a href="../layer/trait.Layer.html" title="trait tracing_subscriber::layer::Layer"><code>Layer</code></a> implementation).</p>
|
||||
<p>See the <a href="../layer/index.html#filtering-with-layers" title="mod tracing_subscriber::layer">documentation on filtering with layers</a> for details.</p>
|
||||
<p>This is equivalent to calling <a href="struct.FilterFn.html#method.new" title="associated function tracing_subscriber::filter::FilterFn::new"><code>FilterFn::new</code></a>.</p>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing_subscriber::{
|
||||
layer::{Layer, SubscriberExt},
|
||||
filter,
|
||||
util::SubscriberInitExt,
|
||||
};
|
||||
|
||||
<span class="kw">let </span>my_filter = filter::filter_fn(|metadata| {
|
||||
<span class="comment">// Only enable spans or events with the target "interesting_things"
|
||||
</span>metadata.target() == <span class="string">"interesting_things"
|
||||
</span>});
|
||||
|
||||
<span class="kw">let </span>my_layer = tracing_subscriber::fmt::layer();
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(my_layer.with_filter(my_filter))
|
||||
.init();
|
||||
|
||||
<span class="comment">// This event will not be enabled.
|
||||
</span><span class="macro">tracing::warn!</span>(<span class="string">"something important but uninteresting happened!"</span>);
|
||||
|
||||
<span class="comment">// This event will be enabled.
|
||||
</span><span class="macro">tracing::debug!</span>(target: <span class="string">"interesting_things"</span>, <span class="string">"an interesting minor detail..."</span>);</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
15
tracing_subscriber/filter/index.html
Normal file
15
tracing_subscriber/filter/index.html
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="`Layer`s that control which spans and events are enabled by the wrapped subscriber."><title>tracing_subscriber::filter - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="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.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../tracing_subscriber/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing_subscriber/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing_subscriber/index.html">tracing_<wbr>subscriber</a><span class="version">0.3.19</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module filter</a></h2><h3><a href="#reexports">Module Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate tracing_<wbr>subscriber</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">tracing_subscriber</a></span><h1>Module <span>filter</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing_subscriber/filter/mod.rs.html#1-66">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><a href="../layer/index.html" title="mod tracing_subscriber::layer"><code>Layer</code></a>s that control which spans and events are enabled by the wrapped
|
||||
subscriber.</p>
|
||||
<p>This module contains a number of types that provide implementations of
|
||||
various strategies for filtering which spans and events are enabled. For
|
||||
details on filtering spans and events using <a href="../layer/index.html" title="mod tracing_subscriber::layer"><code>Layer</code></a>s, see the
|
||||
<a href="../layer/index.html#filtering-with-layers" title="mod tracing_subscriber::layer"><code>layer</code> module’s documentation</a>.</p>
|
||||
</div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name" id="reexport.Targets"><code>pub use self::targets::<a class="struct" href="targets/struct.Targets.html" title="struct tracing_subscriber::filter::targets::Targets">Targets</a>;</code></div></li></ul><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="combinator/index.html" title="mod tracing_subscriber::filter::combinator">combinator</a></div><div class="desc docblock-short">Filter combinators</div></li><li><div class="item-name"><a class="mod" href="targets/index.html" title="mod tracing_subscriber::filter::targets">targets</a></div><div class="desc docblock-short">A <a href="../layer/index.html#filtering-with-layers" title="mod tracing_subscriber::layer">filter</a> that enables or disables spans and events based on their <a href="../../tracing_core/metadata/struct.Metadata.html#method.target" title="method tracing_core::metadata::Metadata::target">target</a> and <a href="../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level">level</a>.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.DynFilterFn.html" title="struct tracing_subscriber::filter::DynFilterFn">DynFilter<wbr>Fn</a></div><div class="desc docblock-short">A filter implemented by a closure or function pointer that
|
||||
determines whether a given span or event is enabled <em>dynamically</em>,
|
||||
potentially based on the current <a href="../layer/struct.Context.html" title="struct tracing_subscriber::layer::Context">span context</a>.</div></li><li><div class="item-name"><a class="struct" href="struct.FilterFn.html" title="struct tracing_subscriber::filter::FilterFn">Filter<wbr>Fn</a></div><div class="desc docblock-short">A filter implemented by a closure or function pointer that
|
||||
determines whether a given span or event is enabled, based on its
|
||||
<a href="../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata"><code>Metadata</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.FilterId.html" title="struct tracing_subscriber::filter::FilterId">Filter<wbr>Id</a></div><div class="desc docblock-short">Uniquely identifies an individual <a href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a> instance in the context of
|
||||
a <a href="../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber"><code>Subscriber</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.Filtered.html" title="struct tracing_subscriber::filter::Filtered">Filtered</a></div><div class="desc docblock-short">A <a href="../layer/trait.Layer.html" title="trait tracing_subscriber::layer::Layer"><code>Layer</code></a> that wraps an inner <a href="../layer/trait.Layer.html" title="trait tracing_subscriber::layer::Layer"><code>Layer</code></a> and adds a <a href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a> which
|
||||
controls what spans and events are enabled for that layer.</div></li><li><div class="item-name"><a class="struct" href="struct.LevelFilter.html" title="struct tracing_subscriber::filter::LevelFilter">Level<wbr>Filter</a></div><div class="desc docblock-short">A filter comparable to a verbosity <a href="../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level"><code>Level</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.LevelParseError.html" title="struct tracing_subscriber::filter::LevelParseError">Level<wbr>Parse<wbr>Error</a></div><div class="desc docblock-short">Indicates that a string could not be parsed to a valid level.</div></li><li><div class="item-name"><a class="struct" href="struct.ParseError.html" title="struct tracing_subscriber::filter::ParseError">Parse<wbr>Error</a></div><div class="desc docblock-short">Indicates that a string could not be parsed as a filtering directive.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.FilterExt.html" title="trait tracing_subscriber::filter::FilterExt">Filter<wbr>Ext</a></div><div class="desc docblock-short">Extension trait adding <a href="combinator/index.html" title="mod tracing_subscriber::filter::combinator">combinators</a> for combining <a href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a>.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.dynamic_filter_fn.html" title="fn tracing_subscriber::filter::dynamic_filter_fn">dynamic_<wbr>filter_<wbr>fn</a></div><div class="desc docblock-short">Constructs a <a href="struct.DynFilterFn.html" title="struct tracing_subscriber::filter::DynFilterFn"><code>DynFilterFn</code></a> from a function or closure that returns <code>true</code>
|
||||
if a span or event should be enabled within a particular <a href="../layer/struct.Context.html" title="struct tracing_subscriber::layer::Context">span context</a>.</div></li><li><div class="item-name"><a class="fn" href="fn.filter_fn.html" title="fn tracing_subscriber::filter::filter_fn">filter_<wbr>fn</a></div><div class="desc docblock-short">Constructs a <a href="struct.FilterFn.html" title="struct tracing_subscriber::filter::FilterFn"><code>FilterFn</code></a>, from a function or closure that returns <code>true</code> if
|
||||
a span or event should be enabled, based on its <a href="../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata"><code>Metadata</code></a>.</div></li></ul></section></div></main></body></html>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tracing_subscriber/filter/combinator/index.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tracing_subscriber/filter/combinator/index.html">../../../../tracing_subscriber/filter/combinator/index.html</a>...</p>
|
||||
<script>location.replace("../../../../tracing_subscriber/filter/combinator/index.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tracing_subscriber/filter/combinator/struct.And.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tracing_subscriber/filter/combinator/struct.And.html">../../../../tracing_subscriber/filter/combinator/struct.And.html</a>...</p>
|
||||
<script>location.replace("../../../../tracing_subscriber/filter/combinator/struct.And.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tracing_subscriber/filter/combinator/struct.Not.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tracing_subscriber/filter/combinator/struct.Not.html">../../../../tracing_subscriber/filter/combinator/struct.Not.html</a>...</p>
|
||||
<script>location.replace("../../../../tracing_subscriber/filter/combinator/struct.Not.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tracing_subscriber/filter/combinator/struct.Or.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tracing_subscriber/filter/combinator/struct.Or.html">../../../../tracing_subscriber/filter/combinator/struct.Or.html</a>...</p>
|
||||
<script>location.replace("../../../../tracing_subscriber/filter/combinator/struct.Or.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tracing_subscriber/filter/layer_filters/struct.FilterId.html
Normal file
11
tracing_subscriber/filter/layer_filters/struct.FilterId.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/filter/struct.FilterId.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/filter/struct.FilterId.html">../../../tracing_subscriber/filter/struct.FilterId.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/filter/struct.FilterId.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tracing_subscriber/filter/layer_filters/struct.Filtered.html
Normal file
11
tracing_subscriber/filter/layer_filters/struct.Filtered.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/filter/struct.Filtered.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/filter/struct.Filtered.html">../../../tracing_subscriber/filter/struct.Filtered.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/filter/struct.Filtered.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tracing_subscriber/filter/layer_filters/trait.FilterExt.html
Normal file
11
tracing_subscriber/filter/layer_filters/trait.FilterExt.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/filter/trait.FilterExt.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/filter/trait.FilterExt.html">../../../tracing_subscriber/filter/trait.FilterExt.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/filter/trait.FilterExt.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tracing_subscriber/filter/level/struct.LevelFilter.html
Normal file
11
tracing_subscriber/filter/level/struct.LevelFilter.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/filter/struct.LevelFilter.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/filter/struct.LevelFilter.html">../../../tracing_subscriber/filter/struct.LevelFilter.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/filter/struct.LevelFilter.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tracing_subscriber/filter/level/struct.ParseError.html
Normal file
11
tracing_subscriber/filter/level/struct.ParseError.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/filter/struct.LevelParseError.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/filter/struct.LevelParseError.html">../../../tracing_subscriber/filter/struct.LevelParseError.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/filter/struct.LevelParseError.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
1
tracing_subscriber/filter/sidebar-items.js
Normal file
1
tracing_subscriber/filter/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"fn":["dynamic_filter_fn","filter_fn"],"mod":["combinator","targets"],"struct":["DynFilterFn","FilterFn","FilterId","Filtered","LevelFilter","LevelParseError","ParseError"],"trait":["FilterExt"]};
|
||||
221
tracing_subscriber/filter/struct.DynFilterFn.html
Normal file
221
tracing_subscriber/filter/struct.DynFilterFn.html
Normal file
File diff suppressed because one or more lines are too long
123
tracing_subscriber/filter/struct.FilterFn.html
Normal file
123
tracing_subscriber/filter/struct.FilterFn.html
Normal file
File diff suppressed because one or more lines are too long
26
tracing_subscriber/filter/struct.FilterId.html
Normal file
26
tracing_subscriber/filter/struct.FilterId.html
Normal file
File diff suppressed because one or more lines are too long
78
tracing_subscriber/filter/struct.Filtered.html
Normal file
78
tracing_subscriber/filter/struct.Filtered.html
Normal file
File diff suppressed because one or more lines are too long
99
tracing_subscriber/filter/struct.LevelFilter.html
Normal file
99
tracing_subscriber/filter/struct.LevelFilter.html
Normal file
File diff suppressed because one or more lines are too long
15
tracing_subscriber/filter/struct.LevelParseError.html
Normal file
15
tracing_subscriber/filter/struct.LevelParseError.html
Normal file
File diff suppressed because one or more lines are too long
13
tracing_subscriber/filter/struct.ParseError.html
Normal file
13
tracing_subscriber/filter/struct.ParseError.html
Normal file
File diff suppressed because one or more lines are too long
4
tracing_subscriber/filter/targets/index.html
Normal file
4
tracing_subscriber/filter/targets/index.html
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A filter that enables or disables spans and events based on their target and level."><title>tracing_subscriber::filter::targets - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-42caa33d.css"><meta name="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.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../../tracing_subscriber/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../tracing_subscriber/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></a><h2><a href="../../../tracing_subscriber/index.html">tracing_<wbr>subscriber</a><span class="version">0.3.19</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module targets</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In tracing_<wbr>subscriber::<wbr>filter</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../../index.html">tracing_subscriber</a>::<wbr><a href="../index.html">filter</a></span><h1>Module <span>targets</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/tracing_subscriber/filter/targets.rs.html#1-834">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A <a href="../../layer/index.html#filtering-with-layers" title="mod tracing_subscriber::layer">filter</a> that enables or disables spans and events based on their <a href="../../../tracing_core/metadata/struct.Metadata.html#method.target" title="method tracing_core::metadata::Metadata::target">target</a> and <a href="../../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level">level</a>.</p>
|
||||
<p>See <a href="struct.Targets.html" title="struct tracing_subscriber::filter::targets::Targets"><code>Targets</code></a> for details.</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.IntoIter.html" title="struct tracing_subscriber::filter::targets::IntoIter">Into<wbr>Iter</a></div><div class="desc docblock-short">An owning iterator over the <a href="../../../tracing_core/metadata/struct.Metadata.html#method.target" title="method tracing_core::metadata::Metadata::target">target</a>-<a href="../../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level">level</a> pairs of a <code>Targets</code> filter.</div></li><li><div class="item-name"><a class="struct" href="struct.Iter.html" title="struct tracing_subscriber::filter::targets::Iter">Iter</a></div><div class="desc docblock-short">A borrowing iterator over the <a href="../../../tracing_core/metadata/struct.Metadata.html#method.target" title="method tracing_core::metadata::Metadata::target">target</a>-<a href="../../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level">level</a> pairs of a <code>Targets</code> filter.</div></li><li><div class="item-name"><a class="struct" href="struct.Targets.html" title="struct tracing_subscriber::filter::targets::Targets">Targets</a></div><div class="desc docblock-short">A filter that enables or disables spans and events based on their <a href="../../../tracing_core/metadata/struct.Metadata.html#method.target" title="method tracing_core::metadata::Metadata::target">target</a>
|
||||
and <a href="../../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level">level</a>.</div></li></ul></section></div></main></body></html>
|
||||
1
tracing_subscriber/filter/targets/sidebar-items.js
Normal file
1
tracing_subscriber/filter/targets/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"struct":["IntoIter","Iter","Targets"]};
|
||||
221
tracing_subscriber/filter/targets/struct.IntoIter.html
Normal file
221
tracing_subscriber/filter/targets/struct.IntoIter.html
Normal file
File diff suppressed because one or more lines are too long
212
tracing_subscriber/filter/targets/struct.Iter.html
Normal file
212
tracing_subscriber/filter/targets/struct.Iter.html
Normal file
File diff suppressed because one or more lines are too long
293
tracing_subscriber/filter/targets/struct.Targets.html
Normal file
293
tracing_subscriber/filter/targets/struct.Targets.html
Normal file
File diff suppressed because one or more lines are too long
219
tracing_subscriber/filter/trait.FilterExt.html
Normal file
219
tracing_subscriber/filter/trait.FilterExt.html
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Extension trait adding combinators for combining `Filter`."><title>FilterExt in tracing_subscriber::filter - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="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.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../tracing_subscriber/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing_subscriber/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing_subscriber/index.html">tracing_<wbr>subscriber</a><span class="version">0.3.19</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Filter<wbr>Ext</a></h2><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.and" title="and">and</a></li><li><a href="#method.boxed" title="boxed">boxed</a></li><li><a href="#method.not" title="not">not</a></li><li><a href="#method.or" title="or">or</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>filter</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">tracing_subscriber</a>::<wbr><a href="index.html">filter</a></span><h1>Trait <span class="trait">FilterExt</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing_subscriber/filter/layer_filters/mod.rs.html#183-457">Source</a> </span></div><pre class="rust item-decl"><code>pub trait FilterExt<S>: <a class="trait" href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter">Filter</a><S> {
|
||||
// Provided methods
|
||||
fn <a href="#method.and" class="fn">and</a><B>(self, other: B) -> <a class="struct" href="combinator/struct.And.html" title="struct tracing_subscriber::filter::combinator::And">And</a><Self, B, S>
|
||||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
||||
B: <a class="trait" href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter">Filter</a><S></span> { ... }
|
||||
<span class="item-spacer"></span> fn <a href="#method.or" class="fn">or</a><B>(self, other: B) -> <a class="struct" href="combinator/struct.Or.html" title="struct tracing_subscriber::filter::combinator::Or">Or</a><Self, B, S>
|
||||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
||||
B: <a class="trait" href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter">Filter</a><S></span> { ... }
|
||||
<span class="item-spacer"></span> fn <a href="#method.not" class="fn">not</a>(self) -> <a class="struct" href="combinator/struct.Not.html" title="struct tracing_subscriber::filter::combinator::Not">Not</a><Self, S>
|
||||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||||
<span class="item-spacer"></span> fn <a href="#method.boxed" class="fn">boxed</a>(self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><dyn <a class="trait" href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter">Filter</a><S> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static>
|
||||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static</span> { ... }
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Extension trait adding <a href="combinator/index.html" title="mod tracing_subscriber::filter::combinator">combinators</a> for combining <a href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a>.</p>
|
||||
</div></details><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.and" class="method"><a class="src rightside" href="../../src/tracing_subscriber/filter/layer_filters/mod.rs.html#225-231">Source</a><h4 class="code-header">fn <a href="#method.and" class="fn">and</a><B>(self, other: B) -> <a class="struct" href="combinator/struct.And.html" title="struct tracing_subscriber::filter::combinator::And">And</a><Self, B, S><div class="where">where
|
||||
Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
||||
B: <a class="trait" href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter">Filter</a><S>,</div></h4></section></summary><div class="docblock"><p>Combines this <a href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a> with another <a href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a> s so that spans and
|
||||
events are enabled if and only if <em>both</em> filters return <code>true</code>.</p>
|
||||
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
|
||||
<p>Enabling spans or events if they have both a particular target <em>and</em> are
|
||||
above a certain level:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing_subscriber::{
|
||||
filter::{filter_fn, LevelFilter, FilterExt},
|
||||
prelude::<span class="kw-2">*</span>,
|
||||
};
|
||||
|
||||
<span class="comment">// Enables spans and events with targets starting with `interesting_target`:
|
||||
</span><span class="kw">let </span>target_filter = filter_fn(|meta| {
|
||||
meta.target().starts_with(<span class="string">"interesting_target"</span>)
|
||||
});
|
||||
|
||||
<span class="comment">// Enables spans and events with levels `INFO` and below:
|
||||
</span><span class="kw">let </span>level_filter = LevelFilter::INFO;
|
||||
|
||||
<span class="comment">// Combine the two filters together, returning a filter that only enables
|
||||
// spans and events that *both* filters will enable:
|
||||
</span><span class="kw">let </span>filter = target_filter.and(level_filter);
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::fmt::layer().with_filter(filter))
|
||||
.init();
|
||||
|
||||
<span class="comment">// This event will *not* be enabled:
|
||||
</span><span class="macro">tracing::info!</span>(<span class="string">"an event with an uninteresting target"</span>);
|
||||
|
||||
<span class="comment">// This event *will* be enabled:
|
||||
</span><span class="macro">tracing::info!</span>(target: <span class="string">"interesting_target"</span>, <span class="string">"a very interesting event"</span>);
|
||||
|
||||
<span class="comment">// This event will *not* be enabled:
|
||||
</span><span class="macro">tracing::debug!</span>(target: <span class="string">"interesting_target"</span>, <span class="string">"interesting debug event..."</span>);</code></pre></div>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.or" class="method"><a class="src rightside" href="../../src/tracing_subscriber/filter/layer_filters/mod.rs.html#307-313">Source</a><h4 class="code-header">fn <a href="#method.or" class="fn">or</a><B>(self, other: B) -> <a class="struct" href="combinator/struct.Or.html" title="struct tracing_subscriber::filter::combinator::Or">Or</a><Self, B, S><div class="where">where
|
||||
Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
||||
B: <a class="trait" href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter">Filter</a><S>,</div></h4></section></summary><div class="docblock"><p>Combines two <a href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter"><code>Filter</code></a>s so that spans and events are enabled if <em>either</em> filter
|
||||
returns <code>true</code>.</p>
|
||||
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
||||
<p>Enabling spans and events at the <code>INFO</code> level and above, and all spans
|
||||
and events with a particular target:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing_subscriber::{
|
||||
filter::{filter_fn, LevelFilter, FilterExt},
|
||||
prelude::<span class="kw-2">*</span>,
|
||||
};
|
||||
|
||||
<span class="comment">// Enables spans and events with targets starting with `interesting_target`:
|
||||
</span><span class="kw">let </span>target_filter = filter_fn(|meta| {
|
||||
meta.target().starts_with(<span class="string">"interesting_target"</span>)
|
||||
});
|
||||
|
||||
<span class="comment">// Enables spans and events with levels `INFO` and below:
|
||||
</span><span class="kw">let </span>level_filter = LevelFilter::INFO;
|
||||
|
||||
<span class="comment">// Combine the two filters together so that a span or event is enabled
|
||||
// if it is at INFO or lower, or if it has a target starting with
|
||||
// `interesting_target`.
|
||||
</span><span class="kw">let </span>filter = level_filter.or(target_filter);
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::fmt::layer().with_filter(filter))
|
||||
.init();
|
||||
|
||||
<span class="comment">// This event will *not* be enabled:
|
||||
</span><span class="macro">tracing::debug!</span>(<span class="string">"an uninteresting event"</span>);
|
||||
|
||||
<span class="comment">// This event *will* be enabled:
|
||||
</span><span class="macro">tracing::info!</span>(<span class="string">"an uninteresting INFO event"</span>);
|
||||
|
||||
<span class="comment">// This event *will* be enabled:
|
||||
</span><span class="macro">tracing::info!</span>(target: <span class="string">"interesting_target"</span>, <span class="string">"a very interesting event"</span>);
|
||||
|
||||
<span class="comment">// This event *will* be enabled:
|
||||
</span><span class="macro">tracing::debug!</span>(target: <span class="string">"interesting_target"</span>, <span class="string">"interesting debug event..."</span>);</code></pre></div>
|
||||
<p>Enabling a higher level for a particular target by using <code>or</code> in
|
||||
conjunction with the <a href="trait.FilterExt.html#method.and" title="method tracing_subscriber::filter::FilterExt::and"><code>and</code></a> combinator:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing_subscriber::{
|
||||
filter::{filter_fn, LevelFilter, FilterExt},
|
||||
prelude::<span class="kw-2">*</span>,
|
||||
};
|
||||
|
||||
<span class="comment">// This filter will enable spans and events with targets beginning with
|
||||
// `my_crate`:
|
||||
</span><span class="kw">let </span>my_crate = filter_fn(|meta| {
|
||||
meta.target().starts_with(<span class="string">"my_crate"</span>)
|
||||
});
|
||||
|
||||
<span class="kw">let </span>filter = my_crate
|
||||
<span class="comment">// Combine the `my_crate` filter with a `LevelFilter` to produce a
|
||||
// filter that will enable the `INFO` level and lower for spans and
|
||||
// events with `my_crate` targets:
|
||||
</span>.and(LevelFilter::INFO)
|
||||
<span class="comment">// If a span or event *doesn't* have a target beginning with
|
||||
// `my_crate`, enable it if it has the `WARN` level or lower:
|
||||
</span>.or(LevelFilter::WARN);
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::fmt::layer().with_filter(filter))
|
||||
.init();</code></pre></div>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.not" class="method"><a class="src rightside" href="../../src/tracing_subscriber/filter/layer_filters/mod.rs.html#374-379">Source</a><h4 class="code-header">fn <a href="#method.not" class="fn">not</a>(self) -> <a class="struct" href="combinator/struct.Not.html" title="struct tracing_subscriber::filter::combinator::Not">Not</a><Self, S><div class="where">where
|
||||
Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Inverts <code>self</code>, returning a filter that enables spans and events only if
|
||||
<code>self</code> would <em>not</em> enable them.</p>
|
||||
<p>This inverts the values returned by the <a href="../layer/trait.Filter.html#tymethod.enabled" title="method tracing_subscriber::layer::Filter::enabled"><code>enabled</code></a> and <a href="../layer/trait.Filter.html#method.callsite_enabled" title="method tracing_subscriber::layer::Filter::callsite_enabled"><code>callsite_enabled</code></a>
|
||||
methods on the wrapped filter; it does <em>not</em> invert <a href="../layer/trait.Filter.html#method.event_enabled" title="method tracing_subscriber::layer::Filter::event_enabled"><code>event_enabled</code></a>, as
|
||||
filters which do not implement filtering on event field values will return
|
||||
the default <code>true</code> even for events that their <a href="../layer/trait.Filter.html#tymethod.enabled" title="method tracing_subscriber::layer::Filter::enabled"><code>enabled</code></a> method disables.</p>
|
||||
<p>Consider a normal filter defined as:</p>
|
||||
|
||||
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="comment">// for spans
|
||||
</span><span class="kw">match </span>callsite_enabled() {
|
||||
ALWAYS => on_span(),
|
||||
SOMETIMES => <span class="kw">if </span>enabled() { on_span() },
|
||||
NEVER => (),
|
||||
}
|
||||
<span class="comment">// for events
|
||||
</span><span class="kw">match </span>callsite_enabled() {
|
||||
ALWAYS => on_event(),
|
||||
SOMETIMES => <span class="kw">if </span>enabled() && event_enabled() { on_event() },
|
||||
NEVER => (),
|
||||
}</code></pre></div>
|
||||
<p>and an inverted filter defined as:</p>
|
||||
|
||||
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="comment">// for spans
|
||||
</span><span class="kw">match </span>callsite_enabled() {
|
||||
ALWAYS => (),
|
||||
SOMETIMES => <span class="kw">if </span>!enabled() { on_span() },
|
||||
NEVER => on_span(),
|
||||
}
|
||||
<span class="comment">// for events
|
||||
</span><span class="kw">match </span>callsite_enabled() {
|
||||
ALWAYS => (),
|
||||
SOMETIMES => <span class="kw">if </span>!enabled() { on_event() },
|
||||
NEVER => on_event(),
|
||||
}</code></pre></div>
|
||||
<p>A proper inversion would do <code>!(enabled() && event_enabled())</code> (or
|
||||
<code>!enabled() || !event_enabled()</code>), but because of the implicit <code>&&</code>
|
||||
relation between <code>enabled</code> and <code>event_enabled</code>, it is difficult to
|
||||
short circuit and not call the wrapped <code>event_enabled</code>.</p>
|
||||
<p>A combinator which remembers the result of <code>enabled</code> in order to call
|
||||
<code>event_enabled</code> only when <code>enabled() == true</code> is possible, but requires
|
||||
additional thread-local mutable state to support a very niche use case.</p>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.boxed" class="method"><a class="src rightside" href="../../src/tracing_subscriber/filter/layer_filters/mod.rs.html#451-456">Source</a><h4 class="code-header">fn <a href="#method.boxed" class="fn">boxed</a>(self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><dyn <a class="trait" href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter">Filter</a><S> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static><div class="where">where
|
||||
Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,</div></h4></section></summary><div class="docblock"><p><a href="https://doc.rust-lang.org/1.84.1/alloc/boxed/index.html" title="mod alloc::boxed">Boxes</a> <code>self</code>, erasing its concrete type.</p>
|
||||
<p>This is equivalent to calling <a href="https://doc.rust-lang.org/1.84.1/alloc/boxed/struct.Box.html#method.new" title="associated function alloc::boxed::Box::new"><code>Box::new</code></a>, but in method form, so that
|
||||
it can be used when chaining combinator methods.</p>
|
||||
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
|
||||
<p>When different combinations of filters are used conditionally, they may
|
||||
have different types. For example, the following code won’t compile,
|
||||
since the <code>if</code> and <code>else</code> clause produce filters of different types:</p>
|
||||
|
||||
<div class="example-wrap compile_fail"><a href="#" class="tooltip" title="This example deliberately fails to compile">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing_subscriber::{
|
||||
filter::{filter_fn, LevelFilter, FilterExt},
|
||||
prelude::<span class="kw-2">*</span>,
|
||||
};
|
||||
|
||||
<span class="kw">let </span>enable_bar_target: bool = <span class="comment">// ...
|
||||
|
||||
</span><span class="kw">let </span>filter = <span class="kw">if </span>enable_bar_target {
|
||||
filter_fn(|meta| meta.target().starts_with(<span class="string">"foo"</span>))
|
||||
<span class="comment">// If `enable_bar_target` is true, add a `filter_fn` enabling
|
||||
// spans and events with the target `bar`:
|
||||
</span>.or(filter_fn(|meta| meta.target().starts_with(<span class="string">"bar"</span>)))
|
||||
.and(LevelFilter::INFO)
|
||||
} <span class="kw">else </span>{
|
||||
filter_fn(|meta| meta.target().starts_with(<span class="string">"foo"</span>))
|
||||
.and(LevelFilter::INFO)
|
||||
};
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::fmt::layer().with_filter(filter))
|
||||
.init();</code></pre></div>
|
||||
<p>By using <code>boxed</code>, the types of the two different branches can be erased,
|
||||
so the assignment to the <code>filter</code> variable is valid (as both branches
|
||||
have the type <code>Box<dyn Filter<S> + Send + Sync + 'static></code>). The
|
||||
following code <em>does</em> compile:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing_subscriber::{
|
||||
filter::{filter_fn, LevelFilter, FilterExt},
|
||||
prelude::<span class="kw-2">*</span>,
|
||||
};
|
||||
|
||||
<span class="kw">let </span>enable_bar_target: bool = <span class="comment">// ...
|
||||
|
||||
</span><span class="kw">let </span>filter = <span class="kw">if </span>enable_bar_target {
|
||||
filter_fn(|meta| meta.target().starts_with(<span class="string">"foo"</span>))
|
||||
.or(filter_fn(|meta| meta.target().starts_with(<span class="string">"bar"</span>)))
|
||||
.and(LevelFilter::INFO)
|
||||
<span class="comment">// Boxing the filter erases its type, so both branches now
|
||||
// have the same type.
|
||||
</span>.boxed()
|
||||
} <span class="kw">else </span>{
|
||||
filter_fn(|meta| meta.target().starts_with(<span class="string">"foo"</span>))
|
||||
.and(LevelFilter::INFO)
|
||||
.boxed()
|
||||
};
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::fmt::layer().with_filter(filter))
|
||||
.init();</code></pre></div>
|
||||
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-FilterExt%3CS%3E-for-F" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/filter/layer_filters/mod.rs.html#1042">Source</a><a href="#impl-FilterExt%3CS%3E-for-F" class="anchor">§</a><h3 class="code-header">impl<F, S> <a class="trait" href="trait.FilterExt.html" title="trait tracing_subscriber::filter::FilterExt">FilterExt</a><S> for F<div class="where">where
|
||||
F: <a class="trait" href="../layer/trait.Filter.html" title="trait tracing_subscriber::layer::Filter">Filter</a><S>,</div></h3></section></div><script src="../../trait.impl/tracing_subscriber/filter/layer_filters/trait.FilterExt.js" async></script></section></div></main></body></html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue