mirror of
https://github.com/NotAShelf/mpvrc.git
synced 2026-04-26 19:37:41 +00:00
deploy: de38ae62916547ad097c066f94a32e9ba7790eeb
This commit is contained in:
commit
9a86359447
28502 changed files with 1261284 additions and 0 deletions
11
tracing_subscriber/fmt/fmt_layer/struct.FmtContext.html
Normal file
11
tracing_subscriber/fmt/fmt_layer/struct.FmtContext.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/fmt/struct.FmtContext.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/fmt/struct.FmtContext.html">../../../tracing_subscriber/fmt/struct.FmtContext.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/fmt/struct.FmtContext.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tracing_subscriber/fmt/fmt_layer/struct.FormattedFields.html
Normal file
11
tracing_subscriber/fmt/fmt_layer/struct.FormattedFields.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/fmt/struct.FormattedFields.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/fmt/struct.FormattedFields.html">../../../tracing_subscriber/fmt/struct.FormattedFields.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/fmt/struct.FormattedFields.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
tracing_subscriber/fmt/fmt_layer/struct.Layer.html
Normal file
11
tracing_subscriber/fmt/fmt_layer/struct.Layer.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../tracing_subscriber/fmt/struct.Layer.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../tracing_subscriber/fmt/struct.Layer.html">../../../tracing_subscriber/fmt/struct.Layer.html</a>...</p>
|
||||
<script>location.replace("../../../tracing_subscriber/fmt/struct.Layer.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
44
tracing_subscriber/fmt/fn.fmt.html
Normal file
44
tracing_subscriber/fmt/fn.fmt.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<!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="Returns a new `SubscriberBuilder` for configuring a formatting subscriber."><title>fmt in tracing_subscriber::fmt - 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="#">fmt</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>fmt</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">fmt</a></span><h1>Function <span class="fn">fmt</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/fmt/mod.rs.html#321-323">Source</a> </span></div><pre class="rust item-decl"><code>pub fn fmt() -> <a class="struct" href="struct.SubscriberBuilder.html" title="struct tracing_subscriber::fmt::SubscriberBuilder">SubscriberBuilder</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returns a new <a href="struct.SubscriberBuilder.html" title="struct tracing_subscriber::fmt::SubscriberBuilder"><code>SubscriberBuilder</code></a> for configuring a <a href="struct.Subscriber.html" title="struct tracing_subscriber::fmt::Subscriber">formatting subscriber</a>.</p>
|
||||
<p>This is essentially shorthand for [<code>SubscriberBuilder::default()]</code>.</p>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<p>Using <a href="struct.SubscriberBuilder.html#method.init" title="method tracing_subscriber::fmt::SubscriberBuilder::init"><code>init</code></a> to set the default subscriber:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>tracing_subscriber::fmt().init();</code></pre></div>
|
||||
<p>Configuring the output format:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
|
||||
tracing_subscriber::fmt()
|
||||
<span class="comment">// Configure formatting settings.
|
||||
</span>.with_target(<span class="bool-val">false</span>)
|
||||
.with_timer(tracing_subscriber::fmt::time::uptime())
|
||||
.with_level(<span class="bool-val">true</span>)
|
||||
<span class="comment">// Set the subscriber as the default.
|
||||
</span>.init();</code></pre></div>
|
||||
<p><a href="struct.SubscriberBuilder.html#method.try_init" title="method tracing_subscriber::fmt::SubscriberBuilder::try_init"><code>try_init</code></a> returns an error if the default subscriber could not be set:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::error::Error;
|
||||
|
||||
<span class="kw">fn </span>init_subscriber() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error + Send + Sync + <span class="lifetime">'static</span>>> {
|
||||
tracing_subscriber::fmt()
|
||||
<span class="comment">// Configure the subscriber to emit logs in JSON format.
|
||||
</span>.json()
|
||||
<span class="comment">// Configure the subscriber to flatten event fields in the output JSON objects.
|
||||
</span>.flatten_event(<span class="bool-val">true</span>)
|
||||
<span class="comment">// Set the subscriber as the default, returning an error if this fails.
|
||||
</span>.try_init()<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</code></pre></div>
|
||||
<p>Rather than setting the subscriber as the default, <a href="struct.SubscriberBuilder.html#method.finish" title="method tracing_subscriber::fmt::SubscriberBuilder::finish"><code>finish</code></a> <em>returns</em> the
|
||||
constructed subscriber, which may then be passed to other functions:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>subscriber = tracing_subscriber::fmt()
|
||||
.with_max_level(tracing::Level::DEBUG)
|
||||
.compact()
|
||||
.finish();
|
||||
|
||||
tracing::subscriber::with_default(subscriber, || {
|
||||
<span class="comment">// the subscriber will only be set as the default
|
||||
// inside this closure...
|
||||
</span>})</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
15
tracing_subscriber/fmt/fn.format.html
Normal file
15
tracing_subscriber/fmt/fn.format.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="Returns the default configuration for an [event formatter]."><title>format in tracing_subscriber::fmt - 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"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt</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">fmt</a></span><h1>Function <span class="fn">format</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/fmt/format/mod.rs.html#270-272">Source</a> </span></div><pre class="rust item-decl"><code>pub fn format() -> <a class="struct" href="format/struct.Format.html" title="struct tracing_subscriber::fmt::format::Format">Format</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returns the default configuration for an [event formatter].</p>
|
||||
<p>Methods on the returned event formatter can be used for further
|
||||
configuration. For example:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>format = tracing_subscriber::fmt::format()
|
||||
.without_time() <span class="comment">// Don't include timestamps
|
||||
</span>.with_target(<span class="bool-val">false</span>) <span class="comment">// Don't include event targets.
|
||||
</span>.with_level(<span class="bool-val">false</span>) <span class="comment">// Don't include event levels.
|
||||
</span>.compact(); <span class="comment">// Use a more compact, abbreviated format.
|
||||
|
||||
// Use the configured formatter when building a new subscriber.
|
||||
</span>tracing_subscriber::fmt()
|
||||
.event_format(format)
|
||||
.init();</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
15
tracing_subscriber/fmt/fn.init.html
Normal file
15
tracing_subscriber/fmt/fn.init.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="Install a global tracing subscriber that listens for events and filters based on the value of the `RUST_LOG` environment variable."><title>init in tracing_subscriber::fmt - 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="#">init</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#panics" title="Panics">Panics</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt</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">fmt</a></span><h1>Function <span class="fn">init</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/fmt/mod.rs.html#1243-1245">Source</a> </span></div><pre class="rust item-decl"><code>pub fn init()</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Install a global tracing subscriber that listens for events and
|
||||
filters based on the value of the <a href="crate::filter::EnvFilter::DEFAULT_ENV"><code>RUST_LOG</code> environment variable</a>.</p>
|
||||
<p>The configuration of the subscriber initialized by this function
|
||||
depends on what <a href="../index.html#feature-flags" title="mod tracing_subscriber">feature flags</a> are enabled.</p>
|
||||
<p>If the <code>tracing-log</code> feature is enabled, this will also install
|
||||
the LogTracer to convert <code>Log</code> records into <code>tracing</code> <code>Event</code>s.</p>
|
||||
<p>If the <code>env-filter</code> feature is enabled, this is shorthand for</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>tracing_subscriber::fmt()
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.init();</code></pre></div>
|
||||
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
|
||||
<p>Panics if the initialization was unsuccessful, likely because a
|
||||
global subscriber was already installed by another call to <code>try_init</code>.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
4
tracing_subscriber/fmt/fn.layer.html
Normal file
4
tracing_subscriber/fmt/fn.layer.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="Returns a new formatting layer that can be composed with other layers to construct a `Subscriber`."><title>layer in tracing_subscriber::fmt - 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"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt</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">fmt</a></span><h1>Function <span class="fn">layer</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/fmt/mod.rs.html#334-336">Source</a> </span></div><pre class="rust item-decl"><code>pub fn layer<S>() -> <a class="struct" href="struct.Layer.html" title="struct tracing_subscriber::fmt::Layer">Layer</a><S></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returns a new <a href="struct.Layer.html" title="struct tracing_subscriber::fmt::Layer">formatting layer</a> that can be <a href="../layer/index.html" title="mod tracing_subscriber::layer">composed</a> with other layers to
|
||||
construct a <a href="struct.Subscriber.html" title="struct tracing_subscriber::fmt::Subscriber"><code>Subscriber</code></a>.</p>
|
||||
<p>This is a shorthand for the equivalent <a href="struct.Layer.html#method.default" title="associated function tracing_subscriber::fmt::Layer::default"><code>Layer::default()</code></a> function.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
7
tracing_subscriber/fmt/fn.time.html
Normal file
7
tracing_subscriber/fmt/fn.time.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<!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="Returns a new `SystemTime` timestamp provider."><title>time in tracing_subscriber::fmt - 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"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt</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">fmt</a></span><h1>Function <span class="fn">time</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/fmt/time/mod.rs.html#67-69">Source</a> </span></div><pre class="rust item-decl"><code>pub fn time() -> <a class="struct" href="time/struct.SystemTime.html" title="struct tracing_subscriber::fmt::time::SystemTime">SystemTime</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returns a new <code>SystemTime</code> timestamp provider.</p>
|
||||
<p>This can then be configured further to determine how timestamps should be
|
||||
configured.</p>
|
||||
<p>This is equivalent to calling</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>tracing_subscriber::fmt::time::SystemTime::default()</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
13
tracing_subscriber/fmt/fn.try_init.html
Normal file
13
tracing_subscriber/fmt/fn.try_init.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<!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="Install a global tracing subscriber that listens for events and filters based on the value of the `RUST_LOG` environment variable, if one is not already set."><title>try_init in tracing_subscriber::fmt - 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="#">try_<wbr>init</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt</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">fmt</a></span><h1>Function <span class="fn">try_init</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/fmt/mod.rs.html#1181-1218">Source</a> </span></div><pre class="rust item-decl"><code>pub fn try_init() -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, <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="https://doc.rust-lang.org/1.84.1/core/error/trait.Error.html" title="trait core::error::Error">Error</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>></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Install a global tracing subscriber that listens for events and
|
||||
filters based on the value of the <a href="crate::filter::EnvFilter::DEFAULT_ENV"><code>RUST_LOG</code> environment variable</a>,
|
||||
if one is not already set.</p>
|
||||
<p>If the <code>tracing-log</code> feature is enabled, this will also install
|
||||
the <a href="https://docs.rs/tracing-log/0.1.0/tracing_log/struct.LogTracer.html"><code>LogTracer</code></a> to convert <code>log</code> records into <code>tracing</code> <code>Event</code>s.</p>
|
||||
<p>This is shorthand for</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>tracing_subscriber::fmt().try_init()</code></pre></div>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Returns an Error if the initialization was unsuccessful,
|
||||
likely because a global subscriber was already installed by another
|
||||
call to <code>try_init</code>.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
4
tracing_subscriber/fmt/format/fn.debug_fn.html
Normal file
4
tracing_subscriber/fmt/format/fn.debug_fn.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="Returns a `FormatFields` implementation that formats fields using the provided function or closure."><title>debug_fn in tracing_subscriber::fmt::format - 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"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt::<wbr>format</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">fmt</a>::<wbr><a href="index.html">format</a></span><h1>Function <span class="fn">debug_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/fmt/format/mod.rs.html#284-289">Source</a> </span></div><pre class="rust item-decl"><code>pub fn debug_fn<F>(f: F) -> <a class="struct" href="struct.FieldFn.html" title="struct tracing_subscriber::fmt::format::FieldFn">FieldFn</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>(&mut <a class="struct" href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>, &<a class="struct" href="../../../tracing_core/field/struct.Field.html" title="struct tracing_core::field::Field">Field</a>, &dyn <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returns a <a href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields"><code>FormatFields</code></a> implementation that formats fields using the
|
||||
provided function or closure.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
15
tracing_subscriber/fmt/format/fn.format.html
Normal file
15
tracing_subscriber/fmt/format/fn.format.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="Returns the default configuration for an [event formatter]."><title>format in tracing_subscriber::fmt::format - 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"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt::<wbr>format</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">fmt</a>::<wbr><a href="index.html">format</a></span><h1>Function <span class="fn">format</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/fmt/format/mod.rs.html#270-272">Source</a> </span></div><pre class="rust item-decl"><code>pub fn format() -> <a class="struct" href="struct.Format.html" title="struct tracing_subscriber::fmt::format::Format">Format</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returns the default configuration for an [event formatter].</p>
|
||||
<p>Methods on the returned event formatter can be used for further
|
||||
configuration. For example:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>format = tracing_subscriber::fmt::format()
|
||||
.without_time() <span class="comment">// Don't include timestamps
|
||||
</span>.with_target(<span class="bool-val">false</span>) <span class="comment">// Don't include event targets.
|
||||
</span>.with_level(<span class="bool-val">false</span>) <span class="comment">// Don't include event levels.
|
||||
</span>.compact(); <span class="comment">// Use a more compact, abbreviated format.
|
||||
|
||||
// Use the configured formatter when building a new subscriber.
|
||||
</span>tracing_subscriber::fmt()
|
||||
.event_format(format)
|
||||
.init();</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
37
tracing_subscriber/fmt/format/index.html
Normal file
37
tracing_subscriber/fmt/format/index.html
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<!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="Formatters for logging `tracing` events."><title>tracing_subscriber::fmt::format - 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 format</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#formatters" title="Formatters">Formatters</a></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><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><a href="../index.html">In tracing_<wbr>subscriber::<wbr>fmt</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">fmt</a></span><h1>Module <span>format</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/fmt/format/mod.rs.html#1-2179">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Formatters for logging <code>tracing</code> events.</p>
|
||||
<p>This module provides several formatter implementations, as well as utilities
|
||||
for implementing custom formatters.</p>
|
||||
<h2 id="formatters"><a class="doc-anchor" href="#formatters">§</a>Formatters</h2>
|
||||
<p>This module provides a number of formatter implementations:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p><a href="struct.Full.html" title="struct tracing_subscriber::fmt::format::Full"><code>Full</code></a>: The default formatter. This emits human-readable,
|
||||
single-line logs for each event that occurs, with the current span context
|
||||
displayed before the formatted representation of the event. See
|
||||
<a href="struct.Full.html#example-output" title="struct tracing_subscriber::fmt::format::Full">here</a> for sample output.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><a href="struct.Compact.html" title="struct tracing_subscriber::fmt::format::Compact"><code>Compact</code></a>: A variant of the default formatter, optimized for
|
||||
short line lengths. Fields from the current span context are appended to
|
||||
the fields of the formatted event, and span names are not shown; the
|
||||
verbosity level is abbreviated to a single character. See
|
||||
<a href="struct.Compact.html#example-output" title="struct tracing_subscriber::fmt::format::Compact">here</a> for sample output.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><a href="struct.Pretty.html" title="struct tracing_subscriber::fmt::format::Pretty"><code>Pretty</code></a>: Emits excessively pretty, multi-line logs, optimized
|
||||
for human readability. This is primarily intended to be used in local
|
||||
development and debugging, or for command-line applications, where
|
||||
automated analysis and compact storage of logs is less of a priority than
|
||||
readability and visual appeal. See <a href="struct.Pretty.html#example-output" title="struct tracing_subscriber::fmt::format::Pretty">here</a>
|
||||
for sample output.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>[<code>Json</code>]: Outputs newline-delimited JSON logs. This is intended
|
||||
for production use with systems where structured logs are consumed as JSON
|
||||
by analysis and viewing tools. The JSON output is not optimized for human
|
||||
readability. See <a href="Json#example-output">here</a> for sample output.</p>
|
||||
</li>
|
||||
</ul>
|
||||
</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.Compact.html" title="struct tracing_subscriber::fmt::format::Compact">Compact</a></div><div class="desc docblock-short">Marker for <a href="struct.Format.html" title="struct tracing_subscriber::fmt::format::Format"><code>Format</code></a> that indicates that the compact log format should be used.</div></li><li><div class="item-name"><a class="struct" href="struct.DefaultFields.html" title="struct tracing_subscriber::fmt::format::DefaultFields">Default<wbr>Fields</a></div><div class="desc docblock-short">The default <a href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields"><code>FormatFields</code></a> implementation.</div></li><li><div class="item-name"><a class="struct" href="struct.DefaultVisitor.html" title="struct tracing_subscriber::fmt::format::DefaultVisitor">Default<wbr>Visitor</a></div><div class="desc docblock-short">The <a href="../../field/trait.Visit.html" title="trait tracing_subscriber::field::Visit">visitor</a> produced by <a href="struct.DefaultFields.html" title="struct tracing_subscriber::fmt::format::DefaultFields"><code>DefaultFields</code></a>’s <a href="../../field/trait.MakeVisitor.html" title="trait tracing_subscriber::field::MakeVisitor"><code>MakeVisitor</code></a> implementation.</div></li><li><div class="item-name"><a class="struct" href="struct.FieldFn.html" title="struct tracing_subscriber::fmt::format::FieldFn">FieldFn</a></div><div class="desc docblock-short">A <a href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields"><code>FormatFields</code></a> implementation that formats fields by calling a function
|
||||
or closure.</div></li><li><div class="item-name"><a class="struct" href="struct.FieldFnVisitor.html" title="struct tracing_subscriber::fmt::format::FieldFnVisitor">Field<wbr>FnVisitor</a></div><div class="desc docblock-short">The <a href="../../field/trait.Visit.html" title="trait tracing_subscriber::field::Visit">visitor</a> produced by <a href="struct.FieldFn.html" title="struct tracing_subscriber::fmt::format::FieldFn"><code>FieldFn</code></a>’s <a href="../../field/trait.MakeVisitor.html" title="trait tracing_subscriber::field::MakeVisitor"><code>MakeVisitor</code></a> implementation.</div></li><li><div class="item-name"><a class="struct" href="struct.FmtSpan.html" title="struct tracing_subscriber::fmt::format::FmtSpan">FmtSpan</a></div><div class="desc docblock-short">Configures what points in the span lifecycle are logged as events.</div></li><li><div class="item-name"><a class="struct" href="struct.Format.html" title="struct tracing_subscriber::fmt::format::Format">Format</a></div><div class="desc docblock-short">A pre-configured event formatter.</div></li><li><div class="item-name"><a class="struct" href="struct.Full.html" title="struct tracing_subscriber::fmt::format::Full">Full</a></div><div class="desc docblock-short">Marker for <a href="struct.Format.html" title="struct tracing_subscriber::fmt::format::Format"><code>Format</code></a> that indicates that the default log format should be used.</div></li><li><div class="item-name"><a class="struct" href="struct.Pretty.html" title="struct tracing_subscriber::fmt::format::Pretty">Pretty</a></div><div class="desc docblock-short">An excessively pretty, human-readable event formatter.</div></li><li><div class="item-name"><a class="struct" href="struct.PrettyFields.html" title="struct tracing_subscriber::fmt::format::PrettyFields">Pretty<wbr>Fields</a></div><div class="desc docblock-short">An excessively pretty, human-readable <a href="../../field/trait.MakeVisitor.html" title="trait tracing_subscriber::field::MakeVisitor"><code>MakeVisitor</code></a> implementation.</div></li><li><div class="item-name"><a class="struct" href="struct.PrettyVisitor.html" title="struct tracing_subscriber::fmt::format::PrettyVisitor">Pretty<wbr>Visitor</a></div><div class="desc docblock-short">The <a href="../../field/trait.Visit.html" title="trait tracing_subscriber::field::Visit">visitor</a> produced by <a href="struct.Pretty.html" title="struct tracing_subscriber::fmt::format::Pretty"><code>Pretty</code></a>’s <a href="../../field/trait.MakeVisitor.html" title="trait tracing_subscriber::field::MakeVisitor"><code>MakeVisitor</code></a> implementation.</div></li><li><div class="item-name"><a class="struct" href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a></div><div class="desc docblock-short">A writer to which formatted representations of spans and events are written.</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.FormatEvent.html" title="trait tracing_subscriber::fmt::format::FormatEvent">Format<wbr>Event</a></div><div class="desc docblock-short">A type that can format a tracing <a href="tracing::Event"><code>Event</code></a> to a <a href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a>.</div></li><li><div class="item-name"><a class="trait" href="trait.FormatFields.html" title="trait tracing_subscriber::fmt::format::FormatFields">Format<wbr>Fields</a></div><div class="desc docblock-short">A type that can format a <a href="../../field/trait.RecordFields.html" title="trait tracing_subscriber::field::RecordFields">set of fields</a> to a <a href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</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.debug_fn.html" title="fn tracing_subscriber::fmt::format::debug_fn">debug_<wbr>fn</a></div><div class="desc docblock-short">Returns a <a href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields"><code>FormatFields</code></a> implementation that formats fields using the
|
||||
provided function or closure.</div></li><li><div class="item-name"><a class="fn" href="fn.format.html" title="fn tracing_subscriber::fmt::format::format">format</a></div><div class="desc docblock-short">Returns the default configuration for an [event formatter].</div></li></ul></section></div></main></body></html>
|
||||
11
tracing_subscriber/fmt/format/pretty/struct.Pretty.html
Normal file
11
tracing_subscriber/fmt/format/pretty/struct.Pretty.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../../tracing_subscriber/fmt/format/struct.Pretty.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tracing_subscriber/fmt/format/struct.Pretty.html">../../../../tracing_subscriber/fmt/format/struct.Pretty.html</a>...</p>
|
||||
<script>location.replace("../../../../tracing_subscriber/fmt/format/struct.Pretty.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/fmt/format/struct.PrettyFields.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tracing_subscriber/fmt/format/struct.PrettyFields.html">../../../../tracing_subscriber/fmt/format/struct.PrettyFields.html</a>...</p>
|
||||
<script>location.replace("../../../../tracing_subscriber/fmt/format/struct.PrettyFields.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/fmt/format/struct.PrettyVisitor.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../../tracing_subscriber/fmt/format/struct.PrettyVisitor.html">../../../../tracing_subscriber/fmt/format/struct.PrettyVisitor.html</a>...</p>
|
||||
<script>location.replace("../../../../tracing_subscriber/fmt/format/struct.PrettyVisitor.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
1
tracing_subscriber/fmt/format/sidebar-items.js
Normal file
1
tracing_subscriber/fmt/format/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"fn":["debug_fn","format"],"struct":["Compact","DefaultFields","DefaultVisitor","FieldFn","FieldFnVisitor","FmtSpan","Format","Full","Pretty","PrettyFields","PrettyVisitor","Writer"],"trait":["FormatEvent","FormatFields"]};
|
||||
40
tracing_subscriber/fmt/format/struct.Compact.html
Normal file
40
tracing_subscriber/fmt/format/struct.Compact.html
Normal file
File diff suppressed because one or more lines are too long
19
tracing_subscriber/fmt/format/struct.DefaultFields.html
Normal file
19
tracing_subscriber/fmt/format/struct.DefaultFields.html
Normal file
File diff suppressed because one or more lines are too long
22
tracing_subscriber/fmt/format/struct.DefaultVisitor.html
Normal file
22
tracing_subscriber/fmt/format/struct.DefaultVisitor.html
Normal file
File diff suppressed because one or more lines are too long
28
tracing_subscriber/fmt/format/struct.FieldFn.html
Normal file
28
tracing_subscriber/fmt/format/struct.FieldFn.html
Normal file
File diff suppressed because one or more lines are too long
20
tracing_subscriber/fmt/format/struct.FieldFnVisitor.html
Normal file
20
tracing_subscriber/fmt/format/struct.FieldFnVisitor.html
Normal file
File diff suppressed because one or more lines are too long
29
tracing_subscriber/fmt/format/struct.FmtSpan.html
Normal file
29
tracing_subscriber/fmt/format/struct.FmtSpan.html
Normal file
File diff suppressed because one or more lines are too long
96
tracing_subscriber/fmt/format/struct.Format.html
Normal file
96
tracing_subscriber/fmt/format/struct.Format.html
Normal file
File diff suppressed because one or more lines are too long
36
tracing_subscriber/fmt/format/struct.Full.html
Normal file
36
tracing_subscriber/fmt/format/struct.Full.html
Normal file
File diff suppressed because one or more lines are too long
98
tracing_subscriber/fmt/format/struct.Pretty.html
Normal file
98
tracing_subscriber/fmt/format/struct.Pretty.html
Normal file
File diff suppressed because one or more lines are too long
20
tracing_subscriber/fmt/format/struct.PrettyFields.html
Normal file
20
tracing_subscriber/fmt/format/struct.PrettyFields.html
Normal file
File diff suppressed because one or more lines are too long
22
tracing_subscriber/fmt/format/struct.PrettyVisitor.html
Normal file
22
tracing_subscriber/fmt/format/struct.PrettyVisitor.html
Normal file
File diff suppressed because one or more lines are too long
67
tracing_subscriber/fmt/format/struct.Writer.html
Normal file
67
tracing_subscriber/fmt/format/struct.Writer.html
Normal file
File diff suppressed because one or more lines are too long
142
tracing_subscriber/fmt/format/trait.FormatEvent.html
Normal file
142
tracing_subscriber/fmt/format/trait.FormatEvent.html
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
<!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 type that can format a tracing `Event` to a `Writer`."><title>FormatEvent in tracing_subscriber::fmt::format - 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="#">Format<wbr>Event</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#arguments" title="Arguments">Arguments</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.format_event" title="format_event">format_event</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-FormatEvent%3CS,+N%3E-for-fn(%26FmtContext%3C'b,+S,+N%3E,+Writer%3C'c%3E,+%26Event%3C'e%3E)+-%3E+Result%3C(),+Error%3E" title="fn(ctx: &FmtContext<'_, S, N>, _: Writer<'_>, _: &Event<'_>) -> Result">fn(ctx: &FmtContext<'_, S, N>, _: Writer<'_>, _: &Event<'_>) -> Result</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>fmt::<wbr>format</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">fmt</a>::<wbr><a href="index.html">format</a></span><h1>Trait <span class="trait">FormatEvent</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/fmt/format/mod.rs.html#195-207">Source</a> </span></div><pre class="rust item-decl"><code>pub trait FormatEvent<S, N><div class="where">where
|
||||
S: <a class="trait" href="../../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber">Subscriber</a> + for<'a> <a class="trait" href="../../registry/trait.LookupSpan.html" title="trait tracing_subscriber::registry::LookupSpan">LookupSpan</a><'a>,
|
||||
N: for<'a> <a class="trait" href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'a> + 'static,</div>{
|
||||
// Required method
|
||||
fn <a href="#tymethod.format_event" class="fn">format_event</a>(
|
||||
&self,
|
||||
ctx: &<a class="struct" href="../struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext">FmtContext</a><'_, S, N>,
|
||||
writer: <a class="struct" href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>,
|
||||
event: &<a class="struct" href="../../../tracing_core/event/struct.Event.html" title="struct tracing_core::event::Event">Event</a><'_>,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>;
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A type that can format a tracing <a href="tracing::Event"><code>Event</code></a> to a <a href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a>.</p>
|
||||
<p><code>FormatEvent</code> is primarily used in the context of <a href="../struct.Subscriber.html" title="struct tracing_subscriber::fmt::Subscriber"><code>fmt::Subscriber</code></a> or
|
||||
<a href="../struct.Layer.html" title="struct tracing_subscriber::fmt::Layer"><code>fmt::Layer</code></a>. Each time an event is dispatched to <a href="../struct.Subscriber.html" title="struct tracing_subscriber::fmt::Subscriber"><code>fmt::Subscriber</code></a> or
|
||||
<a href="../struct.Layer.html" title="struct tracing_subscriber::fmt::Layer"><code>fmt::Layer</code></a>, the subscriber or layer
|
||||
forwards it to its associated <code>FormatEvent</code> to emit a log message.</p>
|
||||
<p>This trait is already implemented for function pointers with the same
|
||||
signature as <code>format_event</code>.</p>
|
||||
<h2 id="arguments"><a class="doc-anchor" href="#arguments">§</a>Arguments</h2>
|
||||
<p>The following arguments are passed to <code>FormatEvent::format_event</code>:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>A <a href="../struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext"><code>FmtContext</code></a>. This is an extension of the <a href="../../layer/struct.Context.html" title="struct tracing_subscriber::layer::Context"><code>layer::Context</code></a> type,
|
||||
which can be used for accessing stored information such as the current
|
||||
span context an event occurred in.</p>
|
||||
<p>In addition, <a href="../struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext"><code>FmtContext</code></a> exposes access to the <a href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields"><code>FormatFields</code></a>
|
||||
implementation that the subscriber was configured to use via the
|
||||
<a href="../struct.FmtContext.html#method.field_format" title="method tracing_subscriber::fmt::FmtContext::field_format"><code>FmtContext::field_format</code></a> method. This can be used when the
|
||||
<a href="../trait.FormatEvent.html" title="trait tracing_subscriber::fmt::FormatEvent"><code>FormatEvent</code></a> implementation needs to format the event’s fields.</p>
|
||||
<p>For convenience, <a href="../struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext"><code>FmtContext</code></a> also <a href="../struct.FmtContext.html#impl-FormatFields%3C'writer%3E" title="struct tracing_subscriber::fmt::FmtContext">implements <code>FormatFields</code></a>,
|
||||
forwarding to the configured <a href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields"><code>FormatFields</code></a> type.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>A <a href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a> to which the formatted representation of the event is
|
||||
written. This type implements the <a href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Write.html" title="trait core::fmt::Write"><code>std::fmt::Write</code></a> trait, and therefore
|
||||
can be used with the <a href="https://doc.rust-lang.org/1.84.1/core/macro.write.html" title="macro core::write"><code>std::write!</code></a> and <a href="https://doc.rust-lang.org/1.84.1/core/macro.writeln.html" title="macro core::writeln"><code>std::writeln!</code></a> macros, as well
|
||||
as calling <a href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Write.html" title="trait core::fmt::Write"><code>std::fmt::Write</code></a> methods directly.</p>
|
||||
<p>The <a href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a> type also implements additional methods that provide
|
||||
information about how the event should be formatted. The
|
||||
<a href="struct.Writer.html#method.has_ansi_escapes" title="method tracing_subscriber::fmt::format::Writer::has_ansi_escapes"><code>Writer::has_ansi_escapes</code></a> method indicates whether <a href="https://en.wikipedia.org/wiki/ANSI_escape_code">ANSI terminal
|
||||
escape codes</a> are supported by the underlying I/O writer that the event
|
||||
will be written to. If this returns <code>true</code>, the formatter is permitted to
|
||||
use ANSI escape codes to add colors and other text formatting to its
|
||||
output. If it returns <code>false</code>, the event will be written to an output that
|
||||
does not support ANSI escape codes (such as a log file), and they should
|
||||
not be emitted.</p>
|
||||
<p>Crates like <a href="https://crates.io/crates/nu_ansi_term"><code>nu_ansi_term</code></a> and <a href="https://crates.io/crates/owo-colors"><code>owo-colors</code></a> can be used to add ANSI
|
||||
escape codes to formatted output.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>The actual <a href="tracing::Event"><code>Event</code></a> to be formatted.</p>
|
||||
</li>
|
||||
</ul>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<p>This example re-implements a simiplified version of this crate’s <a href="struct.Full.html" title="struct tracing_subscriber::fmt::format::Full">default
|
||||
formatter</a>:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::fmt;
|
||||
<span class="kw">use </span>tracing_core::{Subscriber, Event};
|
||||
<span class="kw">use </span>tracing_subscriber::fmt::{
|
||||
format::{<span class="self">self</span>, FormatEvent, FormatFields},
|
||||
FmtContext,
|
||||
FormattedFields,
|
||||
};
|
||||
<span class="kw">use </span>tracing_subscriber::registry::LookupSpan;
|
||||
|
||||
<span class="kw">struct </span>MyFormatter;
|
||||
|
||||
<span class="kw">impl</span><S, N> FormatEvent<S, N> <span class="kw">for </span>MyFormatter
|
||||
<span class="kw">where
|
||||
</span>S: Subscriber + <span class="kw">for</span><<span class="lifetime">'a</span>> LookupSpan<<span class="lifetime">'a</span>>,
|
||||
N: <span class="kw">for</span><<span class="lifetime">'a</span>> FormatFields<<span class="lifetime">'a</span>> + <span class="lifetime">'static</span>,
|
||||
{
|
||||
<span class="kw">fn </span>format_event(
|
||||
<span class="kw-2">&</span><span class="self">self</span>,
|
||||
ctx: <span class="kw-2">&</span>FmtContext<<span class="lifetime">'_</span>, S, N>,
|
||||
<span class="kw-2">mut </span>writer: format::Writer<<span class="lifetime">'_</span>>,
|
||||
event: <span class="kw-2">&</span>Event<<span class="lifetime">'_</span>>,
|
||||
) -> fmt::Result {
|
||||
<span class="comment">// Format values from the event's's metadata:
|
||||
</span><span class="kw">let </span>metadata = event.metadata();
|
||||
<span class="macro">write!</span>(<span class="kw-2">&mut </span>writer, <span class="string">"{} {}: "</span>, metadata.level(), metadata.target())<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Format all the spans in the event's span context.
|
||||
</span><span class="kw">if let </span><span class="prelude-val">Some</span>(scope) = ctx.event_scope() {
|
||||
<span class="kw">for </span>span <span class="kw">in </span>scope.from_root() {
|
||||
<span class="macro">write!</span>(writer, <span class="string">"{}"</span>, span.name())<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// `FormattedFields` is a formatted representation of the span's
|
||||
// fields, which is stored in its extensions by the `fmt` layer's
|
||||
// `new_span` method. The fields will have been formatted
|
||||
// by the same field formatter that's provided to the event
|
||||
// formatter in the `FmtContext`.
|
||||
</span><span class="kw">let </span>ext = span.extensions();
|
||||
<span class="kw">let </span>fields = <span class="kw-2">&</span>ext
|
||||
.get::<FormattedFields<N>>()
|
||||
.expect(<span class="string">"will never be `None`"</span>);
|
||||
|
||||
<span class="comment">// Skip formatting the fields if the span had no fields.
|
||||
</span><span class="kw">if </span>!fields.is_empty() {
|
||||
<span class="macro">write!</span>(writer, <span class="string">"{{{}}}"</span>, fields)<span class="question-mark">?</span>;
|
||||
}
|
||||
<span class="macro">write!</span>(writer, <span class="string">": "</span>)<span class="question-mark">?</span>;
|
||||
}
|
||||
}
|
||||
|
||||
<span class="comment">// Write fields on the event
|
||||
</span>ctx.field_format().format_fields(writer.by_ref(), event)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">writeln!</span>(writer)
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">let </span>_subscriber = tracing_subscriber::fmt()
|
||||
.event_format(MyFormatter)
|
||||
.init();
|
||||
|
||||
<span class="kw">let </span>_span = <span class="macro">tracing::info_span!</span>(<span class="string">"my_span"</span>, answer = <span class="number">42</span>).entered();
|
||||
<span class="macro">tracing::info!</span>(question = <span class="string">"life, the universe, and everything"</span>, <span class="string">"hello world"</span>);</code></pre></div>
|
||||
<p>This formatter will print events like this:</p>
|
||||
<div class="example-wrap"><pre class="language-text"><code>DEBUG yak_shaving::shaver: some-span{field-on-span=foo}: started shaving yak</code></pre></div></div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.format_event" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/format/mod.rs.html#201-206">Source</a><h4 class="code-header">fn <a href="#tymethod.format_event" class="fn">format_event</a>(
|
||||
&self,
|
||||
ctx: &<a class="struct" href="../struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext">FmtContext</a><'_, S, N>,
|
||||
writer: <a class="struct" href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>,
|
||||
event: &<a class="struct" href="../../../tracing_core/event/struct.Event.html" title="struct tracing_core::event::Event">Event</a><'_>,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class="docblock"><p>Write a log message for <code>Event</code> in <code>Context</code> to the given <a href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a>.</p>
|
||||
</div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-FormatEvent%3CS,+N%3E-for-fn(%26FmtContext%3C'b,+S,+N%3E,+Writer%3C'c%3E,+%26Event%3C'e%3E)+-%3E+Result%3C(),+Error%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/format/mod.rs.html#209-223">Source</a><a href="#impl-FormatEvent%3CS,+N%3E-for-fn(%26FmtContext%3C'b,+S,+N%3E,+Writer%3C'c%3E,+%26Event%3C'e%3E)+-%3E+Result%3C(),+Error%3E" class="anchor">§</a><h3 class="code-header">impl<S, N> <a class="trait" href="../trait.FormatEvent.html" title="trait tracing_subscriber::fmt::FormatEvent">FormatEvent</a><S, N> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.fn.html">fn</a>(ctx: &<a class="struct" href="../struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext">FmtContext</a><'_, S, N>, _: <a class="struct" href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>, _: &<a class="struct" href="../../../tracing_core/event/struct.Event.html" title="struct tracing_core::event::Event">Event</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a><div class="where">where
|
||||
S: <a class="trait" href="../../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber">Subscriber</a> + for<'a> <a class="trait" href="../../registry/trait.LookupSpan.html" title="trait tracing_subscriber::registry::LookupSpan">LookupSpan</a><'a>,
|
||||
N: for<'a> <a class="trait" href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'a> + 'static,</div></h3></section></summary><div class="impl-items"><section id="method.format_event" class="method trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/format/mod.rs.html#215-222">Source</a><a href="#method.format_event" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.format_event" class="fn">format_event</a>(
|
||||
&self,
|
||||
ctx: &<a class="struct" href="../struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext">FmtContext</a><'_, S, N>,
|
||||
writer: <a class="struct" href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>,
|
||||
event: &<a class="struct" href="../../../tracing_core/event/struct.Event.html" title="struct tracing_core::event::Event">Event</a><'_>,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-FormatEvent%3CC,+N%3E-for-Format%3CPretty,+T%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/format/pretty.rs.html#169-335">Source</a><a href="#impl-FormatEvent%3CC,+N%3E-for-Format%3CPretty,+T%3E" class="anchor">§</a><h3 class="code-header">impl<C, N, T> <a class="trait" href="../trait.FormatEvent.html" title="trait tracing_subscriber::fmt::FormatEvent">FormatEvent</a><C, N> for <a class="struct" href="struct.Format.html" title="struct tracing_subscriber::fmt::format::Format">Format</a><<a class="struct" href="struct.Pretty.html" title="struct tracing_subscriber::fmt::format::Pretty">Pretty</a>, T><div class="where">where
|
||||
C: <a class="trait" href="../../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber">Subscriber</a> + for<'a> <a class="trait" href="../../registry/trait.LookupSpan.html" title="trait tracing_subscriber::registry::LookupSpan">LookupSpan</a><'a>,
|
||||
N: for<'a> <a class="trait" href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'a> + 'static,
|
||||
T: <a class="trait" href="../time/trait.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">FormatTime</a>,</div></h3></section><section id="impl-FormatEvent%3CS,+N%3E-for-Format%3CCompact,+T%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/format/mod.rs.html#1026-1156">Source</a><a href="#impl-FormatEvent%3CS,+N%3E-for-Format%3CCompact,+T%3E" class="anchor">§</a><h3 class="code-header">impl<S, N, T> <a class="trait" href="../trait.FormatEvent.html" title="trait tracing_subscriber::fmt::FormatEvent">FormatEvent</a><S, N> for <a class="struct" href="struct.Format.html" title="struct tracing_subscriber::fmt::format::Format">Format</a><<a class="struct" href="struct.Compact.html" title="struct tracing_subscriber::fmt::format::Compact">Compact</a>, T><div class="where">where
|
||||
S: <a class="trait" href="../../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber">Subscriber</a> + for<'a> <a class="trait" href="../../registry/trait.LookupSpan.html" title="trait tracing_subscriber::registry::LookupSpan">LookupSpan</a><'a>,
|
||||
N: for<'a> <a class="trait" href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'a> + 'static,
|
||||
T: <a class="trait" href="../time/trait.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">FormatTime</a>,</div></h3></section><section id="impl-FormatEvent%3CS,+N%3E-for-Format%3CFull,+T%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/format/mod.rs.html#898-1024">Source</a><a href="#impl-FormatEvent%3CS,+N%3E-for-Format%3CFull,+T%3E" class="anchor">§</a><h3 class="code-header">impl<S, N, T> <a class="trait" href="../trait.FormatEvent.html" title="trait tracing_subscriber::fmt::FormatEvent">FormatEvent</a><S, N> for <a class="struct" href="struct.Format.html" title="struct tracing_subscriber::fmt::format::Format">Format</a><<a class="struct" href="struct.Full.html" title="struct tracing_subscriber::fmt::format::Full">Full</a>, T><div class="where">where
|
||||
S: <a class="trait" href="../../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber">Subscriber</a> + for<'a> <a class="trait" href="../../registry/trait.LookupSpan.html" title="trait tracing_subscriber::registry::LookupSpan">LookupSpan</a><'a>,
|
||||
N: for<'a> <a class="trait" href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'a> + 'static,
|
||||
T: <a class="trait" href="../time/trait.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">FormatTime</a>,</div></h3></section></div><script src="../../../trait.impl/tracing_subscriber/fmt/format/trait.FormatEvent.js" data-ignore-extern-crates="std" async></script></section></div></main></body></html>
|
||||
36
tracing_subscriber/fmt/format/trait.FormatFields.html
Normal file
36
tracing_subscriber/fmt/format/trait.FormatFields.html
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<!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 type that can format a set of fields to a `Writer`."><title>FormatFields in tracing_subscriber::fmt::format - 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="#">Format<wbr>Fields</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.format_fields" title="format_fields">format_fields</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.add_fields" title="add_fields">add_fields</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt::<wbr>format</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">fmt</a>::<wbr><a href="index.html">format</a></span><h1>Trait <span class="trait">FormatFields</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/fmt/format/mod.rs.html#232-251">Source</a> </span></div><pre class="rust item-decl"><code>pub trait FormatFields<'writer> {
|
||||
// Required method
|
||||
fn <a href="#tymethod.format_fields" class="fn">format_fields</a><R: <a class="trait" href="../../field/trait.RecordFields.html" title="trait tracing_subscriber::field::RecordFields">RecordFields</a>>(
|
||||
&self,
|
||||
writer: <a class="struct" href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'writer>,
|
||||
fields: R,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>;
|
||||
|
||||
// Provided method
|
||||
fn <a href="#method.add_fields" class="fn">add_fields</a>(
|
||||
&self,
|
||||
current: &'writer mut <a class="struct" href="../struct.FormattedFields.html" title="struct tracing_subscriber::fmt::FormattedFields">FormattedFields</a><Self>,
|
||||
fields: &<a class="struct" href="../../../tracing_core/span/struct.Record.html" title="struct tracing_core::span::Record">Record</a><'_>,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a> { ... }
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A type that can format a <a href="../../field/trait.RecordFields.html" title="trait tracing_subscriber::field::RecordFields">set of fields</a> to a <a href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a>.</p>
|
||||
<p><code>FormatFields</code> is primarily used in the context of <a href="../struct.Subscriber.html" title="struct tracing_subscriber::fmt::Subscriber"><code>FmtSubscriber</code></a>. Each
|
||||
time a span or event with fields is recorded, the subscriber will format
|
||||
those fields with its associated <code>FormatFields</code> implementation.</p>
|
||||
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.format_fields" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/format/mod.rs.html#234">Source</a><h4 class="code-header">fn <a href="#tymethod.format_fields" class="fn">format_fields</a><R: <a class="trait" href="../../field/trait.RecordFields.html" title="trait tracing_subscriber::field::RecordFields">RecordFields</a>>(
|
||||
&self,
|
||||
writer: <a class="struct" href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'writer>,
|
||||
fields: R,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class="docblock"><p>Format the provided <code>fields</code> to the provided <a href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a>, returning a result.</p>
|
||||
</div></details></div><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.add_fields" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/format/mod.rs.html#241-250">Source</a><h4 class="code-header">fn <a href="#method.add_fields" class="fn">add_fields</a>(
|
||||
&self,
|
||||
current: &'writer mut <a class="struct" href="../struct.FormattedFields.html" title="struct tracing_subscriber::fmt::FormattedFields">FormattedFields</a><Self>,
|
||||
fields: &<a class="struct" href="../../../tracing_core/span/struct.Record.html" title="struct tracing_core::span::Record">Record</a><'_>,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class="docblock"><p>Record additional field(s) on an existing span.</p>
|
||||
<p>By default, this appends a space to the current set of fields if it is
|
||||
non-empty, and then calls <code>self.format_fields</code>. If different behavior is
|
||||
required, the default implementation of this method can be overridden.</p>
|
||||
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.84.1/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-FormatFields%3C'writer%3E-for-Pretty" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/format/pretty.rs.html#337-355">Source</a><a href="#impl-FormatFields%3C'writer%3E-for-Pretty" class="anchor">§</a><h3 class="code-header">impl<'writer> <a class="trait" href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'writer> for <a class="struct" href="struct.Pretty.html" title="struct tracing_subscriber::fmt::format::Pretty">Pretty</a></h3></section><section id="impl-FormatFields%3C'writer%3E-for-M" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/format/mod.rs.html#1159-1169">Source</a><a href="#impl-FormatFields%3C'writer%3E-for-M" class="anchor">§</a><h3 class="code-header">impl<'writer, M> <a class="trait" href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'writer> for M<div class="where">where
|
||||
M: <a class="trait" href="../../field/trait.MakeOutput.html" title="trait tracing_subscriber::field::MakeOutput">MakeOutput</a><<a class="struct" href="struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'writer>, <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>>,
|
||||
M::<a class="associatedtype" href="../../field/trait.MakeVisitor.html#associatedtype.Visitor" title="type tracing_subscriber::field::MakeVisitor::Visitor">Visitor</a>: <a class="trait" href="../../field/trait.VisitFmt.html" title="trait tracing_subscriber::field::VisitFmt">VisitFmt</a> + <a class="trait" href="../../field/trait.VisitOutput.html" title="trait tracing_subscriber::field::VisitOutput">VisitOutput</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>>,</div></h3></section><section id="impl-FormatFields%3C'writer%3E-for-FmtContext%3C'_,+S,+N%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/fmt_layer.rs.html#1044-1056">Source</a><a href="#impl-FormatFields%3C'writer%3E-for-FmtContext%3C'_,+S,+N%3E" class="anchor">§</a><h3 class="code-header">impl<'writer, S, N> <a class="trait" href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'writer> for <a class="struct" href="../struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext">FmtContext</a><'_, S, N><div class="where">where
|
||||
S: <a class="trait" href="../../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber">Subscriber</a> + for<'lookup> <a class="trait" href="../../registry/trait.LookupSpan.html" title="trait tracing_subscriber::registry::LookupSpan">LookupSpan</a><'lookup>,
|
||||
N: <a class="trait" href="../trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'writer> + 'static,</div></h3></section></div><script src="../../../trait.impl/tracing_subscriber/fmt/format/trait.FormatFields.js" async></script></section></div></main></body></html>
|
||||
150
tracing_subscriber/fmt/index.html
Normal file
150
tracing_subscriber/fmt/index.html
Normal file
File diff suppressed because one or more lines are too long
1
tracing_subscriber/fmt/sidebar-items.js
Normal file
1
tracing_subscriber/fmt/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"fn":["fmt","format","init","layer","time","try_init"],"mod":["format","time","writer"],"struct":["FmtContext","FormattedFields","Layer","Subscriber","SubscriberBuilder","TestWriter"],"trait":["FormatEvent","FormatFields","MakeWriter"],"type":["Formatter"]};
|
||||
95
tracing_subscriber/fmt/struct.FmtContext.html
Normal file
95
tracing_subscriber/fmt/struct.FmtContext.html
Normal file
File diff suppressed because one or more lines are too long
1473
tracing_subscriber/fmt/struct.FormattedFields.html
Normal file
1473
tracing_subscriber/fmt/struct.FormattedFields.html
Normal file
File diff suppressed because one or more lines are too long
266
tracing_subscriber/fmt/struct.Layer.html
Normal file
266
tracing_subscriber/fmt/struct.Layer.html
Normal file
File diff suppressed because one or more lines are too long
58
tracing_subscriber/fmt/struct.Subscriber.html
Normal file
58
tracing_subscriber/fmt/struct.Subscriber.html
Normal file
File diff suppressed because one or more lines are too long
292
tracing_subscriber/fmt/struct.SubscriberBuilder.html
Normal file
292
tracing_subscriber/fmt/struct.SubscriberBuilder.html
Normal file
File diff suppressed because one or more lines are too long
43
tracing_subscriber/fmt/struct.TestWriter.html
Normal file
43
tracing_subscriber/fmt/struct.TestWriter.html
Normal file
File diff suppressed because one or more lines are too long
7
tracing_subscriber/fmt/time/fn.time.html
Normal file
7
tracing_subscriber/fmt/time/fn.time.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<!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="Returns a new `SystemTime` timestamp provider."><title>time in tracing_subscriber::fmt::time - 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"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt::<wbr>time</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">fmt</a>::<wbr><a href="index.html">time</a></span><h1>Function <span class="fn">time</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/fmt/time/mod.rs.html#67-69">Source</a> </span></div><pre class="rust item-decl"><code>pub fn time() -> <a class="struct" href="struct.SystemTime.html" title="struct tracing_subscriber::fmt::time::SystemTime">SystemTime</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returns a new <code>SystemTime</code> timestamp provider.</p>
|
||||
<p>This can then be configured further to determine how timestamps should be
|
||||
configured.</p>
|
||||
<p>This is equivalent to calling</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>tracing_subscriber::fmt::time::SystemTime::default()</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
9
tracing_subscriber/fmt/time/fn.uptime.html
Normal file
9
tracing_subscriber/fmt/time/fn.uptime.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<!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="Returns a new `Uptime` timestamp provider."><title>uptime in tracing_subscriber::fmt::time - 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"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt::<wbr>time</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">fmt</a>::<wbr><a href="index.html">time</a></span><h1>Function <span class="fn">uptime</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/fmt/time/mod.rs.html#85-87">Source</a> </span></div><pre class="rust item-decl"><code>pub fn uptime() -> <a class="struct" href="struct.Uptime.html" title="struct tracing_subscriber::fmt::time::Uptime">Uptime</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returns a new <code>Uptime</code> timestamp provider.</p>
|
||||
<p>With this timer, timestamps will be formatted with the amount of time
|
||||
elapsed since the timestamp provider was constructed.</p>
|
||||
<p>This can then be configured further to determine how timestamps should be
|
||||
configured.</p>
|
||||
<p>This is equivalent to calling</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>tracing_subscriber::fmt::time::Uptime::default()</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
2
tracing_subscriber/fmt/time/index.html
Normal file
2
tracing_subscriber/fmt/time/index.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!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="Formatters for event timestamps."><title>tracing_subscriber::fmt::time - 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 time</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><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><a href="../index.html">In tracing_<wbr>subscriber::<wbr>fmt</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">fmt</a></span><h1>Module <span>time</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/fmt/time/mod.rs.html#1-151">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Formatters for event timestamps.</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.SystemTime.html" title="struct tracing_subscriber::fmt::time::SystemTime">System<wbr>Time</a></div><div class="desc docblock-short">Retrieve and print the current wall-clock time.</div></li><li><div class="item-name"><a class="struct" href="struct.Uptime.html" title="struct tracing_subscriber::fmt::time::Uptime">Uptime</a></div><div class="desc docblock-short">Retrieve and print the relative elapsed wall-clock time since an epoch.</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.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">Format<wbr>Time</a></div><div class="desc docblock-short">A type that can measure and format the current time.</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.time.html" title="fn tracing_subscriber::fmt::time::time">time</a></div><div class="desc docblock-short">Returns a new <code>SystemTime</code> timestamp provider.</div></li><li><div class="item-name"><a class="fn" href="fn.uptime.html" title="fn tracing_subscriber::fmt::time::uptime">uptime</a></div><div class="desc docblock-short">Returns a new <code>Uptime</code> timestamp provider.</div></li></ul></section></div></main></body></html>
|
||||
1
tracing_subscriber/fmt/time/sidebar-items.js
Normal file
1
tracing_subscriber/fmt/time/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"fn":["time","uptime"],"struct":["SystemTime","Uptime"],"trait":["FormatTime"]};
|
||||
15
tracing_subscriber/fmt/time/struct.SystemTime.html
Normal file
15
tracing_subscriber/fmt/time/struct.SystemTime.html
Normal file
File diff suppressed because one or more lines are too long
16
tracing_subscriber/fmt/time/struct.Uptime.html
Normal file
16
tracing_subscriber/fmt/time/struct.Uptime.html
Normal file
File diff suppressed because one or more lines are too long
16
tracing_subscriber/fmt/time/trait.FormatTime.html
Normal file
16
tracing_subscriber/fmt/time/trait.FormatTime.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<!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 type that can measure and format the current time."><title>FormatTime in tracing_subscriber::fmt::time - 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="#">Format<wbr>Time</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.format_time" title="format_time">format_time</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-FormatTime-for-%26F" title="&F">&F</a></li><li><a href="#impl-FormatTime-for-()" title="()">()</a></li><li><a href="#impl-FormatTime-for-fn(%26mut+Writer%3C'b%3E)+-%3E+Result%3C(),+Error%3E" title="fn(_: &mut Writer<'_>) -> Result">fn(_: &mut Writer<'_>) -> Result</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>fmt::<wbr>time</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">fmt</a>::<wbr><a href="index.html">time</a></span><h1>Trait <span class="trait">FormatTime</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/fmt/time/mod.rs.html#47-54">Source</a> </span></div><pre class="rust item-decl"><code>pub trait FormatTime {
|
||||
// Required method
|
||||
fn <a href="#tymethod.format_time" class="fn">format_time</a>(&self, w: &mut <a class="struct" href="../format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>;
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A type that can measure and format the current time.</p>
|
||||
<p>This trait is used by <code>Format</code> to include a timestamp with each <code>Event</code> when it is logged.</p>
|
||||
<p>Notable default implementations of this trait are <code>SystemTime</code> and <code>()</code>. The former prints the
|
||||
current time as reported by <code>std::time::SystemTime</code>, and the latter does not print the current
|
||||
time at all. <code>FormatTime</code> is also automatically implemented for any function pointer with the
|
||||
appropriate signature.</p>
|
||||
<p>The full list of provided implementations can be found in <a href="index.html" title="mod tracing_subscriber::fmt::time"><code>time</code></a>.</p>
|
||||
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.format_time" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/time/mod.rs.html#53">Source</a><h4 class="code-header">fn <a href="#tymethod.format_time" class="fn">format_time</a>(&self, w: &mut <a class="struct" href="../format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class="docblock"><p>Measure and write out the current time.</p>
|
||||
<p>When <code>format_time</code> is called, implementors should get the current time using their desired
|
||||
mechanism, and write it out to the given <code>fmt::Write</code>. Implementors must insert a trailing
|
||||
space themselves if they wish to separate the time from subsequent log message text.</p>
|
||||
</div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-FormatTime-for-fn(%26mut+Writer%3C'b%3E)+-%3E+Result%3C(),+Error%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/time/mod.rs.html#104-108">Source</a><a href="#impl-FormatTime-for-fn(%26mut+Writer%3C'b%3E)+-%3E+Result%3C(),+Error%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">FormatTime</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.fn.html">fn</a>(_: &mut <a class="struct" href="../format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h3></section></summary><div class="impl-items"><section id="method.format_time" class="method trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/time/mod.rs.html#105-107">Source</a><a href="#method.format_time" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.format_time" class="fn">format_time</a>(&self, w: &mut <a class="struct" href="../format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-FormatTime-for-()" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/time/mod.rs.html#98-102">Source</a><a href="#impl-FormatTime-for-()" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">FormatTime</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a></h3></section></summary><div class="impl-items"><section id="method.format_time-1" class="method trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/time/mod.rs.html#99-101">Source</a><a href="#method.format_time-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.format_time" class="fn">format_time</a>(&self, _: &mut <a class="struct" href="../format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-FormatTime-for-%26F" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/time/mod.rs.html#89-96">Source</a><a href="#impl-FormatTime-for-%26F" class="anchor">§</a><h3 class="code-header">impl<F> <a class="trait" href="trait.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">FormatTime</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&F</a><div class="where">where
|
||||
F: <a class="trait" href="trait.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">FormatTime</a>,</div></h3></section></summary><div class="impl-items"><section id="method.format_time-2" class="method trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/time/mod.rs.html#93-95">Source</a><a href="#method.format_time-2" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.format_time" class="fn">format_time</a>(&self, w: &mut <a class="struct" href="../format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-FormatTime-for-SystemTime" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/time/mod.rs.html#136-144">Source</a><a href="#impl-FormatTime-for-SystemTime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">FormatTime</a> for <a class="struct" href="struct.SystemTime.html" title="struct tracing_subscriber::fmt::time::SystemTime">SystemTime</a></h3></section><section id="impl-FormatTime-for-Uptime" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/time/mod.rs.html#146-151">Source</a><a href="#impl-FormatTime-for-Uptime" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">FormatTime</a> for <a class="struct" href="struct.Uptime.html" title="struct tracing_subscriber::fmt::time::Uptime">Uptime</a></h3></section></div><script src="../../../trait.impl/tracing_subscriber/fmt/time/trait.FormatTime.js" data-ignore-extern-crates="std" async></script></section></div></main></body></html>
|
||||
142
tracing_subscriber/fmt/trait.FormatEvent.html
Normal file
142
tracing_subscriber/fmt/trait.FormatEvent.html
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
<!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 type that can format a tracing `Event` to a `Writer`."><title>FormatEvent in tracing_subscriber::fmt - 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="#">Format<wbr>Event</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#arguments" title="Arguments">Arguments</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.format_event" title="format_event">format_event</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-FormatEvent%3CS,+N%3E-for-fn(%26FmtContext%3C'b,+S,+N%3E,+Writer%3C'c%3E,+%26Event%3C'e%3E)+-%3E+Result%3C(),+Error%3E" title="fn(ctx: &FmtContext<'_, S, N>, _: Writer<'_>, _: &Event<'_>) -> Result">fn(ctx: &FmtContext<'_, S, N>, _: Writer<'_>, _: &Event<'_>) -> Result</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>fmt</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">fmt</a></span><h1>Trait <span class="trait">FormatEvent</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/fmt/format/mod.rs.html#195-207">Source</a> </span></div><pre class="rust item-decl"><code>pub trait FormatEvent<S, N><div class="where">where
|
||||
S: <a class="trait" href="../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber">Subscriber</a> + for<'a> <a class="trait" href="../registry/trait.LookupSpan.html" title="trait tracing_subscriber::registry::LookupSpan">LookupSpan</a><'a>,
|
||||
N: for<'a> <a class="trait" href="trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'a> + 'static,</div>{
|
||||
// Required method
|
||||
fn <a href="#tymethod.format_event" class="fn">format_event</a>(
|
||||
&self,
|
||||
ctx: &<a class="struct" href="struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext">FmtContext</a><'_, S, N>,
|
||||
writer: <a class="struct" href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>,
|
||||
event: &<a class="struct" href="../../tracing_core/event/struct.Event.html" title="struct tracing_core::event::Event">Event</a><'_>,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>;
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A type that can format a tracing <a href="tracing::Event"><code>Event</code></a> to a <a href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a>.</p>
|
||||
<p><code>FormatEvent</code> is primarily used in the context of <a href="struct.Subscriber.html" title="struct tracing_subscriber::fmt::Subscriber"><code>fmt::Subscriber</code></a> or
|
||||
<a href="struct.Layer.html" title="struct tracing_subscriber::fmt::Layer"><code>fmt::Layer</code></a>. Each time an event is dispatched to <a href="struct.Subscriber.html" title="struct tracing_subscriber::fmt::Subscriber"><code>fmt::Subscriber</code></a> or
|
||||
<a href="struct.Layer.html" title="struct tracing_subscriber::fmt::Layer"><code>fmt::Layer</code></a>, the subscriber or layer
|
||||
forwards it to its associated <code>FormatEvent</code> to emit a log message.</p>
|
||||
<p>This trait is already implemented for function pointers with the same
|
||||
signature as <code>format_event</code>.</p>
|
||||
<h2 id="arguments"><a class="doc-anchor" href="#arguments">§</a>Arguments</h2>
|
||||
<p>The following arguments are passed to <code>FormatEvent::format_event</code>:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>A <a href="struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext"><code>FmtContext</code></a>. This is an extension of the <a href="../layer/struct.Context.html" title="struct tracing_subscriber::layer::Context"><code>layer::Context</code></a> type,
|
||||
which can be used for accessing stored information such as the current
|
||||
span context an event occurred in.</p>
|
||||
<p>In addition, <a href="struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext"><code>FmtContext</code></a> exposes access to the <a href="trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields"><code>FormatFields</code></a>
|
||||
implementation that the subscriber was configured to use via the
|
||||
<a href="struct.FmtContext.html#method.field_format" title="method tracing_subscriber::fmt::FmtContext::field_format"><code>FmtContext::field_format</code></a> method. This can be used when the
|
||||
<a href="trait.FormatEvent.html" title="trait tracing_subscriber::fmt::FormatEvent"><code>FormatEvent</code></a> implementation needs to format the event’s fields.</p>
|
||||
<p>For convenience, <a href="struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext"><code>FmtContext</code></a> also <a href="struct.FmtContext.html#impl-FormatFields%3C'writer%3E" title="struct tracing_subscriber::fmt::FmtContext">implements <code>FormatFields</code></a>,
|
||||
forwarding to the configured <a href="trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields"><code>FormatFields</code></a> type.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>A <a href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a> to which the formatted representation of the event is
|
||||
written. This type implements the <a href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Write.html" title="trait core::fmt::Write"><code>std::fmt::Write</code></a> trait, and therefore
|
||||
can be used with the <a href="https://doc.rust-lang.org/1.84.1/core/macro.write.html" title="macro core::write"><code>std::write!</code></a> and <a href="https://doc.rust-lang.org/1.84.1/core/macro.writeln.html" title="macro core::writeln"><code>std::writeln!</code></a> macros, as well
|
||||
as calling <a href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Write.html" title="trait core::fmt::Write"><code>std::fmt::Write</code></a> methods directly.</p>
|
||||
<p>The <a href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a> type also implements additional methods that provide
|
||||
information about how the event should be formatted. The
|
||||
<a href="format/struct.Writer.html#method.has_ansi_escapes" title="method tracing_subscriber::fmt::format::Writer::has_ansi_escapes"><code>Writer::has_ansi_escapes</code></a> method indicates whether <a href="https://en.wikipedia.org/wiki/ANSI_escape_code">ANSI terminal
|
||||
escape codes</a> are supported by the underlying I/O writer that the event
|
||||
will be written to. If this returns <code>true</code>, the formatter is permitted to
|
||||
use ANSI escape codes to add colors and other text formatting to its
|
||||
output. If it returns <code>false</code>, the event will be written to an output that
|
||||
does not support ANSI escape codes (such as a log file), and they should
|
||||
not be emitted.</p>
|
||||
<p>Crates like <a href="https://crates.io/crates/nu_ansi_term"><code>nu_ansi_term</code></a> and <a href="https://crates.io/crates/owo-colors"><code>owo-colors</code></a> can be used to add ANSI
|
||||
escape codes to formatted output.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>The actual <a href="tracing::Event"><code>Event</code></a> to be formatted.</p>
|
||||
</li>
|
||||
</ul>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<p>This example re-implements a simiplified version of this crate’s <a href="format/struct.Full.html" title="struct tracing_subscriber::fmt::format::Full">default
|
||||
formatter</a>:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::fmt;
|
||||
<span class="kw">use </span>tracing_core::{Subscriber, Event};
|
||||
<span class="kw">use </span>tracing_subscriber::fmt::{
|
||||
format::{<span class="self">self</span>, FormatEvent, FormatFields},
|
||||
FmtContext,
|
||||
FormattedFields,
|
||||
};
|
||||
<span class="kw">use </span>tracing_subscriber::registry::LookupSpan;
|
||||
|
||||
<span class="kw">struct </span>MyFormatter;
|
||||
|
||||
<span class="kw">impl</span><S, N> FormatEvent<S, N> <span class="kw">for </span>MyFormatter
|
||||
<span class="kw">where
|
||||
</span>S: Subscriber + <span class="kw">for</span><<span class="lifetime">'a</span>> LookupSpan<<span class="lifetime">'a</span>>,
|
||||
N: <span class="kw">for</span><<span class="lifetime">'a</span>> FormatFields<<span class="lifetime">'a</span>> + <span class="lifetime">'static</span>,
|
||||
{
|
||||
<span class="kw">fn </span>format_event(
|
||||
<span class="kw-2">&</span><span class="self">self</span>,
|
||||
ctx: <span class="kw-2">&</span>FmtContext<<span class="lifetime">'_</span>, S, N>,
|
||||
<span class="kw-2">mut </span>writer: format::Writer<<span class="lifetime">'_</span>>,
|
||||
event: <span class="kw-2">&</span>Event<<span class="lifetime">'_</span>>,
|
||||
) -> fmt::Result {
|
||||
<span class="comment">// Format values from the event's's metadata:
|
||||
</span><span class="kw">let </span>metadata = event.metadata();
|
||||
<span class="macro">write!</span>(<span class="kw-2">&mut </span>writer, <span class="string">"{} {}: "</span>, metadata.level(), metadata.target())<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Format all the spans in the event's span context.
|
||||
</span><span class="kw">if let </span><span class="prelude-val">Some</span>(scope) = ctx.event_scope() {
|
||||
<span class="kw">for </span>span <span class="kw">in </span>scope.from_root() {
|
||||
<span class="macro">write!</span>(writer, <span class="string">"{}"</span>, span.name())<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// `FormattedFields` is a formatted representation of the span's
|
||||
// fields, which is stored in its extensions by the `fmt` layer's
|
||||
// `new_span` method. The fields will have been formatted
|
||||
// by the same field formatter that's provided to the event
|
||||
// formatter in the `FmtContext`.
|
||||
</span><span class="kw">let </span>ext = span.extensions();
|
||||
<span class="kw">let </span>fields = <span class="kw-2">&</span>ext
|
||||
.get::<FormattedFields<N>>()
|
||||
.expect(<span class="string">"will never be `None`"</span>);
|
||||
|
||||
<span class="comment">// Skip formatting the fields if the span had no fields.
|
||||
</span><span class="kw">if </span>!fields.is_empty() {
|
||||
<span class="macro">write!</span>(writer, <span class="string">"{{{}}}"</span>, fields)<span class="question-mark">?</span>;
|
||||
}
|
||||
<span class="macro">write!</span>(writer, <span class="string">": "</span>)<span class="question-mark">?</span>;
|
||||
}
|
||||
}
|
||||
|
||||
<span class="comment">// Write fields on the event
|
||||
</span>ctx.field_format().format_fields(writer.by_ref(), event)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="macro">writeln!</span>(writer)
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">let </span>_subscriber = tracing_subscriber::fmt()
|
||||
.event_format(MyFormatter)
|
||||
.init();
|
||||
|
||||
<span class="kw">let </span>_span = <span class="macro">tracing::info_span!</span>(<span class="string">"my_span"</span>, answer = <span class="number">42</span>).entered();
|
||||
<span class="macro">tracing::info!</span>(question = <span class="string">"life, the universe, and everything"</span>, <span class="string">"hello world"</span>);</code></pre></div>
|
||||
<p>This formatter will print events like this:</p>
|
||||
<div class="example-wrap"><pre class="language-text"><code>DEBUG yak_shaving::shaver: some-span{field-on-span=foo}: started shaving yak</code></pre></div></div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.format_event" class="method"><a class="src rightside" href="../../src/tracing_subscriber/fmt/format/mod.rs.html#201-206">Source</a><h4 class="code-header">fn <a href="#tymethod.format_event" class="fn">format_event</a>(
|
||||
&self,
|
||||
ctx: &<a class="struct" href="struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext">FmtContext</a><'_, S, N>,
|
||||
writer: <a class="struct" href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>,
|
||||
event: &<a class="struct" href="../../tracing_core/event/struct.Event.html" title="struct tracing_core::event::Event">Event</a><'_>,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class="docblock"><p>Write a log message for <code>Event</code> in <code>Context</code> to the given <a href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a>.</p>
|
||||
</div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-FormatEvent%3CS,+N%3E-for-fn(%26FmtContext%3C'b,+S,+N%3E,+Writer%3C'c%3E,+%26Event%3C'e%3E)+-%3E+Result%3C(),+Error%3E" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/format/mod.rs.html#209-223">Source</a><a href="#impl-FormatEvent%3CS,+N%3E-for-fn(%26FmtContext%3C'b,+S,+N%3E,+Writer%3C'c%3E,+%26Event%3C'e%3E)+-%3E+Result%3C(),+Error%3E" class="anchor">§</a><h3 class="code-header">impl<S, N> <a class="trait" href="trait.FormatEvent.html" title="trait tracing_subscriber::fmt::FormatEvent">FormatEvent</a><S, N> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.fn.html">fn</a>(ctx: &<a class="struct" href="struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext">FmtContext</a><'_, S, N>, _: <a class="struct" href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>, _: &<a class="struct" href="../../tracing_core/event/struct.Event.html" title="struct tracing_core::event::Event">Event</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a><div class="where">where
|
||||
S: <a class="trait" href="../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber">Subscriber</a> + for<'a> <a class="trait" href="../registry/trait.LookupSpan.html" title="trait tracing_subscriber::registry::LookupSpan">LookupSpan</a><'a>,
|
||||
N: for<'a> <a class="trait" href="trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'a> + 'static,</div></h3></section></summary><div class="impl-items"><section id="method.format_event" class="method trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/format/mod.rs.html#215-222">Source</a><a href="#method.format_event" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.format_event" class="fn">format_event</a>(
|
||||
&self,
|
||||
ctx: &<a class="struct" href="struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext">FmtContext</a><'_, S, N>,
|
||||
writer: <a class="struct" href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'_>,
|
||||
event: &<a class="struct" href="../../tracing_core/event/struct.Event.html" title="struct tracing_core::event::Event">Event</a><'_>,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-FormatEvent%3CC,+N%3E-for-Format%3CPretty,+T%3E" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/format/pretty.rs.html#169-335">Source</a><a href="#impl-FormatEvent%3CC,+N%3E-for-Format%3CPretty,+T%3E" class="anchor">§</a><h3 class="code-header">impl<C, N, T> <a class="trait" href="trait.FormatEvent.html" title="trait tracing_subscriber::fmt::FormatEvent">FormatEvent</a><C, N> for <a class="struct" href="format/struct.Format.html" title="struct tracing_subscriber::fmt::format::Format">Format</a><<a class="struct" href="format/struct.Pretty.html" title="struct tracing_subscriber::fmt::format::Pretty">Pretty</a>, T><div class="where">where
|
||||
C: <a class="trait" href="../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber">Subscriber</a> + for<'a> <a class="trait" href="../registry/trait.LookupSpan.html" title="trait tracing_subscriber::registry::LookupSpan">LookupSpan</a><'a>,
|
||||
N: for<'a> <a class="trait" href="trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'a> + 'static,
|
||||
T: <a class="trait" href="time/trait.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">FormatTime</a>,</div></h3></section><section id="impl-FormatEvent%3CS,+N%3E-for-Format%3CCompact,+T%3E" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/format/mod.rs.html#1026-1156">Source</a><a href="#impl-FormatEvent%3CS,+N%3E-for-Format%3CCompact,+T%3E" class="anchor">§</a><h3 class="code-header">impl<S, N, T> <a class="trait" href="trait.FormatEvent.html" title="trait tracing_subscriber::fmt::FormatEvent">FormatEvent</a><S, N> for <a class="struct" href="format/struct.Format.html" title="struct tracing_subscriber::fmt::format::Format">Format</a><<a class="struct" href="format/struct.Compact.html" title="struct tracing_subscriber::fmt::format::Compact">Compact</a>, T><div class="where">where
|
||||
S: <a class="trait" href="../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber">Subscriber</a> + for<'a> <a class="trait" href="../registry/trait.LookupSpan.html" title="trait tracing_subscriber::registry::LookupSpan">LookupSpan</a><'a>,
|
||||
N: for<'a> <a class="trait" href="trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'a> + 'static,
|
||||
T: <a class="trait" href="time/trait.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">FormatTime</a>,</div></h3></section><section id="impl-FormatEvent%3CS,+N%3E-for-Format%3CFull,+T%3E" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/format/mod.rs.html#898-1024">Source</a><a href="#impl-FormatEvent%3CS,+N%3E-for-Format%3CFull,+T%3E" class="anchor">§</a><h3 class="code-header">impl<S, N, T> <a class="trait" href="trait.FormatEvent.html" title="trait tracing_subscriber::fmt::FormatEvent">FormatEvent</a><S, N> for <a class="struct" href="format/struct.Format.html" title="struct tracing_subscriber::fmt::format::Format">Format</a><<a class="struct" href="format/struct.Full.html" title="struct tracing_subscriber::fmt::format::Full">Full</a>, T><div class="where">where
|
||||
S: <a class="trait" href="../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber">Subscriber</a> + for<'a> <a class="trait" href="../registry/trait.LookupSpan.html" title="trait tracing_subscriber::registry::LookupSpan">LookupSpan</a><'a>,
|
||||
N: for<'a> <a class="trait" href="trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'a> + 'static,
|
||||
T: <a class="trait" href="time/trait.FormatTime.html" title="trait tracing_subscriber::fmt::time::FormatTime">FormatTime</a>,</div></h3></section></div><script src="../../trait.impl/tracing_subscriber/fmt/format/trait.FormatEvent.js" data-ignore-extern-crates="std" async></script></section></div></main></body></html>
|
||||
36
tracing_subscriber/fmt/trait.FormatFields.html
Normal file
36
tracing_subscriber/fmt/trait.FormatFields.html
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<!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 type that can format a set of fields to a `Writer`."><title>FormatFields in tracing_subscriber::fmt - 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="#">Format<wbr>Fields</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.format_fields" title="format_fields">format_fields</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.add_fields" title="add_fields">add_fields</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt</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">fmt</a></span><h1>Trait <span class="trait">FormatFields</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/fmt/format/mod.rs.html#232-251">Source</a> </span></div><pre class="rust item-decl"><code>pub trait FormatFields<'writer> {
|
||||
// Required method
|
||||
fn <a href="#tymethod.format_fields" class="fn">format_fields</a><R: <a class="trait" href="../field/trait.RecordFields.html" title="trait tracing_subscriber::field::RecordFields">RecordFields</a>>(
|
||||
&self,
|
||||
writer: <a class="struct" href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'writer>,
|
||||
fields: R,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>;
|
||||
|
||||
// Provided method
|
||||
fn <a href="#method.add_fields" class="fn">add_fields</a>(
|
||||
&self,
|
||||
current: &'writer mut <a class="struct" href="struct.FormattedFields.html" title="struct tracing_subscriber::fmt::FormattedFields">FormattedFields</a><Self>,
|
||||
fields: &<a class="struct" href="../../tracing_core/span/struct.Record.html" title="struct tracing_core::span::Record">Record</a><'_>,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a> { ... }
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A type that can format a <a href="../field/trait.RecordFields.html" title="trait tracing_subscriber::field::RecordFields">set of fields</a> to a <a href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a>.</p>
|
||||
<p><code>FormatFields</code> is primarily used in the context of <a href="struct.Subscriber.html" title="struct tracing_subscriber::fmt::Subscriber"><code>FmtSubscriber</code></a>. Each
|
||||
time a span or event with fields is recorded, the subscriber will format
|
||||
those fields with its associated <code>FormatFields</code> implementation.</p>
|
||||
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.format_fields" class="method"><a class="src rightside" href="../../src/tracing_subscriber/fmt/format/mod.rs.html#234">Source</a><h4 class="code-header">fn <a href="#tymethod.format_fields" class="fn">format_fields</a><R: <a class="trait" href="../field/trait.RecordFields.html" title="trait tracing_subscriber::field::RecordFields">RecordFields</a>>(
|
||||
&self,
|
||||
writer: <a class="struct" href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'writer>,
|
||||
fields: R,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class="docblock"><p>Format the provided <code>fields</code> to the provided <a href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer"><code>Writer</code></a>, returning a result.</p>
|
||||
</div></details></div><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.add_fields" class="method"><a class="src rightside" href="../../src/tracing_subscriber/fmt/format/mod.rs.html#241-250">Source</a><h4 class="code-header">fn <a href="#method.add_fields" class="fn">add_fields</a>(
|
||||
&self,
|
||||
current: &'writer mut <a class="struct" href="struct.FormattedFields.html" title="struct tracing_subscriber::fmt::FormattedFields">FormattedFields</a><Self>,
|
||||
fields: &<a class="struct" href="../../tracing_core/span/struct.Record.html" title="struct tracing_core::span::Record">Record</a><'_>,
|
||||
) -> <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class="docblock"><p>Record additional field(s) on an existing span.</p>
|
||||
<p>By default, this appends a space to the current set of fields if it is
|
||||
non-empty, and then calls <code>self.format_fields</code>. If different behavior is
|
||||
required, the default implementation of this method can be overridden.</p>
|
||||
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.84.1/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-FormatFields%3C'writer%3E-for-Pretty" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/format/pretty.rs.html#337-355">Source</a><a href="#impl-FormatFields%3C'writer%3E-for-Pretty" class="anchor">§</a><h3 class="code-header">impl<'writer> <a class="trait" href="trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'writer> for <a class="struct" href="format/struct.Pretty.html" title="struct tracing_subscriber::fmt::format::Pretty">Pretty</a></h3></section><section id="impl-FormatFields%3C'writer%3E-for-M" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/format/mod.rs.html#1159-1169">Source</a><a href="#impl-FormatFields%3C'writer%3E-for-M" class="anchor">§</a><h3 class="code-header">impl<'writer, M> <a class="trait" href="trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'writer> for M<div class="where">where
|
||||
M: <a class="trait" href="../field/trait.MakeOutput.html" title="trait tracing_subscriber::field::MakeOutput">MakeOutput</a><<a class="struct" href="format/struct.Writer.html" title="struct tracing_subscriber::fmt::format::Writer">Writer</a><'writer>, <a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>>,
|
||||
M::<a class="associatedtype" href="../field/trait.MakeVisitor.html#associatedtype.Visitor" title="type tracing_subscriber::field::MakeVisitor::Visitor">Visitor</a>: <a class="trait" href="../field/trait.VisitFmt.html" title="trait tracing_subscriber::field::VisitFmt">VisitFmt</a> + <a class="trait" href="../field/trait.VisitOutput.html" title="trait tracing_subscriber::field::VisitOutput">VisitOutput</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>>,</div></h3></section><section id="impl-FormatFields%3C'writer%3E-for-FmtContext%3C'_,+S,+N%3E" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/fmt_layer.rs.html#1044-1056">Source</a><a href="#impl-FormatFields%3C'writer%3E-for-FmtContext%3C'_,+S,+N%3E" class="anchor">§</a><h3 class="code-header">impl<'writer, S, N> <a class="trait" href="trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'writer> for <a class="struct" href="struct.FmtContext.html" title="struct tracing_subscriber::fmt::FmtContext">FmtContext</a><'_, S, N><div class="where">where
|
||||
S: <a class="trait" href="../../tracing_core/subscriber/trait.Subscriber.html" title="trait tracing_core::subscriber::Subscriber">Subscriber</a> + for<'lookup> <a class="trait" href="../registry/trait.LookupSpan.html" title="trait tracing_subscriber::registry::LookupSpan">LookupSpan</a><'lookup>,
|
||||
N: <a class="trait" href="trait.FormatFields.html" title="trait tracing_subscriber::fmt::FormatFields">FormatFields</a><'writer> + 'static,</div></h3></section></div><script src="../../trait.impl/tracing_subscriber/fmt/format/trait.FormatFields.js" async></script></section></div></main></body></html>
|
||||
147
tracing_subscriber/fmt/trait.MakeWriter.html
Normal file
147
tracing_subscriber/fmt/trait.MakeWriter.html
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
<!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 type that can create `io::Write` instances."><title>MakeWriter in tracing_subscriber::fmt - 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="#">Make<wbr>Writer</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Writer" title="Writer">Writer</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.make_writer" title="make_writer">make_writer</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.make_writer_for" title="make_writer_for">make_writer_for</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-MakeWriter%3C'a%3E-for-Arc%3CW%3E" title="Arc<W>">Arc<W></a></li><li><a href="#impl-MakeWriter%3C'a%3E-for-File" title="File">File</a></li><li><a href="#impl-MakeWriter%3C'a%3E-for-Mutex%3CW%3E" title="Mutex<W>">Mutex<W></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>fmt</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">fmt</a></span><h1>Trait <span class="trait">MakeWriter</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/fmt/writer.rs.html#95-209">Source</a> </span></div><pre class="rust item-decl"><code>pub trait MakeWriter<'a> {
|
||||
type <a href="#associatedtype.Writer" class="associatedtype">Writer</a>: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a>;
|
||||
|
||||
// Required method
|
||||
fn <a href="#tymethod.make_writer" class="fn">make_writer</a>(&'a self) -> Self::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>;
|
||||
|
||||
// Provided method
|
||||
fn <a href="#method.make_writer_for" class="fn">make_writer_for</a>(&'a self, meta: &<a class="struct" href="../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata">Metadata</a><'_>) -> Self::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a> { ... }
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A type that can create <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a> instances.</p>
|
||||
<p><code>MakeWriter</code> is used by <a href="struct.Layer.html" title="struct tracing_subscriber::fmt::Layer"><code>fmt::Layer</code></a> or <a href="struct.Subscriber.html" title="struct tracing_subscriber::fmt::Subscriber"><code>fmt::Subscriber</code></a> to print
|
||||
formatted text representations of <a href="../../tracing_core/event/struct.Event.html" title="struct tracing_core::event::Event"><code>Event</code></a>s.</p>
|
||||
<p>This trait is already implemented for function pointers and
|
||||
immutably-borrowing closures that return an instance of <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a>, such
|
||||
as <a href="https://doc.rust-lang.org/1.84.1/std/io/stdio/fn.stdout.html" title="fn std::io::stdio::stdout"><code>io::stdout</code></a> and <a href="https://doc.rust-lang.org/1.84.1/std/io/stdio/fn.stderr.html" title="fn std::io::stdio::stderr"><code>io::stderr</code></a>. Additionally, it is implemented for
|
||||
<a href="https://doc.rust-lang.org/1.84.1/std/sync/mutex/struct.Mutex.html" title="struct std::sync::mutex::Mutex"><code>std::sync::Mutex</code></a> when the type inside the mutex implements
|
||||
<a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a>.</p>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<p>The simplest usage is to pass in a named function that returns a writer. For
|
||||
example, to log all events to stderr, we could write:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>subscriber = tracing_subscriber::fmt()
|
||||
.with_writer(std::io::stderr)
|
||||
.finish();</code></pre></div>
|
||||
<p>Any function that returns a writer can be used:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>make_my_great_writer() -> <span class="kw">impl </span>std::io::Write {
|
||||
<span class="comment">// ...
|
||||
</span>}
|
||||
|
||||
<span class="kw">let </span>subscriber = tracing_subscriber::fmt()
|
||||
.with_writer(make_my_great_writer)
|
||||
.finish();</code></pre></div>
|
||||
<p>A closure can be used to introduce arbitrary logic into how the writer is
|
||||
created. Consider the (admittedly rather silly) example of sending every 5th
|
||||
event to stderr, and all other events to stdout:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::io;
|
||||
<span class="kw">use </span>std::sync::atomic::{AtomicUsize, Ordering::Relaxed};
|
||||
|
||||
<span class="kw">let </span>n = AtomicUsize::new(<span class="number">0</span>);
|
||||
<span class="kw">let </span>subscriber = tracing_subscriber::fmt()
|
||||
.with_writer(<span class="kw">move </span>|| -> Box<<span class="kw">dyn </span>io::Write> {
|
||||
<span class="kw">if </span>n.fetch_add(<span class="number">1</span>, Relaxed) % <span class="number">5 </span>== <span class="number">0 </span>{
|
||||
Box::new(io::stderr())
|
||||
} <span class="kw">else </span>{
|
||||
Box::new(io::stdout())
|
||||
}
|
||||
})
|
||||
.finish();</code></pre></div>
|
||||
<p>A single instance of a type implementing <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a> may be used as a
|
||||
<code>MakeWriter</code> by wrapping it in a <a href="https://doc.rust-lang.org/1.84.1/std/sync/mutex/struct.Mutex.html" title="struct std::sync::mutex::Mutex"><code>Mutex</code></a>. For example, we could
|
||||
write to a file like so:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::{fs::File, sync::Mutex};
|
||||
|
||||
<span class="kw">let </span>log_file = File::create(<span class="string">"my_cool_trace.log"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>subscriber = tracing_subscriber::fmt()
|
||||
.with_writer(Mutex::new(log_file))
|
||||
.finish();</code></pre></div>
|
||||
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Writer" class="method"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#100">Source</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a>: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a></h4></section></summary><div class="docblock"><p>The concrete <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a> implementation returned by <a href="trait.MakeWriter.html#tymethod.make_writer" title="method tracing_subscriber::fmt::MakeWriter::make_writer"><code>make_writer</code></a>.</p>
|
||||
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.make_writer" class="method"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#115">Source</a><h4 class="code-header">fn <a href="#tymethod.make_writer" class="fn">make_writer</a>(&'a self) -> Self::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a></h4></section></summary><div class="docblock"><p>Returns an instance of <a href="trait.MakeWriter.html#associatedtype.Writer" title="associated type tracing_subscriber::fmt::MakeWriter::Writer"><code>Writer</code></a>.</p>
|
||||
<h5 id="implementer-notes"><a class="doc-anchor" href="#implementer-notes">§</a>Implementer notes</h5>
|
||||
<p><a href="struct.Layer.html" title="struct tracing_subscriber::fmt::Layer"><code>fmt::Layer</code></a> or <a href="struct.Subscriber.html" title="struct tracing_subscriber::fmt::Subscriber"><code>fmt::Subscriber</code></a> will call this method each time an event is recorded. Ensure any state
|
||||
that must be saved across writes is not lost when the <a href="trait.MakeWriter.html#associatedtype.Writer" title="associated type tracing_subscriber::fmt::MakeWriter::Writer"><code>Writer</code></a> instance is dropped. If
|
||||
creating a <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a> instance is expensive, be sure to cache it when implementing
|
||||
<a href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> to improve performance.</p>
|
||||
</div></details></div><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.make_writer_for" class="method"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#205-208">Source</a><h4 class="code-header">fn <a href="#method.make_writer_for" class="fn">make_writer_for</a>(&'a self, meta: &<a class="struct" href="../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata">Metadata</a><'_>) -> Self::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a></h4></section></summary><div class="docblock"><p>Returns a <a href="trait.MakeWriter.html#associatedtype.Writer" title="associated type tracing_subscriber::fmt::MakeWriter::Writer"><code>Writer</code></a> for writing data from the span or event described
|
||||
by the provided <a href="../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata"><code>Metadata</code></a>.</p>
|
||||
<p>By default, this calls <a href="trait.MakeWriter.html#tymethod.make_writer" title="method tracing_subscriber::fmt::MakeWriter::make_writer"><code>self.make_writer()</code></a>, ignoring
|
||||
the provided metadata, but implementations can override this to provide
|
||||
metadata-specific behaviors.</p>
|
||||
<p>This method allows <code>MakeWriter</code> implementations to implement different
|
||||
behaviors based on the span or event being written. The <code>MakeWriter</code>
|
||||
type might return different writers based on the provided metadata, or
|
||||
might write some values to the writer before or after providing it to
|
||||
the caller.</p>
|
||||
<p>For example, we might want to write data from spans and events at the
|
||||
<a href="../../tracing_core/metadata/struct.Level.html#associatedconstant.ERROR" title="associated constant tracing_core::metadata::Level::ERROR"><code>ERROR</code></a> and <a href="../../tracing_core/metadata/struct.Level.html#associatedconstant.WARN" title="associated constant tracing_core::metadata::Level::WARN"><code>WARN</code></a> levels to <code>stderr</code>, and data from spans or events
|
||||
at lower levels to stdout:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::io::{<span class="self">self</span>, Stdout, Stderr, StdoutLock, StderrLock};
|
||||
<span class="kw">use </span>tracing_subscriber::fmt::writer::MakeWriter;
|
||||
<span class="kw">use </span>tracing_core::{Metadata, Level};
|
||||
|
||||
<span class="kw">pub struct </span>MyMakeWriter {
|
||||
stdout: Stdout,
|
||||
stderr: Stderr,
|
||||
}
|
||||
|
||||
<span class="doccomment">/// A lock on either stdout or stderr, depending on the verbosity level
|
||||
/// of the event being written.
|
||||
</span><span class="kw">pub enum </span>StdioLock<<span class="lifetime">'a</span>> {
|
||||
Stdout(StdoutLock<<span class="lifetime">'a</span>>),
|
||||
Stderr(StderrLock<<span class="lifetime">'a</span>>),
|
||||
}
|
||||
|
||||
<span class="kw">impl</span><<span class="lifetime">'a</span>> io::Write <span class="kw">for </span>StdioLock<<span class="lifetime">'a</span>> {
|
||||
<span class="kw">fn </span>write(<span class="kw-2">&mut </span><span class="self">self</span>, buf: <span class="kw-2">&</span>[u8]) -> io::Result<usize> {
|
||||
<span class="kw">match </span><span class="self">self </span>{
|
||||
StdioLock::Stdout(lock) => lock.write(buf),
|
||||
StdioLock::Stderr(lock) => lock.write(buf),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>write_all(<span class="kw-2">&mut </span><span class="self">self</span>, buf: <span class="kw-2">&</span>[u8]) -> io::Result<()> {
|
||||
<span class="comment">// ...
|
||||
</span>}
|
||||
|
||||
<span class="kw">fn </span>flush(<span class="kw-2">&mut </span><span class="self">self</span>) -> io::Result<()> {
|
||||
<span class="comment">// ...
|
||||
</span>}
|
||||
}
|
||||
|
||||
<span class="kw">impl</span><<span class="lifetime">'a</span>> MakeWriter<<span class="lifetime">'a</span>> <span class="kw">for </span>MyMakeWriter {
|
||||
<span class="kw">type </span>Writer = StdioLock<<span class="lifetime">'a</span>>;
|
||||
|
||||
<span class="kw">fn </span>make_writer(<span class="kw-2">&</span><span class="lifetime">'a </span><span class="self">self</span>) -> <span class="self">Self</span>::Writer {
|
||||
<span class="comment">// We must have an implementation of `make_writer` that makes
|
||||
// a "default" writer without any configuring metadata. Let's
|
||||
// just return stdout in that case.
|
||||
</span>StdioLock::Stdout(<span class="self">self</span>.stdout.lock())
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>make_writer_for(<span class="kw-2">&</span><span class="lifetime">'a </span><span class="self">self</span>, meta: <span class="kw-2">&</span>Metadata<<span class="lifetime">'_</span>>) -> <span class="self">Self</span>::Writer {
|
||||
<span class="comment">// Here's where we can implement our special behavior. We'll
|
||||
// check if the metadata's verbosity level is WARN or ERROR,
|
||||
// and return stderr in that case.
|
||||
</span><span class="kw">if </span>meta.level() <= <span class="kw-2">&</span>Level::WARN {
|
||||
<span class="kw">return </span>StdioLock::Stderr(<span class="self">self</span>.stderr.lock());
|
||||
}
|
||||
|
||||
<span class="comment">// Otherwise, we'll return stdout.
|
||||
</span>StdioLock::Stdout(<span class="self">self</span>.stdout.lock())
|
||||
}
|
||||
}</code></pre></div>
|
||||
</div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-File" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#697-702">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-File" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/fs/struct.File.html" title="struct std::fs::File">File</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#698">Source</a><a href="#associatedtype.Writer-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = &'a <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/fs/struct.File.html" title="struct std::fs::File">File</a></h4></section><section id="method.make_writer" class="method trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#699-701">Source</a><a href="#method.make_writer" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.make_writer" class="fn">make_writer</a>(&'a self) -> Self::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-Arc%3CW%3E" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#687-695">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-Arc%3CW%3E" class="anchor">§</a><h3 class="code-header">impl<'a, W> <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/sync/struct.Arc.html" title="struct alloc::sync::Arc">Arc</a><W><div class="where">where
|
||||
<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&'a W</a>: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + 'a,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-2" class="associatedtype trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#691">Source</a><a href="#associatedtype.Writer-2" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&'a W</a></h4></section><section id="method.make_writer-1" class="method trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#692-694">Source</a><a href="#method.make_writer-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.make_writer" class="fn">make_writer</a>(&'a self) -> Self::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-Mutex%3CW%3E" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#792-801">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-Mutex%3CW%3E" class="anchor">§</a><h3 class="code-header">impl<'a, W> <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/sync/mutex/struct.Mutex.html" title="struct std::sync::mutex::Mutex">Mutex</a><W><div class="where">where
|
||||
W: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + 'a,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-3" class="associatedtype trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#796">Source</a><a href="#associatedtype.Writer-3" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="struct" href="writer/struct.MutexGuardWriter.html" title="struct tracing_subscriber::fmt::writer::MutexGuardWriter">MutexGuardWriter</a><'a, W></h4></section><section id="method.make_writer-2" class="method trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#798-800">Source</a><a href="#method.make_writer-2" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.make_writer" class="fn">make_writer</a>(&'a self) -> Self::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a></h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-TestWriter" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#725-731">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-TestWriter" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="struct.TestWriter.html" title="struct tracing_subscriber::fmt::TestWriter">TestWriter</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-4" class="associatedtype trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#726">Source</a><a href="#associatedtype.Writer-4" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="struct" href="struct.TestWriter.html" title="struct tracing_subscriber::fmt::TestWriter">TestWriter</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-BoxMakeWriter" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#757-769">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-BoxMakeWriter" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="writer/struct.BoxMakeWriter.html" title="struct tracing_subscriber::fmt::writer::BoxMakeWriter">BoxMakeWriter</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-5" class="associatedtype trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#758">Source</a><a href="#associatedtype.Writer-5" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <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="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + 'a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-Tee%3CA,+B%3E" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#1035-1051">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-Tee%3CA,+B%3E" class="anchor">§</a><h3 class="code-header">impl<'a, A, B> <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="writer/struct.Tee.html" title="struct tracing_subscriber::fmt::writer::Tee">Tee</a><A, B><div class="where">where
|
||||
A: <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>,
|
||||
B: <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-6" class="associatedtype trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#1040">Source</a><a href="#associatedtype.Writer-6" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="struct" href="writer/struct.Tee.html" title="struct tracing_subscriber::fmt::writer::Tee">Tee</a><<A as <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>>::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>, <B as <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>>::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-OrElse%3CA,+B%3E" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#1113-1136">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-OrElse%3CA,+B%3E" class="anchor">§</a><h3 class="code-header">impl<'a, A, B, W> <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="writer/struct.OrElse.html" title="struct tracing_subscriber::fmt::writer::OrElse">OrElse</a><A, B><div class="where">where
|
||||
A: <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a, Writer = <a class="type" href="writer/type.OptionalWriter.html" title="type tracing_subscriber::fmt::writer::OptionalWriter">OptionalWriter</a><W>>,
|
||||
B: <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>,
|
||||
W: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-7" class="associatedtype trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#1119">Source</a><a href="#associatedtype.Writer-7" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="enum" href="writer/enum.EitherWriter.html" title="enum tracing_subscriber::fmt::writer::EitherWriter">EitherWriter</a><W, <B as <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>>::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-F" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#675-685">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-F" class="anchor">§</a><h3 class="code-header">impl<'a, F, W> <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for 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>() -> W,
|
||||
W: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-8" class="associatedtype trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#680">Source</a><a href="#associatedtype.Writer-8" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = W</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-WithFilter%3CM,+F%3E" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#998-1018">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-WithFilter%3CM,+F%3E" class="anchor">§</a><h3 class="code-header">impl<'a, M, F> <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="writer/struct.WithFilter.html" title="struct tracing_subscriber::fmt::writer::WithFilter">WithFilter</a><M, F><div class="where">where
|
||||
M: <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>,
|
||||
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></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-9" class="associatedtype trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#1003">Source</a><a href="#associatedtype.Writer-9" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="enum" href="writer/enum.EitherWriter.html" title="enum tracing_subscriber::fmt::writer::EitherWriter">EitherWriter</a><<M as <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>>::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>, <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/util/struct.Sink.html" title="struct std::io::util::Sink">Sink</a>></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-WithMaxLevel%3CM%3E" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#928-944">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-WithMaxLevel%3CM%3E" class="anchor">§</a><h3 class="code-header">impl<'a, M: <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>> <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="writer/struct.WithMaxLevel.html" title="struct tracing_subscriber::fmt::writer::WithMaxLevel">WithMaxLevel</a><M></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-10" class="associatedtype trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#929">Source</a><a href="#associatedtype.Writer-10" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="enum" href="writer/enum.EitherWriter.html" title="enum tracing_subscriber::fmt::writer::EitherWriter">EitherWriter</a><<M as <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>>::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>, <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/util/struct.Sink.html" title="struct std::io::util::Sink">Sink</a>></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-WithMinLevel%3CM%3E" class="impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#961-977">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-WithMinLevel%3CM%3E" class="anchor">§</a><h3 class="code-header">impl<'a, M: <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>> <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="writer/struct.WithMinLevel.html" title="struct tracing_subscriber::fmt::writer::WithMinLevel">WithMinLevel</a><M></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-11" class="associatedtype trait-impl"><a class="src rightside" href="../../src/tracing_subscriber/fmt/writer.rs.html#962">Source</a><a href="#associatedtype.Writer-11" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="enum" href="writer/enum.EitherWriter.html" title="enum tracing_subscriber::fmt::writer::EitherWriter">EitherWriter</a><<M as <a class="trait" href="trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>>::<a class="associatedtype" href="trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>, <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/util/struct.Sink.html" title="struct std::io::util::Sink">Sink</a>></h4></section></div></details></div><script src="../../trait.impl/tracing_subscriber/fmt/writer/trait.MakeWriter.js" data-ignore-extern-crates="alloc,std" async></script></section></div></main></body></html>
|
||||
3
tracing_subscriber/fmt/type.Formatter.html
Normal file
3
tracing_subscriber/fmt/type.Formatter.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<!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 `Subscriber` that logs formatted representations of `tracing` events. This type only logs formatted events; it does not perform any filtering."><title>Formatter in tracing_subscriber::fmt - 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 type"><!--[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="#">Formatter</a></h2><h3><a href="#aliased-type">Aliased type</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt</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">fmt</a></span><h1>Type Alias <span class="type">Formatter</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/fmt/mod.rs.html#237-241">Source</a> </span></div><pre class="rust item-decl"><code>pub type Formatter<N = <a class="struct" href="format/struct.DefaultFields.html" title="struct tracing_subscriber::fmt::format::DefaultFields">DefaultFields</a>, E = <a class="struct" href="format/struct.Format.html" title="struct tracing_subscriber::fmt::format::Format">Format</a><<a class="struct" href="format/struct.Full.html" title="struct tracing_subscriber::fmt::format::Full">Full</a>>, W = <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.fn.html">fn</a>() -> <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/stdio/struct.Stdout.html" title="struct std::io::stdio::Stdout">Stdout</a>> = <a class="struct" href="../layer/struct.Layered.html" title="struct tracing_subscriber::layer::Layered">Layered</a><<a class="struct" href="struct.Layer.html" title="struct tracing_subscriber::fmt::Layer">Layer</a><<a class="struct" href="../registry/struct.Registry.html" title="struct tracing_subscriber::registry::Registry">Registry</a>, N, E, W>, <a class="struct" href="../registry/struct.Registry.html" title="struct tracing_subscriber::registry::Registry">Registry</a>>;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A <code>Subscriber</code> that logs formatted representations of <code>tracing</code> events.
|
||||
This type only logs formatted events; it does not perform any filtering.</p>
|
||||
</div></details><h2 id="aliased-type" class="section-header">Aliased Type<a href="#aliased-type" class="anchor">§</a></h2><pre class="rust item-decl"><code>struct Formatter<N = <a class="struct" href="format/struct.DefaultFields.html" title="struct tracing_subscriber::fmt::format::DefaultFields">DefaultFields</a>, E = <a class="struct" href="format/struct.Format.html" title="struct tracing_subscriber::fmt::format::Format">Format</a><<a class="struct" href="format/struct.Full.html" title="struct tracing_subscriber::fmt::format::Full">Full</a>>, W = <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.fn.html">fn</a>() -> <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/stdio/struct.Stdout.html" title="struct std::io::stdio::Stdout">Stdout</a>> { <span class="comment">/* private fields */</span> }</code></pre><script src="../../type.impl/tracing_subscriber/layer/struct.Layered.js" data-self-path="tracing_subscriber::fmt::Formatter" async></script></section></div></main></body></html>
|
||||
45
tracing_subscriber/fmt/writer/enum.EitherWriter.html
Normal file
45
tracing_subscriber/fmt/writer/enum.EitherWriter.html
Normal file
File diff suppressed because one or more lines are too long
12
tracing_subscriber/fmt/writer/index.html
Normal file
12
tracing_subscriber/fmt/writer/index.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<!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="Abstractions for creating `io::Write` instances."><title>tracing_subscriber::fmt::writer - 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 writer</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In tracing_<wbr>subscriber::<wbr>fmt</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">fmt</a></span><h1>Module <span>writer</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/fmt/writer.rs.html#1-1467">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Abstractions for creating <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a> instances.</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.BoxMakeWriter.html" title="struct tracing_subscriber::fmt::writer::BoxMakeWriter">BoxMake<wbr>Writer</a></div><div class="desc docblock-short">A writer that erases the specific <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a> and <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> types being used.</div></li><li><div class="item-name"><a class="struct" href="struct.MutexGuardWriter.html" title="struct tracing_subscriber::fmt::writer::MutexGuardWriter">Mutex<wbr>Guard<wbr>Writer</a></div><div class="desc docblock-short">A type implementing <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a> for a <a href="https://doc.rust-lang.org/1.84.1/std/sync/mutex/struct.MutexGuard.html" title="struct std::sync::mutex::MutexGuard"><code>MutexGuard</code></a> where the type
|
||||
inside the <a href="https://doc.rust-lang.org/1.84.1/std/sync/mutex/struct.Mutex.html" title="struct std::sync::mutex::Mutex"><code>Mutex</code></a> implements <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.OrElse.html" title="struct tracing_subscriber::fmt::writer::OrElse">OrElse</a></div><div class="desc docblock-short">Combines a <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> that returns an <a href="type.OptionalWriter.html" title="type tracing_subscriber::fmt::writer::OptionalWriter"><code>OptionalWriter</code></a> with another
|
||||
<a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a>, so that the second <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> is used when the first
|
||||
<a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> returns <a href="enum.EitherWriter.html#method.none" title="associated function tracing_subscriber::fmt::writer::EitherWriter::none"><code>OptionalWriter::none</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.Tee.html" title="struct tracing_subscriber::fmt::writer::Tee">Tee</a></div><div class="desc docblock-short">Combines two types implementing <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> (or <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>std::io::Write</code></a>) to
|
||||
produce a writer that writes to both <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a>’s returned writers.</div></li><li><div class="item-name"><a class="struct" href="struct.TestWriter.html" title="struct tracing_subscriber::fmt::writer::TestWriter">Test<wbr>Writer</a></div><div class="desc docblock-short">A writer intended to support <a href="https://doc.rust-lang.org/book/ch11-02-running-tests.html#showing-function-output"><code>libtest</code>’s output capturing</a> for use in unit tests.</div></li><li><div class="item-name"><a class="struct" href="struct.WithFilter.html" title="struct tracing_subscriber::fmt::writer::WithFilter">With<wbr>Filter</a></div><div class="desc docblock-short">A <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> combinator that wraps a <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> with a predicate for
|
||||
span and event <a href="../../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata"><code>Metadata</code></a>, so that the <a href="../trait.MakeWriter.html#method.make_writer_for" title="method tracing_subscriber::fmt::MakeWriter::make_writer_for"><code>MakeWriter::make_writer_for</code></a>
|
||||
method returns <a href="enum.EitherWriter.html#method.some" title="associated function tracing_subscriber::fmt::writer::EitherWriter::some"><code>OptionalWriter::some</code></a> when the predicate returns <code>true</code>,
|
||||
and <a href="enum.EitherWriter.html#method.none" title="associated function tracing_subscriber::fmt::writer::EitherWriter::none"><code>OptionalWriter::none</code></a> when the predicate returns <code>false</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.WithMaxLevel.html" title="struct tracing_subscriber::fmt::writer::WithMaxLevel">With<wbr>MaxLevel</a></div><div class="desc docblock-short">A <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> combinator that only returns an enabled <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">writer</a> for spans
|
||||
and events with metadata at or below a specified 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.WithMinLevel.html" title="struct tracing_subscriber::fmt::writer::WithMinLevel">With<wbr>MinLevel</a></div><div class="desc docblock-short">A <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> combinator that only returns an enabled <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">writer</a> for spans
|
||||
and events with metadata at or above a specified verbosity <a href="../../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level"><code>Level</code></a>.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.EitherWriter.html" title="enum tracing_subscriber::fmt::writer::EitherWriter">Either<wbr>Writer</a></div><div class="desc docblock-short">A <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">writer</a> that is one of two types implementing <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a>.</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.MakeWriter.html" title="trait tracing_subscriber::fmt::writer::MakeWriter">Make<wbr>Writer</a></div><div class="desc docblock-short">A type that can create <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a> instances.</div></li><li><div class="item-name"><a class="trait" href="trait.MakeWriterExt.html" title="trait tracing_subscriber::fmt::writer::MakeWriterExt">Make<wbr>Writer<wbr>Ext</a></div><div class="desc docblock-short">Extension trait adding combinators for working with types implementing
|
||||
<a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a>.</div></li></ul><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="type" href="type.OptionalWriter.html" title="type tracing_subscriber::fmt::writer::OptionalWriter">Optional<wbr>Writer</a></div><div class="desc docblock-short">A <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">writer</a> which may or may not be enabled.</div></li></ul></section></div></main></body></html>
|
||||
1
tracing_subscriber/fmt/writer/sidebar-items.js
Normal file
1
tracing_subscriber/fmt/writer/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"enum":["EitherWriter"],"struct":["BoxMakeWriter","MutexGuardWriter","OrElse","Tee","TestWriter","WithFilter","WithMaxLevel","WithMinLevel"],"trait":["MakeWriter","MakeWriterExt"],"type":["OptionalWriter"]};
|
||||
50
tracing_subscriber/fmt/writer/struct.BoxMakeWriter.html
Normal file
50
tracing_subscriber/fmt/writer/struct.BoxMakeWriter.html
Normal file
File diff suppressed because one or more lines are too long
24
tracing_subscriber/fmt/writer/struct.MutexGuardWriter.html
Normal file
24
tracing_subscriber/fmt/writer/struct.MutexGuardWriter.html
Normal file
File diff suppressed because one or more lines are too long
59
tracing_subscriber/fmt/writer/struct.OrElse.html
Normal file
59
tracing_subscriber/fmt/writer/struct.OrElse.html
Normal file
File diff suppressed because one or more lines are too long
63
tracing_subscriber/fmt/writer/struct.Tee.html
Normal file
63
tracing_subscriber/fmt/writer/struct.Tee.html
Normal file
File diff suppressed because one or more lines are too long
43
tracing_subscriber/fmt/writer/struct.TestWriter.html
Normal file
43
tracing_subscriber/fmt/writer/struct.TestWriter.html
Normal file
File diff suppressed because one or more lines are too long
60
tracing_subscriber/fmt/writer/struct.WithFilter.html
Normal file
60
tracing_subscriber/fmt/writer/struct.WithFilter.html
Normal file
File diff suppressed because one or more lines are too long
49
tracing_subscriber/fmt/writer/struct.WithMaxLevel.html
Normal file
49
tracing_subscriber/fmt/writer/struct.WithMaxLevel.html
Normal file
File diff suppressed because one or more lines are too long
49
tracing_subscriber/fmt/writer/struct.WithMinLevel.html
Normal file
49
tracing_subscriber/fmt/writer/struct.WithMinLevel.html
Normal file
File diff suppressed because one or more lines are too long
147
tracing_subscriber/fmt/writer/trait.MakeWriter.html
Normal file
147
tracing_subscriber/fmt/writer/trait.MakeWriter.html
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
<!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 type that can create `io::Write` instances."><title>MakeWriter in tracing_subscriber::fmt::writer - 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="#">Make<wbr>Writer</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Writer" title="Writer">Writer</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.make_writer" title="make_writer">make_writer</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.make_writer_for" title="make_writer_for">make_writer_for</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-MakeWriter%3C'a%3E-for-Arc%3CW%3E" title="Arc<W>">Arc<W></a></li><li><a href="#impl-MakeWriter%3C'a%3E-for-File" title="File">File</a></li><li><a href="#impl-MakeWriter%3C'a%3E-for-Mutex%3CW%3E" title="Mutex<W>">Mutex<W></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>fmt::<wbr>writer</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">fmt</a>::<wbr><a href="index.html">writer</a></span><h1>Trait <span class="trait">MakeWriter</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/fmt/writer.rs.html#95-209">Source</a> </span></div><pre class="rust item-decl"><code>pub trait MakeWriter<'a> {
|
||||
type <a href="#associatedtype.Writer" class="associatedtype">Writer</a>: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a>;
|
||||
|
||||
// Required method
|
||||
fn <a href="#tymethod.make_writer" class="fn">make_writer</a>(&'a self) -> Self::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>;
|
||||
|
||||
// Provided method
|
||||
fn <a href="#method.make_writer_for" class="fn">make_writer_for</a>(&'a self, meta: &<a class="struct" href="../../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata">Metadata</a><'_>) -> Self::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a> { ... }
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A type that can create <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a> instances.</p>
|
||||
<p><code>MakeWriter</code> is used by <a href="../struct.Layer.html" title="struct tracing_subscriber::fmt::Layer"><code>fmt::Layer</code></a> or <a href="../struct.Subscriber.html" title="struct tracing_subscriber::fmt::Subscriber"><code>fmt::Subscriber</code></a> to print
|
||||
formatted text representations of <a href="../../../tracing_core/event/struct.Event.html" title="struct tracing_core::event::Event"><code>Event</code></a>s.</p>
|
||||
<p>This trait is already implemented for function pointers and
|
||||
immutably-borrowing closures that return an instance of <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a>, such
|
||||
as <a href="https://doc.rust-lang.org/1.84.1/std/io/stdio/fn.stdout.html" title="fn std::io::stdio::stdout"><code>io::stdout</code></a> and <a href="https://doc.rust-lang.org/1.84.1/std/io/stdio/fn.stderr.html" title="fn std::io::stdio::stderr"><code>io::stderr</code></a>. Additionally, it is implemented for
|
||||
<a href="https://doc.rust-lang.org/1.84.1/std/sync/mutex/struct.Mutex.html" title="struct std::sync::mutex::Mutex"><code>std::sync::Mutex</code></a> when the type inside the mutex implements
|
||||
<a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a>.</p>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<p>The simplest usage is to pass in a named function that returns a writer. For
|
||||
example, to log all events to stderr, we could write:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>subscriber = tracing_subscriber::fmt()
|
||||
.with_writer(std::io::stderr)
|
||||
.finish();</code></pre></div>
|
||||
<p>Any function that returns a writer can be used:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>make_my_great_writer() -> <span class="kw">impl </span>std::io::Write {
|
||||
<span class="comment">// ...
|
||||
</span>}
|
||||
|
||||
<span class="kw">let </span>subscriber = tracing_subscriber::fmt()
|
||||
.with_writer(make_my_great_writer)
|
||||
.finish();</code></pre></div>
|
||||
<p>A closure can be used to introduce arbitrary logic into how the writer is
|
||||
created. Consider the (admittedly rather silly) example of sending every 5th
|
||||
event to stderr, and all other events to stdout:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::io;
|
||||
<span class="kw">use </span>std::sync::atomic::{AtomicUsize, Ordering::Relaxed};
|
||||
|
||||
<span class="kw">let </span>n = AtomicUsize::new(<span class="number">0</span>);
|
||||
<span class="kw">let </span>subscriber = tracing_subscriber::fmt()
|
||||
.with_writer(<span class="kw">move </span>|| -> Box<<span class="kw">dyn </span>io::Write> {
|
||||
<span class="kw">if </span>n.fetch_add(<span class="number">1</span>, Relaxed) % <span class="number">5 </span>== <span class="number">0 </span>{
|
||||
Box::new(io::stderr())
|
||||
} <span class="kw">else </span>{
|
||||
Box::new(io::stdout())
|
||||
}
|
||||
})
|
||||
.finish();</code></pre></div>
|
||||
<p>A single instance of a type implementing <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a> may be used as a
|
||||
<code>MakeWriter</code> by wrapping it in a <a href="https://doc.rust-lang.org/1.84.1/std/sync/mutex/struct.Mutex.html" title="struct std::sync::mutex::Mutex"><code>Mutex</code></a>. For example, we could
|
||||
write to a file like so:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::{fs::File, sync::Mutex};
|
||||
|
||||
<span class="kw">let </span>log_file = File::create(<span class="string">"my_cool_trace.log"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>subscriber = tracing_subscriber::fmt()
|
||||
.with_writer(Mutex::new(log_file))
|
||||
.finish();</code></pre></div>
|
||||
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Writer" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#100">Source</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a>: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a></h4></section></summary><div class="docblock"><p>The concrete <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a> implementation returned by <a href="../trait.MakeWriter.html#tymethod.make_writer" title="method tracing_subscriber::fmt::MakeWriter::make_writer"><code>make_writer</code></a>.</p>
|
||||
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.make_writer" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#115">Source</a><h4 class="code-header">fn <a href="#tymethod.make_writer" class="fn">make_writer</a>(&'a self) -> Self::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a></h4></section></summary><div class="docblock"><p>Returns an instance of <a href="../trait.MakeWriter.html#associatedtype.Writer" title="associated type tracing_subscriber::fmt::MakeWriter::Writer"><code>Writer</code></a>.</p>
|
||||
<h5 id="implementer-notes"><a class="doc-anchor" href="#implementer-notes">§</a>Implementer notes</h5>
|
||||
<p><a href="../struct.Layer.html" title="struct tracing_subscriber::fmt::Layer"><code>fmt::Layer</code></a> or <a href="../struct.Subscriber.html" title="struct tracing_subscriber::fmt::Subscriber"><code>fmt::Subscriber</code></a> will call this method each time an event is recorded. Ensure any state
|
||||
that must be saved across writes is not lost when the <a href="../trait.MakeWriter.html#associatedtype.Writer" title="associated type tracing_subscriber::fmt::MakeWriter::Writer"><code>Writer</code></a> instance is dropped. If
|
||||
creating a <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write"><code>io::Write</code></a> instance is expensive, be sure to cache it when implementing
|
||||
<a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> to improve performance.</p>
|
||||
</div></details></div><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.make_writer_for" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#205-208">Source</a><h4 class="code-header">fn <a href="#method.make_writer_for" class="fn">make_writer_for</a>(&'a self, meta: &<a class="struct" href="../../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata">Metadata</a><'_>) -> Self::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a></h4></section></summary><div class="docblock"><p>Returns a <a href="../trait.MakeWriter.html#associatedtype.Writer" title="associated type tracing_subscriber::fmt::MakeWriter::Writer"><code>Writer</code></a> for writing data from the span or event described
|
||||
by the provided <a href="../../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata"><code>Metadata</code></a>.</p>
|
||||
<p>By default, this calls <a href="../trait.MakeWriter.html#tymethod.make_writer" title="method tracing_subscriber::fmt::MakeWriter::make_writer"><code>self.make_writer()</code></a>, ignoring
|
||||
the provided metadata, but implementations can override this to provide
|
||||
metadata-specific behaviors.</p>
|
||||
<p>This method allows <code>MakeWriter</code> implementations to implement different
|
||||
behaviors based on the span or event being written. The <code>MakeWriter</code>
|
||||
type might return different writers based on the provided metadata, or
|
||||
might write some values to the writer before or after providing it to
|
||||
the caller.</p>
|
||||
<p>For example, we might want to write data from spans and events at the
|
||||
<a href="../../../tracing_core/metadata/struct.Level.html#associatedconstant.ERROR" title="associated constant tracing_core::metadata::Level::ERROR"><code>ERROR</code></a> and <a href="../../../tracing_core/metadata/struct.Level.html#associatedconstant.WARN" title="associated constant tracing_core::metadata::Level::WARN"><code>WARN</code></a> levels to <code>stderr</code>, and data from spans or events
|
||||
at lower levels to stdout:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::io::{<span class="self">self</span>, Stdout, Stderr, StdoutLock, StderrLock};
|
||||
<span class="kw">use </span>tracing_subscriber::fmt::writer::MakeWriter;
|
||||
<span class="kw">use </span>tracing_core::{Metadata, Level};
|
||||
|
||||
<span class="kw">pub struct </span>MyMakeWriter {
|
||||
stdout: Stdout,
|
||||
stderr: Stderr,
|
||||
}
|
||||
|
||||
<span class="doccomment">/// A lock on either stdout or stderr, depending on the verbosity level
|
||||
/// of the event being written.
|
||||
</span><span class="kw">pub enum </span>StdioLock<<span class="lifetime">'a</span>> {
|
||||
Stdout(StdoutLock<<span class="lifetime">'a</span>>),
|
||||
Stderr(StderrLock<<span class="lifetime">'a</span>>),
|
||||
}
|
||||
|
||||
<span class="kw">impl</span><<span class="lifetime">'a</span>> io::Write <span class="kw">for </span>StdioLock<<span class="lifetime">'a</span>> {
|
||||
<span class="kw">fn </span>write(<span class="kw-2">&mut </span><span class="self">self</span>, buf: <span class="kw-2">&</span>[u8]) -> io::Result<usize> {
|
||||
<span class="kw">match </span><span class="self">self </span>{
|
||||
StdioLock::Stdout(lock) => lock.write(buf),
|
||||
StdioLock::Stderr(lock) => lock.write(buf),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>write_all(<span class="kw-2">&mut </span><span class="self">self</span>, buf: <span class="kw-2">&</span>[u8]) -> io::Result<()> {
|
||||
<span class="comment">// ...
|
||||
</span>}
|
||||
|
||||
<span class="kw">fn </span>flush(<span class="kw-2">&mut </span><span class="self">self</span>) -> io::Result<()> {
|
||||
<span class="comment">// ...
|
||||
</span>}
|
||||
}
|
||||
|
||||
<span class="kw">impl</span><<span class="lifetime">'a</span>> MakeWriter<<span class="lifetime">'a</span>> <span class="kw">for </span>MyMakeWriter {
|
||||
<span class="kw">type </span>Writer = StdioLock<<span class="lifetime">'a</span>>;
|
||||
|
||||
<span class="kw">fn </span>make_writer(<span class="kw-2">&</span><span class="lifetime">'a </span><span class="self">self</span>) -> <span class="self">Self</span>::Writer {
|
||||
<span class="comment">// We must have an implementation of `make_writer` that makes
|
||||
// a "default" writer without any configuring metadata. Let's
|
||||
// just return stdout in that case.
|
||||
</span>StdioLock::Stdout(<span class="self">self</span>.stdout.lock())
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>make_writer_for(<span class="kw-2">&</span><span class="lifetime">'a </span><span class="self">self</span>, meta: <span class="kw-2">&</span>Metadata<<span class="lifetime">'_</span>>) -> <span class="self">Self</span>::Writer {
|
||||
<span class="comment">// Here's where we can implement our special behavior. We'll
|
||||
// check if the metadata's verbosity level is WARN or ERROR,
|
||||
// and return stderr in that case.
|
||||
</span><span class="kw">if </span>meta.level() <= <span class="kw-2">&</span>Level::WARN {
|
||||
<span class="kw">return </span>StdioLock::Stderr(<span class="self">self</span>.stderr.lock());
|
||||
}
|
||||
|
||||
<span class="comment">// Otherwise, we'll return stdout.
|
||||
</span>StdioLock::Stdout(<span class="self">self</span>.stdout.lock())
|
||||
}
|
||||
}</code></pre></div>
|
||||
</div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-File" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#697-702">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-File" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/fs/struct.File.html" title="struct std::fs::File">File</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-1" class="associatedtype trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#698">Source</a><a href="#associatedtype.Writer-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = &'a <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/fs/struct.File.html" title="struct std::fs::File">File</a></h4></section><section id="method.make_writer" class="method trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#699-701">Source</a><a href="#method.make_writer" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.make_writer" class="fn">make_writer</a>(&'a self) -> Self::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-Arc%3CW%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#687-695">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-Arc%3CW%3E" class="anchor">§</a><h3 class="code-header">impl<'a, W> <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/sync/struct.Arc.html" title="struct alloc::sync::Arc">Arc</a><W><div class="where">where
|
||||
<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&'a W</a>: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + 'a,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-2" class="associatedtype trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#691">Source</a><a href="#associatedtype.Writer-2" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&'a W</a></h4></section><section id="method.make_writer-1" class="method trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#692-694">Source</a><a href="#method.make_writer-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.make_writer" class="fn">make_writer</a>(&'a self) -> Self::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-Mutex%3CW%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#792-801">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-Mutex%3CW%3E" class="anchor">§</a><h3 class="code-header">impl<'a, W> <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/sync/mutex/struct.Mutex.html" title="struct std::sync::mutex::Mutex">Mutex</a><W><div class="where">where
|
||||
W: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + 'a,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-3" class="associatedtype trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#796">Source</a><a href="#associatedtype.Writer-3" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="struct" href="struct.MutexGuardWriter.html" title="struct tracing_subscriber::fmt::writer::MutexGuardWriter">MutexGuardWriter</a><'a, W></h4></section><section id="method.make_writer-2" class="method trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#798-800">Source</a><a href="#method.make_writer-2" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.make_writer" class="fn">make_writer</a>(&'a self) -> Self::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a></h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-TestWriter" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#725-731">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-TestWriter" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="../struct.TestWriter.html" title="struct tracing_subscriber::fmt::TestWriter">TestWriter</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-4" class="associatedtype trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#726">Source</a><a href="#associatedtype.Writer-4" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="struct" href="../struct.TestWriter.html" title="struct tracing_subscriber::fmt::TestWriter">TestWriter</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-BoxMakeWriter" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#757-769">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-BoxMakeWriter" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="struct.BoxMakeWriter.html" title="struct tracing_subscriber::fmt::writer::BoxMakeWriter">BoxMakeWriter</a></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-5" class="associatedtype trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#758">Source</a><a href="#associatedtype.Writer-5" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <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="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + 'a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-Tee%3CA,+B%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#1035-1051">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-Tee%3CA,+B%3E" class="anchor">§</a><h3 class="code-header">impl<'a, A, B> <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="struct.Tee.html" title="struct tracing_subscriber::fmt::writer::Tee">Tee</a><A, B><div class="where">where
|
||||
A: <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>,
|
||||
B: <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-6" class="associatedtype trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#1040">Source</a><a href="#associatedtype.Writer-6" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="struct" href="struct.Tee.html" title="struct tracing_subscriber::fmt::writer::Tee">Tee</a><<A as <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>>::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>, <B as <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>>::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-OrElse%3CA,+B%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#1113-1136">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-OrElse%3CA,+B%3E" class="anchor">§</a><h3 class="code-header">impl<'a, A, B, W> <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="struct.OrElse.html" title="struct tracing_subscriber::fmt::writer::OrElse">OrElse</a><A, B><div class="where">where
|
||||
A: <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a, Writer = <a class="type" href="type.OptionalWriter.html" title="type tracing_subscriber::fmt::writer::OptionalWriter">OptionalWriter</a><W>>,
|
||||
B: <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>,
|
||||
W: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-7" class="associatedtype trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#1119">Source</a><a href="#associatedtype.Writer-7" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="enum" href="enum.EitherWriter.html" title="enum tracing_subscriber::fmt::writer::EitherWriter">EitherWriter</a><W, <B as <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>>::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-F" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#675-685">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-F" class="anchor">§</a><h3 class="code-header">impl<'a, F, W> <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for 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>() -> W,
|
||||
W: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-8" class="associatedtype trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#680">Source</a><a href="#associatedtype.Writer-8" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = W</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-WithFilter%3CM,+F%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#998-1018">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-WithFilter%3CM,+F%3E" class="anchor">§</a><h3 class="code-header">impl<'a, M, F> <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="struct.WithFilter.html" title="struct tracing_subscriber::fmt::writer::WithFilter">WithFilter</a><M, F><div class="where">where
|
||||
M: <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>,
|
||||
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></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-9" class="associatedtype trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#1003">Source</a><a href="#associatedtype.Writer-9" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="enum" href="enum.EitherWriter.html" title="enum tracing_subscriber::fmt::writer::EitherWriter">EitherWriter</a><<M as <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>>::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>, <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/util/struct.Sink.html" title="struct std::io::util::Sink">Sink</a>></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-WithMaxLevel%3CM%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#928-944">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-WithMaxLevel%3CM%3E" class="anchor">§</a><h3 class="code-header">impl<'a, M: <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>> <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="struct.WithMaxLevel.html" title="struct tracing_subscriber::fmt::writer::WithMaxLevel">WithMaxLevel</a><M></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-10" class="associatedtype trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#929">Source</a><a href="#associatedtype.Writer-10" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="enum" href="enum.EitherWriter.html" title="enum tracing_subscriber::fmt::writer::EitherWriter">EitherWriter</a><<M as <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>>::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>, <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/util/struct.Sink.html" title="struct std::io::util::Sink">Sink</a>></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-MakeWriter%3C'a%3E-for-WithMinLevel%3CM%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#961-977">Source</a><a href="#impl-MakeWriter%3C'a%3E-for-WithMinLevel%3CM%3E" class="anchor">§</a><h3 class="code-header">impl<'a, M: <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>> <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> for <a class="struct" href="struct.WithMinLevel.html" title="struct tracing_subscriber::fmt::writer::WithMinLevel">WithMinLevel</a><M></h3></section></summary><div class="impl-items"><section id="associatedtype.Writer-11" class="associatedtype trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#962">Source</a><a href="#associatedtype.Writer-11" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Writer" class="associatedtype">Writer</a> = <a class="enum" href="enum.EitherWriter.html" title="enum tracing_subscriber::fmt::writer::EitherWriter">EitherWriter</a><<M as <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>>::<a class="associatedtype" href="../trait.MakeWriter.html#associatedtype.Writer" title="type tracing_subscriber::fmt::MakeWriter::Writer">Writer</a>, <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/util/struct.Sink.html" title="struct std::io::util::Sink">Sink</a>></h4></section></div></details></div><script src="../../../trait.impl/tracing_subscriber/fmt/writer/trait.MakeWriter.js" data-ignore-extern-crates="alloc,std" async></script></section></div></main></body></html>
|
||||
194
tracing_subscriber/fmt/writer/trait.MakeWriterExt.html
Normal file
194
tracing_subscriber/fmt/writer/trait.MakeWriterExt.html
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
<!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 working with types implementing `MakeWriter`."><title>MakeWriterExt in tracing_subscriber::fmt::writer - 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="#">Make<wbr>Writer<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.or_else" title="or_else">or_else</a></li><li><a href="#method.with_filter" title="with_filter">with_filter</a></li><li><a href="#method.with_max_level" title="with_max_level">with_max_level</a></li><li><a href="#method.with_min_level" title="with_min_level">with_min_level</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>fmt::<wbr>writer</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">fmt</a>::<wbr><a href="index.html">writer</a></span><h1>Trait <span class="trait">MakeWriterExt</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/fmt/writer.rs.html#217-491">Source</a> </span></div><pre class="rust item-decl"><code>pub trait MakeWriterExt<'a>: <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> {
|
||||
// Provided methods
|
||||
fn <a href="#method.with_max_level" class="fn">with_max_level</a>(self, level: <a class="struct" href="../../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level">Level</a>) -> <a class="struct" href="struct.WithMaxLevel.html" title="struct tracing_subscriber::fmt::writer::WithMaxLevel">WithMaxLevel</a><Self>
|
||||
<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.with_min_level" class="fn">with_min_level</a>(self, level: <a class="struct" href="../../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level">Level</a>) -> <a class="struct" href="struct.WithMinLevel.html" title="struct tracing_subscriber::fmt::writer::WithMinLevel">WithMinLevel</a><Self>
|
||||
<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.with_filter" class="fn">with_filter</a><F>(self, filter: F) -> <a class="struct" href="struct.WithFilter.html" title="struct tracing_subscriber::fmt::writer::WithFilter">WithFilter</a><Self, F>
|
||||
<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>,
|
||||
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></span> { ... }
|
||||
<span class="item-spacer"></span> fn <a href="#method.and" class="fn">and</a><B>(self, other: B) -> <a class="struct" href="struct.Tee.html" title="struct tracing_subscriber::fmt::writer::Tee">Tee</a><Self, B> <a href="#" class="tooltip" data-notable-ty="Tee<Self, B>">ⓘ</a>
|
||||
<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="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> + <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.or_else" class="fn">or_else</a><W, B>(self, other: B) -> <a class="struct" href="struct.OrElse.html" title="struct tracing_subscriber::fmt::writer::OrElse">OrElse</a><Self, B>
|
||||
<span class="where">where Self: <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a, Writer = <a class="type" href="type.OptionalWriter.html" title="type tracing_subscriber::fmt::writer::OptionalWriter">OptionalWriter</a><W>> + <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="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
||||
W: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a></span> { ... }
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Extension trait adding combinators for working with types implementing
|
||||
<a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a>.</p>
|
||||
<p>This is not intended to be implemented directly for user-defined
|
||||
<a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a>s; instead, it should be imported when the desired methods are
|
||||
used.</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.with_max_level" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#276-281">Source</a><h4 class="code-header">fn <a href="#method.with_max_level" class="fn">with_max_level</a>(self, level: <a class="struct" href="../../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level">Level</a>) -> <a class="struct" href="struct.WithMaxLevel.html" title="struct tracing_subscriber::fmt::writer::WithMaxLevel">WithMaxLevel</a><Self><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>Wraps <code>self</code> and returns a <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> that will only write output
|
||||
for events at or below the provided verbosity <a href="../../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level"><code>Level</code></a>. For instance,
|
||||
<code>Level::TRACE</code> is considered to be _more verbose<code>than</code>Level::INFO`.</p>
|
||||
<p>Events whose level is more verbose than <code>level</code> will be ignored, and no
|
||||
output will be written.</p>
|
||||
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::Level;
|
||||
<span class="kw">use </span>tracing_subscriber::fmt::writer::MakeWriterExt;
|
||||
|
||||
<span class="comment">// Construct a writer that outputs events to `stderr` only if the span or
|
||||
// event's level is >= WARN (WARN and ERROR).
|
||||
</span><span class="kw">let </span>mk_writer = std::io::stderr.with_max_level(Level::WARN);
|
||||
|
||||
tracing_subscriber::fmt().with_writer(mk_writer).init();</code></pre></div>
|
||||
<p>Writing the <code>ERROR</code> and <code>WARN</code> levels to <code>stderr</code>, and everything else
|
||||
to <code>stdout</code>:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
|
||||
<span class="kw">let </span>mk_writer = std::io::stderr
|
||||
.with_max_level(Level::WARN)
|
||||
.or_else(std::io::stdout);
|
||||
|
||||
tracing_subscriber::fmt().with_writer(mk_writer).init();</code></pre></div>
|
||||
<p>Writing the <code>ERROR</code> level to <code>stderr</code>, the <code>INFO</code> and <code>WARN</code> levels to
|
||||
<code>stdout</code>, and the <code>INFO</code> and DEBUG` levels to a file:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::{sync::Arc, fs::File};
|
||||
<span class="kw">let </span>debug_log = Arc::new(File::create(<span class="string">"debug.log"</span>)<span class="question-mark">?</span>);
|
||||
|
||||
<span class="kw">let </span>mk_writer = std::io::stderr
|
||||
.with_max_level(Level::ERROR)
|
||||
.or_else(std::io::stdout
|
||||
.with_max_level(Level::INFO)
|
||||
.and(debug_log.with_max_level(Level::DEBUG))
|
||||
);
|
||||
|
||||
tracing_subscriber::fmt().with_writer(mk_writer).init();</code></pre></div>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.with_min_level" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#318-323">Source</a><h4 class="code-header">fn <a href="#method.with_min_level" class="fn">with_min_level</a>(self, level: <a class="struct" href="../../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level">Level</a>) -> <a class="struct" href="struct.WithMinLevel.html" title="struct tracing_subscriber::fmt::writer::WithMinLevel">WithMinLevel</a><Self><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>Wraps <code>self</code> and returns a <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> that will only write output
|
||||
for events at or above the provided verbosity <a href="../../../tracing_core/metadata/struct.Level.html" title="struct tracing_core::metadata::Level"><code>Level</code></a>.</p>
|
||||
<p>Events whose level is less verbose than <code>level</code> will be ignored, and no
|
||||
output will be written.</p>
|
||||
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::Level;
|
||||
<span class="kw">use </span>tracing_subscriber::fmt::writer::MakeWriterExt;
|
||||
|
||||
<span class="comment">// Construct a writer that outputs events to `stdout` only if the span or
|
||||
// event's level is <= DEBUG (DEBUG and TRACE).
|
||||
</span><span class="kw">let </span>mk_writer = std::io::stdout.with_min_level(Level::DEBUG);
|
||||
|
||||
tracing_subscriber::fmt().with_writer(mk_writer).init();</code></pre></div>
|
||||
<p>This can be combined with <a href="trait.MakeWriterExt.html#method.with_max_level" title="method tracing_subscriber::fmt::writer::MakeWriterExt::with_max_level"><code>MakeWriterExt::with_max_level</code></a> to write
|
||||
only within a range of levels:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Only write the `DEBUG` and `INFO` levels to stdout.
|
||||
</span><span class="kw">let </span>mk_writer = std::io::stdout
|
||||
.with_max_level(Level::DEBUG)
|
||||
.with_min_level(Level::INFO)
|
||||
<span class="comment">// Write the `WARN` and `ERROR` levels to stderr.
|
||||
</span>.and(std::io::stderr.with_min_level(Level::WARN));
|
||||
|
||||
tracing_subscriber::fmt().with_writer(mk_writer).init();</code></pre></div>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.with_filter" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#397-403">Source</a><h4 class="code-header">fn <a href="#method.with_filter" class="fn">with_filter</a><F>(self, filter: F) -> <a class="struct" href="struct.WithFilter.html" title="struct tracing_subscriber::fmt::writer::WithFilter">WithFilter</a><Self, F><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>,
|
||||
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></h4></section></summary><div class="docblock"><p>Wraps <code>self</code> with a predicate that takes a span or event’s <a href="../../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata"><code>Metadata</code></a>
|
||||
and returns a <code>bool</code>. The returned <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a>’s
|
||||
<a href="../trait.MakeWriter.html#method.make_writer_for" title="method tracing_subscriber::fmt::MakeWriter::make_writer_for"><code>MakeWriter::make_writer_for</code></a> method will check the predicate to
|
||||
determine if a writer should be produced for a given span or event.</p>
|
||||
<p>If the predicate returns <code>false</code>, the wrapped <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a>’s
|
||||
<a href="../trait.MakeWriter.html#method.make_writer_for" title="method tracing_subscriber::fmt::MakeWriter::make_writer_for"><code>make_writer_for</code></a> will return <a href="enum.EitherWriter.html#method.none" title="associated function tracing_subscriber::fmt::writer::EitherWriter::none"><code>OptionalWriter::none</code></a>.
|
||||
Otherwise, it calls the wrapped <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a>’s
|
||||
<a href="../trait.MakeWriter.html#method.make_writer_for" title="method tracing_subscriber::fmt::MakeWriter::make_writer_for"><code>make_writer_for</code></a> method, and returns the produced writer.</p>
|
||||
<p>This can be used to filter an output based on arbitrary <a href="../../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata"><code>Metadata</code></a>
|
||||
parameters.</p>
|
||||
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
|
||||
<p>Writing events with a specific target to an HTTP access log, and other
|
||||
events to stdout:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing_subscriber::fmt::writer::MakeWriterExt;
|
||||
<span class="kw">use </span>std::{sync::Arc, fs::File};
|
||||
<span class="kw">let </span>access_log = Arc::new(File::create(<span class="string">"access.log"</span>)<span class="question-mark">?</span>);
|
||||
|
||||
<span class="kw">let </span>mk_writer = access_log
|
||||
<span class="comment">// Only write events with the target "http::access_log" to the
|
||||
// access log file.
|
||||
</span>.with_filter(|meta| meta.target() == <span class="string">"http::access_log"</span>)
|
||||
<span class="comment">// Write events with all other targets to stdout.
|
||||
</span>.or_else(std::io::stdout);
|
||||
|
||||
tracing_subscriber::fmt().with_writer(mk_writer).init();</code></pre></div>
|
||||
<p>Conditionally enabling or disabling a log file:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing_subscriber::fmt::writer::MakeWriterExt;
|
||||
<span class="kw">use </span>std::{
|
||||
sync::{Arc, atomic::{AtomicBool, Ordering}},
|
||||
fs::File,
|
||||
};
|
||||
|
||||
<span class="kw">static </span>DEBUG_LOG_ENABLED: AtomicBool = AtomicBool::new(<span class="bool-val">false</span>);
|
||||
|
||||
<span class="comment">// Create the debug log file
|
||||
</span><span class="kw">let </span>debug_file = Arc::new(File::create(<span class="string">"debug.log"</span>)<span class="question-mark">?</span>)
|
||||
<span class="comment">// Enable the debug log only if the flag is enabled.
|
||||
</span>.with_filter(|<span class="kw">_</span>| DEBUG_LOG_ENABLED.load(Ordering::Acquire));
|
||||
|
||||
<span class="comment">// Always write to stdout
|
||||
</span><span class="kw">let </span>mk_writer = std::io::stdout
|
||||
<span class="comment">// Write to the debug file if it's enabled
|
||||
</span>.and(debug_file);
|
||||
|
||||
tracing_subscriber::fmt().with_writer(mk_writer).init();
|
||||
|
||||
<span class="comment">// ...
|
||||
|
||||
// Later, we can toggle on or off the debug log file.
|
||||
</span>DEBUG_LOG_ENABLED.store(<span class="bool-val">true</span>, Ordering::Release);</code></pre></div>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.and" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#452-458">Source</a><h4 class="code-header">fn <a href="#method.and" class="fn">and</a><B>(self, other: B) -> <a class="struct" href="struct.Tee.html" title="struct tracing_subscriber::fmt::writer::Tee">Tee</a><Self, B> <a href="#" class="tooltip" data-notable-ty="Tee<Self, B>">ⓘ</a><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="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> + <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>Combines <code>self</code> with another type implementing <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a>, returning
|
||||
a new <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> that produces <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">writers</a> that write to <em>both</em>
|
||||
outputs.</p>
|
||||
<p>If writing to either writer returns an error, the returned writer will
|
||||
return that error. However, both writers will still be written to before
|
||||
the error is returned, so it is possible for one writer to fail while
|
||||
the other is written to successfully.</p>
|
||||
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing_subscriber::fmt::writer::MakeWriterExt;
|
||||
|
||||
<span class="comment">// Construct a writer that outputs events to `stdout` *and* `stderr`.
|
||||
</span><span class="kw">let </span>mk_writer = std::io::stdout.and(std::io::stderr);
|
||||
|
||||
tracing_subscriber::fmt().with_writer(mk_writer).init();</code></pre></div>
|
||||
<p><code>and</code> can be used in conjunction with filtering combinators. For
|
||||
example, if we want to write to a number of outputs depending on the
|
||||
level of an event, we could write:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::Level;
|
||||
<span class="kw">use </span>std::{sync::Arc, fs::File};
|
||||
<span class="kw">let </span>debug_log = Arc::new(File::create(<span class="string">"debug.log"</span>)<span class="question-mark">?</span>);
|
||||
|
||||
<span class="comment">// Write everything to the debug log.
|
||||
</span><span class="kw">let </span>mk_writer = debug_log
|
||||
<span class="comment">// Write the `ERROR` and `WARN` levels to stderr.
|
||||
</span>.and(std::io::stderr.with_max_level(Level::WARN))
|
||||
<span class="comment">// Write `INFO` to `stdout`.
|
||||
</span>.and(std::io::stdout
|
||||
.with_max_level(Level::INFO)
|
||||
.with_min_level(Level::INFO)
|
||||
);
|
||||
|
||||
tracing_subscriber::fmt().with_writer(mk_writer).init();</code></pre></div>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.or_else" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#483-490">Source</a><h4 class="code-header">fn <a href="#method.or_else" class="fn">or_else</a><W, B>(self, other: B) -> <a class="struct" href="struct.OrElse.html" title="struct tracing_subscriber::fmt::writer::OrElse">OrElse</a><Self, B><div class="where">where
|
||||
Self: <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a, Writer = <a class="type" href="type.OptionalWriter.html" title="type tracing_subscriber::fmt::writer::OptionalWriter">OptionalWriter</a><W>> + <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="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
||||
W: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a>,</div></h4></section></summary><div class="docblock"><p>Combines <code>self</code> with another type implementing <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a>, returning
|
||||
a new <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> that calls <code>other</code>’s <a href="../trait.MakeWriter.html#tymethod.make_writer" title="method tracing_subscriber::fmt::MakeWriter::make_writer"><code>make_writer</code></a> if <code>self</code>’s
|
||||
<code>make_writer</code> returns <a href="enum.EitherWriter.html#method.none" title="associated function tracing_subscriber::fmt::writer::EitherWriter::none"><code>OptionalWriter::none</code></a>.</p>
|
||||
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::Level;
|
||||
<span class="kw">use </span>tracing_subscriber::fmt::writer::MakeWriterExt;
|
||||
|
||||
<span class="comment">// Produces a writer that writes to `stderr` if the level is >= WARN,
|
||||
// or returns `OptionalWriter::none()` otherwise.
|
||||
</span><span class="kw">let </span>stderr = std::io::stderr.with_max_level(Level::WARN);
|
||||
|
||||
<span class="comment">// If the `stderr` `MakeWriter` is disabled by the max level filter,
|
||||
// write to stdout instead:
|
||||
</span><span class="kw">let </span>mk_writer = stderr.or_else(std::io::stdout);
|
||||
|
||||
tracing_subscriber::fmt().with_writer(mk_writer).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-MakeWriterExt%3C'a%3E-for-M" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#1205">Source</a><a href="#impl-MakeWriterExt%3C'a%3E-for-M" class="anchor">§</a><h3 class="code-header">impl<'a, M> <a class="trait" href="trait.MakeWriterExt.html" title="trait tracing_subscriber::fmt::writer::MakeWriterExt">MakeWriterExt</a><'a> for M<div class="where">where
|
||||
M: <a class="trait" href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter">MakeWriter</a><'a>,</div></h3></section></div><script src="../../../trait.impl/tracing_subscriber/fmt/writer/trait.MakeWriterExt.js" async></script><script type="text/json" id="notable-traits-data">{"Tee<Self, B>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Tee.html\" title=\"struct tracing_subscriber::fmt::writer::Tee\">Tee</a><A, B></code></h3><pre><code><div class=\"where\">impl<A, B> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for <a class=\"struct\" href=\"struct.Tee.html\" title=\"struct tracing_subscriber::fmt::writer::Tee\">Tee</a><A, B><div class=\"where\">where\n A: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a>,\n B: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a>,</div></div>"}</script></section></div></main></body></html>
|
||||
15
tracing_subscriber/fmt/writer/type.OptionalWriter.html
Normal file
15
tracing_subscriber/fmt/writer/type.OptionalWriter.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="A writer which may or may not be enabled."><title>OptionalWriter in tracing_subscriber::fmt::writer - 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 type"><!--[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="#">Optional<wbr>Writer</a></h2><h3><a href="#aliased-type">Aliased type</a></h3><h3><a href="#variants">Variants</a></h3><ul class="block variant"><li><a href="#variant.A" title="A">A</a></li><li><a href="#variant.B" title="B">B</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.none" title="none">none</a></li><li><a href="#method.some" title="some">some</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-From%3COption%3CT%3E%3E-for-EitherWriter%3CT,+Sink%3E" title="From<Option<T>>">From<Option<T>></a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing_<wbr>subscriber::<wbr>fmt::<wbr>writer</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">fmt</a>::<wbr><a href="index.html">writer</a></span><h1>Type Alias <span class="type">OptionalWriter</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/fmt/writer.rs.html#567">Source</a> </span></div><pre class="rust item-decl"><code>pub type OptionalWriter<T> = <a class="enum" href="enum.EitherWriter.html" title="enum tracing_subscriber::fmt::writer::EitherWriter">EitherWriter</a><T, <a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/util/struct.Sink.html" title="struct std::io::util::Sink">Sink</a>>;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A <a href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">writer</a> which may or may not be enabled.</p>
|
||||
<p>This may be used by <a href="../trait.MakeWriter.html" title="trait tracing_subscriber::fmt::MakeWriter"><code>MakeWriter</code></a> implementations that wish to
|
||||
conditionally enable or disable the returned writer based on a span or
|
||||
event’s <a href="../../../tracing_core/metadata/struct.Metadata.html" title="struct tracing_core::metadata::Metadata"><code>Metadata</code></a>.</p>
|
||||
</div></details><h2 id="aliased-type" class="section-header">Aliased Type<a href="#aliased-type" class="anchor">§</a></h2><pre class="rust item-decl"><code>enum OptionalWriter<T> {
|
||||
A(T),
|
||||
B(<a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/util/struct.Sink.html" title="struct std::io::util::Sink">Sink</a>),
|
||||
}</code></pre><h2 id="variants" class="variants section-header">Variants<a href="#variants" class="anchor">§</a></h2><div class="variants"><section id="variant.A" class="variant"><a href="#variant.A" class="anchor">§</a><h3 class="code-header">A(T)</h3></section><div class="docblock"><p>A writer of type <code>A</code>.</p>
|
||||
</div><section id="variant.B" class="variant"><a href="#variant.B" class="anchor">§</a><h3 class="code-header">B(<a class="struct" href="https://doc.rust-lang.org/1.84.1/std/io/util/struct.Sink.html" title="struct std::io::util::Sink">Sink</a>)</h3></section><div class="docblock"><p>A writer of type <code>B</code>.</p>
|
||||
</div></div><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-EitherWriter%3CT,+Sink%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#881-901">Source</a><a href="#impl-EitherWriter%3CT,+Sink%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="type" href="type.OptionalWriter.html" title="type tracing_subscriber::fmt::writer::OptionalWriter">OptionalWriter</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.none" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#890-892">Source</a><h4 class="code-header">pub fn <a href="#method.none" class="fn">none</a>() -> Self</h4></section></summary><div class="docblock"><p>Returns a <a href="https://doc.rust-lang.org/1.84.1/std/io/util/fn.sink.html" title="fn std::io::util::sink">disabled writer</a>.</p>
|
||||
<p>Any bytes written to the returned writer are discarded.</p>
|
||||
<p>This is equivalent to returning <a href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>Option::None</code></a>.</p>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.some" class="method"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#898-900">Source</a><h4 class="code-header">pub fn <a href="#method.some" class="fn">some</a>(t: T) -> Self</h4></section></summary><div class="docblock"><p>Returns an enabled writer of type <code>T</code>.</p>
|
||||
<p>This is equivalent to returning <a href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html#variant.Some" title="variant core::option::Option::Some"><code>Option::Some</code></a>.</p>
|
||||
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-From%3COption%3CT%3E%3E-for-EitherWriter%3CT,+Sink%3E" class="impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#903-911">Source</a><a href="#impl-From%3COption%3CT%3E%3E-for-EitherWriter%3CT,+Sink%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><T>> for <a class="type" href="type.OptionalWriter.html" title="type tracing_subscriber::fmt::writer::OptionalWriter">OptionalWriter</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="../../../src/tracing_subscriber/fmt/writer.rs.html#905-910">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(opt: <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><T>) -> Self</h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details></div><script src="../../../type.impl/tracing_subscriber/fmt/writer/enum.EitherWriter.js" data-self-path="tracing_subscriber::fmt::writer::OptionalWriter" async></script></section></div></main></body></html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue