Skip to content

Releases: rust-cli/env_logger

0.5.10

05 May 01:13
4e39b74

Choose a tag to compare

Key Changes

  • Update regex to 1.0.

Contributions

0.5.9

21 Apr 10:09
6b672d8

Choose a tag to compare

Key Changes

  • Add some convenient methods for adding filter directives

Contributions

More Details

filter_module and filter_level

Adds two new methods to Builder and filter::Builder that are specific cases of the existing filter method:

  • filter_module adds a directive for the given module. It's the same as filter(Some(module), level)
  • filter_level adds a directive for all modules. It's the same as filter(None, level)

0.5.8

18 Apr 03:15
afd147a

Choose a tag to compare

Key Changes

  • Support setting default values for environment variables before initialising a logger

Contributions

More Details

Env::filter_or and Env::write_style_or

Default values for environment variables can be specified on the Env type using the filter_or and write_style_or methods. The default value is a string in the same format as the environment variable:

impl Env {
    fn filter_or<E, V>(self, filter_env: E, default: V) -> Self
    where
        E: Into<Cow<'a, str>>,
        V: Into<Cow<'a, str>>;

    fn write_style_or<E, V>(self, write_style_env: E, default: V) -> Self
        where
            E: Into<Cow<'a, str>>,
            V: Into<Cow<'a, str>>;
}

In usage:

let env = Env::default()
    .filter_or("MY_LOG_LEVEL", "trace")
    .write_style_or("MY_LOG_STYLE", "always");

env_logger::init_from_env(env);

DEFAULT_FILTER_ENV and DEFAULT_WRITE_STYLE_ENV

Two new constants are publicly exported that correspond to the default environment variable names used for the filters and style preferences.

0.5.7

11 Apr 23:25
b43890a

Choose a tag to compare

0.5.6

18 Mar 01:55
a3e25b3

Choose a tag to compare

Key Changes

  • Wrap the termcolor::Color API so it's no longer a public dependency

Contributions

More Details

This patch fixes an issue that slipped through 0.5.0 where the termcolor::Color type was re-exported instead of redefined.

This is a potentially breaking change

Instead of re-exporting termcolor::Color, we now redefine the same API in env_logger. The potential breakage is if anyone was relying on the fact that env_logger::Color and termcolor::Color were equivalent types. This was only obvious from the source, and a survey of public code using env_logger and call for comment hasn't revealed any code relying on this.

0.5.5

09 Mar 02:15
4d7926c

Choose a tag to compare

Key Changes

  • Allow toggling parts of the default format without having to write one from scratch

Contributions

More Details

Builder::default_format_*

The default format can be easily tweaked by conditionally enabling/disabling parts of it in the main Builder. The API looks like:

impl Builder {
    fn default_format(&mut self) -> &mut Self;
    fn default_format_timestamp(&mut self, write: bool) -> &mut Self;
    fn default_format_module_path(&mut self, write: bool) -> &mut Self;
    fn default_format_level(&mut self, write: bool) -> &mut Self;
}

Calling default_format_* will store whether or not we want to include those parts of the log, without affecting a custom format. That means:

Builder::new()
    .format(|buf, record| { ... })
    .default_format_timestamp(false)
    .init();

Is the same as:

Builder::new()
    .format(|buf, record| { ... })
    .init();

Setting a custom format won't clobber any values passed to default_format_* methods. That means:

Builder::new()
    .default_format_timestamp(false)
    .format(|buf, record| { ... })
    .default_format()
    .init();

Is the same as:

Builder::new()
    .default_format_timestamp(false)
    .init();

Builder::from_default_env

A new from_default_env method that's a convenient way of calling from_env(env_logger::Env::default()).

0.5.4

25 Feb 00:25
02fda0f

Choose a tag to compare

Key Changes

  • Better panic message when attempting to initialise the global logger multiple times
  • Use humantime instead of chrono for formatting timestamps

Changes to minimum Rust

The minimum version of Rust required has been set at 1.18.0. We may change this in patch versions, but will always flag it in the release notes here.

You can always check the .travis.yml file to see the current minimum supported version.

New Dependencies

  • humantime for formatting timestamps. This replaces the dependency on chrono

Contributions

0.5.3

21 Jan 01:11
b7c4626

Choose a tag to compare

Key Changes

  • Support more intense variants of color using intensity. Call set_intense(true) to produce a lighter color, and set_intense(false) to produce the default color.

Contributions

0.5.2

19 Jan 06:17
5e10f66

Choose a tag to compare

Key Changes

  • Detect whether stdout/stderr is a tty and write styles accordingly. This fixes an issue with color control characters showing up logs piped to files

New Dependencies

  • atty for interrogating stdout/stderr

Contributions

0.5.1

17 Jan 21:22
d8cdb6e

Choose a tag to compare

Key Changes

  • Fixed a panic in some rare logging cases and updated some incorrect sample code in the readme

Contributions