Files
mercator_service/env_logger/struct.Builder.html

195 lines
46 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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="API documentation for the Rust `Builder` struct in crate `env_logger`."><meta name="keywords" content="rust, rustlang, rust-lang, Builder"><title>env_logger::Builder - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="https://www.rust-lang.org/static/images/favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../env_logger/index.html'><div class='logo-container'><img src='https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='logo'></div></a><p class='location'>Struct Builder</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.build">build</a><a href="#method.default_format">default_format</a><a href="#method.default_format_level">default_format_level</a><a href="#method.default_format_module_path">default_format_module_path</a><a href="#method.default_format_timestamp">default_format_timestamp</a><a href="#method.default_format_timestamp_nanos">default_format_timestamp_nanos</a><a href="#method.filter">filter</a><a href="#method.filter_level">filter_level</a><a href="#method.filter_module">filter_module</a><a href="#method.format">format</a><a href="#method.from_default_env">from_default_env</a><a href="#method.from_env">from_env</a><a href="#method.init">init</a><a href="#method.is_test">is_test</a><a href="#method.new">new</a><a href="#method.parse">parse</a><a href="#method.parse_filters">parse_filters</a><a href="#method.parse_write_style">parse_write_style</a><a href="#method.target">target</a><a href="#method.try_init">try_init</a><a href="#method.write_style">write_style</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a></div></div><p class='location'><a href='index.html'>env_logger</a></p><script>window.sidebarCurrent = {name: 'Builder', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../src/env_logger/lib.rs.html#358-363' title='goto source code'>[src]</a></span><span class='in-band'>Struct <a href='index.html'>env_logger</a>::<wbr><a class="struct" href=''>Builder</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust struct'>pub struct Builder { /* fields omitted */ }</pre></div><div class='docblock'><p><code>Builder</code> acts as builder for initializing a <code>Logger</code>.</p>
<p>It can be used to customize the log format, change the environment variable used
to provide the logging directives and also set the default log level filter.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="attribute">#[<span class="ident">macro_use</span>]</span>
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">log</span>;
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">env_logger</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">env</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Write</span>;
<span class="kw">use</span> <span class="ident">log</span>::<span class="ident">LevelFilter</span>;
<span class="kw">use</span> <span class="ident">env_logger</span>::<span class="ident">Builder</span>;
<span class="kw">fn</span> <span class="ident">main</span>() {
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">from_default_env</span>();
<span class="ident">builder</span>.<span class="ident">format</span>(<span class="op">|</span><span class="ident">buf</span>, <span class="ident">record</span><span class="op">|</span> <span class="macro">writeln</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">&quot;{} - {}&quot;</span>, <span class="ident">record</span>.<span class="ident">level</span>(), <span class="ident">record</span>.<span class="ident">args</span>()))
.<span class="ident">filter</span>(<span class="prelude-val">None</span>, <span class="ident">LevelFilter</span>::<span class="ident">Info</span>)
.<span class="ident">init</span>();
<span class="macro">error</span><span class="macro">!</span>(<span class="string">&quot;error message&quot;</span>);
<span class="macro">info</span><span class="macro">!</span>(<span class="string">&quot;info message&quot;</span>);
}</pre></div>
</div><h2 id='methods' class='small-section-header'>Methods<a href='#methods' class='anchor'></a></h2><h3 id='impl' class='impl'><code class='in-band'>impl <a class="struct" href="../env_logger/struct.Builder.html" title="struct env_logger::Builder">Builder</a></code><a href='#impl' class='anchor'></a><a class='srclink' href='../src/env_logger/lib.rs.html#365-732' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.new' class="method"><code id='new.v'>pub fn <a href='#method.new' class='fnname'>new</a>() -&gt; <a class="struct" href="../env_logger/struct.Builder.html" title="struct env_logger::Builder">Builder</a></code><a class='srclink' href='../src/env_logger/lib.rs.html#395-397' title='goto source code'>[src]</a></h4><div class='docblock'><p>Initializes the log builder with defaults.</p>
<p><strong>NOTE:</strong> This method won't read from any environment variables.
Use the <a href="#method.filter"><code>filter</code></a> and <a href="#method.write_style"><code>write_style</code></a> methods to configure the builder
or use <a href="#method.from_env"><code>from_env</code></a> or <a href="#method.from_default_env"><code>from_default_env</code></a> instead.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<p>Create a new builder and configure filters and style:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">log</span>::<span class="ident">LevelFilter</span>;
<span class="kw">use</span> <span class="ident">env_logger</span>::{<span class="ident">Builder</span>, <span class="ident">WriteStyle</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">new</span>();
<span class="ident">builder</span>.<span class="ident">filter</span>(<span class="prelude-val">None</span>, <span class="ident">LevelFilter</span>::<span class="ident">Info</span>)
.<span class="ident">write_style</span>(<span class="ident">WriteStyle</span>::<span class="ident">Always</span>)
.<span class="ident">init</span>();</pre></div>
</div><h4 id='method.from_env' class="method"><code id='from_env.v'>pub fn <a href='#method.from_env' class='fnname'>from_env</a>&lt;'a, E&gt;(env: E) -&gt; Self <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;E: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="struct" href="../env_logger/struct.Env.html" title="struct env_logger::Env">Env</a>&lt;'a&gt;&gt;,&nbsp;</span></code><a class='srclink' href='../src/env_logger/lib.rs.html#427-443' title='goto source code'>[src]</a></h4><div class='docblock'><p>Initializes the log builder from the environment.</p>
<p>The variables used to read configuration from can be tweaked before
passing in.</p>
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
<p>Initialise a logger reading the log filter from an environment variable
called <code>MY_LOG</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">env_logger</span>::<span class="ident">Builder</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">from_env</span>(<span class="string">&quot;MY_LOG&quot;</span>);
<span class="ident">builder</span>.<span class="ident">init</span>();</pre></div>
<p>Initialise a logger using the <code>MY_LOG</code> variable for filtering and
<code>MY_LOG_STYLE</code> for whether or not to write styles:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">env_logger</span>::{<span class="ident">Builder</span>, <span class="ident">Env</span>};
<span class="kw">let</span> <span class="ident">env</span> <span class="op">=</span> <span class="ident">Env</span>::<span class="ident">new</span>().<span class="ident">filter</span>(<span class="string">&quot;MY_LOG&quot;</span>).<span class="ident">write_style</span>(<span class="string">&quot;MY_LOG_STYLE&quot;</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">from_env</span>(<span class="ident">env</span>);
<span class="ident">builder</span>.<span class="ident">init</span>();</pre></div>
</div><h4 id='method.from_default_env' class="method"><code id='from_default_env.v'>pub fn <a href='#method.from_default_env' class='fnname'>from_default_env</a>() -&gt; Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#463-465' title='goto source code'>[src]</a></h4><div class='docblock'><p>Initializes the log builder from the environment using default variable names.</p>
<p>This method is a convenient way to call <code>from_env(Env::default())</code> without
having to use the <code>Env</code> type explicitly. The builder will use the
<a href="struct.Env.html#default-environment-variables">default environment variables</a>.</p>
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
<p>Initialise a logger using the default environment variables:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">env_logger</span>::<span class="ident">Builder</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">from_default_env</span>();
<span class="ident">builder</span>.<span class="ident">init</span>();</pre></div>
</div><h4 id='method.format' class="method"><code id='format.v'>pub fn <a href='#method.format' class='fnname'>format</a>&lt;F:&nbsp;'static&gt;(&amp;mut self, format: F) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;mut <a class="struct" href="../env_logger/fmt/struct.Formatter.html" title="struct env_logger::fmt::Formatter">Formatter</a>, &amp;<a class="struct" href="../log/struct.Record.html" title="struct log::Record">Record</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,&nbsp;</span></code><a class='srclink' href='../src/env_logger/lib.rs.html#493-498' title='goto source code'>[src]</a></h4><div class='docblock'><p>Sets the format function for formatting the log output.</p>
<p>This function is called on each record logged and should format the
log record and output it to the given <a href="fmt/struct.Formatter.html"><code>Formatter</code></a>.</p>
<p>The format function is expected to output the string directly to the
<code>Formatter</code> so that implementations can use the <a href="https://doc.rust-lang.org/std/fmt/index.html"><code>std::fmt</code></a> macros
to format and output without intermediate heap allocations. The default
<code>env_logger</code> formatter takes advantage of this.</p>
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
<p>Use a custom format to write only the log message:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Write</span>;
<span class="kw">use</span> <span class="ident">env_logger</span>::<span class="ident">Builder</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">new</span>();
<span class="ident">builder</span>.<span class="ident">format</span>(<span class="op">|</span><span class="ident">buf</span>, <span class="ident">record</span><span class="op">|</span> <span class="macro">writeln</span><span class="macro">!</span>(<span class="ident">buf</span>, <span class="string">&quot;{}&quot;</span>, <span class="ident">record</span>.<span class="ident">args</span>()));</pre></div>
</div><h4 id='method.default_format' class="method"><code id='default_format.v'>pub fn <a href='#method.default_format' class='fnname'>default_format</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#503-506' title='goto source code'>[src]</a></h4><div class='docblock'><p>Use the default format.</p>
<p>This method will clear any custom format set on the builder.</p>
</div><h4 id='method.default_format_level' class="method"><code id='default_format_level.v'>pub fn <a href='#method.default_format_level' class='fnname'>default_format_level</a>(&amp;mut self, write: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#509-512' title='goto source code'>[src]</a></h4><div class='docblock'><p>Whether or not to write the level in the default format.</p>
</div><h4 id='method.default_format_module_path' class="method"><code id='default_format_module_path.v'>pub fn <a href='#method.default_format_module_path' class='fnname'>default_format_module_path</a>(&amp;mut self, write: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#515-518' title='goto source code'>[src]</a></h4><div class='docblock'><p>Whether or not to write the module path in the default format.</p>
</div><h4 id='method.default_format_timestamp' class="method"><code id='default_format_timestamp.v'>pub fn <a href='#method.default_format_timestamp' class='fnname'>default_format_timestamp</a>(&amp;mut self, write: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#521-524' title='goto source code'>[src]</a></h4><div class='docblock'><p>Whether or not to write the timestamp in the default format.</p>
</div><h4 id='method.default_format_timestamp_nanos' class="method"><code id='default_format_timestamp_nanos.v'>pub fn <a href='#method.default_format_timestamp_nanos' class='fnname'>default_format_timestamp_nanos</a>(&amp;mut self, write: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#527-530' title='goto source code'>[src]</a></h4><div class='docblock'><p>Whether or not to write the timestamp with nanos.</p>
</div><h4 id='method.filter_module' class="method"><code id='filter_module.v'>pub fn <a href='#method.filter_module' class='fnname'>filter_module</a>(&amp;mut self, module: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, level: <a class="enum" href="../log/enum.LevelFilter.html" title="enum log::LevelFilter">LevelFilter</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#550-553' title='goto source code'>[src]</a></h4><div class='docblock'><p>Adds a directive to the filter for a specific module.</p>
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
<p>Only include messages for warning and above for logs in <code>path::to::module</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">log</span>::<span class="ident">LevelFilter</span>;
<span class="kw">use</span> <span class="ident">env_logger</span>::<span class="ident">Builder</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">new</span>();
<span class="ident">builder</span>.<span class="ident">filter_module</span>(<span class="string">&quot;path::to::module&quot;</span>, <span class="ident">LevelFilter</span>::<span class="ident">Info</span>);</pre></div>
</div><h4 id='method.filter_level' class="method"><code id='filter_level.v'>pub fn <a href='#method.filter_level' class='fnname'>filter_level</a>(&amp;mut self, level: <a class="enum" href="../log/enum.LevelFilter.html" title="enum log::LevelFilter">LevelFilter</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#573-576' title='goto source code'>[src]</a></h4><div class='docblock'><p>Adds a directive to the filter for all modules.</p>
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
<p>Only include messages for warning and above for logs in <code>path::to::module</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">log</span>::<span class="ident">LevelFilter</span>;
<span class="kw">use</span> <span class="ident">env_logger</span>::<span class="ident">Builder</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">new</span>();
<span class="ident">builder</span>.<span class="ident">filter_level</span>(<span class="ident">LevelFilter</span>::<span class="ident">Info</span>);</pre></div>
</div><h4 id='method.filter' class="method"><code id='filter.v'>pub fn <a href='#method.filter' class='fnname'>filter</a>(&amp;mut self, module: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;, level: <a class="enum" href="../log/enum.LevelFilter.html" title="enum log::LevelFilter">LevelFilter</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#599-604' title='goto source code'>[src]</a></h4><div class='docblock'><p>Adds filters to the logger.</p>
<p>The given module (if any) will log at most the specified level provided.
If no module is provided then the filter will apply to all log messages.</p>
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
<p>Only include messages for warning and above for logs in <code>path::to::module</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">log</span>::<span class="ident">LevelFilter</span>;
<span class="kw">use</span> <span class="ident">env_logger</span>::<span class="ident">Builder</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">new</span>();
<span class="ident">builder</span>.<span class="ident">filter</span>(<span class="prelude-val">Some</span>(<span class="string">&quot;path::to::module&quot;</span>), <span class="ident">LevelFilter</span>::<span class="ident">Info</span>);</pre></div>
</div><h4 id='method.parse' class="method"><code id='parse.v'>pub fn <a href='#method.parse' class='fnname'>parse</a>(&amp;mut self, filters: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#611-613' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab deprecated'>Deprecated since 0.6.1: <p>use <code>parse_filters</code> instead.</p>
</div></div><div class='docblock'><p>Parses the directives string in the same form as the <code>RUST_LOG</code>
environment variable.</p>
<p>See the module documentation for more details.</p>
</div><h4 id='method.parse_filters' class="method"><code id='parse_filters.v'>pub fn <a href='#method.parse_filters' class='fnname'>parse_filters</a>(&amp;mut self, filters: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#619-622' title='goto source code'>[src]</a></h4><div class='docblock'><p>Parses the directives string in the same form as the <code>RUST_LOG</code>
environment variable.</p>
<p>See the module documentation for more details.</p>
</div><h4 id='method.target' class="method"><code id='target.v'>pub fn <a href='#method.target' class='fnname'>target</a>(&amp;mut self, target: <a class="enum" href="../env_logger/enum.Target.html" title="enum env_logger::Target">Target</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#639-642' title='goto source code'>[src]</a></h4><div class='docblock'><p>Sets the target for the log output.</p>
<p>Env logger can log to either stdout or stderr. The default is stderr.</p>
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
<p>Write log message to <code>stdout</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">env_logger</span>::{<span class="ident">Builder</span>, <span class="ident">Target</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">new</span>();
<span class="ident">builder</span>.<span class="ident">target</span>(<span class="ident">Target</span>::<span class="ident">Stdout</span>);</pre></div>
</div><h4 id='method.write_style' class="method"><code id='write_style.v'>pub fn <a href='#method.write_style' class='fnname'>write_style</a>(&amp;mut self, write_style: <a class="enum" href="../env_logger/enum.WriteStyle.html" title="enum env_logger::WriteStyle">WriteStyle</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#660-663' title='goto source code'>[src]</a></h4><div class='docblock'><p>Sets whether or not styles will be written.</p>
<p>This can be useful in environments that don't support control characters
for setting colors.</p>
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
<p>Never attempt to write styles:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">env_logger</span>::{<span class="ident">Builder</span>, <span class="ident">WriteStyle</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">builder</span> <span class="op">=</span> <span class="ident">Builder</span>::<span class="ident">new</span>();
<span class="ident">builder</span>.<span class="ident">write_style</span>(<span class="ident">WriteStyle</span>::<span class="ident">Never</span>);</pre></div>
</div><h4 id='method.parse_write_style' class="method"><code id='parse_write_style.v'>pub fn <a href='#method.parse_write_style' class='fnname'>parse_write_style</a>(&amp;mut self, write_style: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#669-672' title='goto source code'>[src]</a></h4><div class='docblock'><p>Parses whether or not to write styles in the same form as the <code>RUST_LOG_STYLE</code>
environment variable.</p>
<p>See the module documentation for more details.</p>
</div><h4 id='method.is_test' class="method"><code id='is_test.v'>pub fn <a href='#method.is_test' class='fnname'>is_test</a>(&amp;mut self, is_test: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</code><a class='srclink' href='../src/env_logger/lib.rs.html#678-681' title='goto source code'>[src]</a></h4><div class='docblock'><p>Sets whether or not the logger will be used in unit tests.</p>
<p>If <code>is_test</code> is <code>true</code> then the logger will allow the testing framework to
capture log records rather than printing them to the terminal directly.</p>
</div><h4 id='method.try_init' class="method"><code id='try_init.v'>pub fn <a href='#method.try_init' class='fnname'>try_init</a>(&amp;mut self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="../log/struct.SetLoggerError.html" title="struct log::SetLoggerError">SetLoggerError</a>&gt;</code><a class='srclink' href='../src/env_logger/lib.rs.html#692-703' title='goto source code'>[src]</a></h4><div class='docblock'><p>Initializes the global logger with the built env logger.</p>
<p>This should be called early in the execution of a Rust program. Any log
events that occur before initialization will be ignored.</p>
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
<p>This function will fail if it is called more than once, or if another
library has already initialized a global logger.</p>
</div><h4 id='method.init' class="method"><code id='init.v'>pub fn <a href='#method.init' class='fnname'>init</a>(&amp;mut self)</code><a class='srclink' href='../src/env_logger/lib.rs.html#714-716' title='goto source code'>[src]</a></h4><div class='docblock'><p>Initializes the global logger with the built env logger.</p>
<p>This should be called early in the execution of a Rust program. Any log
events that occur before initialization will be ignored.</p>
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
<p>This function will panic if it is called more than once, or if another
library has already initialized a global logger.</p>
</div><h4 id='method.build' class="method"><code id='build.v'>pub fn <a href='#method.build' class='fnname'>build</a>(&amp;mut self) -&gt; <a class="struct" href="../env_logger/struct.Logger.html" title="struct env_logger::Logger">Logger</a></code><a class='srclink' href='../src/env_logger/lib.rs.html#722-731' title='goto source code'>[src]</a></h4><div class='docblock'><p>Build an env logger.</p>
<p>The returned logger implements the <code>Log</code> trait and can be installed manually
or nested within another logger.</p>
</div></div><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-Debug' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../env_logger/struct.Builder.html" title="struct env_logger::Builder">Builder</a></code><a href='#impl-Debug' class='anchor'></a><a class='srclink' href='../src/env_logger/lib.rs.html#1007-1020' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fmt' class="method hidden"><code id='fmt.v'>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class='srclink' href='../src/env_logger/lib.rs.html#1008-1019' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id='impl-Default' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="../env_logger/struct.Builder.html" title="struct env_logger::Builder">Builder</a></code><a href='#impl-Default' class='anchor'></a><a class='srclink' href='../src/env_logger/lib.rs.html#357' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.default' class="method hidden"><code id='default.v'>fn <a href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -&gt; <a class="struct" href="../env_logger/struct.Builder.html" title="struct env_logger::Builder">Builder</a></code><a class='srclink' href='../src/env_logger/lib.rs.html#357' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Returns the &quot;default value&quot; for a type. <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default">Read more</a></p>
</div></div></div><h2 id='synthetic-implementations' class='small-section-header'>Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a></h2><div id='synthetic-implementations-list'><h3 id='impl-RefUnwindSafe' class='impl'><code class='in-band'>impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../env_logger/struct.Builder.html" title="struct env_logger::Builder">Builder</a></code><a href='#impl-RefUnwindSafe' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-Send' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../env_logger/struct.Builder.html" title="struct env_logger::Builder">Builder</a></code><a href='#impl-Send' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-Sync' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../env_logger/struct.Builder.html" title="struct env_logger::Builder">Builder</a></code><a href='#impl-Sync' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-Unpin' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../env_logger/struct.Builder.html" title="struct env_logger::Builder">Builder</a></code><a href='#impl-Unpin' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-UnwindSafe' class='impl'><code class='in-band'>impl !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../env_logger/struct.Builder.html" title="struct env_logger::Builder">Builder</a></code><a href='#impl-UnwindSafe' class='anchor'></a></h3><div class='impl-items'></div></div><h2 id='blanket-implementations' class='small-section-header'>Blanket Implementations<a href='#blanket-implementations' class='anchor'></a></h2><div id='blanket-implementations-list'><h3 id='impl-Any' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Any' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#108-112' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.type_id' class="method hidden"><code id='type_id.v'>fn <a href='https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id' class='fnname'>type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/any.rs.html#109-111' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div><h3 id='impl-Borrow%3CT%3E' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Borrow%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#213-217' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow' class="method hidden"><code id='borrow.v'>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#214-216' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id='impl-BorrowMut%3CT%3E' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-BorrowMut%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#220-224' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow_mut' class="method hidden"><code id='borrow_mut.v'>fn <a href='https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut' class='fnname'>borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#221-223' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></div><h3 id='impl-From%3CT%3E' class='impl'><code class='in-band'>impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</code><a href='#impl-From%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#564-568' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from' class="method hidden"><code id='from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -&gt; T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#565-567' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-Into%3CU%3E' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-Into%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#553-560' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.into' class="method hidden"><code id='into.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -&gt; U</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#557-559' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-TryFrom%3CU%3E' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryFrom%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#601-610' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error' class="type"><code id='Error.t'>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_from' class="method hidden"><code id='try_from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#607-609' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id='impl-TryInto%3CU%3E' class='impl'><code class='in-band'>impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,&nbsp;</span></code><a href='#impl-TryInto%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#587-596' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error-1' class="type"><code id='Error.t-1'>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error' class="type">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id='method.try_into' class="method hidden"><code id='try_into.v'>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into' class='fnname'>try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#593-595' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "env_logger";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>