You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2026/05/20 04:16:22 UTC

(logging-log4cxx) 01/01: Restore console output compactness

This is an automated email from the ASF dual-hosted git repository.

swebb2066 pushed a commit to branch squash_console_output
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git

commit ce25f4a54f4f97460e16ac3e1843b1c3a18ff941
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Wed May 20 14:15:56 2026 +1000

    Restore console output compactness
---
 src/main/cpp/consolewriter.cpp                 |  1 -
 src/test/cpp/helpers/consolewritertestcase.cpp | 10 +++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/main/cpp/consolewriter.cpp b/src/main/cpp/consolewriter.cpp
index 52118d90..0acfdae9 100644
--- a/src/main/cpp/consolewriter.cpp
+++ b/src/main/cpp/consolewriter.cpp
@@ -53,6 +53,5 @@ size_t helpers::writeToConsole(const LogString& str, FILE *file)
 	// as the message may contain embedded null bytes, which would cause the
 	// message to be prematurely truncated.
 	//
-	msg.append("\n");
 	return fwrite(msg.data(), 1, msg.size(), file);
 }
diff --git a/src/test/cpp/helpers/consolewritertestcase.cpp b/src/test/cpp/helpers/consolewritertestcase.cpp
index e44e23ff..bb366998 100644
--- a/src/test/cpp/helpers/consolewritertestcase.cpp
+++ b/src/test/cpp/helpers/consolewritertestcase.cpp
@@ -46,15 +46,13 @@ public:
 		std::string path = tmpdir;
 		path += "/log4cxx.test.log";
 
-		remove(path.c_str());
-
-		std::string message{"Hello\0World!", 12};
+		std::string message{"Hello\0World!\n", 13};
 
 		{
 			FILE *fp = fopen(path.c_str(), "wb");
 			LOG4CXX_DECODE_CHAR(lsMessage, message);
 			size_t written = helpers::writeToConsole(lsMessage, fp);
-			LOGUNIT_ASSERT_EQUAL(message.size() + 1, written);
+			LOGUNIT_ASSERT_EQUAL(message.size(), written);
 			fclose(fp);
 		}
 
@@ -68,7 +66,9 @@ public:
 			fclose(fp);
 		}
 
-		LOGUNIT_ASSERT_EQUAL(content, message + "\n");
+		remove(path.c_str());
+
+		LOGUNIT_ASSERT(content == message);
 	}
 
 };