From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH backup stable-2 3/3] pbs2to3: set failure messages to bold
Date: Wed, 28 Jun 2023 17:40:54 +0200 [thread overview]
Message-ID: <20230628154054.1272-4-c.ebner@proxmox.com> (raw)
In-Reply-To: <20230628154054.1272-1-c.ebner@proxmox.com>
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
src/bin/pbs2to3.rs | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/src/bin/pbs2to3.rs b/src/bin/pbs2to3.rs
index d85551ec..54504a39 100644
--- a/src/bin/pbs2to3.rs
+++ b/src/bin/pbs2to3.rs
@@ -485,9 +485,9 @@ impl ConsoleOutput {
Ok(())
}
- pub fn set_color(&mut self, color: Color) -> Result<(), Error> {
+ pub fn set_color(&mut self, color: Color, bold: bool) -> Result<(), Error> {
self.stream
- .set_color(ColorSpec::new().set_fg(Some(color)))?;
+ .set_color(ColorSpec::new().set_fg(Some(color)).set_bold(bold))?;
Ok(())
}
@@ -495,9 +495,9 @@ impl ConsoleOutput {
match level {
LogLevel::Pass => {
self.counters.pass += 1;
- self.set_color(Color::Green)?;
+ self.set_color(Color::Green, false)?;
writeln!(&mut self.stream, "PASS: {}", message)?;
- self.set_color(Color::White)?;
+ self.set_color(Color::White, false)?;
}
LogLevel::Info => {
writeln!(&mut self.stream, "INFO: {}", message)?;
@@ -508,19 +508,21 @@ impl ConsoleOutput {
}
LogLevel::Notice => {
self.counters.notice += 1;
+ self.set_color(Color::White, true)?;
writeln!(&mut self.stream, "NOTICE: {}", message)?;
+ self.set_color(Color::White, false)?;
}
LogLevel::Warn => {
self.counters.warn += 1;
- self.set_color(Color::Yellow)?;
+ self.set_color(Color::Yellow, true)?;
writeln!(&mut self.stream, "WARN: {}", message)?;
- self.set_color(Color::White)?;
+ self.set_color(Color::White, false)?;
}
LogLevel::Fail => {
self.counters.fail += 1;
- self.set_color(Color::Red)?;
+ self.set_color(Color::Red, true)?;
writeln!(&mut self.stream, "FAIL: {}", message)?;
- self.set_color(Color::White)?;
+ self.set_color(Color::White, false)?;
}
}
Ok(())
@@ -559,28 +561,29 @@ impl ConsoleOutput {
+ self.counters.skip
+ self.counters.warn;
- self.set_color(Color::White)?;
+ self.set_color(Color::White, false)?;
writeln!(&mut self.stream, "TOTAL: {total}")?;
- self.set_color(Color::Green)?;
+ self.set_color(Color::Green, false)?;
writeln!(&mut self.stream, "PASSED: {}", self.counters.pass)?;
- self.set_color(Color::White)?;
+ self.set_color(Color::White, false)?;
writeln!(&mut self.stream, "SKIPPED: {}", self.counters.skip)?;
writeln!(&mut self.stream, "NOTICE: {}", self.counters.notice)?;
if self.counters.warn > 0 {
- self.set_color(Color::Yellow)?;
+ self.set_color(Color::Yellow, false)?;
writeln!(&mut self.stream, "WARNINGS: {}", self.counters.warn)?;
}
if self.counters.fail > 0 {
- self.set_color(Color::Red)?;
+ self.set_color(Color::Red, true)?;
writeln!(&mut self.stream, "FAILURES: {}", self.counters.fail)?;
}
if self.counters.warn > 0 || self.counters.fail > 0 {
- let mut color = Color::Yellow;
- if self.counters.fail > 0 {
- color = Color::Red;
- }
+ let (color, bold) = if self.counters.fail > 0 {
+ (Color::Red, true)
+ } else {
+ (Color::Yellow, false)
+ };
- self.set_color(color)?;
+ self.set_color(color, bold)?;
writeln!(
&mut self.stream,
"\nATTENTION: Please check the output for detailed information!",
@@ -592,7 +595,7 @@ impl ConsoleOutput {
)?;
}
}
- self.set_color(Color::White)?;
+ self.set_color(Color::White, false)?;
Ok(())
}
}
--
2.30.2
next prev parent reply other threads:[~2023-06-28 15:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-28 15:40 [pbs-devel] [PATCH backup stable-2 0/3] followup fixes for pbs2to3 Christian Ebner
2023-06-28 15:40 ` [pbs-devel] [PATCH backup stable-2 1/3] pbs2to3: fix typo s/neighter/neither/ Christian Ebner
2023-06-29 6:59 ` Lukas Wagner
2023-06-29 7:10 ` Christian Ebner
2023-06-28 15:40 ` [pbs-devel] [PATCH backup stable-2 2/3] pbs2to3: fix whitespaces Christian Ebner
2023-06-28 15:40 ` Christian Ebner [this message]
2023-06-28 16:01 ` [pbs-devel] [PATCH backup stable-2 0/3] followup fixes for pbs2to3 Christian Ebner
2023-06-29 5:54 ` [pbs-devel] applied-series: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230628154054.1272-4-c.ebner@proxmox.com \
--to=c.ebner@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox