From 93cdd371898674ba8fdeed9e65982f91b25cf530 Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Mon, 4 Nov 2024 18:54:04 -0600 Subject: [PATCH] fix: clean up debug log output --- .../mise__cli__shell__tests__shell-2.snap | 5 ++++ .../mise__cli__upgrade__tests__upgrade-2.snap | 10 +++++++- ...__cli__upgrade__tests__upgrade_bump-2.snap | 10 +++++++- src/cli/use.rs | 24 +++++++++++++++---- src/logger.rs | 3 +-- src/ui/progress_report.rs | 7 +++--- 6 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/cli/snapshots/mise__cli__shell__tests__shell-2.snap b/src/cli/snapshots/mise__cli__shell__tests__shell-2.snap index af9542c92..96b8104a6 100644 --- a/src/cli/snapshots/mise__cli__shell__tests__shell-2.snap +++ b/src/cli/snapshots/mise__cli__shell__tests__shell-2.snap @@ -1,5 +1,10 @@ --- source: src/cli/shell.rs expression: output +snapshot_kind: text --- export MISE_TINY_VERSION=1.0.1 +mise mise tiny@1.0.1 installing +mise mise tiny@1.0.1 installing +mise mise tiny@1.0.1 ~/data/plugins/tiny/bin/install +mise mise tiny@1.0.1 ✓ installed diff --git a/src/cli/snapshots/mise__cli__upgrade__tests__upgrade-2.snap b/src/cli/snapshots/mise__cli__upgrade__tests__upgrade-2.snap index 23c1cf15c..80d11db24 100644 --- a/src/cli/snapshots/mise__cli__upgrade__tests__upgrade-2.snap +++ b/src/cli/snapshots/mise__cli__upgrade__tests__upgrade-2.snap @@ -1,5 +1,13 @@ --- source: src/cli/upgrade.rs expression: output +snapshot_kind: text --- - +mise mise tiny@3.1.0 installing +mise mise tiny@3.1.0 installing +mise mise tiny@3.1.0 ~/data/plugins/tiny/bin/install +mise mise tiny@3.1.0 ✓ installed +mise mise Uninstalling tiny@3.0.0 uninstall +mise mise Uninstalling tiny@3.0.0 removing ~/data/installs/tiny/3.0.0 +mise mise Uninstalling tiny@3.0.0 removing ~/data/cache/tiny/3.0.0 +mise mise Uninstalling tiny@3.0.0 ✓ done diff --git a/src/cli/snapshots/mise__cli__upgrade__tests__upgrade_bump-2.snap b/src/cli/snapshots/mise__cli__upgrade__tests__upgrade_bump-2.snap index 23c1cf15c..80d11db24 100644 --- a/src/cli/snapshots/mise__cli__upgrade__tests__upgrade_bump-2.snap +++ b/src/cli/snapshots/mise__cli__upgrade__tests__upgrade_bump-2.snap @@ -1,5 +1,13 @@ --- source: src/cli/upgrade.rs expression: output +snapshot_kind: text --- - +mise mise tiny@3.1.0 installing +mise mise tiny@3.1.0 installing +mise mise tiny@3.1.0 ~/data/plugins/tiny/bin/install +mise mise tiny@3.1.0 ✓ installed +mise mise Uninstalling tiny@3.0.0 uninstall +mise mise Uninstalling tiny@3.0.0 removing ~/data/installs/tiny/3.0.0 +mise mise Uninstalling tiny@3.0.0 removing ~/data/cache/tiny/3.0.0 +mise mise Uninstalling tiny@3.0.0 ✓ done diff --git a/src/cli/use.rs b/src/cli/use.rs index c0e2f6b98..7e718a5bf 100644 --- a/src/cli/use.rs +++ b/src/cli/use.rs @@ -255,7 +255,13 @@ mod tests { tiny = "2" "###); - assert_cli_snapshot!("use", "tiny@1", "tiny@2", "tiny@3", @"mise ~/cwd/.test.mise.toml tools: tiny@1.0.1, tiny@2.1.0, tiny@3.1.0"); + assert_cli_snapshot!("use", "tiny@1", "tiny@2", "tiny@3", @r" + mise ~/cwd/.test.mise.toml tools: tiny@1.0.1, tiny@2.1.0, tiny@3.1.0 + mise mise tiny@1.0.1 installing + mise mise tiny@1.0.1 installing + mise mise tiny@1.0.1 ~/data/plugins/tiny/bin/install + mise mise tiny@1.0.1 ✓ installed + "); assert_snapshot!(file::read_to_string(&cf_path).unwrap(), @r###" [tools] tiny = ["1", "2", "3"] @@ -292,7 +298,13 @@ mod tests { tiny = "2" "###); - assert_cli_snapshot!("use", "tiny@1", "tiny@2", "tiny@3", @"mise ~/cwd/.test.mise.toml tools: tiny@1.0.1, tiny@2.1.0, tiny@3.1.0"); + assert_cli_snapshot!("use", "tiny@1", "tiny@2", "tiny@3", @r" + mise ~/cwd/.test.mise.toml tools: tiny@1.0.1, tiny@2.1.0, tiny@3.1.0 + mise mise tiny@1.0.1 installing + mise mise tiny@1.0.1 installing + mise mise tiny@1.0.1 ~/data/plugins/tiny/bin/install + mise mise tiny@1.0.1 ✓ installed + "); assert_snapshot!(file::read_to_string(&cf_path).unwrap(), @r###" [tools] tiny = ["1", "2", "3"] @@ -350,10 +362,14 @@ mod tests { let cf_path = dirs::CONFIG.join("config.toml"); let orig = file::read_to_string(&cf_path).unwrap(); - assert_cli_snapshot!("use", "-g", "tiny@2", @r###" + assert_cli_snapshot!("use", "-g", "tiny@2", @r" mise ~/config/config.toml tools: tiny@2.1.0 + mise mise tiny@2.1.0 installing + mise mise tiny@2.1.0 installing + mise mise tiny@2.1.0 ~/data/plugins/tiny/bin/install + mise mise tiny@2.1.0 ✓ installed mise tiny is defined in ~/cwd/.test-tool-versions which overrides the global config (~/config/config.toml) - "###); + "); assert_snapshot!(file::read_to_string(&cf_path).unwrap(), @r##" [env] TEST_ENV_VAR = 'test-123' diff --git a/src/logger.rs b/src/logger.rs index ee4377dcd..30fd08264 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -85,9 +85,8 @@ impl Logger { ) } LevelFilter::Debug => format!( - "{level} {module_path} {args}", + "{level} {args}", level = self.styled_level(record.level()), - module_path = record.module_path().unwrap_or_default(), args = record.args() ), _ => { diff --git a/src/ui/progress_report.rs b/src/ui/progress_report.rs index cd02678ab..b2e04c001 100644 --- a/src/ui/progress_report.rs +++ b/src/ui/progress_report.rs @@ -144,9 +144,8 @@ impl SingleReport for VerboseReport { eprintln!("{message}"); } fn set_message(&self, message: String) { - // let prefix = normal_prefix(self.pad, &self.prefix); - // eprintln!("{prefix} {message}"); - eprintln!("{message}"); + let prefix = normal_prefix(self.pad, &self.prefix); + info!("{prefix} {message}"); } fn finish(&self) { self.finish_with_message(style::egreen("done").to_string()); @@ -154,7 +153,7 @@ impl SingleReport for VerboseReport { fn finish_with_message(&self, message: String) { let prefix = success_prefix(self.pad - 2, &self.prefix); let ico = style::egreen("✓").bright(); - eprintln!("{prefix} {ico} {message}"); + info!("{prefix} {ico} {message}"); } }