Skip to content

Commit 75b4252

Browse files
bkchrliamaharon
andauthored
Colorize the output (#66)
Adds some colors to the logs and also some empty space around the log lines from try-runtime-cli to make it more clear what belongs to what. Before I always had the problem that there was a wall of text and I didn't know when something started and something ended. This pr makes it a little bit better. The ashetics are discussable and clearly can be improved. --------- Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
1 parent 68c3c10 commit 75b4252

4 files changed

Lines changed: 63 additions & 9 deletions

File tree

Cargo.lock

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ resolver = "2"
44
members = ["cli", "core"]
55

66
[workspace.package]
7-
version = "0.5.1"
7+
version = "0.5.2"
88
authors = ["Parity Technologies <admin@parity.io>"]
99
description = "Substrate's programmatic testing framework."
1010
edition = "2021"

core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ sp-version = { workspace = true }
5252
sp-weights = { workspace = true }
5353

5454
substrate-rpc-client = { workspace = true }
55+
paris = "1.5.15"
5556

5657
[dev-dependencies]
5758
assert_cmd = { workspace = true }

core/src/commands/on_runtime_upgrade.rs

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::{fmt::Debug, str::FromStr};
1919

2020
use bytesize::ByteSize;
2121
use frame_try_runtime::UpgradeCheckSelect;
22+
use paris::formatter::colorize_string;
2223
use parity_scale_codec::Encode;
2324
use sc_executor::sp_wasm_interface::HostFunctions;
2425
use sp_core::{hexdisplay::HexDisplay, Hasher};
@@ -101,8 +102,23 @@ where
101102

102103
// Run `TryRuntime_on_runtime_upgrade` with the given checks.
103104
log::info!(
104-
"🔬 Running TryRuntime_on_runtime_upgrade with checks: {:?}",
105-
command.checks
105+
"{}",
106+
colorize_string(
107+
"<bold><blue>-------------------------------------------------------------------\n\n"
108+
)
109+
);
110+
log::info!(
111+
"{}",
112+
colorize_string(format!(
113+
"🔬 <bold><blue>Running TryRuntime_on_runtime_upgrade with checks: {:?}\n\n",
114+
command.checks
115+
))
116+
);
117+
log::info!(
118+
"{}",
119+
colorize_string(
120+
"<bold><blue>-------------------------------------------------------------------"
121+
)
106122
);
107123
// Save the overlayed changes from the first run, so we can use them later for idempotency
108124
// checks.
@@ -126,7 +142,16 @@ where
126142
UpgradeCheckSelect::None => (proof, ref_time_results),
127143
_ => {
128144
log::info!(
129-
"🔬 TryRuntime_on_runtime_upgrade succeeded! Running it again without checks for weight measurements."
145+
"{}",
146+
colorize_string("<bold><blue>-------------------------------------------------------------------\n\n")
147+
);
148+
log::info!(
149+
"{}",
150+
colorize_string("🔬 <bold><blue>TryRuntime_on_runtime_upgrade succeeded! Running it again without checks for weight measurements.\n\n"),
151+
);
152+
log::info!(
153+
"{}",
154+
colorize_string("<bold><blue>-------------------------------------------------------------------")
130155
);
131156
let (proof, encoded_result) = state_machine_call_with_proof::<Block, HostFns>(
132157
&ext,
@@ -150,8 +175,16 @@ where
150175
}
151176
false => {
152177
log::info!(
153-
"🔬 Running TryRuntime_on_runtime_upgrade again to check idempotency: {:?}",
154-
command.checks
178+
"{}",
179+
colorize_string("<bold><blue>-------------------------------------------------------------------\n\n")
180+
);
181+
log::info!(
182+
"{}",
183+
colorize_string(format!("🔬 <bold><blue>Running TryRuntime_on_runtime_upgrade again to check idempotency: {:?}\n\n", command.checks)),
184+
);
185+
log::info!(
186+
"{}",
187+
colorize_string("<bold><blue>-------------------------------------------------------------------")
155188
);
156189
let (oc_pre_root, _) = overlayed_changes.storage_root(&ext.backend, ext.state_version);
157190
match state_machine_call_with_proof::<Block, HostFns>(
@@ -213,7 +246,20 @@ where
213246
};
214247

215248
if !weight_ok || !idempotency_ok {
216-
log::error!("❌ Issues detected, exiting non-zero. See logs.");
249+
log::error!(
250+
"{}",
251+
colorize_string("<bold><red>-------------------------------------------------------------------\n\n")
252+
);
253+
log::error!(
254+
"{}",
255+
colorize_string("❌ <bold><red>Issues detected, exiting non-zero. See logs.\n\n"),
256+
);
257+
log::error!(
258+
"{}",
259+
colorize_string(
260+
"<bold><red>-------------------------------------------------------------------"
261+
)
262+
);
217263
std::process::exit(1);
218264
}
219265

0 commit comments

Comments
 (0)