Bug 1772068 - Force update env_logger to 0.9. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D147837
This commit is contained in:
Mike Hommey 2022-06-02 01:06:13 +00:00
Родитель f590f4d97c
Коммит 600bc7f33d
9 изменённых файлов: 193 добавлений и 38 удалений

27
Cargo.lock сгенерированный
Просмотреть файл

@ -63,7 +63,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9ed09b18365ed295d722d0b5ed59c01b79a826ff2d2a8f73d5ecca8e6fb2f66"
dependencies = [
"android_log-sys",
"env_logger",
"env_logger 0.8.999",
"lazy_static",
"log",
]
@ -340,7 +340,7 @@ dependencies = [
"bindgen 0.59.2",
"cranelift-codegen",
"cranelift-wasm",
"env_logger",
"env_logger 0.8.999",
"log",
"mozbuild",
"smallvec",
@ -1452,9 +1452,16 @@ dependencies = [
[[package]]
name = "env_logger"
version = "0.8.4"
version = "0.8.999"
dependencies = [
"env_logger 0.9.0",
]
[[package]]
name = "env_logger"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
dependencies = [
"atty",
"humantime",
@ -1912,7 +1919,7 @@ name = "gecko_logger"
version = "0.1.0"
dependencies = [
"app_services_logger",
"env_logger",
"env_logger 0.8.999",
"lazy_static",
"log",
]
@ -2162,7 +2169,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ed48dd0ba3a92d6bdf9efe7950664658daf346e72f0970868893643de25be26"
dependencies = [
"android_logger",
"env_logger",
"env_logger 0.8.999",
"ffi-support",
"glean-core",
"libc",
@ -3402,7 +3409,7 @@ source = "git+https://github.com/mozilla/mp4parse-rust?rev=3bfc47d9a571d08426760
dependencies = [
"bitreader",
"byteorder",
"env_logger",
"env_logger 0.8.999",
"fallible_collections",
"log",
"num-traits",
@ -3467,7 +3474,7 @@ version = "0.5.7"
source = "git+https://github.com/mozilla/neqo?tag=v0.5.7#f3de275b12c40f45718ce43a0482e771ba6cd4b8"
dependencies = [
"chrono",
"env_logger",
"env_logger 0.8.999",
"lazy_static",
"log",
"qlog",
@ -3772,7 +3779,7 @@ version = "0.1.4"
dependencies = [
"byteorder",
"core-foundation",
"env_logger",
"env_logger 0.8.999",
"lazy_static",
"libloading 0.5.2",
"log",
@ -4749,7 +4756,7 @@ name = "smoosh"
version = "0.1.0"
dependencies = [
"bumpalo",
"env_logger",
"env_logger 0.8.999",
"jsparagus",
"log",
]

Просмотреть файл

@ -120,6 +120,9 @@ hashbrown = { path = "build/rust/hashbrown" }
# Patch tokio-util 0.6 to 0.7
tokio-util = { path = "build/rust/tokio-util" }
# Patch env_logger 0.8 to 0.9
env_logger = { path = "build/rust/env_logger" }
# Patch autocfg to hide rustc output. Workaround for https://github.com/cuviper/autocfg/issues/30
autocfg = { path = "third_party/rust/autocfg" }

Просмотреть файл

@ -0,0 +1,19 @@
[package]
name = "env_logger"
version = "0.8.999"
edition = "2018"
license = "MPL-2.0"
[lib]
path = "lib.rs"
[dependencies.env_logger]
version = "0.9"
default-features = false
[features]
default = ["env_logger/default"]
termcolor = ["env_logger/termcolor"]
atty = ["env_logger/atty"]
humantime = ["env_logger/humantime"]
regex = ["env_logger/regex"]

Просмотреть файл

@ -0,0 +1,5 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
pub use env_logger::*;

Просмотреть файл

@ -1 +1 @@
{"files":{"CHANGELOG.md":"34c3abc5bfaeb865e9b901c245f7e41f02a96b6be50beef5302458bff548ef3c","Cargo.toml":"1003082e60245b8e54440285a0004e41b79bbece07dd077f831a82d59067e9cf","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"534d72fab83eaa93e0e61e3d092b888681e4705c77e568e4acad6d42993278ed","src/filter/mod.rs":"adc194701c7176a06e46f0e5d7f7fef101516ba51204aca9b7351c1dbc127daf","src/filter/regex.rs":"bdf875bac25e089e1e462f5dd01a88678067c24118ecd6268561c6a6af39747d","src/filter/string.rs":"fac54d51189fc0b5d2bff334b7a7e465177b431e3428299e345e1f90062d832e","src/fmt/humantime/extern_impl.rs":"f3087b29eedb8b4d5573621ad206e48a2eac72a77277be3b0e631d7dc9fb7a2e","src/fmt/humantime/mod.rs":"f4111c26cf2ffb85c1d639bd7674d55af7e1736e7e98c52f7be3070046a3253f","src/fmt/humantime/shim_impl.rs":"cce9a252abd5952fa109a72b1dfb85a593d237e22606b2b608a32c69184560e9","src/fmt/mod.rs":"e34bc64dea71c7439605aaafe53f08abd243e3478c99dd0425f6406b5f1a30dd","src/fmt/writer/atty.rs":"09d14097dee61492828daaabdbde9f43251e2cb32e79d66c1c0e63f317761704","src/fmt/writer/mod.rs":"960d9bdeb356b555d32269c6a2f68252c0553078d0c2b7915fdaf98842ef4ef3","src/fmt/writer/termcolor/extern_impl.rs":"839b8bf043939f3f22a6cd21c94e339149e5d0578a9b40fa8ca4fbe574573475","src/fmt/writer/termcolor/mod.rs":"a790f9391a50cd52be6823e3e55942de13a8d12e23d63765342ae9e8dd6d091c","src/fmt/writer/termcolor/shim_impl.rs":"9e9997823434d6741934ddeb5f4354c7da5083cee1e9dda997b4c6ccb31f9842","src/lib.rs":"cb93648746aad20da76a0630fc8ef904c2152a88e64f19123cb79284e7e35ed5","tests/init-twice-retains-filter.rs":"be5cd2132342d89ede1f5c4266173bb3c4d51cc22a1847f133d299a1c5430ccb","tests/log-in-log.rs":"29fecc65c1e0d1c22d79c97e7ca843ad44a91f27934148d7a05c48899a3f39d8","tests/log_tls_dtors.rs":"7320667d774a9b05037f7bf273fb2574dec0705707692a9cd2f46f4cd5bc68dd","tests/regexp_filter.rs":"a84263c995b534b6479a1d0abadf63f4f0264958ff86d9173d6b2139b82c4dc5"},"package":"a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"}
{"files":{"CHANGELOG.md":"34c3abc5bfaeb865e9b901c245f7e41f02a96b6be50beef5302458bff548ef3c","Cargo.toml":"ee8ec2750c4a2c13b1140b72a17355ddd7496f5636e9694d7648fd4d4ff23151","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"534d72fab83eaa93e0e61e3d092b888681e4705c77e568e4acad6d42993278ed","src/filter/mod.rs":"1df1659ebe5815119999a7f49dadb1c69d703acd6fad69a29574470aa1dd3533","src/filter/regex.rs":"bdf875bac25e089e1e462f5dd01a88678067c24118ecd6268561c6a6af39747d","src/filter/string.rs":"fac54d51189fc0b5d2bff334b7a7e465177b431e3428299e345e1f90062d832e","src/fmt/humantime/extern_impl.rs":"f3087b29eedb8b4d5573621ad206e48a2eac72a77277be3b0e631d7dc9fb7a2e","src/fmt/humantime/mod.rs":"f4111c26cf2ffb85c1d639bd7674d55af7e1736e7e98c52f7be3070046a3253f","src/fmt/humantime/shim_impl.rs":"cce9a252abd5952fa109a72b1dfb85a593d237e22606b2b608a32c69184560e9","src/fmt/mod.rs":"6256c12a661c471c2e8e4c3cb21a9a19bf9da793ae44addbbe059a056d5fa964","src/fmt/writer/atty.rs":"09d14097dee61492828daaabdbde9f43251e2cb32e79d66c1c0e63f317761704","src/fmt/writer/mod.rs":"960d9bdeb356b555d32269c6a2f68252c0553078d0c2b7915fdaf98842ef4ef3","src/fmt/writer/termcolor/extern_impl.rs":"839b8bf043939f3f22a6cd21c94e339149e5d0578a9b40fa8ca4fbe574573475","src/fmt/writer/termcolor/mod.rs":"a790f9391a50cd52be6823e3e55942de13a8d12e23d63765342ae9e8dd6d091c","src/fmt/writer/termcolor/shim_impl.rs":"9e9997823434d6741934ddeb5f4354c7da5083cee1e9dda997b4c6ccb31f9842","src/lib.rs":"2c97b9d898197b5b8f2a62c181f4d3ded0584b4548a888991e5fbe61caec5fa2","tests/init-twice-retains-filter.rs":"be5cd2132342d89ede1f5c4266173bb3c4d51cc22a1847f133d299a1c5430ccb","tests/log-in-log.rs":"29fecc65c1e0d1c22d79c97e7ca843ad44a91f27934148d7a05c48899a3f39d8","tests/log_tls_dtors.rs":"7320667d774a9b05037f7bf273fb2574dec0705707692a9cd2f46f4cd5bc68dd","tests/regexp_filter.rs":"a84263c995b534b6479a1d0abadf63f4f0264958ff86d9173d6b2139b82c4dc5"},"package":"0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"}

2
third_party/rust/env_logger/Cargo.toml поставляемый
Просмотреть файл

@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "env_logger"
version = "0.8.4"
version = "0.9.0"
authors = ["The Rust Project Developers"]
include = ["src/**/*", "tests", "LICENSE-*", "README.md", "CHANGELOG.md"]
description = "A logging implementation for `log` which is configured via an environment\nvariable.\n"

Просмотреть файл

@ -238,7 +238,7 @@ impl Builder {
});
} else {
// Consume map of directives.
let directives_map = mem::replace(&mut self.directives, HashMap::new());
let directives_map = mem::take(&mut self.directives);
directives = directives_map
.into_iter()
.map(|(name, level)| Directive { name, level })
@ -253,7 +253,7 @@ impl Builder {
}
Filter {
directives: mem::replace(&mut directives, Vec::new()),
directives: mem::take(&mut directives),
filter: mem::replace(&mut self.filter, None),
}
}

125
third_party/rust/env_logger/src/fmt/mod.rs поставляемый
Просмотреть файл

@ -141,6 +141,7 @@ pub(crate) type FormatFn = Box<dyn Fn(&mut Formatter, &Record) -> io::Result<()>
pub(crate) struct Builder {
pub format_timestamp: Option<TimestampPrecision>,
pub format_module_path: bool,
pub format_target: bool,
pub format_level: bool,
pub format_indent: Option<usize>,
pub custom_format: Option<FormatFn>,
@ -152,7 +153,8 @@ impl Default for Builder {
fn default() -> Self {
Builder {
format_timestamp: Some(Default::default()),
format_module_path: true,
format_module_path: false,
format_target: true,
format_level: true,
format_indent: Some(4),
custom_format: None,
@ -186,6 +188,7 @@ impl Builder {
let fmt = DefaultFormat {
timestamp: built.format_timestamp,
module_path: built.format_module_path,
target: built.format_target,
level: built.format_level,
written_header_value: false,
indent: built.format_indent,
@ -210,6 +213,7 @@ type SubtleStyle = &'static str;
struct DefaultFormat<'a> {
timestamp: Option<TimestampPrecision>,
module_path: bool,
target: bool,
level: bool,
written_header_value: bool,
indent: Option<usize>,
@ -222,6 +226,7 @@ impl<'a> DefaultFormat<'a> {
self.write_timestamp()?;
self.write_level(record)?;
self.write_module_path(record)?;
self.write_target(record)?;
self.finish_header()?;
self.write_args(record)
@ -311,6 +316,17 @@ impl<'a> DefaultFormat<'a> {
}
}
fn write_target(&mut self, record: &Record) -> io::Result<()> {
if !self.target {
return Ok(());
}
match record.target() {
"" => Ok(()),
target => self.write_header_value(target),
}
}
fn finish_header(&mut self) -> io::Result<()> {
if self.written_header_value {
let close_brace = self.subtle_style("]");
@ -381,23 +397,33 @@ mod tests {
use log::{Level, Record};
fn write(fmt: DefaultFormat) -> String {
fn write_record(record: Record, fmt: DefaultFormat) -> String {
let buf = fmt.buf.buf.clone();
let record = Record::builder()
.args(format_args!("log\nmessage"))
.level(Level::Info)
.file(Some("test.rs"))
.line(Some(144))
.module_path(Some("test::path"))
.build();
fmt.write(&record).expect("failed to write record");
let buf = buf.borrow();
String::from_utf8(buf.bytes().to_vec()).expect("failed to read record")
}
fn write_target<'a>(target: &'a str, fmt: DefaultFormat) -> String {
write_record(
Record::builder()
.args(format_args!("log\nmessage"))
.level(Level::Info)
.file(Some("test.rs"))
.line(Some(144))
.module_path(Some("test::path"))
.target(target)
.build(),
fmt,
)
}
fn write(fmt: DefaultFormat) -> String {
write_target("", fmt)
}
#[test]
fn format_with_header() {
let writer = writer::Builder::new()
@ -409,6 +435,7 @@ mod tests {
let written = write(DefaultFormat {
timestamp: None,
module_path: true,
target: false,
level: true,
written_header_value: false,
indent: None,
@ -430,6 +457,7 @@ mod tests {
let written = write(DefaultFormat {
timestamp: None,
module_path: false,
target: false,
level: false,
written_header_value: false,
indent: None,
@ -451,6 +479,7 @@ mod tests {
let written = write(DefaultFormat {
timestamp: None,
module_path: true,
target: false,
level: true,
written_header_value: false,
indent: Some(4),
@ -472,6 +501,7 @@ mod tests {
let written = write(DefaultFormat {
timestamp: None,
module_path: true,
target: false,
level: true,
written_header_value: false,
indent: Some(0),
@ -493,6 +523,7 @@ mod tests {
let written = write(DefaultFormat {
timestamp: None,
module_path: false,
target: false,
level: false,
written_header_value: false,
indent: Some(4),
@ -514,6 +545,7 @@ mod tests {
let written = write(DefaultFormat {
timestamp: None,
module_path: false,
target: false,
level: false,
written_header_value: false,
indent: None,
@ -535,6 +567,7 @@ mod tests {
let written = write(DefaultFormat {
timestamp: None,
module_path: false,
target: false,
level: false,
written_header_value: false,
indent: Some(4),
@ -544,4 +577,76 @@ mod tests {
assert_eq!("log\n\n message\n\n", written);
}
#[test]
fn format_target() {
let writer = writer::Builder::new()
.write_style(WriteStyle::Never)
.build();
let mut f = Formatter::new(&writer);
let written = write_target(
"target",
DefaultFormat {
timestamp: None,
module_path: true,
target: true,
level: true,
written_header_value: false,
indent: None,
suffix: "\n",
buf: &mut f,
},
);
assert_eq!("[INFO test::path target] log\nmessage\n", written);
}
#[test]
fn format_empty_target() {
let writer = writer::Builder::new()
.write_style(WriteStyle::Never)
.build();
let mut f = Formatter::new(&writer);
let written = write(DefaultFormat {
timestamp: None,
module_path: true,
target: true,
level: true,
written_header_value: false,
indent: None,
suffix: "\n",
buf: &mut f,
});
assert_eq!("[INFO test::path] log\nmessage\n", written);
}
#[test]
fn format_no_target() {
let writer = writer::Builder::new()
.write_style(WriteStyle::Never)
.build();
let mut f = Formatter::new(&writer);
let written = write_target(
"target",
DefaultFormat {
timestamp: None,
module_path: true,
target: false,
level: true,
written_header_value: false,
indent: None,
suffix: "\n",
buf: &mut f,
},
);
assert_eq!("[INFO test::path] log\nmessage\n", written);
}
}

44
third_party/rust/env_logger/src/lib.rs поставляемый
Просмотреть файл

@ -97,28 +97,38 @@
//! directives*. A logging directive is of the form:
//!
//! ```text
//! path::to::module=level
//! example::log::target=level
//! ```
//!
//! The path to the module is rooted in the name of the crate it was compiled
//! for, so if your program is contained in a file `hello.rs`, for example, to
//! turn on logging for this file you would use a value of `RUST_LOG=hello`.
//! Furthermore, this path is a prefix-search, so all modules nested in the
//! specified module will also have logging enabled.
//! The log target is typically equal to the path of the module the message
//! in question originated from, though it can be overriden.
//!
//! The path is rooted in the name of the crate it was compiled for, so if
//! your program is in a file called, for example, `hello.rs`, the path would
//! simply be be `hello`.
//!
//! Furthermore, the the log can be filtered using prefix-search based on the
//! specified log target. A value of, for example, `RUST_LOG=example`, would
//! match all of the messages with targets:
//!
//! * `example`
//! * `example::test`
//! * `example::test::module::submodule`
//! * `examples::and_more_examples`
//!
//! When providing the crate name or a module path, explicitly specifying the
//! log level is optional. If omitted, all logging for the item (and its
//! children) will be enabled.
//! log level is optional. If omitted, all logging for the item will be
//! enabled.
//!
//! The names of the log levels that may be specified correspond to the
//! variations of the [`log::Level`][level-enum] enum from the `log`
//! crate. They are:
//!
//! * `error`
//! * `warn`
//! * `info`
//! * `debug`
//! * `trace`
//! * `error`
//! * `warn`
//! * `info`
//! * `debug`
//! * `trace`
//!
//! There is also a pseudo logging level, `off`, which may be specified to
//! disable all logging for a given module or for the entire application. As
@ -260,7 +270,7 @@
//! env_logger::Builder::from_env(Env::default().default_filter_or("warn")).init();
//! ```
//!
//! [gh-repo-examples]: https://github.com/env-logger-rs/env_logger/tree/master/examples
//! [gh-repo-examples]: https://github.com/env-logger-rs/env_logger/tree/main/examples
//! [level-enum]: https://docs.rs/log/latest/log/enum.Level.html
//! [log-crate-url]: https://docs.rs/log/
//! [`Builder`]: struct.Builder.html
@ -598,6 +608,12 @@ impl Builder {
self
}
/// Whether or not to write the target in the default format.
pub fn format_target(&mut self, write: bool) -> &mut Self {
self.format.format_target = write;
self
}
/// Configures the amount of spaces to use to indent multiline log records.
/// A value of `None` disables any kind of indentation.
pub fn format_indent(&mut self, indent: Option<usize>) -> &mut Self {