refactor: find & replace log:: -> tracing::

Except HTTP network debugging
This commit is contained in:
Weihang Lo 2023-08-05 09:07:45 +01:00
parent 9f0565e985
commit af1a78b424
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7
54 changed files with 117 additions and 117 deletions

View File

@ -237,7 +237,7 @@ pub fn mtime_recursive(path: &Path) -> Result<FileTime> {
Err(e) => {
// Ignore errors while walking. If Cargo can't access it, the
// build script probably can't access it, either.
log::debug!("failed to determine mtime while walking directory: {}", e);
tracing::debug!("failed to determine mtime while walking directory: {}", e);
None
}
})
@ -252,7 +252,7 @@ pub fn mtime_recursive(path: &Path) -> Result<FileTime> {
// I'm not sure when this is really possible (maybe a
// race with unlinking?). Regardless, if Cargo can't
// read it, the build script probably can't either.
log::debug!(
tracing::debug!(
"failed to determine mtime while fetching symlink metadata of {}: {}",
e.path().display(),
err
@ -271,7 +271,7 @@ pub fn mtime_recursive(path: &Path) -> Result<FileTime> {
// Can't access the symlink target. If Cargo can't
// access it, the build script probably can't access
// it either.
log::debug!(
tracing::debug!(
"failed to determine mtime of symlink target for {}: {}",
e.path().display(),
err
@ -286,7 +286,7 @@ pub fn mtime_recursive(path: &Path) -> Result<FileTime> {
// I'm not sure when this is really possible (maybe a
// race with unlinking?). Regardless, if Cargo can't
// read it, the build script probably can't either.
log::debug!(
tracing::debug!(
"failed to determine mtime while fetching metadata of {}: {}",
e.path().display(),
err
@ -314,7 +314,7 @@ pub fn set_invocation_time(path: &Path) -> Result<FileTime> {
"This file has an mtime of when this was started.",
)?;
let ft = mtime(&timestamp)?;
log::debug!("invocation time for {:?} is {}", path, ft);
tracing::debug!("invocation time for {:?} is {}", path, ft);
Ok(ft)
}
@ -508,7 +508,7 @@ pub fn link_or_copy(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()>
}
fn _link_or_copy(src: &Path, dst: &Path) -> Result<()> {
log::debug!("linking {} to {}", src.display(), dst.display());
tracing::debug!("linking {} to {}", src.display(), dst.display());
if same_file::is_same_file(src, dst).unwrap_or(false) {
return Ok(());
}
@ -567,7 +567,7 @@ fn _link_or_copy(src: &Path, dst: &Path) -> Result<()> {
};
link_result
.or_else(|err| {
log::debug!("link failed {}. falling back to fs::copy", err);
tracing::debug!("link failed {}. falling back to fs::copy", err);
fs::copy(src, dst).map(|_| ())
})
.with_context(|| {
@ -598,8 +598,8 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64> {
pub fn set_file_time_no_err<P: AsRef<Path>>(path: P, time: FileTime) {
let path = path.as_ref();
match filetime::set_file_times(path, time, time) {
Ok(()) => log::debug!("set file mtime {} to {}", path.display(), time),
Err(e) => log::warn!(
Ok(()) => tracing::debug!("set file mtime {} to {}", path.display(), time),
Err(e) => tracing::warn!(
"could not set mtime of {} to {}: {:?}",
path.display(),
time,
@ -621,7 +621,7 @@ pub fn strip_prefix_canonical<P: AsRef<Path>>(
let safe_canonicalize = |path: &Path| match path.canonicalize() {
Ok(p) => p,
Err(e) => {
log::warn!("cannot canonicalize {:?}: {:?}", path, e);
tracing::warn!("cannot canonicalize {:?}: {:?}", path, e);
path.to_path_buf()
}
};

View File

@ -449,7 +449,7 @@ impl ProcessBuilder {
arg.push(tmp.path());
let mut cmd = self.build_command_without_args();
cmd.arg(arg);
log::debug!("created argfile at {} for {self}", tmp.path().display());
tracing::debug!("created argfile at {} for {self}", tmp.path().display());
let cap = self.get_args().map(|arg| arg.len() + 1).sum::<usize>();
let mut buf = Vec::with_capacity(cap);
@ -558,7 +558,7 @@ fn piped(cmd: &mut Command, pipe_stdin: bool) -> &mut Command {
fn close_tempfile_and_log_error(file: NamedTempFile) {
file.close().unwrap_or_else(|e| {
log::warn!("failed to close temporary file: {e}");
tracing::warn!("failed to close temporary file: {e}");
});
}

View File

@ -126,7 +126,7 @@ fn bump_check(args: &clap::ArgMatches, config: &mut cargo::util::Config) -> Carg
for referenced_member in checkout_ws(&ws, &repo, referenced_commit)?.members() {
let Some(changed_member) = changed_members.get(referenced_member) else {
let name = referenced_member.name().as_str();
log::trace!("skipping {name}, may be removed or not published");
tracing::trace!("skipping {name}, may be removed or not published");
continue;
};
@ -264,10 +264,10 @@ fn get_referenced_commit<'a>(
let referenced_commit = if rev_id == stable_commit.id() {
None
} else if rev_id == beta_commit.id() {
log::trace!("stable branch from `{}`", stable.name().unwrap().unwrap());
tracing::trace!("stable branch from `{}`", stable.name().unwrap().unwrap());
Some(stable_commit)
} else {
log::trace!("beta branch from `{}`", beta.name().unwrap().unwrap());
tracing::trace!("beta branch from `{}`", beta.name().unwrap().unwrap());
Some(beta_commit)
};
@ -287,11 +287,11 @@ fn beta_and_stable_branch(repo: &git2::Repository) -> CargoResult<[git2::Branch<
let (branch, _) = branch?;
let name = branch.name()?.unwrap();
let Some((_, version)) = name.split_once("/rust-") else {
log::trace!("branch `{name}` is not in the format of `<remote>/rust-<semver>`");
tracing::trace!("branch `{name}` is not in the format of `<remote>/rust-<semver>`");
continue;
};
let Ok(version) = version.to_semver() else {
log::trace!("branch `{name}` is not a valid semver: `{version}`");
tracing::trace!("branch `{name}` is not a valid semver: `{version}`");
continue;
};
release_branches.push((version, branch));
@ -380,7 +380,7 @@ fn check_crates_io<'a>(
}
};
if possibilities.is_empty() {
log::trace!("dep `{name}` has no version greater than or equal to `{current}`");
tracing::trace!("dep `{name}` has no version greater than or equal to `{current}`");
} else {
needs_bump.push(member);
}

View File

@ -1065,7 +1065,7 @@ impl RustDocFingerprint {
if fingerprint.rustc_vv == actual_rustdoc_target_data.rustc_vv {
return Ok(());
} else {
log::debug!(
tracing::debug!(
"doc fingerprint changed:\noriginal:\n{}\nnew:\n{}",
fingerprint.rustc_vv,
actual_rustdoc_target_data.rustc_vv
@ -1073,11 +1073,11 @@ impl RustDocFingerprint {
}
}
Err(e) => {
log::debug!("could not deserialize {:?}: {}", fingerprint_path, e);
tracing::debug!("could not deserialize {:?}: {}", fingerprint_path, e);
}
};
// Fingerprint does not match, delete the doc directories and write a new fingerprint.
log::debug!(
tracing::debug!(
"fingerprint {:?} mismatch, clearing doc directories",
fingerprint_path
);

View File

@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
use std::sync::Arc;
use lazycell::LazyCell;
use log::debug;
use tracing::debug;
use super::{BuildContext, CompileKind, Context, FileFlavor, Layout};
use crate::core::compiler::{CompileMode, CompileTarget, CrateType, FileType, Unit};

View File

@ -366,7 +366,7 @@ use std::time::SystemTime;
use anyhow::{bail, format_err, Context as _};
use cargo_util::{paths, ProcessBuilder};
use filetime::FileTime;
use log::{debug, info};
use tracing::{debug, info};
use serde::de;
use serde::ser;
use serde::{Deserialize, Serialize};
@ -1815,7 +1815,7 @@ pub fn parse_dep_info(
let info = match EncodedDepInfo::parse(&data) {
Some(info) => info,
None => {
log::warn!("failed to parse cargo's dep-info at {:?}", dep_info);
tracing::warn!("failed to parse cargo's dep-info at {:?}", dep_info);
return Ok(None);
}
};

View File

@ -417,7 +417,7 @@ pub fn save_and_display_report(
let current_reports = match OnDiskReports::load(bcx.ws) {
Ok(r) => r,
Err(e) => {
log::debug!(
tracing::debug!(
"saving future-incompatible reports failed to load current reports: {:?}",
e
);

View File

@ -125,7 +125,7 @@ use std::time::Duration;
use anyhow::{format_err, Context as _};
use cargo_util::ProcessBuilder;
use jobserver::{Acquired, HelperThread};
use log::{debug, trace};
use tracing::{debug, trace};
use semver::Version;
pub use self::job::Freshness::{self, Dirty, Fresh};
@ -840,7 +840,7 @@ impl<'cfg> DrainState<'cfg> {
}
err_state.count += 1;
} else {
log::warn!("{:?}", new_err.error);
tracing::warn!("{:?}", new_err.error);
}
}

View File

@ -65,7 +65,7 @@ use std::sync::Arc;
use anyhow::{Context as _, Error};
use lazycell::LazyCell;
use log::{debug, trace};
use tracing::{debug, trace};
pub use self::build_config::{BuildConfig, CompileMode, MessageFormat, TimingOutput};
pub use self::build_context::{
@ -368,7 +368,7 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc<dyn Executor>) -> Car
// See rust-lang/cargo#8348.
if output.hardlink.is_some() && output.path.exists() {
_ = paths::remove_file(&output.path).map_err(|e| {
log::debug!(
tracing::debug!(
"failed to delete previous output file `{:?}`: {e:?}",
output.path
);

View File

@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};
use super::{fingerprint, Context, FileFlavor, Unit};
use crate::util::{internal, CargoResult};
use cargo_util::paths;
use log::debug;
use tracing::debug;
/// Bacially just normalizes a given path and converts it to a string.
fn render_filename<P: AsRef<Path>>(path: P, basedir: Option<&str>) -> CargoResult<String> {

View File

@ -112,7 +112,7 @@ pub fn add_root_urls(
) -> CargoResult<()> {
let config = cx.bcx.config;
if !config.cli_unstable().rustdoc_map {
log::debug!("`doc.extern-map` ignored, requires -Zrustdoc-map flag");
tracing::debug!("`doc.extern-map` ignored, requires -Zrustdoc-map flag");
return Ok(());
}
let map = config.doc_extern_map()?;
@ -125,7 +125,7 @@ pub fn add_root_urls(
if let Ok(index_url) = config.get_registry_index(name) {
Some((name, index_url))
} else {
log::warn!(
tracing::warn!(
"`doc.extern-map.{}` specifies a registry that is not defined",
name
);
@ -181,7 +181,7 @@ pub fn add_root_urls(
})?;
Some(url.to_string())
} else {
log::warn!(
tracing::warn!(
"`doc.extern-map.std` is \"local\", but local docs don't appear to exist at {}",
html_root.display()
);

View File

@ -122,7 +122,7 @@ impl<'cfg> Timings<'cfg> {
match State::current() {
Ok(state) => Some(state),
Err(e) => {
log::info!("failed to get CPU state, CPU tracking disabled: {:?}", e);
tracing::info!("failed to get CPU state, CPU tracking disabled: {:?}", e);
None
}
}
@ -276,7 +276,7 @@ impl<'cfg> Timings<'cfg> {
let current = match State::current() {
Ok(s) => s,
Err(e) => {
log::info!("failed to get CPU state: {:?}", e);
tracing::info!("failed to get CPU state: {:?}", e);
return;
}
};

View File

@ -17,7 +17,7 @@
use std::collections::{HashMap, HashSet};
use log::trace;
use tracing::trace;
use crate::core::compiler::artifact::match_artifacts_kind_with_targets;
use crate::core::compiler::unit_graph::{UnitDep, UnitGraph};

View File

@ -1,5 +1,5 @@
use cargo_platform::Platform;
use log::trace;
use tracing::trace;
use semver::VersionReq;
use serde::ser;
use serde::Serialize;

View File

@ -13,7 +13,7 @@ use bytesize::ByteSize;
use curl::easy::Easy;
use curl::multi::{EasyHandle, Multi};
use lazycell::LazyCell;
use log::debug;
use tracing::debug;
use semver::Version;
use serde::Serialize;

View File

@ -8,7 +8,7 @@ use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::{CanonicalUrl, Config};
use anyhow::{bail, Context as _};
use log::{debug, trace};
use tracing::{debug, trace};
use url::Url;
/// Source of information about a group of packages.
@ -876,7 +876,7 @@ fn summary_for_patch(
// Since the locked patch did not match anything, try the unlocked one.
let orig_matches =
ready!(source.query_vec(orig_patch, QueryKind::Exact)).unwrap_or_else(|e| {
log::warn!(
tracing::warn!(
"could not determine unlocked summaries for dep {:?}: {:?}",
orig_patch,
e
@ -895,7 +895,7 @@ fn summary_for_patch(
let name_summaries =
ready!(source.query_vec(&name_only_dep, QueryKind::Exact)).unwrap_or_else(|e| {
log::warn!(
tracing::warn!(
"failed to do name-only summary query for {:?}: {:?}",
name_only_dep,
e

View File

@ -1,6 +1,6 @@
use std::collections::{BTreeMap, HashMap, HashSet};
use log::trace;
use tracing::trace;
use super::types::ConflictMap;
use crate::core::resolver::Context;

View File

@ -6,7 +6,7 @@ use crate::core::{Dependency, PackageId, SourceId, Summary};
use crate::util::interning::InternedString;
use crate::util::Graph;
use anyhow::format_err;
use log::debug;
use tracing::debug;
use std::collections::HashMap;
use std::num::NonZeroU64;

View File

@ -23,7 +23,7 @@ use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use anyhow::Context as _;
use log::debug;
use tracing::debug;
use std::collections::{BTreeSet, HashMap, HashSet};
use std::rc::Rc;
use std::task::Poll;

View File

@ -117,7 +117,7 @@ use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::{internal, Graph};
use anyhow::{bail, Context as _};
use log::debug;
use tracing::debug;
use serde::de;
use serde::ser;
use serde::{Deserialize, Serialize};

View File

@ -470,7 +470,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
deferred_weak_dependencies: HashMap::new(),
};
r.do_resolve(specs, cli_features)?;
log::debug!("features={:#?}", r.activated_features);
tracing::debug!("features={:#?}", r.activated_features);
if r.opts.compare {
r.compare();
}
@ -518,7 +518,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
fk: FeaturesFor,
fvs: &[FeatureValue],
) -> CargoResult<()> {
log::trace!("activate_pkg {} {}", pkg_id.name(), fk);
tracing::trace!("activate_pkg {} {}", pkg_id.name(), fk);
// Add an empty entry to ensure everything is covered. This is intended for
// finding bugs where the resolver missed something it should have visited.
// Remove this in the future if `activated_features` uses an empty default.
@ -566,7 +566,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
fk: FeaturesFor,
fv: &FeatureValue,
) -> CargoResult<()> {
log::trace!("activate_fv {} {} {}", pkg_id.name(), fk, fv);
tracing::trace!("activate_fv {} {} {}", pkg_id.name(), fk, fv);
match fv {
FeatureValue::Feature(f) => {
self.activate_rec(pkg_id, fk, *f)?;
@ -593,7 +593,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
fk: FeaturesFor,
feature_to_enable: InternedString,
) -> CargoResult<()> {
log::trace!(
tracing::trace!(
"activate_rec {} {} feat={}",
pkg_id.name(),
fk,
@ -615,7 +615,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
// TODO: this should only happen for optional dependencies.
// Other cases should be validated by Summary's `build_feature_map`.
// Figure out some way to validate this assumption.
log::debug!(
tracing::debug!(
"pkg {:?} does not define feature {}",
pkg_id,
feature_to_enable
@ -654,7 +654,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
}
if let Some(to_enable) = &to_enable {
for dep_feature in to_enable {
log::trace!(
tracing::trace!(
"activate deferred {} {} -> {}/{}",
pkg_id.name(),
fk,
@ -697,7 +697,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
{
// This is weak, but not yet activated. Defer in case
// something comes along later and enables it.
log::trace!(
tracing::trace!(
"deferring feature {} {} -> {}/{}",
pkg_id.name(),
fk,

View File

@ -63,7 +63,7 @@ use std::mem;
use std::rc::Rc;
use std::time::{Duration, Instant};
use log::{debug, trace};
use tracing::{debug, trace};
use crate::core::PackageIdSpec;
use crate::core::{Dependency, PackageId, Registry, Summary};

View File

@ -3,7 +3,7 @@ use crate::sources::registry::CRATES_IO_HTTP_INDEX;
use crate::sources::{DirectorySource, CRATES_IO_DOMAIN, CRATES_IO_INDEX, CRATES_IO_REGISTRY};
use crate::sources::{GitSource, PathSource, RegistrySource};
use crate::util::{config, CanonicalUrl, CargoResult, Config, IntoUrl};
use log::trace;
use tracing::trace;
use serde::de;
use serde::ser;
use std::cmp::{self, Ordering};

View File

@ -7,7 +7,7 @@ use std::rc::Rc;
use anyhow::{anyhow, bail, Context as _};
use glob::glob;
use itertools::Itertools;
use log::debug;
use tracing::debug;
use url::Url;
use crate::core::compiler::Unit;

View File

@ -147,7 +147,7 @@
use crate::core::shell::Verbosity::Verbose;
use crate::core::Shell;
use anyhow::Error;
use log::debug;
use tracing::debug;
pub use crate::util::errors::{AlreadyPrintedError, InternalError, VerboseError};
pub use crate::util::{indented_lines, CargoResult, CliError, CliResult, Config};

View File

@ -753,7 +753,7 @@ fn remove_duplicate_doc(
.into_iter()
.partition(|unit| cb(unit) && !root_units.contains(unit));
for unit in to_remove {
log::debug!(
tracing::debug!(
"removing duplicate doc due to {} for package {} target `{}`",
reason,
unit.pkg,

View File

@ -6,7 +6,7 @@ use crate::ops;
use crate::util::config::Config;
use crate::util::CargoResult;
use anyhow::Context;
use log::debug;
use tracing::debug;
use std::collections::{BTreeMap, HashSet};
use termcolor::Color::{self, Cyan, Green, Red, Yellow};

View File

@ -879,7 +879,7 @@ mod tests {
.arg(&path_of_source_file)
.exec_with_output()
{
log::warn!("failed to call rustfmt: {:#}", e);
tracing::warn!("failed to call rustfmt: {:#}", e);
}
}
}

View File

@ -22,7 +22,7 @@ use anyhow::Context as _;
use cargo_util::paths;
use flate2::read::GzDecoder;
use flate2::{Compression, GzBuilder};
use log::debug;
use tracing::debug;
use serde::Serialize;
use tar::{Archive, Builder, EntryType, Header, HeaderMode};
use unicase::Ascii as UncasedAscii;

View File

@ -9,7 +9,7 @@ use crate::util::important_paths::find_project_manifest_exact;
use crate::util::toml::read_manifest;
use crate::util::Config;
use cargo_util::paths;
use log::{info, trace};
use tracing::{info, trace};
pub fn read_package(
path: &Path,

View File

@ -46,7 +46,7 @@ use std::{env, fs, str};
use anyhow::{bail, Context as _};
use cargo_util::{exit_status_to_string, is_simple_exit_code, paths, ProcessBuilder};
use log::{debug, trace, warn};
use tracing::{debug, trace, warn};
use rustfix::diagnostics::Diagnostic;
use rustfix::{self, CodeFix};
use semver::Version;

View File

@ -71,7 +71,7 @@ use crate::sources::PathSource;
use crate::util::errors::CargoResult;
use crate::util::{profile, CanonicalUrl};
use anyhow::Context as _;
use log::{debug, trace};
use tracing::{debug, trace};
use std::collections::{HashMap, HashSet};
/// Result for `resolve_ws_with_opts`.

View File

@ -642,7 +642,7 @@ fn add_feature_rec(
let dep_indexes = match graph.dep_name_map[&package_index].get(dep_name) {
Some(indexes) => indexes.clone(),
None => {
log::debug!(
tracing::debug!(
"enabling feature {} on {}, found {}/{}, \
dep appears to not be enabled",
feature_name,

View File

@ -10,7 +10,7 @@ use crate::util::config::{self, ConfigRelativePath, OptValue};
use crate::util::errors::CargoResult;
use crate::util::{Config, IntoUrl};
use anyhow::{bail, Context as _};
use log::debug;
use tracing::debug;
use std::collections::{HashMap, HashSet};
use url::Url;

View File

@ -342,7 +342,7 @@ fn check_ssh_known_hosts(
};
match parse_known_hosts_line(&line_value.val, location) {
Some(known_host) => known_hosts.push(known_host),
None => log::warn!(
None => tracing::warn!(
"failed to parse known host {} from {}",
line_value.val,
line_value.definition

View File

@ -6,7 +6,7 @@ use crate::util::{human_readable_bytes, network, MetricsCounter, Progress};
use crate::{CargoResult, Config};
use cargo_util::paths;
use gix::bstr::{BString, ByteSlice};
use log::debug;
use tracing::debug;
use std::cell::RefCell;
use std::path::Path;
use std::sync::atomic::{AtomicBool, Ordering};

View File

@ -10,7 +10,7 @@ use crate::util::hex::short_hash;
use crate::util::Config;
use anyhow::Context;
use cargo_util::paths::exclude_from_backups_and_indexing;
use log::trace;
use tracing::trace;
use std::fmt::{self, Debug, Formatter};
use std::task::Poll;
use url::Url;

View File

@ -11,7 +11,7 @@ use anyhow::{anyhow, Context as _};
use cargo_util::{paths, ProcessBuilder};
use curl::easy::List;
use git2::{self, ErrorClass, ObjectType, Oid};
use log::{debug, info};
use tracing::{debug, info};
use serde::ser;
use serde::Serialize;
use std::borrow::Cow;
@ -1316,7 +1316,7 @@ fn clean_repo_temp_files(repo: &git2::Repository) {
let pattern = match path.to_str() {
Some(p) => p,
None => {
log::warn!("cannot convert {path:?} to a string");
tracing::warn!("cannot convert {path:?} to a string");
return;
}
};
@ -1327,8 +1327,8 @@ fn clean_repo_temp_files(repo: &git2::Repository) {
for path in paths {
if let Ok(path) = path {
match paths::remove_file(&path) {
Ok(_) => log::debug!("removed stale temp git file {path:?}"),
Err(e) => log::warn!("failed to remove {path:?} while cleaning temp files: {e}"),
Ok(_) => tracing::debug!("removed stale temp git file {path:?}"),
Err(e) => tracing::warn!("failed to remove {path:?} while cleaning temp files: {e}"),
}
}
}

View File

@ -11,7 +11,7 @@ use anyhow::Context as _;
use cargo_util::paths;
use filetime::FileTime;
use ignore::gitignore::GitignoreBuilder;
use log::{trace, warn};
use tracing::{trace, warn};
use walkdir::WalkDir;
/// A source represents one or multiple packages gathering from a given root
@ -203,7 +203,7 @@ impl<'cfg> PathSource<'cfg> {
let repo = match git2::Repository::discover(root) {
Ok(repo) => repo,
Err(e) => {
log::debug!(
tracing::debug!(
"could not discover git repo at or above {}: {}",
root.display(),
e
@ -223,7 +223,7 @@ impl<'cfg> PathSource<'cfg> {
let repo_relative_path = match paths::strip_prefix_canonical(root, repo_root) {
Ok(p) => p,
Err(e) => {
log::warn!(
tracing::warn!(
"cannot determine if path `{:?}` is in git repo `{:?}`: {:?}",
root,
repo_root,

View File

@ -14,7 +14,7 @@ use cargo_credential::Operation;
use cargo_util::paths;
use curl::easy::{Easy, List};
use curl::multi::{EasyHandle, Multi};
use log::{debug, trace};
use tracing::{debug, trace};
use std::cell::RefCell;
use std::collections::{HashMap, HashSet};
use std::fs::{self, File};
@ -394,11 +394,11 @@ impl<'cfg> HttpRegistry<'cfg> {
Ok(json) => {
self.registry_config = Some(json);
}
Err(e) => log::debug!("failed to decode cached config.json: {}", e),
Err(e) => tracing::debug!("failed to decode cached config.json: {}", e),
},
Err(e) => {
if e.kind() != ErrorKind::NotFound {
log::debug!("failed to read config.json cache: {}", e)
tracing::debug!("failed to read config.json cache: {}", e)
}
}
}
@ -423,7 +423,7 @@ impl<'cfg> HttpRegistry<'cfg> {
self.registry_config = Some(serde_json::from_slice(&raw_data)?);
if paths::create_dir_all(&config_json_path.parent().unwrap()).is_ok() {
if let Err(e) = fs::write(&config_json_path, &raw_data) {
log::debug!("failed to write config.json cache: {}", e);
tracing::debug!("failed to write config.json cache: {}", e);
}
}
Poll::Ready(Ok(self.registry_config.as_ref().unwrap()))

View File

@ -94,7 +94,7 @@ use crate::util::IntoUrl;
use crate::util::{internal, CargoResult, Config, Filesystem, OptVersionReq, ToSemver};
use anyhow::bail;
use cargo_util::{paths, registry::make_dep_path};
use log::{debug, info};
use tracing::{debug, info};
use semver::Version;
use serde::Deserialize;
use std::borrow::Cow;
@ -673,23 +673,23 @@ impl Summaries {
index_version = Some(v);
}
Err(e) => {
log::debug!("failed to parse {:?} cache: {}", relative, e);
tracing::debug!("failed to parse {:?} cache: {}", relative, e);
}
},
Err(e) => log::debug!("cache missing for {:?} error: {}", relative, e),
Err(e) => tracing::debug!("cache missing for {:?} error: {}", relative, e),
}
let response = ready!(load.load(root, relative, index_version.as_deref())?);
match response {
LoadResponse::CacheValid => {
log::debug!("fast path for registry cache of {:?}", relative);
tracing::debug!("fast path for registry cache of {:?}", relative);
return Poll::Ready(Ok(cached_summaries));
}
LoadResponse::NotFound => {
if let Err(e) = fs::remove_file(cache_path) {
if e.kind() != ErrorKind::NotFound {
log::debug!("failed to remove from cache: {}", e);
tracing::debug!("failed to remove from cache: {}", e);
}
}
return Poll::Ready(Ok(None));
@ -701,7 +701,7 @@ impl Summaries {
// This is the fallback path where we actually talk to the registry backend to load
// information. Here we parse every single line in the index (as we need
// to find the versions)
log::debug!("slow path for {:?}", relative);
tracing::debug!("slow path for {:?}", relative);
let mut cache = SummariesCache::default();
let mut ret = Summaries::default();
ret.raw_data = raw_data;
@ -722,7 +722,7 @@ impl Summaries {
// entries in the cache preventing those newer
// versions from reading them (that is, until the
// cache is rebuilt).
log::info!("failed to parse {:?} registry package: {}", relative, e);
tracing::info!("failed to parse {:?} registry package: {}", relative, e);
continue;
}
};
@ -731,7 +731,7 @@ impl Summaries {
ret.versions.insert(version, summary.into());
}
if let Some(index_version) = index_version {
log::trace!("caching index_version {}", index_version);
tracing::trace!("caching index_version {}", index_version);
let cache_bytes = cache.serialize(index_version.as_str());
// Once we have our `cache_bytes` which represents the `Summaries` we're
// about to return, write that back out to disk so future Cargo
@ -743,7 +743,7 @@ impl Summaries {
let path = Filesystem::new(cache_path.clone());
config.assert_package_cache_locked(&path);
if let Err(e) = fs::write(cache_path, &cache_bytes) {
log::info!("failed to write cache: {}", e);
tracing::info!("failed to write cache: {}", e);
}
}
@ -906,7 +906,7 @@ impl IndexSummary {
v,
} = serde_json::from_slice(line)?;
let v = v.unwrap_or(1);
log::trace!("json parsed registry {}/{}", name, vers);
tracing::trace!("json parsed registry {}/{}", name, vers);
let pkgid = PackageId::new(name, &vers, source_id)?;
let deps = deps
.into_iter()

View File

@ -195,7 +195,7 @@ use std::task::{ready, Poll};
use anyhow::Context as _;
use cargo_util::paths::{self, exclude_from_backups_and_indexing};
use flate2::read::GzDecoder;
use log::debug;
use tracing::debug;
use serde::Deserialize;
use serde::Serialize;
use tar::Archive;
@ -589,9 +589,9 @@ impl<'cfg> RegistrySource<'cfg> {
}
_ => {
if ok == "ok" {
log::debug!("old `ok` content found, clearing cache");
tracing::debug!("old `ok` content found, clearing cache");
} else {
log::warn!("unrecognized .cargo-ok content, clearing cache: {ok}");
tracing::warn!("unrecognized .cargo-ok content, clearing cache: {ok}");
}
// See comment of `unpack_package` about why removing all stuff.
paths::remove_dir_all(dst.as_path_unlocked())?;

View File

@ -12,7 +12,7 @@ use crate::util::{Config, Filesystem};
use anyhow::Context as _;
use cargo_util::paths;
use lazycell::LazyCell;
use log::{debug, trace};
use tracing::{debug, trace};
use std::cell::{Cell, Ref, RefCell};
use std::fs::File;
use std::mem;

View File

@ -220,7 +220,7 @@ fn registry_credential_config_raw_uncached(
config: &Config,
sid: &SourceId,
) -> CargoResult<Option<RegistryConfig>> {
log::trace!("loading credential config for {}", sid);
tracing::trace!("loading credential config for {}", sid);
config.load_credentials()?;
if !sid.is_remote_registry() {
bail!(
@ -307,10 +307,10 @@ fn registry_credential_config_raw_uncached(
}
if let Some(name) = &name {
log::debug!("found alternative registry name `{name}` for {sid}");
tracing::debug!("found alternative registry name `{name}` for {sid}");
config.get::<Option<RegistryConfig>>(&format!("registries.{name}"))
} else {
log::debug!("no registry name found for {sid}");
tracing::debug!("no registry name found for {sid}");
Ok(None)
}
}
@ -320,7 +320,7 @@ fn resolve_credential_alias(config: &Config, mut provider: PathAndArgs) -> Vec<S
if provider.args.is_empty() {
let key = format!("credential-alias.{}", provider.path.raw_value());
if let Ok(alias) = config.get::<PathAndArgs>(&key) {
log::debug!("resolving credential alias '{key}' -> '{alias:?}'");
tracing::debug!("resolving credential alias '{key}' -> '{alias:?}'");
provider = alias;
}
}
@ -444,7 +444,7 @@ fn credential_action(
for provider in providers {
let args: Vec<&str> = provider.iter().map(String::as_str).collect();
let process = args[0];
log::debug!("attempting credential provider: {args:?}");
tracing::debug!("attempting credential provider: {args:?}");
let provider: Box<dyn Credential> = match process {
"cargo:token" => Box::new(TokenCredential::new(config)),
"cargo:paseto" => Box::new(PasetoCredential::new(config)),
@ -510,7 +510,7 @@ fn auth_token_optional(
operation: Operation<'_>,
headers: Vec<String>,
) -> CargoResult<Option<Secret<String>>> {
log::trace!("token requested for {}", sid.display_registry_name());
tracing::trace!("token requested for {}", sid.display_registry_name());
let mut cache = config.credential_cache();
let url = sid.canonical_url();
if let Some(cached_token) = cache.get(url) {
@ -520,7 +520,7 @@ fn auth_token_optional(
.unwrap_or(true)
{
if cached_token.operation_independent || matches!(operation, Operation::Read) {
log::trace!("using token from in-memory cache");
tracing::trace!("using token from in-memory cache");
return Ok(Some(cached_token.token_value.clone()));
}
} else {
@ -548,7 +548,7 @@ fn auth_token_optional(
bail!("credential provider produced unexpected response for `get` request: {credential_response:?}")
};
let token = Secret::from(token);
log::trace!("found token");
tracing::trace!("found token");
let expiration = match cache_control {
CacheControl::Expires(expiration) => Some(expiration),
CacheControl::Session => None,

View File

@ -611,7 +611,7 @@ impl Config {
key: &ConfigKey,
vals: &HashMap<String, ConfigValue>,
) -> CargoResult<Option<ConfigValue>> {
log::trace!("get cv {:?}", key);
tracing::trace!("get cv {:?}", key);
if key.is_root() {
// Returning the entire root table (for example `cargo config get`
// with no key). The definition here shouldn't matter.
@ -2798,7 +2798,7 @@ fn disables_multiplexing_for_bad_curl(
.iter()
.any(|v| curl_version.starts_with(v))
{
log::info!("disabling multiplexing with proxy, curl version is {curl_version}");
tracing::info!("disabling multiplexing with proxy, curl version is {curl_version}");
http.multiplexing = Some(false);
}
}

View File

@ -45,7 +45,7 @@ pub(super) fn load_target_cfgs(config: &Config) -> CargoResult<Vec<(String, Targ
// rebuilds. We may perhaps one day wish to ensure a deterministic
// ordering via the order keys were defined in files perhaps.
let target: BTreeMap<String, TargetCfgConfig> = config.get("target")?;
log::debug!("Got all targets {:#?}", target);
tracing::debug!("Got all targets {:#?}", target);
for (key, cfg) in target {
if key.starts_with("cfg(") {
// Unfortunately this is not able to display the location of the

View File

@ -35,7 +35,7 @@ impl<'a> Credential for CredentialProcessCredential {
cmd.stdout(Stdio::piped());
cmd.stdin(Stdio::piped());
cmd.arg("--cargo-plugin");
log::debug!("credential-process: {cmd:?}");
tracing::debug!("credential-process: {cmd:?}");
let mut child = cmd.spawn().context("failed to spawn credential process")?;
let mut output_from_child = BufReader::new(child.stdout.take().unwrap());
let mut input_to_child = child.stdin.take().unwrap();
@ -45,7 +45,7 @@ impl<'a> Credential for CredentialProcessCredential {
.context("failed to read hello from credential provider")?;
let credential_hello: CredentialHello =
serde_json::from_str(&buffer).context("failed to deserialize hello")?;
log::debug!("credential-process > {credential_hello:?}");
tracing::debug!("credential-process > {credential_hello:?}");
let req = CredentialRequest {
v: cargo_credential::PROTOCOL_VERSION_1,
@ -54,7 +54,7 @@ impl<'a> Credential for CredentialProcessCredential {
args: args.to_vec(),
};
let request = serde_json::to_string(&req).context("failed to serialize request")?;
log::debug!("credential-process < {req:?}");
tracing::debug!("credential-process < {req:?}");
writeln!(input_to_child, "{request}").context("failed to write to credential provider")?;
buffer.clear();
@ -63,7 +63,7 @@ impl<'a> Credential for CredentialProcessCredential {
.context("failed to read response from credential provider")?;
let response: Result<CredentialResponse, cargo_credential::Error> =
serde_json::from_str(&buffer).context("failed to deserialize response")?;
log::debug!("credential-process > {response:?}");
tracing::debug!("credential-process > {response:?}");
drop(input_to_child);
let status = child.wait().context("credential process never started")?;
if !status.success() {
@ -74,7 +74,7 @@ impl<'a> Credential for CredentialProcessCredential {
)
.into());
}
log::trace!("credential process exited successfully");
tracing::trace!("credential process exited successfully");
response
}
}

View File

@ -11,7 +11,7 @@ use std::thread::{self, JoinHandle};
use anyhow::{Context, Error};
use cargo_util::ProcessBuilder;
use log::warn;
use tracing::warn;
use serde::{Deserialize, Serialize};
use crate::core::Edition;

View File

@ -49,7 +49,7 @@ mod imp {
use std::ptr;
use std::ptr::addr_of;
use log::info;
use tracing::info;
use windows_sys::Win32::Foundation::CloseHandle;
use windows_sys::Win32::Foundation::HANDLE;

View File

@ -29,7 +29,7 @@ macro_rules! try_old_curl {
let result = $e;
if cfg!(target_os = "macos") {
if let Err(e) = result {
::log::warn!("ignoring libcurl {} error: {}", $msg, e);
::tracing::warn!("ignoring libcurl {} error: {}", $msg, e);
}
} else {
use ::anyhow::Context;

View File

@ -68,7 +68,7 @@ impl<T> SleepTracker<T> {
let now = Instant::now();
let mut result = Vec::new();
while let Some(next) = self.heap.peek() {
log::debug!("ERIC: now={now:?} next={:?}", next.wakeup);
tracing::debug!("ERIC: now={now:?} next={:?}", next.wakeup);
if next.wakeup < now {
result.push(self.heap.pop().unwrap().data);
} else {

View File

@ -6,7 +6,7 @@ use std::sync::Mutex;
use anyhow::Context as _;
use cargo_util::{paths, ProcessBuilder, ProcessError};
use log::{debug, info, warn};
use tracing::{debug, info, warn};
use serde::{Deserialize, Serialize};
use crate::util::interning::InternedString;

View File

@ -18,7 +18,7 @@ pub fn expand_manifest(
let comment = match extract_comment(content) {
Ok(comment) => Some(comment),
Err(err) => {
log::trace!("failed to extract doc comment: {err}");
tracing::trace!("failed to extract doc comment: {err}");
None
}
}
@ -26,7 +26,7 @@ pub fn expand_manifest(
let manifest = match extract_manifest(&comment)? {
Some(manifest) => Some(manifest),
None => {
log::trace!("failed to extract manifest");
tracing::trace!("failed to extract manifest");
None
}
}

View File

@ -11,7 +11,7 @@ use cargo_platform::Platform;
use cargo_util::paths;
use itertools::Itertools;
use lazycell::LazyCell;
use log::{debug, trace};
use tracing::{debug, trace};
use semver::{self, VersionReq};
use serde::de::IntoDeserializer as _;
use serde::de::{self, Unexpected};