From 4abf7f058e2fc467bb28ec457813abac82bbf5b2 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Fri, 26 Jul 2024 10:48:07 -0400 Subject: [PATCH] Upgrade `env_logger` to v0.11 (#15278) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR upgrades `env_logger` to v0.11. There were some breaking changes in the style API. I followed the [migration guide](https://github.com/rust-cli/env_logger/blob/73bb4188026f1ad5e6409c4148d37d572cc921bd/CHANGELOG.md#migration-guide) to update the usage. Visually there shouldn't be any changes: ### Before Screenshot 2024-07-26 at 10 20 07 AM ### After Screenshot 2024-07-26 at 10 37 35 AM Release Notes: - N/A --- Cargo.lock | 57 ++++++++++++++++++++++++++++++++++++------ Cargo.toml | 2 +- crates/zed/src/main.rs | 15 +++++------ 3 files changed, 56 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0276251d7f..2cd5f58395 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -203,11 +203,26 @@ dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", - "anstyle-wincon", + "anstyle-wincon 2.1.0", "colorchoice", "utf8parse", ] +[[package]] +name = "anstream" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon 3.0.4", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + [[package]] name = "anstyle" version = "1.0.7" @@ -242,6 +257,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anthropic" version = "0.1.0" @@ -2227,7 +2252,7 @@ version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" dependencies = [ - "anstream", + "anstream 0.5.0", "anstyle", "clap_lex", "strsim", @@ -3679,16 +3704,26 @@ dependencies = [ ] [[package]] -name = "env_logger" -version = "0.10.2" +name = "env_filter" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" dependencies = [ - "humantime", - "is-terminal", "log", "regex", - "termcolor", +] + +[[package]] +name = "env_logger" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +dependencies = [ + "anstream 0.6.15", + "anstyle", + "env_filter", + "humantime", + "log", ] [[package]] @@ -5667,6 +5702,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "isahc" version = "1.7.2" diff --git a/Cargo.toml b/Cargo.toml index 01238fc16e..9a613ba5c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -334,7 +334,7 @@ dashmap = "5.5.3" derive_more = "0.99.17" dirs = "4.0" emojis = "0.6.1" -env_logger = "0.10" +env_logger = "0.11" exec = "0.3.1" fork = "0.1.23" futures = "0.3" diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 2ecf58748d..2c3d1d7d9f 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -803,24 +803,21 @@ fn init_stdout_logger() { Builder::new() .parse_default_env() .format(|buf, record| { - use env_logger::fmt::Color; + use env_logger::fmt::style::{AnsiColor, Style}; - let subtle = buf - .style() - .set_color(Color::Black) - .set_intense(true) - .clone(); - write!(buf, "{}", subtle.value("["))?; + let subtle = Style::new().fg_color(Some(AnsiColor::BrightBlack.into())); + write!(buf, "{subtle}[{subtle:#}")?; write!( buf, "{} ", chrono::Local::now().format("%Y-%m-%dT%H:%M:%S%:z") )?; - write!(buf, "{:<5}", buf.default_styled_level(record.level()))?; + let level_style = buf.default_level_style(record.level()); + write!(buf, "{level_style}{:<5}{level_style:#}", record.level())?; if let Some(path) = record.module_path() { write!(buf, " {path}")?; } - write!(buf, "{}", subtle.value("]"))?; + write!(buf, "{subtle}]{subtle:#}")?; writeln!(buf, " {}", record.args()) }) .init();