Skip to content

Commit

Permalink
fix: clean up debug log output
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Nov 5, 2024
1 parent 0329868 commit 93cdd37
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/cli/snapshots/mise__cli__shell__tests__shell-2.snap
Original file line number Diff line number Diff line change
@@ -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.1installed
10 changes: 9 additions & 1 deletion src/cli/snapshots/mise__cli__upgrade__tests__upgrade-2.snap
Original file line number Diff line number Diff line change
@@ -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.0installed
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.0done
Original file line number Diff line number Diff line change
@@ -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.0installed
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.0done
24 changes: 20 additions & 4 deletions src/cli/use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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'
Expand Down
3 changes: 1 addition & 2 deletions src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
),
_ => {
Expand Down
7 changes: 3 additions & 4 deletions src/ui/progress_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,16 @@ 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());
}
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}");
}
}

Expand Down

0 comments on commit 93cdd37

Please sign in to comment.