Skip to content

Commit

Permalink
subcriber: update docs for EnvFilter Builder (#2782)
Browse files Browse the repository at this point in the history
The `from_env` and `try_from_env` methods on the builder had the same documentation. This change updates their docs to correctly describe their difference in behavior.


## Motivation

Make the docs more clear, so that users need not look at the source to understand the difference between these two functions.

## Solution

Updated the docs

Co-authored-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
nathanielc and hawkw committed Nov 7, 2023
1 parent 119f91a commit 7b59435
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tracing-subscriber/src/filter/env/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,16 @@ impl Builder {
self.parse_lossy(var)
}

/// Returns a new [`EnvFilter`] from the directives in the in the configured
/// environment variable, or an error if the environment variable is not set
/// or contains invalid directives.
/// Returns a new [`EnvFilter`] from the directives in the configured
/// environment variable. If the environment variable is unset, no directive is added.
///
/// An error is returned if the environment contains invalid directives.
pub fn from_env(&self) -> Result<EnvFilter, FromEnvError> {
let var = env::var(self.env_var_name()).unwrap_or_default();
self.parse(var).map_err(Into::into)
}

/// Returns a new [`EnvFilter`] from the directives in the in the configured
/// Returns a new [`EnvFilter`] from the directives in the configured
/// environment variable, or an error if the environment variable is not set
/// or contains invalid directives.
pub fn try_from_env(&self) -> Result<EnvFilter, FromEnvError> {
Expand Down

0 comments on commit 7b59435

Please sign in to comment.