From 07c7eeb624468ff1a046444c673076f49863d1aa Mon Sep 17 00:00:00 2001 From: James Cherry Date: Fri, 20 Mar 2026 09:05:07 -0700 Subject: [PATCH 1/3] Report::warn etc virtuals Signed-off-by: James Cherry --- include/sta/Report.hh | 66 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/include/sta/Report.hh b/include/sta/Report.hh index 7e9aab55..28f685a9 100644 --- a/include/sta/Report.hh +++ b/include/sta/Report.hh @@ -61,7 +61,11 @@ public: void report(std::string_view fmt, Args &&...args) { - reportLine(sta::vformat(fmt, sta::make_format_args(args...))); + report(sta::vformat(fmt, sta::make_format_args(args...))); + } + virtual void report(const std::string &formatted_msg) + { + reportLine(formatted_msg); } //////////////////////////////////////////////////////////////// @@ -73,10 +77,14 @@ public: Args &&...args) { if (!isSuppressed(id)) { - reportLine(sta::format( - "Warning {}: {}", id, sta::vformat(fmt, sta::make_format_args(args...)))); + warn(id, sta::vformat(fmt, sta::make_format_args(args...))); } } + virtual void warn(int id, + const std::string &formatted_msg) { + reportLine(sta::format("Warning {}: {}", id, formatted_msg)); + } + // Report warning in a file. template void fileWarn(int id, @@ -86,19 +94,30 @@ public: Args &&...args) { if (!isSuppressed(id)) { - reportLine( - sta::format("Warning {}: {} line {}, {}", id, filename, line, - sta::vformat(fmt, sta::make_format_args(args...)))); + fileWarn(id, filename, line, + sta::vformat(fmt, sta::make_format_args(args...))); } } + virtual void + fileWarn(int id, + std::string_view filename, + int line, + const std::string &formatted_msg) { + reportLine(sta::format("Warning {}: {} line {}, {}", + id, filename, line, formatted_msg)); + } template void error(int id, std::string_view fmt, Args &&...args) { - std::string msg = sta::vformat(fmt, sta::make_format_args(args...)); - reportThrowExceptionMsg(sta::format("{} {}", id, msg), isSuppressed(id)); + error(id, sta::vformat(fmt, sta::make_format_args(args...))); + } + virtual void error(int id, + const std::string &formatted_msg) + { + reportThrowExceptionMsg(sta::format("{} {}", id, formatted_msg), isSuppressed(id)); } // Report error in a file. template @@ -108,8 +127,16 @@ public: std::string_view fmt, Args &&...args) { - const std::string msg = sta::vformat(fmt, sta::make_format_args(args...)); - reportThrowExceptionMsg(sta::format("{} {} line {}, {}", id, filename, line, msg), + fileError(id, filename, line, + sta::vformat(fmt, sta::make_format_args(args...))); + } + virtual void fileError(int id, + std::string_view filename, + int line, + const std::string &formatted_msg) + { + reportThrowExceptionMsg(sta::format("{} {} line {}, {}", + id, filename, line, formatted_msg), isSuppressed(id)); } @@ -121,19 +148,32 @@ public: std::string_view fmt, Args &&...args) { - reportLine(sta::format("Critical {}: {}", id, - sta::vformat(fmt, sta::make_format_args(args...)))); + critical(id, sta::vformat(fmt, sta::make_format_args(args...))); + } + virtual void critical(int id, + const std::string &formatted_msg) + { + reportLine(sta::format("Critical {}: {}", id, formatted_msg)); exit(1); } + template void fileCritical(int id, std::string_view filename, int line, std::string_view fmt, Args &&...args) + { + fileCritical(id, filename, line, + sta::vformat(fmt, sta::make_format_args(args...))); + } + virtual void fileCritical(int id, + std::string_view filename, + int line, + const std::string &formatted_msg) { reportLine(sta::format("Critical {}: {} line {}, {}", id, filename, line, - sta::vformat(fmt, sta::make_format_args(args...)))); + formatted_msg)); exit(1); } From 2ed1c2c06bb5edf177c34ffde3bad9d10a95719a Mon Sep 17 00:00:00 2001 From: James Cherry Date: Fri, 20 Mar 2026 09:11:39 -0700 Subject: [PATCH 2/3] report json Signed-off-by: James Cherry --- search/ReportPath.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/search/ReportPath.cc b/search/ReportPath.cc index 158b7919..21a4c485 100644 --- a/search/ReportPath.cc +++ b/search/ReportPath.cc @@ -1057,14 +1057,14 @@ ReportPath::pathEndpoint(const PathEnd *end) const void ReportPath::reportJsonHeader() const { - report_->report("{{\"checks\": ["); + report_->report("{\"checks\": ["); } void ReportPath::reportJsonFooter() const { report_->report("]"); - report_->report("}}"); + report_->report("}"); } void From d90bf7d93bf84b6619ae02e91f737929a4679dd6 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Fri, 20 Mar 2026 10:14:57 -0700 Subject: [PATCH 3/3] rename Report virtuals to warnMsg etc This reverts commit 2ed1c2c06bb5edf177c34ffde3bad9d10a95719a. Signed-off-by: James Cherry --- include/sta/Report.hh | 61 +++++++++++++++++++++---------------------- search/ReportPath.cc | 4 +-- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/include/sta/Report.hh b/include/sta/Report.hh index 28f685a9..51cde2ed 100644 --- a/include/sta/Report.hh +++ b/include/sta/Report.hh @@ -61,9 +61,9 @@ public: void report(std::string_view fmt, Args &&...args) { - report(sta::vformat(fmt, sta::make_format_args(args...))); + reportMsg(sta::vformat(fmt, sta::make_format_args(args...))); } - virtual void report(const std::string &formatted_msg) + virtual void reportMsg(const std::string &formatted_msg) { reportLine(formatted_msg); } @@ -76,12 +76,11 @@ public: std::string_view fmt, Args &&...args) { - if (!isSuppressed(id)) { - warn(id, sta::vformat(fmt, sta::make_format_args(args...))); - } + if (!isSuppressed(id)) + warnMsg(id, sta::vformat(fmt, sta::make_format_args(args...))); } - virtual void warn(int id, - const std::string &formatted_msg) { + virtual void warnMsg(int id, + const std::string &formatted_msg) { reportLine(sta::format("Warning {}: {}", id, formatted_msg)); } @@ -94,15 +93,15 @@ public: Args &&...args) { if (!isSuppressed(id)) { - fileWarn(id, filename, line, - sta::vformat(fmt, sta::make_format_args(args...))); + fileWarnMsg(id, filename, line, + sta::vformat(fmt, sta::make_format_args(args...))); } } virtual void - fileWarn(int id, - std::string_view filename, - int line, - const std::string &formatted_msg) { + fileWarnMsg(int id, + std::string_view filename, + int line, + const std::string &formatted_msg) { reportLine(sta::format("Warning {}: {} line {}, {}", id, filename, line, formatted_msg)); } @@ -112,10 +111,10 @@ public: std::string_view fmt, Args &&...args) { - error(id, sta::vformat(fmt, sta::make_format_args(args...))); + errorMsg(id, sta::vformat(fmt, sta::make_format_args(args...))); } - virtual void error(int id, - const std::string &formatted_msg) + virtual void errorMsg(int id, + const std::string &formatted_msg) { reportThrowExceptionMsg(sta::format("{} {}", id, formatted_msg), isSuppressed(id)); } @@ -127,13 +126,13 @@ public: std::string_view fmt, Args &&...args) { - fileError(id, filename, line, - sta::vformat(fmt, sta::make_format_args(args...))); + fileErrorMsg(id, filename, line, + sta::vformat(fmt, sta::make_format_args(args...))); } - virtual void fileError(int id, - std::string_view filename, - int line, - const std::string &formatted_msg) + virtual void fileErrorMsg(int id, + std::string_view filename, + int line, + const std::string &formatted_msg) { reportThrowExceptionMsg(sta::format("{} {} line {}, {}", id, filename, line, formatted_msg), @@ -148,10 +147,10 @@ public: std::string_view fmt, Args &&...args) { - critical(id, sta::vformat(fmt, sta::make_format_args(args...))); + criticalMsg(id, sta::vformat(fmt, sta::make_format_args(args...))); } - virtual void critical(int id, - const std::string &formatted_msg) + virtual void criticalMsg(int id, + const std::string &formatted_msg) { reportLine(sta::format("Critical {}: {}", id, formatted_msg)); exit(1); @@ -164,13 +163,13 @@ public: std::string_view fmt, Args &&...args) { - fileCritical(id, filename, line, - sta::vformat(fmt, sta::make_format_args(args...))); + fileCriticalMsg(id, filename, line, + sta::vformat(fmt, sta::make_format_args(args...))); } - virtual void fileCritical(int id, - std::string_view filename, - int line, - const std::string &formatted_msg) + virtual void fileCriticalMsg(int id, + std::string_view filename, + int line, + const std::string &formatted_msg) { reportLine(sta::format("Critical {}: {} line {}, {}", id, filename, line, formatted_msg)); diff --git a/search/ReportPath.cc b/search/ReportPath.cc index 21a4c485..158b7919 100644 --- a/search/ReportPath.cc +++ b/search/ReportPath.cc @@ -1057,14 +1057,14 @@ ReportPath::pathEndpoint(const PathEnd *end) const void ReportPath::reportJsonHeader() const { - report_->report("{\"checks\": ["); + report_->report("{{\"checks\": ["); } void ReportPath::reportJsonFooter() const { report_->report("]"); - report_->report("}"); + report_->report("}}"); } void