Skip to content

Commit 1cfbf67

Browse files
committed
Use tracing macros directly
1 parent 4bfd68e commit 1cfbf67

File tree

11 files changed

+25
-35
lines changed

11 files changed

+25
-35
lines changed

src/cli/common.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::{cmp, env};
1111
use anyhow::{anyhow, Context, Result};
1212
use git_testament::{git_testament, render_testament};
1313
use once_cell::sync::Lazy;
14+
use tracing::{debug, error, info, warn};
1415

1516
use super::self_update;
1617
use crate::cli::download_tracker::DownloadTracker;
@@ -159,7 +160,7 @@ impl Notifier {
159160
match level {
160161
NotificationLevel::Verbose => {
161162
if self.verbose {
162-
verbose!("{}", n);
163+
debug!("{}", n);
163164
}
164165
}
165166
NotificationLevel::Info => {
@@ -169,7 +170,7 @@ impl Notifier {
169170
warn!("{}", n);
170171
}
171172
NotificationLevel::Error => {
172-
err!("{}", n);
173+
error!("{}", n);
173174
}
174175
NotificationLevel::Debug => {
175176
debug!("{}", n);
@@ -359,7 +360,7 @@ where
359360
{
360361
match self_update_permitted(false)? {
361362
SelfUpdatePermission::HardFail => {
362-
err!("Unable to self-update. STOP");
363+
error!("Unable to self-update. STOP");
363364
return Ok(utils::ExitCode(1));
364365
}
365366
SelfUpdatePermission::Skip => return Ok(utils::ExitCode(0)),
@@ -604,9 +605,9 @@ pub fn report_error(e: &anyhow::Error, process: &Process) {
604605
// hunk to revisit, that and a similar build.rs auto-detect glue as anyhow
605606
// has to detect when backtrace is available.
606607
if show_backtrace(process) {
607-
err!("{:?}", e);
608+
error!("{:?}", e);
608609
} else {
609-
err!("{:#}", e);
610+
error!("{:#}", e);
610611
}
611612
}
612613

src/cli/job.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ mod imp {
4040
use std::mem;
4141
use std::ptr;
4242

43+
use tracing::info;
4344
use windows_sys::Win32::Foundation::*;
4445
use windows_sys::Win32::System::JobObjects::*;
4546
use windows_sys::Win32::System::Threading::*;

src/cli/log.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,6 @@ use opentelemetry_sdk::trace::Tracer;
1818

1919
use crate::{currentprocess::Process, utils::notify::NotificationLevel};
2020

21-
macro_rules! debug {
22-
( $ ( $ arg : tt ) * ) => ( ::tracing::trace ! ( $ ( $ arg ) * ) )
23-
}
24-
25-
macro_rules! verbose {
26-
( $ ( $ arg : tt ) * ) => ( ::tracing::debug ! ( $ ( $ arg ) * ) )
27-
}
28-
29-
macro_rules! info {
30-
( $ ( $ arg : tt ) * ) => ( ::tracing::info ! ( $ ( $ arg ) * ) )
31-
}
32-
33-
macro_rules! warn {
34-
( $ ( $ arg : tt ) * ) => ( ::tracing::warn ! ( $ ( $ arg ) * ) )
35-
}
36-
37-
macro_rules! err {
38-
( $ ( $ arg : tt ) * ) => ( ::tracing::error ! ( $ ( $ arg ) * ) )
39-
}
40-
4121
pub fn tracing_subscriber(process: &Process) -> impl tracing::Subscriber {
4222
use tracing_subscriber::{layer::SubscriberExt, Registry};
4323

src/cli/rustup_mode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use anyhow::{anyhow, Error, Result};
88
use clap::{builder::PossibleValue, Args, CommandFactory, Parser, Subcommand, ValueEnum};
99
use clap_complete::Shell;
1010
use itertools::Itertools;
11+
use tracing::{debug, error, info, warn};
1112

1213
use crate::{
1314
cli::{
@@ -828,7 +829,7 @@ async fn update(cfg: &mut Cfg<'_>, opts: UpdateOpts) -> Result<utils::ExitCode>
828829

829830
let target_triple = name.clone().resolve(&host_arch)?.target;
830831
if !forced && !host_arch.can_run(&target_triple)? {
831-
err!("DEPRECATED: future versions of rustup will require --force-non-host to install a non-host toolchain.");
832+
error!("DEPRECATED: future versions of rustup will require --force-non-host to install a non-host toolchain.");
832833
warn!("toolchain '{name}' may not be able to run on this system.");
833834
warn!(
834835
"If you meant to build software to target that platform, perhaps try `rustup target add {}` instead?",

src/cli/self_update.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ use clap::ValueEnum;
6161
use itertools::Itertools;
6262
use same_file::Handle;
6363
use serde::{Deserialize, Serialize};
64+
use tracing::{debug, error, info, warn};
6465

6566
use crate::currentprocess::terminalsource;
6667
use crate::errors::RustupError;
@@ -983,8 +984,8 @@ async fn maybe_install_rust(
983984

984985
pub(crate) fn uninstall(no_prompt: bool, process: &Process) -> Result<utils::ExitCode> {
985986
if NEVER_SELF_UPDATE {
986-
err!("self-uninstall is disabled for this build of rustup");
987-
err!("you should probably use your system package manager to uninstall rustup");
987+
error!("self-uninstall is disabled for this build of rustup");
988+
error!("you should probably use your system package manager to uninstall rustup");
988989
return Ok(utils::ExitCode(1));
989990
}
990991

@@ -1110,8 +1111,8 @@ pub(crate) async fn update(cfg: &Cfg<'_>) -> Result<utils::ExitCode> {
11101111
match update_permitted {
11111112
HardFail => {
11121113
// TODO: Detect which package manager and be more useful.
1113-
err!("self-update is disabled for this build of rustup");
1114-
err!("you should probably use your system package manager to update rustup");
1114+
error!("self-update is disabled for this build of rustup");
1115+
error!("you should probably use your system package manager to update rustup");
11151116
return Ok(utils::ExitCode(1));
11161117
}
11171118
Skip => {
@@ -1124,7 +1125,7 @@ pub(crate) async fn update(cfg: &Cfg<'_>) -> Result<utils::ExitCode> {
11241125
match prepare_update(cfg.process).await? {
11251126
Some(setup_path) => {
11261127
let Some(version) = get_and_parse_new_rustup_version(&setup_path) else {
1127-
err!("failed to get rustup version");
1128+
error!("failed to get rustup version");
11281129
return Ok(utils::ExitCode(1));
11291130
};
11301131

src/cli/self_update/unix.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::path::{Path, PathBuf};
22
use std::process::Command;
33

44
use anyhow::{bail, Context, Result};
5+
use tracing::{error, warn};
56

67
use super::install_bins;
78
use super::shell;
@@ -34,11 +35,11 @@ pub(crate) fn do_anti_sudo_check(no_prompt: bool, process: &Process) -> Result<u
3435
match home_mismatch(process) {
3536
(false, _, _) => {}
3637
(true, env_home, euid_home) => {
37-
err!("$HOME differs from euid-obtained home directory: you may be using sudo");
38-
err!("$HOME directory: {}", env_home.display());
39-
err!("euid-obtained home directory: {}", euid_home.display());
38+
error!("$HOME differs from euid-obtained home directory: you may be using sudo");
39+
error!("$HOME directory: {}", env_home.display());
40+
error!("euid-obtained home directory: {}", euid_home.display());
4041
if !no_prompt {
41-
err!("if this is what you want, restart the installation with `-y'");
42+
error!("if this is what you want, restart the installation with `-y'");
4243
return Ok(utils::ExitCode(1));
4344
}
4445
}

src/cli/self_update/windows.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::process::Command;
88
use std::sync::{Arc, Mutex};
99

1010
use anyhow::{anyhow, Context, Result};
11+
use tracing::{info, warn};
1112

1213
use super::super::errors::*;
1314
use super::common;

src/cli/setup_mode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::path::PathBuf;
22

33
use anyhow::Result;
44
use clap::Parser;
5+
use tracing::warn;
56

67
use crate::{
78
cli::{

src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use anyhow::{anyhow, bail, Context, Result};
99
use serde::Deserialize;
1010
use thiserror::Error as ThisError;
1111
use tokio_stream::StreamExt;
12+
use tracing::debug;
1213

1314
use crate::settings::MetadataVersion;
1415
use crate::{

src/dist/component/package.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::path::{Path, PathBuf};
1010

1111
use anyhow::{anyhow, bail, Context, Result};
1212
use tar::EntryType;
13+
use tracing::warn;
1314

1415
use crate::currentprocess::Process;
1516
use crate::diskio::{get_executor, CompletedIo, Executor, FileBuffer, Item, Kind, IO_CHUNK_SIZE};

0 commit comments

Comments
 (0)