Skip to content

refactor(log): rename NotificationLevel variants to align with tracing::Level #3890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions rustup-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ ensure_loongarch_uapi() {
exit 1
;;
*)
echo "Warning: Cannot determine current system's ABI flavor, continuing anyway." >&2
echo "warn: Cannot determine current system's ABI flavor, continuing anyway." >&2
echo >&2
echo 'Note that the official Rust distribution only works with the upstream' >&2
echo 'kernel ABI. Installation will fail if your running kernel happens to be' >&2
Expand Down Expand Up @@ -601,9 +601,9 @@ downloader() {
_err=$(curl $_retry --proto '=https' --tlsv1.2 --ciphers "$_ciphersuites" --silent --show-error --fail --location "$1" --output "$2" 2>&1)
_status=$?
else
echo "Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure"
echo "warn: Not enforcing strong cipher suites for TLS, this is potentially less secure"
if ! check_help_for "$3" curl --proto --tlsv1.2; then
echo "Warning: Not enforcing TLS v1.2, this is potentially less secure"
echo "warn: Not enforcing TLS v1.2, this is potentially less secure"
_err=$(curl $_retry --silent --show-error --fail --location "$1" --output "$2" 2>&1)
_status=$?
else
Expand All @@ -620,7 +620,7 @@ downloader() {
return $_status
elif [ "$_dld" = wget ]; then
if [ "$(wget -V 2>&1|head -2|tail -1|cut -f1 -d" ")" = "BusyBox" ]; then
echo "Warning: using the BusyBox version of wget. Not enforcing strong cipher suites for TLS or TLS v1.2, this is potentially less secure"
echo "warn: using the BusyBox version of wget. Not enforcing strong cipher suites for TLS or TLS v1.2, this is potentially less secure"
_err=$(wget "$1" -O "$2" 2>&1)
_status=$?
else
Expand All @@ -630,9 +630,9 @@ downloader() {
_err=$(wget --https-only --secure-protocol=TLSv1_2 --ciphers "$_ciphersuites" "$1" -O "$2" 2>&1)
_status=$?
else
echo "Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure"
echo "warn: Not enforcing strong cipher suites for TLS, this is potentially less secure"
if ! check_help_for "$3" wget --https-only --secure-protocol; then
echo "Warning: Not enforcing TLS v1.2, this is potentially less secure"
echo "warn: Not enforcing TLS v1.2, this is potentially less secure"
_err=$(wget "$1" -O "$2" 2>&1)
_status=$?
else
Expand Down Expand Up @@ -679,7 +679,7 @@ check_help_for() {
# fail to find these options to force fallback
if [ "$(sw_vers -productVersion | cut -d. -f2)" -lt 13 ]; then
# Older than 10.13
echo "Warning: Detected macOS platform older than 10.13"
echo "warn: Detected macOS platform older than 10.13"
return 1
fi
;;
Expand All @@ -688,7 +688,7 @@ check_help_for() {
;;
*)
# Unknown product version, warn and continue
echo "Warning: Detected unknown macOS major version: $(sw_vers -productVersion)"
echo "warn: Detected unknown macOS major version: $(sw_vers -productVersion)"
echo "Warning TLS capabilities detection may fail"
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl Notifier {
let level = n.level();
for n in format!("{n}").lines() {
match level {
NotificationLevel::Verbose => {
NotificationLevel::Debug => {
if self.verbose {
debug!("{}", n);
}
Expand All @@ -169,7 +169,7 @@ impl Notifier {
NotificationLevel::Error => {
error!("{}", n);
}
NotificationLevel::Debug => {
NotificationLevel::Trace => {
trace!("{}", n);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/cli/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ where
impl NotificationLevel {
fn fg_color(&self) -> Option<Color> {
match self {
NotificationLevel::Debug => Some(Color::Blue),
NotificationLevel::Verbose => Some(Color::Magenta),
NotificationLevel::Trace => Some(Color::Blue),
NotificationLevel::Debug => Some(Color::Magenta),
NotificationLevel::Info => None,
NotificationLevel::Warn => Some(Color::Yellow),
NotificationLevel::Error => Some(Color::Red),
Expand Down
2 changes: 1 addition & 1 deletion src/cli/self_update/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ mod tests {
);
});
assert_eq!(
r"warning: the registry key HKEY_CURRENT_USER\Environment\PATH is not a string. Not modifying the PATH variable
r"warn: the registry key HKEY_CURRENT_USER\Environment\PATH is not a string. Not modifying the PATH variable
",
String::from_utf8(tp.stderr()).unwrap()
);
Expand Down
2 changes: 1 addition & 1 deletion src/dist/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<'a> Notification<'a> {
ChecksumValid(_)
| NoUpdateHash(_)
| FileAlreadyDownloaded
| DownloadingLegacyManifest => NotificationLevel::Verbose,
| DownloadingLegacyManifest => NotificationLevel::Debug,
Extracting(_, _)
| DownloadingComponent(_, _, _)
| InstallingComponent(_, _, _)
Expand Down
4 changes: 2 additions & 2 deletions src/dist/temp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ impl<'a> Notification<'a> {
pub(crate) fn level(&self) -> NotificationLevel {
use self::Notification::*;
match self {
CreatingRoot(_) | CreatingFile(_) | CreatingDirectory(_) => NotificationLevel::Verbose,
CreatingRoot(_) | CreatingFile(_) | CreatingDirectory(_) => NotificationLevel::Debug,
FileDeletion(_, result) | DirectoryDeletion(_, result) => {
if result.is_ok() {
NotificationLevel::Verbose
NotificationLevel::Debug
} else {
NotificationLevel::Warn
}
Expand Down
2 changes: 1 addition & 1 deletion src/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<'a> Notification<'a> {
| UpdatingToolchain(_)
| ReadMetadataVersion(_)
| InstalledToolchain(_)
| UpdateHashMatches => NotificationLevel::Verbose,
| UpdateHashMatches => NotificationLevel::Debug,
SetDefaultToolchain(_)
| SetOverrideToolchain(_, _)
| SetProfile(_)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<'a> Notification<'a> {
pub(crate) fn level(&self) -> NotificationLevel {
use self::Notification::*;
match self {
SetDefaultBufferSize(_) => NotificationLevel::Debug,
SetDefaultBufferSize(_) => NotificationLevel::Trace,
CreatingDirectory(_, _)
| RemovingDirectory(_, _)
| LinkingDirectory(_, _)
Expand All @@ -59,7 +59,7 @@ impl<'a> Notification<'a> {
| DownloadFinished
| ResumingPartialDownload
| UsingCurl
| UsingReqwest => NotificationLevel::Verbose,
| UsingReqwest => NotificationLevel::Debug,
RenameInUse(_, _) => NotificationLevel::Info,
NoCanonicalPath(_) => NotificationLevel::Warn,
Error(_) => NotificationLevel::Error,
Expand Down
10 changes: 5 additions & 5 deletions src/utils/notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use tracing::Level;

#[derive(Debug)]
pub(crate) enum NotificationLevel {
Trace,
Debug,
Verbose,
Info,
Warn,
Error,
Expand All @@ -14,10 +14,10 @@ pub(crate) enum NotificationLevel {
impl fmt::Display for NotificationLevel {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
NotificationLevel::Trace => "trace",
NotificationLevel::Debug => "debug",
NotificationLevel::Verbose => "verbose",
NotificationLevel::Info => "info",
NotificationLevel::Warn => "warning",
NotificationLevel::Warn => "warn",
NotificationLevel::Error => "error",
})
}
Expand All @@ -26,8 +26,8 @@ impl fmt::Display for NotificationLevel {
impl From<Level> for NotificationLevel {
fn from(level: Level) -> Self {
match level {
Level::TRACE => Self::Debug,
Level::DEBUG => Self::Verbose,
Level::TRACE => Self::Trace,
Level::DEBUG => Self::Debug,
Level::INFO => Self::Info,
Level::WARN => Self::Warn,
Level::ERROR => Self::Error,
Expand Down
16 changes: 8 additions & 8 deletions tests/suite/cli_inst_interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ fn install_forces_and_skips_rls() {
assert!(out.ok);
assert!(out
.stderr
.contains("warning: Force-skipping unavailable component"));
.contains("warn: Force-skipping unavailable component"));
});
}

Expand All @@ -447,7 +447,7 @@ fn test_warn_if_complete_profile_is_used() {
"complete",
"--no-modify-path",
],
"warning: downloading with complete profile",
"warn: downloading with complete profile",
);
});
}
Expand All @@ -460,7 +460,7 @@ fn test_prompt_fail_if_rustup_sh_already_installed_reply_nothing() {
assert!(!out.ok);
assert!(out
.stderr
.contains("warning: it looks like you have existing rustup.sh metadata"));
.contains("warn: it looks like you have existing rustup.sh metadata"));
assert!(out
.stderr
.contains("error: cannot install while rustup.sh is installed"));
Expand All @@ -476,7 +476,7 @@ fn test_prompt_fail_if_rustup_sh_already_installed_reply_no() {
assert!(!out.ok);
assert!(out
.stderr
.contains("warning: it looks like you have existing rustup.sh metadata"));
.contains("warn: it looks like you have existing rustup.sh metadata"));
assert!(out
.stderr
.contains("error: cannot install while rustup.sh is installed"));
Expand All @@ -491,14 +491,14 @@ fn test_prompt_succeed_if_rustup_sh_already_installed_reply_yes() {
let out = run_input(config, &["rustup-init", "--no-modify-path"], "yes\n\n\n");
assert!(out
.stderr
.contains("warning: it looks like you have existing rustup.sh metadata"));
.contains("warn: it looks like you have existing rustup.sh metadata"));
assert!(out
.stderr
.contains("error: cannot install while rustup.sh is installed"));
assert!(out.stdout.contains("Continue? (y/N)"));
assert!(!out.stdout.contains(
"warning: continuing (because the -y flag is set and the error is ignorable)"
));
assert!(!out
.stdout
.contains("warn: continuing (because the -y flag is set and the error is ignorable)"));
assert!(out.ok);
})
}
Expand Down
10 changes: 5 additions & 5 deletions tests/suite/cli_rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,7 @@ components = [ "rust-bongo" ]

config.expect_stderr_ok(
&["rustc", "--version"],
"warning: Force-skipping unavailable component 'rust-bongo",
"warn: Force-skipping unavailable component 'rust-bongo",
);
})
});
Expand Down Expand Up @@ -2533,8 +2533,8 @@ fn warn_on_unmatch_build() {
config.expect_stderr_ok(
&["rustup", "toolchain", "install", &format!("nightly-{arch}")],
&format!(
r"warning: toolchain 'nightly-{arch}' may not be able to run on this system.
warning: If you meant to build software to target that platform, perhaps try `rustup target add {arch}` instead?",
r"warn: toolchain 'nightly-{arch}' may not be able to run on this system.
warn: If you meant to build software to target that platform, perhaps try `rustup target add {arch}` instead?",
),
);
})
Expand All @@ -2560,7 +2560,7 @@ fn dont_warn_on_partial_build() {
r"info: syncing channel updates for 'nightly-{triple}'"
)));
assert!(!stderr.contains(&format!(
r"warning: toolchain 'nightly-{arch}' may not be able to run on this system."
r"warn: toolchain 'nightly-{arch}' may not be able to run on this system."
)));
})
})
Expand Down Expand Up @@ -2613,7 +2613,7 @@ fn warn_on_duplicate_rust_toolchain_file() {
config.expect_stderr_ok(
&["rustc", "--version"],
&format!(
"warning: both `{0}` and `{1}` exist. Using `{0}`",
"warn: both `{0}` and `{1}` exist. Using `{0}`",
toolchain_file_1.canonicalize().unwrap().display(),
toolchain_file_2.canonicalize().unwrap().display(),
),
Expand Down
16 changes: 8 additions & 8 deletions tests/suite/cli_self_upd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,13 +744,13 @@ fn test_warn_succeed_if_rustup_sh_already_installed_y_flag() {
assert!(out.ok);
assert!(out
.stderr
.contains("warning: it looks like you have existing rustup.sh metadata"));
.contains("warn: it looks like you have existing rustup.sh metadata"));
assert!(out
.stderr
.contains("error: cannot install while rustup.sh is installed"));
assert!(out.stderr.contains(
"warning: continuing (because the -y flag is set and the error is ignorable)"
));
assert!(out
.stderr
.contains("warn: continuing (because the -y flag is set and the error is ignorable)"));
assert!(!out.stdout.contains("Continue? (y/N)"));
})
}
Expand All @@ -767,13 +767,13 @@ fn test_succeed_if_rustup_sh_already_installed_env_var_set() {
assert!(out.ok);
assert!(!out
.stderr
.contains("warning: it looks like you have existing rustup.sh metadata"));
.contains("warn: it looks like you have existing rustup.sh metadata"));
assert!(!out
.stderr
.contains("error: cannot install while rustup.sh is installed"));
assert!(!out.stderr.contains(
"warning: continuing (because the -y flag is set and the error is ignorable)"
));
assert!(!out
.stderr
.contains("warn: continuing (because the -y flag is set and the error is ignorable)"));
assert!(!out.stdout.contains("Continue? (y/N)"));
})
}
Expand Down
6 changes: 3 additions & 3 deletions tests/suite/cli_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ fn test_warn_if_complete_profile_is_used() {
"complete",
"stable",
],
"warning: downloading with complete profile",
"warn: downloading with complete profile",
);
});
}
Expand All @@ -1377,7 +1377,7 @@ fn test_complete_profile_skips_missing_when_forced() {
// Now try and force
config.expect_stderr_ok(
&["rustup", "toolchain", "install", "--force", "nightly"],
for_host!("warning: Force-skipping unavailable component 'rls-{}'"),
for_host!("warn: Force-skipping unavailable component 'rls-{}'"),
);

// Ensure that the skipped component (rls) is not installed
Expand Down Expand Up @@ -1407,7 +1407,7 @@ fn run_with_install_flag_against_unavailable_component() {
for_host!(
r"info: syncing channel updates for 'nightly-{0}'
info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2)
warning: Force-skipping unavailable component 'rust-std-{0}'
warn: Force-skipping unavailable component 'rust-std-{0}'
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: downloading component 'rustc'
Expand Down
Loading