From 2ba240e21479bf97e7fae11fe77a640f4a31bf6d Mon Sep 17 00:00:00 2001 From: Sergey Kuznetsov Date: Mon, 12 Jan 2026 16:19:26 +0000 Subject: [PATCH 1/2] fix: No output from failed assert in tests --- src/util/Assert.cpp | 2 +- src/util/log/Logger.cpp | 6 ++++++ src/util/log/Logger.hpp | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/util/Assert.cpp b/src/util/Assert.cpp index 87165d607b..0e923504fc 100644 --- a/src/util/Assert.cpp +++ b/src/util/Assert.cpp @@ -54,7 +54,7 @@ OnAssert::resetAction() void OnAssert::defaultAction(std::string_view message) { - if (LogServiceState::initialized()) { + if (LogServiceState::initialized() and LogServiceState::hasSinks()) { LOG(LogService::fatal()) << message; } else { std::cerr << message; diff --git a/src/util/log/Logger.cpp b/src/util/log/Logger.cpp index 5a3c2f771c..28b6cab143 100644 --- a/src/util/log/Logger.cpp +++ b/src/util/log/Logger.cpp @@ -271,6 +271,12 @@ LogServiceState::initialized() return initialized_; } +bool +LogServiceState::hasSinks() +{ + return not sinks_.empty(); +} + void LogServiceState::reset() { diff --git a/src/util/log/Logger.hpp b/src/util/log/Logger.hpp index 370625890a..9e7b61eb49 100644 --- a/src/util/log/Logger.hpp +++ b/src/util/log/Logger.hpp @@ -267,6 +267,14 @@ class LogServiceState { [[nodiscard]] static bool initialized(); + /** + * @brief Whether the LogService has any sink. If there is no sink, logger will not log messages anywhere. + * + * @return true if the LogService has at least one sink + */ + [[nodiscard]] static bool + hasSinks(); + /** * @brief Reset the logging service to uninitialized state. */ From 52485926eac2d6d4d122b324826d77a291392517 Mon Sep 17 00:00:00 2001 From: Sergey Kuznetsov Date: Mon, 12 Jan 2026 16:42:12 +0000 Subject: [PATCH 2/2] Fix review issue Co-authored-by: Ayaz Salikhov --- src/util/Assert.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/Assert.cpp b/src/util/Assert.cpp index 0e923504fc..94f415951d 100644 --- a/src/util/Assert.cpp +++ b/src/util/Assert.cpp @@ -57,7 +57,7 @@ OnAssert::defaultAction(std::string_view message) if (LogServiceState::initialized() and LogServiceState::hasSinks()) { LOG(LogService::fatal()) << message; } else { - std::cerr << message; + std::cerr << message << std::endl; } std::exit(EXIT_FAILURE); // std::abort does not flush gcovr output and causes uncovered lines }