From f9737b8a6cf88ddbd20831f06fde34d7624e313d Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Thu, 10 Oct 2024 19:41:31 +0200 Subject: [PATCH] fix(logger): handle empty log messages (partial fix for gh #241) --- src/logger.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/logger.cpp b/src/logger.cpp index 99ad5885..4aa60d82 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -222,8 +222,12 @@ void stream_logger::write(level_type level, const std::string& output, split_to(output, '\n', lines); } - if (lines.back().empty()) { - lines.pop_back(); + if (!lines.empty()) { + if (lines.back().empty()) { + lines.pop_back(); + } + } else { + lines.push_back("<<< no log message >>>"); } std::ostringstream oss;