mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-13 08:28:51 +08:00
Add a warning counter
This commit is contained in:
@@ -6,6 +6,7 @@ pub struct Counter {
|
||||
ok: AtomicUsize,
|
||||
ignored: AtomicUsize,
|
||||
error: AtomicUsize,
|
||||
warning: AtomicUsize,
|
||||
}
|
||||
|
||||
impl Counter {
|
||||
@@ -14,6 +15,7 @@ impl Counter {
|
||||
ok: AtomicUsize::new(0),
|
||||
ignored: AtomicUsize::new(0),
|
||||
error: AtomicUsize::new(0),
|
||||
warning: AtomicUsize::new(0),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +23,10 @@ impl Counter {
|
||||
self.error.fetch_add(1, SeqCst);
|
||||
}
|
||||
|
||||
pub fn inc_warning(&self) {
|
||||
self.warning.fetch_add(1, SeqCst);
|
||||
}
|
||||
|
||||
pub fn inc(&self, result: ScriptResult) {
|
||||
match result {
|
||||
ScriptResult::Ok => self.ok.fetch_add(1, SeqCst),
|
||||
@@ -33,10 +39,11 @@ impl std::fmt::Display for Counter {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"OK: {}, Ignored: {}, Error: {}",
|
||||
"OK: {}, Ignored: {}, Error: {}, Warning: {}",
|
||||
self.ok.load(SeqCst),
|
||||
self.ignored.load(SeqCst),
|
||||
self.error.load(SeqCst)
|
||||
self.error.load(SeqCst),
|
||||
self.warning.load(SeqCst),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user