Skip to content

Commit af1a78b

Browse files
committed
refactor: find & replace log:: -> tracing::
Except HTTP network debugging
1 parent 9f0565e commit af1a78b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+117
-117
lines changed

crates/cargo-util/src/paths.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ pub fn mtime_recursive(path: &Path) -> Result<FileTime> {
237237
Err(e) => {
238238
// Ignore errors while walking. If Cargo can't access it, the
239239
// build script probably can't access it, either.
240-
log::debug!("failed to determine mtime while walking directory: {}", e);
240+
tracing::debug!("failed to determine mtime while walking directory: {}", e);
241241
None
242242
}
243243
})
@@ -252,7 +252,7 @@ pub fn mtime_recursive(path: &Path) -> Result<FileTime> {
252252
// I'm not sure when this is really possible (maybe a
253253
// race with unlinking?). Regardless, if Cargo can't
254254
// read it, the build script probably can't either.
255-
log::debug!(
255+
tracing::debug!(
256256
"failed to determine mtime while fetching symlink metadata of {}: {}",
257257
e.path().display(),
258258
err
@@ -271,7 +271,7 @@ pub fn mtime_recursive(path: &Path) -> Result<FileTime> {
271271
// Can't access the symlink target. If Cargo can't
272272
// access it, the build script probably can't access
273273
// it either.
274-
log::debug!(
274+
tracing::debug!(
275275
"failed to determine mtime of symlink target for {}: {}",
276276
e.path().display(),
277277
err
@@ -286,7 +286,7 @@ pub fn mtime_recursive(path: &Path) -> Result<FileTime> {
286286
// I'm not sure when this is really possible (maybe a
287287
// race with unlinking?). Regardless, if Cargo can't
288288
// read it, the build script probably can't either.
289-
log::debug!(
289+
tracing::debug!(
290290
"failed to determine mtime while fetching metadata of {}: {}",
291291
e.path().display(),
292292
err
@@ -314,7 +314,7 @@ pub fn set_invocation_time(path: &Path) -> Result<FileTime> {
314314
"This file has an mtime of when this was started.",
315315
)?;
316316
let ft = mtime(&timestamp)?;
317-
log::debug!("invocation time for {:?} is {}", path, ft);
317+
tracing::debug!("invocation time for {:?} is {}", path, ft);
318318
Ok(ft)
319319
}
320320

@@ -508,7 +508,7 @@ pub fn link_or_copy(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()>
508508
}
509509

510510
fn _link_or_copy(src: &Path, dst: &Path) -> Result<()> {
511-
log::debug!("linking {} to {}", src.display(), dst.display());
511+
tracing::debug!("linking {} to {}", src.display(), dst.display());
512512
if same_file::is_same_file(src, dst).unwrap_or(false) {
513513
return Ok(());
514514
}
@@ -567,7 +567,7 @@ fn _link_or_copy(src: &Path, dst: &Path) -> Result<()> {
567567
};
568568
link_result
569569
.or_else(|err| {
570-
log::debug!("link failed {}. falling back to fs::copy", err);
570+
tracing::debug!("link failed {}. falling back to fs::copy", err);
571571
fs::copy(src, dst).map(|_| ())
572572
})
573573
.with_context(|| {
@@ -598,8 +598,8 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64> {
598598
pub fn set_file_time_no_err<P: AsRef<Path>>(path: P, time: FileTime) {
599599
let path = path.as_ref();
600600
match filetime::set_file_times(path, time, time) {
601-
Ok(()) => log::debug!("set file mtime {} to {}", path.display(), time),
602-
Err(e) => log::warn!(
601+
Ok(()) => tracing::debug!("set file mtime {} to {}", path.display(), time),
602+
Err(e) => tracing::warn!(
603603
"could not set mtime of {} to {}: {:?}",
604604
path.display(),
605605
time,
@@ -621,7 +621,7 @@ pub fn strip_prefix_canonical<P: AsRef<Path>>(
621621
let safe_canonicalize = |path: &Path| match path.canonicalize() {
622622
Ok(p) => p,
623623
Err(e) => {
624-
log::warn!("cannot canonicalize {:?}: {:?}", path, e);
624+
tracing::warn!("cannot canonicalize {:?}: {:?}", path, e);
625625
path.to_path_buf()
626626
}
627627
};

crates/cargo-util/src/process_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ impl ProcessBuilder {
449449
arg.push(tmp.path());
450450
let mut cmd = self.build_command_without_args();
451451
cmd.arg(arg);
452-
log::debug!("created argfile at {} for {self}", tmp.path().display());
452+
tracing::debug!("created argfile at {} for {self}", tmp.path().display());
453453

454454
let cap = self.get_args().map(|arg| arg.len() + 1).sum::<usize>();
455455
let mut buf = Vec::with_capacity(cap);
@@ -558,7 +558,7 @@ fn piped(cmd: &mut Command, pipe_stdin: bool) -> &mut Command {
558558

559559
fn close_tempfile_and_log_error(file: NamedTempFile) {
560560
file.close().unwrap_or_else(|e| {
561-
log::warn!("failed to close temporary file: {e}");
561+
tracing::warn!("failed to close temporary file: {e}");
562562
});
563563
}
564564

crates/xtask-bump-check/src/xtask.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn bump_check(args: &clap::ArgMatches, config: &mut cargo::util::Config) -> Carg
126126
for referenced_member in checkout_ws(&ws, &repo, referenced_commit)?.members() {
127127
let Some(changed_member) = changed_members.get(referenced_member) else {
128128
let name = referenced_member.name().as_str();
129-
log::trace!("skipping {name}, may be removed or not published");
129+
tracing::trace!("skipping {name}, may be removed or not published");
130130
continue;
131131
};
132132

@@ -264,10 +264,10 @@ fn get_referenced_commit<'a>(
264264
let referenced_commit = if rev_id == stable_commit.id() {
265265
None
266266
} else if rev_id == beta_commit.id() {
267-
log::trace!("stable branch from `{}`", stable.name().unwrap().unwrap());
267+
tracing::trace!("stable branch from `{}`", stable.name().unwrap().unwrap());
268268
Some(stable_commit)
269269
} else {
270-
log::trace!("beta branch from `{}`", beta.name().unwrap().unwrap());
270+
tracing::trace!("beta branch from `{}`", beta.name().unwrap().unwrap());
271271
Some(beta_commit)
272272
};
273273

@@ -287,11 +287,11 @@ fn beta_and_stable_branch(repo: &git2::Repository) -> CargoResult<[git2::Branch<
287287
let (branch, _) = branch?;
288288
let name = branch.name()?.unwrap();
289289
let Some((_, version)) = name.split_once("/rust-") else {
290-
log::trace!("branch `{name}` is not in the format of `<remote>/rust-<semver>`");
290+
tracing::trace!("branch `{name}` is not in the format of `<remote>/rust-<semver>`");
291291
continue;
292292
};
293293
let Ok(version) = version.to_semver() else {
294-
log::trace!("branch `{name}` is not a valid semver: `{version}`");
294+
tracing::trace!("branch `{name}` is not a valid semver: `{version}`");
295295
continue;
296296
};
297297
release_branches.push((version, branch));
@@ -380,7 +380,7 @@ fn check_crates_io<'a>(
380380
}
381381
};
382382
if possibilities.is_empty() {
383-
log::trace!("dep `{name}` has no version greater than or equal to `{current}`");
383+
tracing::trace!("dep `{name}` has no version greater than or equal to `{current}`");
384384
} else {
385385
needs_bump.push(member);
386386
}

src/cargo/core/compiler/build_context/target_info.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,19 +1065,19 @@ impl RustDocFingerprint {
10651065
if fingerprint.rustc_vv == actual_rustdoc_target_data.rustc_vv {
10661066
return Ok(());
10671067
} else {
1068-
log::debug!(
1068+
tracing::debug!(
10691069
"doc fingerprint changed:\noriginal:\n{}\nnew:\n{}",
10701070
fingerprint.rustc_vv,
10711071
actual_rustdoc_target_data.rustc_vv
10721072
);
10731073
}
10741074
}
10751075
Err(e) => {
1076-
log::debug!("could not deserialize {:?}: {}", fingerprint_path, e);
1076+
tracing::debug!("could not deserialize {:?}: {}", fingerprint_path, e);
10771077
}
10781078
};
10791079
// Fingerprint does not match, delete the doc directories and write a new fingerprint.
1080-
log::debug!(
1080+
tracing::debug!(
10811081
"fingerprint {:?} mismatch, clearing doc directories",
10821082
fingerprint_path
10831083
);

src/cargo/core/compiler/context/compilation_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
77
use std::sync::Arc;
88

99
use lazycell::LazyCell;
10-
use log::debug;
10+
use tracing::debug;
1111

1212
use super::{BuildContext, CompileKind, Context, FileFlavor, Layout};
1313
use crate::core::compiler::{CompileMode, CompileTarget, CrateType, FileType, Unit};

src/cargo/core/compiler/fingerprint/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ use std::time::SystemTime;
366366
use anyhow::{bail, format_err, Context as _};
367367
use cargo_util::{paths, ProcessBuilder};
368368
use filetime::FileTime;
369-
use log::{debug, info};
369+
use tracing::{debug, info};
370370
use serde::de;
371371
use serde::ser;
372372
use serde::{Deserialize, Serialize};
@@ -1815,7 +1815,7 @@ pub fn parse_dep_info(
18151815
let info = match EncodedDepInfo::parse(&data) {
18161816
Some(info) => info,
18171817
None => {
1818-
log::warn!("failed to parse cargo's dep-info at {:?}", dep_info);
1818+
tracing::warn!("failed to parse cargo's dep-info at {:?}", dep_info);
18191819
return Ok(None);
18201820
}
18211821
};

src/cargo/core/compiler/future_incompat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ pub fn save_and_display_report(
417417
let current_reports = match OnDiskReports::load(bcx.ws) {
418418
Ok(r) => r,
419419
Err(e) => {
420-
log::debug!(
420+
tracing::debug!(
421421
"saving future-incompatible reports failed to load current reports: {:?}",
422422
e
423423
);

src/cargo/core/compiler/job_queue/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ use std::time::Duration;
125125
use anyhow::{format_err, Context as _};
126126
use cargo_util::ProcessBuilder;
127127
use jobserver::{Acquired, HelperThread};
128-
use log::{debug, trace};
128+
use tracing::{debug, trace};
129129
use semver::Version;
130130

131131
pub use self::job::Freshness::{self, Dirty, Fresh};
@@ -840,7 +840,7 @@ impl<'cfg> DrainState<'cfg> {
840840
}
841841
err_state.count += 1;
842842
} else {
843-
log::warn!("{:?}", new_err.error);
843+
tracing::warn!("{:?}", new_err.error);
844844
}
845845
}
846846

src/cargo/core/compiler/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ use std::sync::Arc;
6565

6666
use anyhow::{Context as _, Error};
6767
use lazycell::LazyCell;
68-
use log::{debug, trace};
68+
use tracing::{debug, trace};
6969

7070
pub use self::build_config::{BuildConfig, CompileMode, MessageFormat, TimingOutput};
7171
pub use self::build_context::{
@@ -368,7 +368,7 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc<dyn Executor>) -> Car
368368
// See rust-lang/cargo#8348.
369369
if output.hardlink.is_some() && output.path.exists() {
370370
_ = paths::remove_file(&output.path).map_err(|e| {
371-
log::debug!(
371+
tracing::debug!(
372372
"failed to delete previous output file `{:?}`: {e:?}",
373373
output.path
374374
);

src/cargo/core/compiler/output_depinfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};
99
use super::{fingerprint, Context, FileFlavor, Unit};
1010
use crate::util::{internal, CargoResult};
1111
use cargo_util::paths;
12-
use log::debug;
12+
use tracing::debug;
1313

1414
/// Bacially just normalizes a given path and converts it to a string.
1515
fn render_filename<P: AsRef<Path>>(path: P, basedir: Option<&str>) -> CargoResult<String> {

0 commit comments

Comments
 (0)