Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rust crate env_logger to 0.11 #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Aug 22, 2021

This PR contains the following updates:

Package Type Update Change
env_logger dependencies minor 0.3 -> 0.11

Release Notes

rust-cli/env_logger (env_logger)

v0.11.5

Compare Source

v0.11.4

Compare Source

v0.11.3

Compare Source

Features
  • Experimental support for key-value logging behind unstable-kv

v0.11.2

Compare Source

v0.11.1

Compare Source

Fixes
  • Allow styling with Target::Pipe

v0.11.0

Compare Source

Migration Guide

env_logger::fmt::Style:
The bespoke styling API, behind color, was removed, in favor of accepting any
ANSI styled string and adapting it to the target stream's capabilities.

Possible styling libraries include:

  • anstyle is a minimal, runtime string styling API and is re-exported as env_logger::fmt::style
  • owo-colors is a feature rich runtime string styling API
  • color-print for feature-rich compile-time styling API

custom_format.rs
uses anstyle via
Formatter::default_level_style

Breaking Change
  • Removed bespoke styling API
    • env_logger::fmt::Formatter::style
    • env_logger::fmt::Formatter::default_styled_level
    • env_logger::fmt::Style
    • env_logger::fmt::Color
    • env_logger::fmt::StyledValue
  • Removed env_logger::filter in favor of env_filter
Compatibility

MSRV changed to 1.71

Features
  • Automatically adapt ANSI escape codes in logged messages to the current terminal's capabilities
  • Add support for NO_COLOR and CLICOLOR_FORCE, see https://bixense.com/clicolors/
Fixes
  • Print colors when is_test(true)

v0.10.2

Compare Source

Performance
  • Avoid extra UTF-8 validation performed in some cases
Fixes
  • Ensure custom pipes/stdout get flushed
  • Don't panic on broken pipes when color is disabled

v0.10.1

Compare Source

Performance
  • Avoid hashing directives and accessing RNG on startup
Documentation
  • Tweak RUST_LOG documentation

v0.10.0

Compare Source

MSRV changed to 1.60 to hide optional dependencies

Fixes
  • Resolved soundness issue by switching from atty to is-terminal
Breaking Changes

To open room for changing dependencies:

  • Renamed termcolor feature to color
  • Renamed atty feature to auto-color

v0.9.3

Compare Source

  • Fix a regression from v0.9.2 where env_logger would fail to compile with the termcolor feature turned off.

v0.9.2

Compare Source

  • Fix and un-deprecate Target::Pipe, which was basically not working at all before and deprecated in 0.9.1.

v0.9.1

Compare Source

v0.9.0

Compare Source

Breaking Changes
  • Default message format now prints the target instead of the module
Improvements
  • Added a method to print the module instead of the target

v0.8.4: 0.8.4

Compare Source

Improvements:

  • Allow writing logs to a custom output target (via Target::Pipe)

Bug fixes:

  • Actually allow overriding filter levels using env_logger::Builders methods, as documented

v0.8.3: 0.8.3

Compare Source

New features:

  • Suffix customization for the default formatter (Builder::format_suffix) [#​192]

Improvements:

  • Improve documentation about log level names [#​189]

Bug fixes:

  • Ignore whitespace-only filter specifications [#​188]
  • Remove unneded files from crates.io tarball (including rust-toolchain whose presence caused issues for a few people)

v0.8.2: 0.8.2

Compare Source

Fixed a panic on io errors when writing to stdout / stderr (#​184).

v0.8.1: 0.8.1

Compare Source

Update links in the documentation that were pointing to the old repository location.

v0.8.0: 0.8.0

Compare Source

Breaking changes:

  • Update public dependency humantime to 2.0

Improvements:

  • Update default colors for debug (white => blue) and trace (black => cyan)

Deprecations:

  • env_logger::from_env has been deprecated in favor of env_logger::Builder::from_env

This release raises the minimum supported Rust version to 1.41.0.

v0.7.1: 0.7.1

Compare Source

Key Changes

  • More thread-local durability

Contributions

v0.7.0: 0.7.0

Compare Source

Key Changes

  • Indent multiline messages by default
  • Support more timestamp precision
  • Update to the 2018 edition

Changes to minimum Rust

The minimum version of Rust required has been set at 1.31.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.

Contributions

v0.6.2: 0.6.2

Compare Source

Key Changes

  • Additional examples and docs

Contributions

v0.6.1: 0.6.1

Compare Source

Key Changes

  • Support better capturing for cargo test
  • Don't print internal logs to stdout

Contributions

More Details

Builder::is_test

The is_test method can be used in tests to make sure logs are captured by cargo test the same way println! is:

fn init() {
    let _ = env_logger::builder().is_test(true).try_init();
}

#[test]
fn it_adds_one() {
    init();

    info!("can log from the test too");
    assert_eq!(3, add_one(2));
}

There are performance implications of using is_test though, so it should be avoided outside of unit tests.

v0.6.0: 0.6.0

Compare Source

Key Changes

  • Set a policy for changes to the default format
  • Make all dependencies besides log optional (but enabled by default)

Breaking Changes

  • The default format is not considered stable across patch versions. The best way to get a stable format for later ripgrepping is to define a custom one.
  • All dependencies have been made optional except for log. That means compiling env_logger with default-features=false will result in a different experience than in 0.5.x.

Contributions

More Details

Disabling dependencies

Using default-features=false will disable all dependencies of env_logger besides log. This will reduce compile times and alter the default format by disabling colours and timestamps.

Disabling default dependencies is the recommended way to use env_logger for libraries that only need it for logging in tests.

v0.5.13: 0.5.13

Compare Source

Key Changes

  • Add a public function for getting the default level style

Contributions

More Details

Formatter::default_level_style

The style used in the default format for printing level names can be fetched using the new default_level_style method on a Formatter. The below example will format just the record message using the style of its level:

builder.format(|buf, record| {
    let level_style = buf.default_level_style(level);
    write!(buf, "{} ", level_style.value(record.args()))
});

v0.5.12: 0.5.12

Compare Source

Key Changes

  • Add support for high-precision timestamps

Contributions

More Details

Builder::default_format_timestamp_nanos

The Builder::default_format_timestamp_nanos method can be used to toggle the precision of timestamps in the default format. When set to true, timestamps will include a 6-digit nanosecond component like 2018-02-14T00:28:07.000000000Z.

Formatter::precise_timestamp

Custom formats can get a precise timestamp instead of the default by calling the precise_timestamp method instead of the existing timestamp one.

v0.5.11: 0.5.11

Compare Source

Key Changes

  • Update termcolor to 1.0
  • Bump minimum rustc to 1.20.0

Changes to minimum Rust

The minimum version of Rust required has been set at 1.20.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.

Contributions

v0.5.10: 0.5.10

Compare Source

Key Changes

  • Update regex to 1.0.

Contributions

v0.5.9: 0.5.9

Compare Source

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)

v0.5.8: 0.5.8

Compare Source

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.

v0.5.7: 0.5.7

Compare Source

Contributions

v0.5.6: 0.5.6

Compare Source

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.

v0.5.5: 0.5.5

Compare Source

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()).

v0.5.4: 0.5.4

Compare Source

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

v0.5.3: 0.5.3

Compare Source

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

v0.5.2: 0.5.2

Compare Source

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

v0.5.1: 0.5.1

Compare Source

Key Changes

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

Contributions

v0.5.0: 0.5.0

Compare Source

NOTE: These release notes are collected from the 0.5.0-rc.1 and 0.5.0-rc.2 release notes.

Key Changes

  • Support for using custom environment variables to parse the log level filter and color output
  • Added colors with configuration through an environment variable and an RFC3339-formatted timestamp to the default format
  • Buffer log output so logs over multiple lines won't end up interleaved in multi-threaded applications
  • Move the filter parsing into its own module so it's easier to consume in custom loggers
  • Documentation!

Breaking Changes

  • LogTarget has been renamed to Target
  • LogBuilder has been renamed to Builder
  • The Builder::format method now accepts a F: Fn(&mut Formatter, &Record) -> Result<()> + Sync + Send. This is the new formatting API that writes into a Formatter instead of producing an owned String
  • Builder::init will panic if the logger can't be initialised. A new Builder::try_init method has been added with the same semantics as the old Builder::init method

New Dependencies

Contributions

Thanks to everybody who helped make this release of env_logger happen!

More Details

Disabling colors

Adds a new builder property for whether or not to include colors. By default this is controlled by the RUST_LOG_STYLE environment variable, but it can be overridden.

Setting this environment variable to never will disable colors and other styles:

$ export RUST_LOG_STYLE=never
$ ./my-app

Valid values are:

  • auto (or missing/invalid) will decide whether or not the terminal supports colors
  • always will always use colors
  • never will never use colors

In order to support multiple environment variables, I've refactored our from_env functions to accept a generic T: Into<Env>, where Env is a container for the environment variables we care about. These methods can now be called in a few ways:

// reads filters from `MY_LOG` and styles from `RUST_LOG_STYLE`
env_logger::init_from_env("MY_LOG");

// reads filters from `MY_LOG` and styles from `MY_LOG_STYLE`
env_logger::init_from_env(Env::default().filter("MY_LOG").write_style("MY_LOG_STYLE"));

This lets us add new environment variables in the future without potentially breaking people. But it does mean if you're overriding all environment variables that new ones could slip in without you noticing.

Using alternative environment variables

Since we use two environment variables to configure the logger we need an ergonomic way to pass different combinations of those variables to from_env methods. This PR adds an Env type with builder methods for naming environment variables:

env_logger::init_from_env(Env::new().filter("MY_LOG"));

With a few From conversions, the above is also equivalent to:

env_logger::init_from_env("MY_LOG");

Whether or not we want to keep these conversions is up for discussion.

Writing colors

The color API has been refactored and made public so you can use them in your own formats:

let mut style = buf.style();

style.set_color(Color::Red).set_bold(true).set_bg(Color::White);

writeln!(buf, "{}", style.value(42))

This saves you from having to split the writes into multiple calls and juggle Result types.

Writing timestamps

Call the timestamp method on a Formatter to get an opaque timestamp that can be logged. It'll be written in an RFC3339 format:

let ts = buf.timestamp();

writeline!(buf, "log at: {}", ts)

v0.4.3

Compare Source

v0.4.2

Compare Source

v0.4.1

Compare Source

v0.4.0

Compare Source


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 5 times, most recently from 7bc1cfb to 50960b9 Compare August 31, 2021 15:07
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from 4989c06 to 7b2538d Compare September 1, 2021 10:44
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from 7b2538d to edf0e28 Compare September 13, 2021 06:25
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from edf0e28 to 7457daf Compare October 4, 2021 03:14
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from 7457daf to d971712 Compare October 16, 2021 18:29
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from 9e2feb6 to 9111559 Compare November 3, 2021 22:05
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from 9111559 to db6c49b Compare November 15, 2021 04:56
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from a628738 to f7a41ec Compare December 12, 2021 10:59
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from f7a41ec to d244898 Compare December 20, 2021 03:52
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from d244898 to d232c4a Compare January 3, 2022 03:43
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from d232c4a to f0c0b95 Compare May 1, 2022 12:03
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from f0c0b95 to 982939c Compare May 9, 2022 03:18
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from 982939c to 47edd28 Compare June 6, 2022 04:15
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from 47edd28 to b94f667 Compare June 20, 2022 05:18
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from b94f667 to 64623ec Compare July 4, 2022 02:57
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from 64623ec to 283a2af Compare July 18, 2022 05:23
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from 283a2af to a8f9bf1 Compare August 1, 2022 03:20
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from a8f9bf1 to b9a4938 Compare August 15, 2022 05:29
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from 916310e to f20675f Compare September 5, 2022 04:57
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from be542c4 to 5d3cfbf Compare September 19, 2022 05:46
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from 72ddb98 to 7951fc5 Compare June 29, 2024 08:12
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from 1a84acb to 6b71178 Compare July 9, 2024 06:13
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from 6b71178 to 03aba08 Compare July 16, 2024 07:38
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from 5b34e89 to 6f480b7 Compare July 30, 2024 09:39
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from 8d9f61a to 0d2d3c4 Compare August 13, 2024 08:33
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from ae5b048 to 9c2677a Compare August 27, 2024 06:31
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from bdafbf4 to a0a7bd1 Compare September 10, 2024 07:37
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from 5cae35d to 0e6fdce Compare September 24, 2024 07:15
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from 0e6fdce to 0c103ae Compare October 1, 2024 06:15
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from a1f0061 to 37ea737 Compare October 9, 2024 13:23
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from f6b3b28 to 0f07f63 Compare October 22, 2024 08:09
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from 0f07f63 to ec685f5 Compare October 24, 2024 21:27
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from 3121d65 to 444d524 Compare November 12, 2024 06:02
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from 444d524 to 34ea85d Compare November 19, 2024 06:52
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from 04f9a50 to 9b8060c Compare December 3, 2024 06:24
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch 2 times, most recently from 9c5f5ca to 9f1be66 Compare December 17, 2024 08:00
@renovate renovate bot force-pushed the renovate/env_logger-0.x branch from 9f1be66 to 29c3bcb Compare December 24, 2024 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant