From f16996752fa595a59b7ff461b7b2af9c856bd81e Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 25 Nov 2024 14:18:09 +0100 Subject: [PATCH] feat: enhance logging functionality and update root cause handling in Summary Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- crates/core/src/error/summary.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/core/src/error/summary.rs b/crates/core/src/error/summary.rs index cf362004..c2b99640 100644 --- a/crates/core/src/error/summary.rs +++ b/crates/core/src/error/summary.rs @@ -149,15 +149,20 @@ impl Summary { self.end_time = Some(Instant::now()); } - pub fn enable_log(&mut self) { + pub fn enable_log(&mut self) -> Self { self.log_enabled = true; + self.clone() + } + + pub fn is_error(&self) -> bool { + self.issues.contains_key(&IssueCategory::Error) } pub fn add_error( &mut self, scope: IssueScope, message: impl Into, - root_cause: Option>, + root_cause: impl Into>, ) { self.add_issue(IssueCategory::Error, scope, message, root_cause); } @@ -166,7 +171,7 @@ impl Summary { &mut self, scope: IssueScope, message: impl Into, - root_cause: Option>, + root_cause: impl Into>, ) { self.add_issue(IssueCategory::Warning, scope, message, root_cause); } @@ -175,7 +180,7 @@ impl Summary { &mut self, scope: IssueScope, message: impl Into, - root_cause: Option>, + root_cause: impl Into>, ) { self.add_issue(IssueCategory::Info, scope, message, root_cause); } @@ -186,9 +191,9 @@ impl Summary { category: IssueCategory, scope: IssueScope, message: impl Into, - root_cause: Option>, + root_cause: impl Into>, ) { - let root_cause = root_cause.map(Into::into); + let root_cause = root_cause.into(); let message = message.into(); if self.log_enabled {