blob: dbb9822dc9eca356f408ee872a3751093b6ddd45 [file] [log] [blame]
<!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="Trace verbosity level filtering."><meta name="keywords" content="rust, rustlang, rust-lang, level_filters"><title>tracing::level_filters - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.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">&#9776;</button><a class="sidebar-logo" href="../../tracing/index.html"><div class="logo-container"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../tracing/index.html"><div class="logo-container">
<img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></div></a><h2 class="location"><a href="#">Module level_filters</a></h2><div class="sidebar-elems"><section><ul class="block"><li><a href="#structs">Structs</a></li><li><a href="#constants">Constants</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Module <a href="../index.html">tracing</a>::<wbr><a class="mod" href="#">level_filters</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/tracing/level_filters.rs.html#1-94">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Trace verbosity level filtering.</p>
<h2 id="compile-time-filters"><a href="#compile-time-filters">Compile time filters</a></h2>
<p>Trace verbosity levels can be statically disabled at compile time via Cargo
features, similar to the <a href="https://docs.rs/log/latest/log/#compile-time-filters"><code>log</code> crate</a>. Trace instrumentation at disabled
levels will be skipped and will not even be present in the resulting binary
unless the verbosity level is specified dynamically. This level is
configured separately for release and debug builds. The features are:</p>
<ul>
<li><code>max_level_off</code></li>
<li><code>max_level_error</code></li>
<li><code>max_level_warn</code></li>
<li><code>max_level_info</code></li>
<li><code>max_level_debug</code></li>
<li><code>max_level_trace</code></li>
<li><code>release_max_level_off</code></li>
<li><code>release_max_level_error</code></li>
<li><code>release_max_level_warn</code></li>
<li><code>release_max_level_info</code></li>
<li><code>release_max_level_debug</code></li>
<li><code>release_max_level_trace</code></li>
</ul>
<p>These features control the value of the <code>STATIC_MAX_LEVEL</code> constant. The
instrumentation macros macros check this value before recording an event or
constructing a span. By default, no levels are disabled.</p>
<p>For example, a crate can disable trace level instrumentation in debug builds
and trace, debug, and info level instrumentation in release builds with the
following configuration:</p>
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
tracing = { version = &quot;0.1&quot;, features = [&quot;max_level_debug&quot;, &quot;release_max_level_warn&quot;] }</code></pre></div><h3 id="notes"><a href="#notes">Notes</a></h3>
<p>Please note that <code>tracing</code>’s static max level features do <em>not</em> control the
<a href="https://docs.rs/log/"><code>log</code></a> records that may be emitted when <a href="https://docs.rs/tracing/latest/tracing/#emitting-log-records"><code>tracing</code>’s “log” feature flag</a> is
enabled. This is to allow <code>tracing</code> to be disabled entirely at compile time
while still emitting <code>log</code> records — such as when a library using
<code>tracing</code> is used by an application using <code>log</code> that doesn’t want to
generate any <code>tracing</code>-related code, but does want to collect <code>log</code> records.</p>
<p>This means that if the “log” feature is in use, some code may be generated
for <code>log</code> records emitted by disabled <code>tracing</code> events. If this is not
desirable, <code>log</code> records may be disabled separately using <a href="https://docs.rs/log/latest/log/#compile-time-filters"><code>log</code>’s static
max level features</a>.</p>
</div></details><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.LevelFilter.html" title="tracing::level_filters::LevelFilter struct">LevelFilter</a></div><div class="item-right docblock-short">A filter comparable to a verbosity <a href="../struct.Level.html" title="Level"><code>Level</code></a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ParseLevelFilterError.html" title="tracing::level_filters::ParseLevelFilterError struct">ParseLevelFilterError</a></div><div class="item-right docblock-short">Indicates that a string could not be parsed to a valid level.</div></div></div><h2 id="constants" class="small-section-header"><a href="#constants">Constants</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.STATIC_MAX_LEVEL.html" title="tracing::level_filters::STATIC_MAX_LEVEL constant">STATIC_MAX_LEVEL</a></div><div class="item-right docblock-short">The statically configured maximum trace level.</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="tracing" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>