From 75e83fd171abc6feba93cb1c21e2c196ed75693c Mon Sep 17 00:00:00 2001 From: Rain Date: Sun, 6 Oct 2024 23:34:00 -0700 Subject: [PATCH] [meta] switch to tracing About time we switched over. Write our own simple formatter to match formatting. --- Cargo.lock | 63 ++++++---- Cargo.toml | 5 +- cargo-nextest/Cargo.toml | 4 +- cargo-nextest/src/dispatch.rs | 48 ++++--- cargo-nextest/src/errors.rs | 112 ++++++++--------- cargo-nextest/src/helpers.rs | 21 +++- cargo-nextest/src/output.rs | 125 +++++++++++++++---- cargo-nextest/src/reuse_build.rs | 3 +- cargo-nextest/src/update.rs | 11 +- nextest-runner/Cargo.toml | 2 +- nextest-runner/src/cargo_config/discovery.rs | 3 +- nextest-runner/src/config/config_impl.rs | 9 +- nextest-runner/src/double_spawn.rs | 5 +- nextest-runner/src/list/binary_list.rs | 3 +- nextest-runner/src/list/rust_build_meta.rs | 3 +- nextest-runner/src/list/test_list.rs | 11 +- nextest-runner/src/platform.rs | 9 +- nextest-runner/src/reuse_build/archiver.rs | 7 +- nextest-runner/src/runner.rs | 7 +- nextest-runner/src/rustc_cli.rs | 15 +-- nextest-runner/src/update.rs | 15 +-- workspace-hack/Cargo.toml | 2 + 22 files changed, 305 insertions(+), 178 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 514978f1ac1..092e60d657b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -372,10 +372,8 @@ dependencies = [ "dialoguer", "duct", "enable-ansi-support", - "env_logger", "guppy", "itertools", - "log", "miette", "nextest-filtering", "nextest-metadata", @@ -392,6 +390,8 @@ dependencies = [ "supports-unicode", "swrite", "thiserror", + "tracing", + "tracing-subscriber", ] [[package]] @@ -514,10 +514,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" dependencies = [ "backtrace", + "color-spantrace", "eyre", "indenter", "once_cell", "owo-colors 3.5.0", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" +dependencies = [ + "once_cell", + "owo-colors 3.5.0", + "tracing-core", + "tracing-error", ] [[package]] @@ -801,25 +815,6 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" -[[package]] -name = "env_filter" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" -dependencies = [ - "log", -] - -[[package]] -name = "env_logger" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" -dependencies = [ - "env_filter", - "log", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -1745,7 +1740,6 @@ dependencies = [ "is_ci", "itertools", "libc", - "log", "maplit", "miette", "mukti-metadata", @@ -1782,6 +1776,7 @@ dependencies = [ "tokio", "toml", "toml_edit", + "tracing", "unicode-ident", "unicode-normalization", "win32job", @@ -1820,6 +1815,8 @@ dependencies = [ "smallvec", "syn", "tokio", + "tracing-core", + "tracing-subscriber", "windows-sys 0.52.0", "windows-sys 0.59.0", "xxhash-rust", @@ -3238,6 +3235,27 @@ dependencies = [ "valuable", ] +[[package]] +name = "tracing-error" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" +dependencies = [ + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + [[package]] name = "tracing-subscriber" version = "0.3.18" @@ -3251,6 +3269,7 @@ dependencies = [ "thread_local", "tracing", "tracing-core", + "tracing-log", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 2bd6175bc3e..8a1ea44616e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,8 +35,7 @@ cargo-nextest = { path = "cargo-nextest", default-features = false, features = [ "default-no-update", ] } cfg-if = "1.0.0" -# The default features for color-eyre include tracing support -- for now we don't use that support. -color-eyre = { version = "0.6.3", default-features = false } +color-eyre = "0.6.3" # config's "preserve_order" feature is needed for preserving the order of # setup scripts in .config/nextest.toml. config = { version = "0.14.0", default-features = false, features = [ @@ -116,6 +115,8 @@ thiserror = "1.0.64" tokio = "1.40.0" toml = "0.8.19" toml_edit = "0.22.22" +tracing = "0.1.40" +tracing-subscriber = { version = "0.3.18", default-features = false, features = ["std", "tracing-log", "fmt"] } unicode-ident = "1.0.13" unicode-normalization = "0.1.24" win32job = "2.0.0" diff --git a/cargo-nextest/Cargo.toml b/cargo-nextest/Cargo.toml index ed936347691..4be6b7e249d 100644 --- a/cargo-nextest/Cargo.toml +++ b/cargo-nextest/Cargo.toml @@ -19,9 +19,7 @@ color-eyre.workspace = true dialoguer.workspace = true duct.workspace = true enable-ansi-support.workspace = true -env_logger.workspace = true guppy.workspace = true -log.workspace = true itertools.workspace = true miette = { workspace = true, features = ["fancy"] } # Instead of using workspace dependencies which have floating versions, we pin exact versions here @@ -41,6 +39,8 @@ supports-color.workspace = true supports-unicode.workspace = true swrite.workspace = true thiserror.workspace = true +tracing.workspace = true +tracing-subscriber = { workspace = true, default-features = false } [build-dependencies] camino.workspace = true diff --git a/cargo-nextest/src/dispatch.rs b/cargo-nextest/src/dispatch.rs index ecb394137a5..98ef76b4c7e 100644 --- a/cargo-nextest/src/dispatch.rs +++ b/cargo-nextest/src/dispatch.rs @@ -11,7 +11,6 @@ use camino::{Utf8Path, Utf8PathBuf}; use clap::{builder::BoolishValueParser, ArgAction, Args, Parser, Subcommand, ValueEnum}; use guppy::graph::PackageGraph; use itertools::Itertools; -use log::warn; use nextest_filtering::{EvalContext, Filterset, FiltersetKind, ParseContext}; use nextest_metadata::BuildPlatform; use nextest_runner::{ @@ -58,6 +57,7 @@ use std::{ sync::Arc, }; use swrite::{swrite, SWrite}; +use tracing::{debug, info, warn, Level}; /// A next-generation test runner for Rust. /// @@ -1228,7 +1228,7 @@ impl BaseApp { let experimental = version_only_config.experimental(); if !experimental.is_empty() { - log::info!( + info!( "experimental features enabled: {}", experimental .iter() @@ -1269,13 +1269,13 @@ impl BaseApp { current, tool, } => { - log::warn!( + warn!( "this repository recommends nextest version {}, but the current version is {}", required.style(styles.bold), current.style(styles.bold), ); if let Some(tool) = tool { - log::info!( + info!( target: "cargo_nextest::no_heading", "(recommended version specified by tool `{}`)", tool, @@ -1289,13 +1289,12 @@ impl BaseApp { current, tool, } => { - log::info!( + info!( "overriding version check (required: {}, current: {})", - required, - current + required, current ); if let Some(tool) = tool { - log::info!( + info!( target: "cargo_nextest::no_heading", "(required version specified by tool `{}`)", tool, @@ -1309,13 +1308,12 @@ impl BaseApp { current, tool, } => { - log::info!( + info!( "overriding version check (recommended: {}, current: {})", - recommended, - current, + recommended, current, ); if let Some(tool) = tool { - log::info!( + info!( target: "cargo_nextest::no_heading", "(recommended version specified by tool `{}`)", tool, @@ -1349,13 +1347,13 @@ impl BaseApp { current, tool, } => { - log::warn!( + warn!( "this repository recommends nextest version {}, but the current version is {}", required.style(styles.bold), current.style(styles.bold), ); if let Some(tool) = tool { - log::info!( + info!( target: "cargo_nextest::no_heading", "(recommended version specified by tool `{}`)", tool, @@ -1364,7 +1362,7 @@ impl BaseApp { // Don't need to print extra text here -- this is a warning, not an error. crate::helpers::log_needs_update( - log::Level::Info, + Level::INFO, crate::helpers::BYPASS_VERSION_TEXT, &styles, ); @@ -1382,13 +1380,13 @@ impl BaseApp { fn load_double_spawn(&self) -> &DoubleSpawnInfo { self.double_spawn.get_or_init(|| { if std::env::var("NEXTEST_EXPERIMENTAL_DOUBLE_SPAWN").is_ok() { - log::warn!( + warn!( "double-spawn is no longer experimental: \ NEXTEST_EXPERIMENTAL_DOUBLE_SPAWN does not need to be set" ); } if std::env::var("NEXTEST_DOUBLE_SPAWN") == Ok("0".to_owned()) { - log::info!("NEXTEST_DOUBLE_SPAWN=0 set, disabling double-spawn for test processes"); + info!("NEXTEST_DOUBLE_SPAWN=0 set, disabling double-spawn for test processes"); DoubleSpawnInfo::disabled() } else { DoubleSpawnInfo::try_enable() @@ -1537,7 +1535,7 @@ struct App { fn check_experimental_filtering(_output: OutputContext) { const EXPERIMENTAL_ENV: &str = "NEXTEST_EXPERIMENTAL_FILTER_EXPR"; if std::env::var(EXPERIMENTAL_ENV).is_ok() { - log::warn!("filtersets are no longer experimental: NEXTEST_EXPERIMENTAL_FILTER_EXPR does not need to be set"); + warn!("filtersets are no longer experimental: NEXTEST_EXPERIMENTAL_FILTER_EXPR does not need to be set"); } } @@ -1922,7 +1920,7 @@ impl ShowConfigCommand { NextestVersionEval::Satisfied => Ok(0), NextestVersionEval::Error { .. } => { crate::helpers::log_needs_update( - log::Level::Error, + Level::ERROR, crate::helpers::BYPASS_VERSION_TEXT, &output.stderr_styles(), ); @@ -1930,7 +1928,7 @@ impl ShowConfigCommand { } NextestVersionEval::Warn { .. } => { crate::helpers::log_needs_update( - log::Level::Warn, + Level::WARN, crate::helpers::BYPASS_VERSION_TEXT, &output.stderr_styles(), ); @@ -2049,7 +2047,7 @@ impl SelfCommand { output, ) } else { - log::info!("this version of cargo-nextest cannot perform self-updates\n\ + info!("this version of cargo-nextest cannot perform self-updates\n\ (hint: this usually means nextest was installed by a package manager)"); Ok(nextest_metadata::NextestExitCode::SELF_UPDATE_UNAVAILABLE) } @@ -2273,7 +2271,7 @@ fn discover_target_triple( ) -> Option { match TargetTriple::find(cargo_configs, target_cli_option) { Ok(Some(triple)) => { - log::debug!( + debug!( "using target triple `{}` defined by `{}`; {}", triple.platform.triple_str(), triple.source, @@ -2282,7 +2280,7 @@ fn discover_target_triple( Some(triple) } Ok(None) => { - log::debug!("no target triple found, assuming no cross-compilation"); + debug!("no target triple found, assuming no cross-compilation"); None } @@ -2325,7 +2323,7 @@ fn runner_for_target( fn log_platform_runner(prefix: &str, runner: &PlatformRunner, styles: &StderrStyles) { let runner_command = shell_words::join(std::iter::once(runner.binary()).chain(runner.args())); - log::info!( + info!( "{prefix}using target runner `{}` defined by {}", runner_command.style(styles.bold), runner.source() @@ -2341,7 +2339,7 @@ fn warn_on_err(thing: &str, err: &(dyn std::error::Error), styles: &StderrStyles next_error = err.source(); } - log::warn!("{}", s); + warn!("{}", s); } #[cfg(test)] diff --git a/cargo-nextest/src/errors.rs b/cargo-nextest/src/errors.rs index cce4794c47c..e75d6292904 100644 --- a/cargo-nextest/src/errors.rs +++ b/cargo-nextest/src/errors.rs @@ -11,6 +11,7 @@ use owo_colors::OwoColorize; use semver::Version; use std::{error::Error, string::FromUtf8Error}; use thiserror::Error; +use tracing::{error, info, Level}; pub(crate) type Result = std::result::Result; @@ -443,11 +444,11 @@ impl ExpectedError { pub fn display_to_stderr(&self, styles: &StderrStyles) { let mut next_error = match &self { Self::SetCurrentDirFailed { error } => { - log::error!("could not change to requested directory"); + error!("could not change to requested directory"); Some(error as &dyn Error) } Self::CargoMetadataExecFailed { command, err } => { - log::error!("failed to execute `{}`", command.style(styles.bold)); + error!("failed to execute `{}`", command.style(styles.bold)); Some(err as &dyn Error) } Self::CargoMetadataFailed { .. } => { @@ -455,7 +456,7 @@ impl ExpectedError { None } Self::CargoLocateProjectExecFailed { command, err } => { - log::error!("failed to execute `{}`", command.style(styles.bold)); + error!("failed to execute `{}`", command.style(styles.bold)); Some(err as &dyn Error) } Self::CargoLocateProjectFailed { .. } => { @@ -463,18 +464,18 @@ impl ExpectedError { None } Self::WorkspaceRootInvalidUtf8 { err } => { - log::error!("workspace root is not valid UTF-8"); + error!("workspace root is not valid UTF-8"); Some(err as &dyn Error) } Self::WorkspaceRootInvalid { workspace_root } => { - log::error!( + error!( "workspace root `{}` is invalid", workspace_root.style(styles.bold) ); None } Self::ProfileNotFound { err } => { - log::error!("{}", err); + error!("{}", err); err.source() } Self::RootManifestNotFound { @@ -495,21 +496,21 @@ impl ExpectedError { } ReuseBuildKind::Normal => String::new(), }; - log::error!( + error!( "workspace root manifest at {} does not exist{hint_str}", path.style(styles.bold) ); None } Self::StoreDirCreateError { store_dir, err } => { - log::error!( + error!( "failed to create store dir at `{}`", store_dir.style(styles.bold) ); Some(err as &dyn Error) } Self::CargoConfigError { err } => { - log::error!("{}", err); + error!("{}", err); err.source() } Self::ConfigParseError { err } => { @@ -517,14 +518,14 @@ impl ExpectedError { ConfigParseErrorKind::FiltersetOrCfgParseError(errors) => { // Override errors are printed out using miette. for override_error in errors { - log::error!( + error!( "for config file `{}`{}, failed to parse overrides for profile: {}", err.config_file(), provided_by_tool(err.tool()), override_error.profile_name.style(styles.bold) ); for report in override_error.reports() { - log::error!(target: "cargo_nextest::no_heading", "{report:?}"); + error!(target: "cargo_nextest::no_heading", "{report:?}"); } } None @@ -546,7 +547,7 @@ impl ExpectedError { )); } - log::error!( + error!( "for config file `{}`{}, unknown test groups defined \ (known groups: {known_groups_str}):\n{errors_str}", err.config_file(), @@ -571,7 +572,7 @@ impl ExpectedError { )); } - log::error!( + error!( "for config file `{}`{}, unknown scripts defined \ (known scripts: {known_scripts_str}):\n{errors_str}", err.config_file(), @@ -589,7 +590,7 @@ impl ExpectedError { .map(|feature_name| feature_name.style(styles.bold)) .join(", "); - log::error!( + error!( "for config file `{}`{}, unknown experimental features defined: {unknown_str} (known features: {known_str}):", err.config_file(), @@ -599,32 +600,32 @@ impl ExpectedError { } _ => { // These other errors are printed out normally. - log::error!("{}", err); + error!("{}", err); err.source() } } } Self::TestFilterBuilderError { err } => { - log::error!("{err}"); + error!("{err}"); err.source() } Self::UnknownHostPlatform { err } => { - log::error!("the host platform was unknown to nextest"); + error!("the host platform was unknown to nextest"); Some(err as &dyn Error) } Self::TargetTripleError { err } => { - log::error!("{err}"); + error!("{err}"); err.source() } Self::MetadataMaterializeError { arg_name, err } => { - log::error!( + error!( "error reading metadata from argument {}", format!("--{arg_name}").style(styles.bold) ); Some(err as &dyn Error) } Self::UnknownArchiveFormat { archive_file, err } => { - log::error!( + error!( "failed to autodetect archive format for {}", archive_file.style(styles.bold) ); @@ -635,25 +636,25 @@ impl ExpectedError { err, redactor, } => { - log::error!( + error!( "error creating archive `{}`", redactor.redact_path(archive_file).style(styles.bold) ); Some(err as &dyn Error) } Self::ArchiveExtractError { archive_file, err } => { - log::error!( + error!( "error extracting archive `{}`", archive_file.style(styles.bold) ); Some(err as &dyn Error) } Self::RustBuildMetaParseError { err } => { - log::error!("error parsing Rust build metadata"); + error!("error parsing Rust build metadata"); Some(err as &dyn Error) } Self::PathMapperConstructError { arg_name, err } => { - log::error!( + error!( "argument {} specified `{}` that couldn't be read", format!("--{arg_name}").style(styles.bold), err.input().style(styles.bold) @@ -665,19 +666,19 @@ impl ExpectedError { Some(path) => format!(" from file `{}`", path.style(styles.bold)), None => "".to_owned(), }; - log::error!("error parsing Cargo metadata{}", metadata_source); + error!("error parsing Cargo metadata{}", metadata_source); Some(err as &dyn Error) } Self::FromMessagesError { err } => { - log::error!("failed to parse messages generated by Cargo"); + error!("failed to parse messages generated by Cargo"); Some(err as &dyn Error) } Self::CreateTestListError { err } => { - log::error!("creating test list failed"); + error!("creating test list failed"); Some(err as &dyn Error) } Self::BuildExecFailed { command, err } => { - log::error!("failed to execute `{}`", command.style(styles.bold)); + error!("failed to execute `{}`", command.style(styles.bold)); Some(err as &dyn Error) } Self::BuildFailed { command, exit_code } => { @@ -688,7 +689,7 @@ impl ExpectedError { None => "".to_owned(), }; - log::error!( + error!( "command `{}` exited{}", command.style(styles.bold), with_code_str, @@ -697,27 +698,27 @@ impl ExpectedError { None } Self::TestRunnerBuildError { err } => { - log::error!("failed to build test runner"); + error!("failed to build test runner"); Some(err as &dyn Error) } Self::ConfigureHandleInheritanceError { err } => { - log::error!("{err}"); + error!("{err}"); err.source() } Self::WriteTestListError { err } => { - log::error!("failed to write test list to output"); + error!("failed to write test list to output"); Some(err as &dyn Error) } Self::WriteEventError { err } => { - log::error!("failed to write event to output"); + error!("failed to write event to output"); Some(err as &dyn Error) } Self::SetupScriptFailed => { - log::error!("setup script failed"); + error!("setup script failed"); None } Self::TestRunFailed => { - log::error!("test run failed"); + error!("test run failed"); None } Self::NoTestsRun { is_default } => { @@ -726,11 +727,11 @@ impl ExpectedError { } else { "" }; - log::error!("no tests to run{hint_str}"); + error!("no tests to run{hint_str}"); None } Self::ShowTestGroupsError { err } => { - log::error!("{err}"); + error!("{err}"); err.source() } Self::RequiredVersionNotMet { @@ -738,13 +739,13 @@ impl ExpectedError { current, tool, } => { - log::error!( + error!( "this repository requires nextest version {}, but the current version is {}", required.style(styles.bold), current.style(styles.bold), ); if let Some(tool) = tool { - log::info!( + info!( target: "cargo_nextest::no_heading", "(required version specified by tool `{}`)", tool, @@ -752,7 +753,7 @@ impl ExpectedError { } crate::helpers::log_needs_update( - log::Level::Info, + Level::INFO, crate::helpers::BYPASS_VERSION_TEXT, styles, ); @@ -760,30 +761,29 @@ impl ExpectedError { } #[cfg(feature = "self-update")] Self::UpdateVersionParseError { err } => { - log::error!("failed to parse --version"); + error!("failed to parse --version"); Some(err as &dyn Error) } #[cfg(feature = "self-update")] Self::UpdateError { err } => { - log::error!( + error!( "failed to update nextest (please update manually by visiting <{}>)", "https://get.nexte.st".style(styles.bold) ); Some(err as &dyn Error) } Self::DialoguerError { err } => { - log::error!("error reading input prompt"); + error!("error reading input prompt"); Some(err as &dyn Error) } Self::SignalHandlerSetupError { err } => { - log::error!("error setting up signal handler"); + error!("error setting up signal handler"); Some(err as &dyn Error) } Self::ExperimentalFeatureNotEnabled { name, var_name } => { - log::error!( + error!( "{} is an experimental feature and must be enabled with {}=1", - name, - var_name + name, var_name ); None } @@ -792,44 +792,44 @@ impl ExpectedError { for single_error in &errors.errors { let report = miette::Report::new(single_error.clone()) .with_source_code(errors.input.to_owned()); - log::error!(target: "cargo_nextest::no_heading", "{:?}", report); + error!(target: "cargo_nextest::no_heading", "{:?}", report); } } - log::error!("failed to parse filterset"); + error!("failed to parse filterset"); None } Self::TestBinaryArgsParseError { reason, args } => { - log::error!( + error!( "failed to parse test binary arguments `{}`: arguments are {reason}", args.join(", "), ); None } Self::DoubleSpawnParseArgsError { args, err } => { - log::error!("[double-spawn] failed to parse arguments `{args}`"); + error!("[double-spawn] failed to parse arguments `{args}`"); Some(err as &dyn Error) } Self::DoubleSpawnExecError { command, err } => { - log::error!("[double-spawn] failed to exec `{command:?}`"); + error!("[double-spawn] failed to exec `{command:?}`"); Some(err as &dyn Error) } Self::InvalidMessageFormatVersion { err } => { - log::error!("error parsing message format version"); + error!("error parsing message format version"); Some(err as &dyn Error) } Self::DebugExtractReadError { kind, path, err } => { - log::error!("error reading {kind} file `{}`", path.style(styles.bold),); + error!("error reading {kind} file `{}`", path.style(styles.bold),); Some(err as &dyn Error) } Self::DebugExtractWriteError { format, err } => { - log::error!("error writing {format} output"); + error!("error writing {format} output"); Some(err as &dyn Error) } }; while let Some(err) = next_error { - log::error!(target: "cargo_nextest::no_heading", "\nCaused by:\n {}", err); + error!(target: "cargo_nextest::no_heading", "\nCaused by:\n {}", err); next_error = err.source(); } } diff --git a/cargo-nextest/src/helpers.rs b/cargo-nextest/src/helpers.rs index 92c5dfb88d5..48d1c4d265a 100644 --- a/cargo-nextest/src/helpers.rs +++ b/cargo-nextest/src/helpers.rs @@ -3,11 +3,24 @@ use crate::output::StderrStyles; +// From https://github.com/tokio-rs/tracing/issues/2730#issuecomment-1943022805 +macro_rules! dyn_event { + ($lvl:ident, $($arg:tt)+) => { + match $lvl { + ::tracing::Level::TRACE => ::tracing::trace!($($arg)+), + ::tracing::Level::DEBUG => ::tracing::debug!($($arg)+), + ::tracing::Level::INFO => ::tracing::info!($($arg)+), + ::tracing::Level::WARN => ::tracing::warn!($($arg)+), + ::tracing::Level::ERROR => ::tracing::error!($($arg)+), + } + }; +} + #[cfg(feature = "self-update")] -pub(crate) fn log_needs_update(level: log::Level, extra: &str, styles: &StderrStyles) { +pub(crate) fn log_needs_update(level: tracing::Level, extra: &str, styles: &StderrStyles) { use owo_colors::OwoColorize; - log::log!( + dyn_event!( level, "update nextest with {}{}", "cargo nextest self update".style(styles.bold), @@ -16,8 +29,8 @@ pub(crate) fn log_needs_update(level: log::Level, extra: &str, styles: &StderrSt } #[cfg(not(feature = "self-update"))] -pub(crate) fn log_needs_update(level: log::Level, extra: &str, _styles: &StderrStyles) { - log::log!(level, "update nextest via your package manager{}", extra); +pub(crate) fn log_needs_update(level: tracing::Level, extra: &str, _styles: &StderrStyles) { + dyn_event!(level, "update nextest via your package manager{}", extra); } pub(crate) const BYPASS_VERSION_TEXT: &str = ", or bypass check with --override-version-check"; diff --git a/cargo-nextest/src/output.rs b/cargo-nextest/src/output.rs index 0b77d81a778..f4705f76a83 100644 --- a/cargo-nextest/src/output.rs +++ b/cargo-nextest/src/output.rs @@ -3,15 +3,27 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use clap::{Args, ValueEnum}; -use env_logger::fmt::Formatter; -use log::{Level, LevelFilter, Record}; use miette::{GraphicalTheme, MietteHandlerOpts, ThemeStyles}; use nextest_runner::{reporter::ReporterStderr, write_str::WriteStr}; use owo_colors::{style, OwoColorize, Style}; use std::{ + fmt, io::{self, BufWriter, Stderr, Stdout, Write}, marker::PhantomData, }; +use tracing::{ + field::{Field, Visit}, + level_filters::LevelFilter, + Event, Level, Subscriber, +}; +use tracing_subscriber::{ + filter::Targets, + fmt::{format, FmtContext, FormatEvent, FormatFields}, + layer::SubscriberExt, + registry::LookupSpan, + util::SubscriberInitExt, + Layer, +}; pub(crate) mod clap_styles { use clap::builder::{ @@ -114,6 +126,75 @@ pub enum Color { static INIT_LOGGER: std::sync::Once = std::sync::Once::new(); +struct SimpleFormatter { + styles: LogStyles, +} + +impl FormatEvent for SimpleFormatter +where + S: Subscriber + for<'a> LookupSpan<'a>, + N: for<'a> FormatFields<'a> + 'static, +{ + fn format_event( + &self, + _ctx: &FmtContext<'_, S, N>, + mut writer: format::Writer<'_>, + event: &Event<'_>, + ) -> fmt::Result { + let metadata = event.metadata(); + + if metadata.target() != "cargo_nextest::no_heading" { + match *metadata.level() { + Level::ERROR => { + write!(writer, "{}: ", "error".style(self.styles.error))?; + } + Level::WARN => { + write!(writer, "{}: ", "warning".style(self.styles.warning))?; + } + Level::INFO => { + write!(writer, "{}: ", "info".style(self.styles.info))?; + } + Level::DEBUG => { + write!(writer, "{}: ", "debug".style(self.styles.debug))?; + } + Level::TRACE => { + write!(writer, "{}: ", "trace".style(self.styles.trace))?; + } + } + } + + let mut visitor = MessageVisitor { + writer: &mut writer, + error: None, + }; + + event.record(&mut visitor); + + if let Some(error) = visitor.error { + return Err(error); + } + + writeln!(writer) + } +} + +static MESSAGE_FIELD: &str = "message"; + +struct MessageVisitor<'writer, 'a> { + writer: &'a mut format::Writer<'writer>, + error: Option, +} + +impl<'writer, 'a> Visit for MessageVisitor<'writer, 'a> { + fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { + if field.name() == MESSAGE_FIELD { + if let Err(error) = write!(self.writer, "{:?}", value) { + self.error = Some(error); + } + } + } +} + impl Color { pub(crate) fn init(self) { // Pass the styles in as a stylesheet to ensure we use the latest supports-color here. @@ -123,11 +204,24 @@ impl Color { } INIT_LOGGER.call_once(|| { - env_logger::Builder::new() - .filter_level(LevelFilter::Info) - .parse_env("NEXTEST_LOG") - .format(move |f, record| format_fn(f, record, &log_styles)) - .init(); + let level_str = std::env::var_os("NEXTEST_LOG").unwrap_or_default(); + let level_str = level_str + .into_string() + .unwrap_or_else(|_| panic!("NEXTEST_LOG is not UTF-8")); + + // If the level string is empty, use the standard level filter instead. + let targets = if level_str.is_empty() { + Targets::new().with_default(LevelFilter::INFO) + } else { + level_str.parse().expect("unable to parse NEXTEST_LOG") + }; + + let layer = tracing_subscriber::fmt::layer() + .event_format(SimpleFormatter { styles: log_styles }) + .with_writer(std::io::stderr) + .with_filter(targets); + + tracing_subscriber::registry().with(layer).init(); miette::set_hook(Box::new(move |_| { let theme_styles = if self.should_colorize(supports_color::Stream::Stderr) { @@ -176,27 +270,13 @@ impl Color { } } -fn format_fn(f: &mut Formatter, record: &Record<'_>, styles: &LogStyles) -> std::io::Result<()> { - if record.target() == "cargo_nextest::no_heading" { - writeln!(f, "{}", record.args())?; - return Ok(()); - } - - match record.level() { - Level::Error => writeln!(f, "{}: {}", "error".style(styles.error), record.args()), - Level::Warn => writeln!(f, "{}: {}", "warning".style(styles.warning), record.args()), - Level::Info => writeln!(f, "{}: {}", "info".style(styles.info), record.args()), - Level::Debug => writeln!(f, "{}: {}", "debug".style(styles.debug), record.args()), - _other => Ok(()), - } -} - #[derive(Debug, Default)] struct LogStyles { error: Style, warning: Style, info: Style, debug: Style, + trace: Style, } impl LogStyles { @@ -205,6 +285,7 @@ impl LogStyles { self.warning = style().yellow().bold(); self.info = style().bold(); self.debug = style().bold(); + self.trace = style().dimmed(); } } diff --git a/cargo-nextest/src/reuse_build.rs b/cargo-nextest/src/reuse_build.rs index 6ce371fee91..8aeaa45222b 100644 --- a/cargo-nextest/src/reuse_build.rs +++ b/cargo-nextest/src/reuse_build.rs @@ -14,6 +14,7 @@ use nextest_runner::{ }, }; use std::io::Write; +use tracing::warn; #[derive(Debug, Default, Args)] #[command( @@ -101,7 +102,7 @@ impl ReuseBuildOpts { // before calling this method) pub(crate) fn check_experimental(&self, _output: OutputContext) { if std::env::var(Self::EXPERIMENTAL_ENV).is_ok() { - log::warn!("build reuse is no longer experimental: NEXTEST_EXPERIMENTAL_REUSE_BUILD does not need to be set"); + warn!("build reuse is no longer experimental: NEXTEST_EXPERIMENTAL_REUSE_BUILD does not need to be set"); } } diff --git a/cargo-nextest/src/update.rs b/cargo-nextest/src/update.rs index 1294b63ebf1..3e8b34acb91 100644 --- a/cargo-nextest/src/update.rs +++ b/cargo-nextest/src/update.rs @@ -8,6 +8,7 @@ use nextest_runner::update::{CheckStatus, MuktiBackend, UpdateVersion}; use owo_colors::OwoColorize; use semver::Version; use std::cmp::Ordering; +use tracing::info; // Returns the smallest version with a `self setup` command. fn min_version_with_setup() -> Version { @@ -61,7 +62,7 @@ pub(crate) fn perform_update( match status { CheckStatus::AlreadyOnRequested(version) => { - log::info!( + info!( "cargo-nextest is already at the latest version: {}", version.style(styles.bold), ); @@ -71,7 +72,7 @@ pub(crate) fn perform_update( current_version, requested, } => { - log::info!( + info!( "not performing downgrade from {} to {}\n\ (pass in --force to force downgrade)", current_version.style(styles.bold), @@ -80,7 +81,7 @@ pub(crate) fn perform_update( Ok(NextestExitCode::UPDATE_DOWNGRADE_NOT_PERFORMED) } CheckStatus::Success(ctx) => { - log::info!( + info!( "{} available: {} -> {}", match ctx.version.cmp(¤t_version) { Ordering::Greater => "update", @@ -115,13 +116,13 @@ pub(crate) fn perform_update( if should_apply { ctx.do_update() .map_err(|err| ExpectedError::UpdateError { err })?; - log::info!( + info!( "cargo-nextest updated to {}", ctx.version.style(styles.bold) ); Ok(0) } else { - log::info!("update canceled"); + info!("update canceled"); Ok(NextestExitCode::UPDATE_CANCELED) } } diff --git a/nextest-runner/Cargo.toml b/nextest-runner/Cargo.toml index dad76a53b24..045f89f4a1e 100644 --- a/nextest-runner/Cargo.toml +++ b/nextest-runner/Cargo.toml @@ -39,7 +39,6 @@ indexmap = { workspace = true, features = ["serde"] } indicatif.workspace = true is_ci.workspace = true itertools.workspace = true -log.workspace = true miette.workspace = true newtype-uuid.workspace = true nextest-filtering.workspace = true @@ -79,6 +78,7 @@ tokio = { workspace = true, features = [ ] } toml.workspace = true toml_edit = { workspace = true, features = ["serde"] } +tracing.workspace = true unicode-ident.workspace = true unicode-normalization.workspace = true xxhash-rust = { workspace = true, features = ["xxh64"] } diff --git a/nextest-runner/src/cargo_config/discovery.rs b/nextest-runner/src/cargo_config/discovery.rs index 838e349b6ce..5eb63039f6d 100644 --- a/nextest-runner/src/cargo_config/discovery.rs +++ b/nextest-runner/src/cargo_config/discovery.rs @@ -6,6 +6,7 @@ use camino::{Utf8Path, Utf8PathBuf}; use serde::Deserialize; use std::collections::BTreeMap; use toml_edit::Item; +use tracing::debug; /// The source of a Cargo config. /// @@ -71,7 +72,7 @@ impl CargoConfigs { match Utf8PathBuf::try_from(path) { Ok(path) => target_paths.push(path), Err(error) => { - log::debug!("for RUST_TARGET_PATH, {error}"); + debug!("for RUST_TARGET_PATH, {error}"); } } } diff --git a/nextest-runner/src/config/config_impl.rs b/nextest-runner/src/config/config_impl.rs index 133ff66a471..f31ab188480 100644 --- a/nextest-runner/src/config/config_impl.rs +++ b/nextest-runner/src/config/config_impl.rs @@ -28,6 +28,7 @@ use std::{ collections::{hash_map, BTreeMap, BTreeSet, HashMap}, time::Duration, }; +use tracing::warn; /// Gets the number of available CPUs and caches the value. #[inline] @@ -35,7 +36,7 @@ pub fn get_num_cpus() -> usize { static NUM_CPUS: Lazy = Lazy::new(|| match std::thread::available_parallelism() { Ok(count) => count.into(), Err(err) => { - log::warn!("unable to determine num-cpus ({err}), assuming 1 logical CPU"); + warn!("unable to determine num-cpus ({err}), assuming 1 logical CPU"); 1 } }); @@ -120,7 +121,7 @@ impl NextestConfig { } } - log::warn!( + warn!( "ignoring unknown configuration keys in config file {config_file}{}:{unknown_str}", provided_by_tool(tool), ) @@ -376,7 +377,7 @@ impl NextestConfig { .filter(|p| p.starts_with("default-") && !NextestConfig::DEFAULT_PROFILES.contains(p)) .collect(); if !unknown_default_profiles.is_empty() { - log::warn!( + warn!( "unknown profiles in the reserved `default-` namespace in config file {}{}:", config_file .strip_prefix(workspace_root) @@ -385,7 +386,7 @@ impl NextestConfig { ); for profile in unknown_default_profiles { - log::warn!(" {profile}"); + warn!(" {profile}"); } } diff --git a/nextest-runner/src/double_spawn.rs b/nextest-runner/src/double_spawn.rs index 409dbc2d7e0..88a3dcffb51 100644 --- a/nextest-runner/src/double_spawn.rs +++ b/nextest-runner/src/double_spawn.rs @@ -103,6 +103,7 @@ mod imp { use super::*; use nix::sys::signal::{SigSet, Signal}; use std::path::PathBuf; + use tracing::warn; #[derive(Clone, Debug)] pub(super) struct DoubleSpawnInfo { @@ -117,7 +118,7 @@ mod imp { // TODO: Always use /proc/self/exe directly on Linux, just make sure it's always accessible let current_exe = get_current_exe().map_or_else( |error| { - log::warn!( + warn!( "unable to determine current exe, will not use double-spawning \ for better isolation: {error}" ); @@ -194,7 +195,7 @@ mod imp { let mut sigset = SigSet::empty(); sigset.add(Signal::SIGTSTP); if sigset.thread_unblock().is_err() { - log::warn!("[double-spawn] unable to unblock SIGTSTP in child"); + warn!("[double-spawn] unable to unblock SIGTSTP in child"); } } } diff --git a/nextest-runner/src/list/binary_list.rs b/nextest-runner/src/list/binary_list.rs index dae495c68a3..ec747ada636 100644 --- a/nextest-runner/src/list/binary_list.rs +++ b/nextest-runner/src/list/binary_list.rs @@ -17,6 +17,7 @@ use nextest_metadata::{ }; use owo_colors::OwoColorize; use std::{collections::HashSet, io}; +use tracing::warn; /// A Rust test binary built by Cargo. #[derive(Clone, Debug)] @@ -322,7 +323,7 @@ impl<'g> BinaryListBuildState<'g> { let in_workspace = self.graph.metadata(&package_id).map_or_else( |_| { // Warn about processing a package that isn't in the package graph. - log::warn!( + warn!( target: "nextest-runner::list", "warning: saw package ID `{}` which wasn't produced by cargo metadata", package_id diff --git a/nextest-runner/src/list/rust_build_meta.rs b/nextest-runner/src/list/rust_build_meta.rs index 5561eede8f7..9cdce9df0bf 100644 --- a/nextest-runner/src/list/rust_build_meta.rs +++ b/nextest-runner/src/list/rust_build_meta.rs @@ -15,6 +15,7 @@ use std::{ collections::{BTreeMap, BTreeSet}, marker::PhantomData, }; +use tracing::warn; /// Rust-related metadata used for builds and test runs. #[derive(Clone, Debug, Eq, PartialEq)] @@ -123,7 +124,7 @@ impl RustBuildMeta { .map(|libdir| libdir.to_path_buf()) .collect::>(); if libdirs.is_empty() { - log::warn!("failed to detect the rustc libdir, may fail to list or run tests"); + warn!("failed to detect the rustc libdir, may fail to list or run tests"); } // Cargo puts linked paths before base output directories. diff --git a/nextest-runner/src/list/test_list.rs b/nextest-runner/src/list/test_list.rs index 1627ca16f27..fc86b2c3f97 100644 --- a/nextest-runner/src/list/test_list.rs +++ b/nextest-runner/src/list/test_list.rs @@ -36,6 +36,7 @@ use std::{ sync::{Arc, OnceLock}, }; use tokio::runtime::Runtime; +use tracing::debug; /// A Rust test binary built by Cargo. This artifact hasn't been run yet so there's no information /// about the tests within it. @@ -236,7 +237,7 @@ impl<'g> TestList<'g> { I::IntoIter: Send, { let updated_dylib_path = Self::create_dylib_path(&rust_build_meta)?; - log::debug!( + debug!( "updated {}: {}", dylib_path_envvar(), updated_dylib_path.to_string_lossy(), @@ -255,7 +256,7 @@ impl<'g> TestList<'g> { let binary_match = filter.filter_binary_match(&test_binary, ecx, bound); match binary_match { FilterBinaryMatch::Definite | FilterBinaryMatch::Possible => { - log::debug!( + debug!( "executing test binary to obtain test list \ (match result is {binary_match:?}): {}", test_binary.binary_id, @@ -274,7 +275,7 @@ impl<'g> TestList<'g> { Ok::<_, CreateTestListError>((bin, info)) } FilterBinaryMatch::Mismatch { reason } => { - log::debug!("skipping test binary: {reason}: {}", test_binary.binary_id,); + debug!("skipping test binary: {reason}: {}", test_binary.binary_id,); Ok(Self::process_skipped(test_binary, reason)) } } @@ -327,7 +328,7 @@ impl<'g> TestList<'g> { let binary_match = filter.filter_binary_match(&test_binary, ecx, bound); match binary_match { FilterBinaryMatch::Definite | FilterBinaryMatch::Possible => { - log::debug!( + debug!( "processing output for binary \ (match result is {binary_match:?}): {}", test_binary.binary_id, @@ -344,7 +345,7 @@ impl<'g> TestList<'g> { Ok((bin, info)) } FilterBinaryMatch::Mismatch { reason } => { - log::debug!("skipping test binary: {reason}: {}", test_binary.binary_id,); + debug!("skipping test binary: {reason}: {}", test_binary.binary_id,); Ok(Self::process_skipped(test_binary, reason)) } } diff --git a/nextest-runner/src/platform.rs b/nextest-runner/src/platform.rs index cfb04df989a..a842a082c86 100644 --- a/nextest-runner/src/platform.rs +++ b/nextest-runner/src/platform.rs @@ -15,6 +15,7 @@ use nextest_metadata::{ }; use target_spec::summaries::PlatformSummary; pub use target_spec::Platform; +use tracing::debug; /// A representation of host and target platform. #[derive(Clone, Debug, Eq, PartialEq)] @@ -279,26 +280,26 @@ impl PlatformLibdir { let v = v.ok_or(PlatformLibdirUnavailable::RUSTC_FAILED)?; let s = String::from_utf8(v).map_err(|e| { - log::debug!("failed to convert the output to a string: {e}"); + debug!("failed to convert the output to a string: {e}"); PlatformLibdirUnavailable::RUSTC_OUTPUT_ERROR })?; let mut lines = s.lines(); let Some(out) = lines.next() else { - log::debug!("empty output"); + debug!("empty output"); return Err(PlatformLibdirUnavailable::RUSTC_OUTPUT_ERROR); }; let trimmed = out.trim(); if trimmed.is_empty() { - log::debug!("empty output"); + debug!("empty output"); return Err(PlatformLibdirUnavailable::RUSTC_OUTPUT_ERROR); } // If there's another line, it must be empty. for line in lines { if !line.trim().is_empty() { - log::debug!("unexpected additional output: {line}"); + debug!("unexpected additional output: {line}"); return Err(PlatformLibdirUnavailable::RUSTC_OUTPUT_ERROR); } } diff --git a/nextest-runner/src/reuse_build/archiver.rs b/nextest-runner/src/reuse_build/archiver.rs index 80e4a9af805..ffe7b61cb7b 100644 --- a/nextest-runner/src/reuse_build/archiver.rs +++ b/nextest-runner/src/reuse_build/archiver.rs @@ -23,6 +23,7 @@ use std::{ io::{self, BufWriter, Write}, time::{Instant, SystemTime}, }; +use tracing::{debug, trace}; use zstd::Encoder; /// Archive format. @@ -547,7 +548,7 @@ impl<'a, W: Write> Archiver<'a, W> { let mut stack = vec![(limit, src_path.to_owned(), rel_path.to_owned(), metadata)]; while let Some((depth, src_path, rel_path, metadata)) = stack.pop() { - log::trace!( + trace!( target: "nextest-runner", "processing `{src_path}` with metadata {metadata:?} \ (depth: {depth})", @@ -567,7 +568,7 @@ impl<'a, W: Write> Archiver<'a, W> { } // Iterate over this directory. - log::debug!( + debug!( target: "nextest-runner", "recursing into `{}`", src_path @@ -625,7 +626,7 @@ impl<'a, W: Write> Archiver<'a, W> { ) -> Result<(), ArchiveCreateError> { // Check added_files to ensure we aren't adding duplicate files. if !self.added_files.contains(dest) { - log::debug!( + debug!( target: "nextest-runner", "adding `{src}` to archive as `{dest}`", ); diff --git a/nextest-runner/src/runner.rs b/nextest-runner/src/runner.rs index 9a82843decf..db82d456269 100644 --- a/nextest-runner/src/runner.rs +++ b/nextest-runner/src/runner.rs @@ -52,6 +52,7 @@ use tokio::{ runtime::Runtime, sync::{broadcast, mpsc::UnboundedSender}, }; +use tracing::{debug, warn}; #[derive(Debug)] struct BackoffIter { @@ -370,7 +371,7 @@ impl<'a> TestRunnerInner<'a> { tokio::select! { _ = receiver.recv(), if running_tests > 0 => { running_tests -= 1; - log::debug!( + debug!( "stopping tests: running tests down to {running_tests}" ); } @@ -447,7 +448,7 @@ impl<'a> TestRunnerInner<'a> { { let setup_scripts = self.profile.setup_scripts(self.test_list); let total = setup_scripts.len(); - log::debug!("running {} setup scripts", total); + debug!("running {} setup scripts", total); let mut setup_script_data = SetupScriptExecuteData::new(); @@ -498,7 +499,7 @@ impl<'a> TestRunnerInner<'a> { scope.spawn_cancellable(script_fut, || ()); let script_and_env_map = completion_receiver.blocking_recv().unwrap_or_else(|_| { // This should never happen. - log::warn!("setup script future did not complete -- this is a bug, please report it"); + warn!("setup script future did not complete -- this is a bug, please report it"); None }); if let Some((script, env_map)) = script_and_env_map { diff --git a/nextest-runner/src/rustc_cli.rs b/nextest-runner/src/rustc_cli.rs index ef21e5d853f..f311e6a21e4 100644 --- a/nextest-runner/src/rustc_cli.rs +++ b/nextest-runner/src/rustc_cli.rs @@ -4,6 +4,7 @@ use crate::cargo_config::TargetTriple; use camino::Utf8PathBuf; use std::{borrow::Cow, path::PathBuf}; +use tracing::{debug, trace}; /// Create a rustc CLI call. #[derive(Clone, Debug)] @@ -46,7 +47,7 @@ impl<'a> RustcCli<'a> { /// [`Vec`]. pub fn read(&self) -> Option> { let expression = self.to_expression(); - log::trace!("Executing command: {:?}", expression); + trace!("Executing command: {:?}", expression); let output = match expression .stdout_capture() .stderr_capture() @@ -55,16 +56,16 @@ impl<'a> RustcCli<'a> { { Ok(output) => output, Err(e) => { - log::debug!("Failed to spawn the child process: {}", e); + debug!("Failed to spawn the child process: {}", e); return None; } }; if !output.status.success() { - log::debug!("execution failed with {}", output.status); - log::debug!("stdout:"); - log::debug!("{}", String::from_utf8_lossy(&output.stdout)); - log::debug!("stderr:"); - log::debug!("{}", String::from_utf8_lossy(&output.stderr)); + debug!("execution failed with {}", output.status); + debug!("stdout:"); + debug!("{}", String::from_utf8_lossy(&output.stdout)); + debug!("stderr:"); + debug!("{}", String::from_utf8_lossy(&output.stderr)); return None; } Some(output.stdout) diff --git a/nextest-runner/src/update.rs b/nextest-runner/src/update.rs index cb544e848bf..69101a170f2 100644 --- a/nextest-runner/src/update.rs +++ b/nextest-runner/src/update.rs @@ -15,6 +15,7 @@ use std::{ str::FromStr, }; use target_spec::Platform; +use tracing::{debug, info, warn}; /// Update backend using mukti #[derive(Clone, Debug)] @@ -29,7 +30,7 @@ pub struct MuktiBackend { impl MuktiBackend { /// Fetch releases. pub fn fetch_releases(&self, current_version: Version) -> Result { - log::info!(target: "nextest-runner::update", "checking for self-updates"); + info!(target: "nextest-runner::update", "checking for self-updates"); // Is the URL a file that exists on disk? If so, use that. let as_path = Utf8Path::new(&self.url); let releases_buf = if as_path.exists() { @@ -111,7 +112,7 @@ impl NextestReleases { perform_setup_fn: impl FnOnce(&Version) -> bool, ) -> Result, UpdateError> { let (version, version_data) = self.get_version_data(version)?; - log::debug!( + debug!( target: "nextest-runner::update", "current version is {}, update version is {version}", self.current_version, @@ -129,7 +130,7 @@ impl NextestReleases { // Look for data for this platform. let triple = self.target_triple(); - log::debug!(target: "nextest-runner::update", "target triple: {triple}"); + debug!(target: "nextest-runner::update", "target triple: {triple}"); let location = version_data .locations @@ -199,7 +200,7 @@ impl NextestReleases { match serde_json::from_value::(release_data.metadata.clone()) { Ok(metadata) => Some(metadata), Err(error) => { - log::warn!( + warn!( target: "nextest-runner::update", "failed to parse custom release metadata: {error}", ); @@ -356,7 +357,7 @@ impl<'a> MuktiUpdateContext<'a> { .download_to(&mut tmp_archive_buf) .map_err(UpdateError::SelfUpdate)?; - log::debug!(target: "nextest-runner::update", "downloaded to {tmp_archive_path}"); + debug!(target: "nextest-runner::update", "downloaded to {tmp_archive_path}"); let tmp_archive = tmp_archive_buf @@ -386,7 +387,7 @@ impl<'a> MuktiUpdateContext<'a> { // need to make this file executable. let new_exe = tmp_dir_path.join(self.bin_path_in_archive); - log::debug!(target: "nextest-runner::update", "extracted to {new_exe}, replacing existing binary"); + debug!(target: "nextest-runner::update", "extracted to {new_exe}, replacing existing binary"); let tmp_backup_dir = camino_tempfile::Builder::new() .prefix(&tmp_backup_dir_prefix) @@ -405,7 +406,7 @@ impl<'a> MuktiUpdateContext<'a> { // Finally, run `cargo nextest self setup` if requested. if self.perform_setup { - log::info!(target: "nextest-runner::update", "running `cargo nextest self setup`"); + info!(target: "nextest-runner::update", "running `cargo nextest self setup`"); let mut cmd = std::process::Command::new(&self.context.bin_install_path); cmd.args(["nextest", "self", "setup", "--source", "self-update"]); let status = cmd.status().map_err(UpdateError::SelfSetup)?; diff --git a/workspace-hack/Cargo.toml b/workspace-hack/Cargo.toml index 5569f9ee5f6..67a331a6fe1 100644 --- a/workspace-hack/Cargo.toml +++ b/workspace-hack/Cargo.toml @@ -31,6 +31,8 @@ rand = { version = "0.8.5" } serde = { version = "1.0.210", features = ["alloc", "derive"] } serde_json = { version = "1.0.128", features = ["unbounded_depth"] } tokio = { version = "1.40.0", features = ["fs", "io-util", "macros", "process", "rt-multi-thread", "signal", "sync", "time", "tracing"] } +tracing-core = { version = "0.1.32" } +tracing-subscriber = { version = "0.3.18", default-features = false, features = ["fmt", "tracing-log"] } xxhash-rust = { version = "0.8.12", default-features = false, features = ["xxh3", "xxh64"] } zerocopy = { version = "0.7.35", features = ["derive", "simd"] }