You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ts...@apache.org on 2019/10/23 07:37:24 UTC

[logging-log4cxx] 01/02: Things didn't compile when std::wstring was used, many basic strings needed to be enhanced with LOG4CXX_STR. Additionally replaced "\n" with LOG4CXX_EOL, because that was used in one place already and broke tests on Windows this way. HTMLLayout used that only and with now using that here only as well, the tests succeed on Windows and according the original author still succeed on its non-Windows.

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

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

commit f66b3c421fcc3f81e22e9a262a878e6bcdf53f8b
Author: Thorsten Schöning <ts...@am-soft.de>
AuthorDate: Tue Oct 22 20:26:14 2019 +0200

    Things didn't compile when std::wstring was used, many basic strings needed to be enhanced with LOG4CXX_STR. Additionally
    replaced "\n" with LOG4CXX_EOL, because that was used in one place already and broke tests on Windows this way. HTMLLayout used that only and with now using that here only as well, the tests succeed on Windows and according the original author still succeed on its non-Windows.
---
 src/main/cpp/jsonlayout.cpp     | 135 ++++++++++++------------
 src/test/cpp/jsonlayouttest.cpp | 223 ++++++++++++++++++++--------------------
 2 files changed, 176 insertions(+), 182 deletions(-)

diff --git a/src/main/cpp/jsonlayout.cpp b/src/main/cpp/jsonlayout.cpp
index 66ff09f..a2e72c3 100644
--- a/src/main/cpp/jsonlayout.cpp
+++ b/src/main/cpp/jsonlayout.cpp
@@ -22,6 +22,7 @@
 #include <log4cxx/helpers/optionconverter.h>
 #include <log4cxx/helpers/iso8601dateformat.h>
 #include <log4cxx/helpers/stringhelper.h>
+#include <log4cxx/helpers/transcoder.h>
 
 #include <apr_time.h>
 #include <apr_strings.h>
@@ -38,8 +39,8 @@ JSONLayout::JSONLayout() :
 	locationInfo(false),
 	prettyPrint(false),
 	dateFormat(),
-	ppIndentL1("  "),
-	ppIndentL2("    ")
+	ppIndentL1(LOG4CXX_STR("  ")),
+	ppIndentL2(LOG4CXX_STR("    "))
 {
 }
 
@@ -62,72 +63,68 @@ void JSONLayout::format(LogString& output,
 	const spi::LoggingEventPtr& event,
 	Pool& p) const
 {
-
-	output.append("{");
-	output.append(prettyPrint ? "\n" : " ");
+	output.append(LOG4CXX_STR("{"));
+	output.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
 		output.append(ppIndentL1);
 	}
 
-	appendQuotedEscapedString(output, "timestamp");
-	output.append(": ");
+	appendQuotedEscapedString(output, LOG4CXX_STR("timestamp"));
+	output.append(LOG4CXX_STR(": "));
 	LogString timestamp;
 	dateFormat.format(timestamp, event->getTimeStamp(), p);
 	appendQuotedEscapedString(output, timestamp);
-	output.append(",");
-	output.append(prettyPrint ? "\n" : " ");
+	output.append(LOG4CXX_STR(","));
+	output.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
 		output.append(ppIndentL1);
 	}
 
-	appendQuotedEscapedString(output, "level");
-	output.append(": ");
+	appendQuotedEscapedString(output, LOG4CXX_STR("level"));
+	output.append(LOG4CXX_STR(": "));
 	LogString level;
 	event->getLevel()->toString(level);
 	appendQuotedEscapedString(output, level);
-	output.append(",");
-	output.append(prettyPrint ? "\n" : " ");
+	output.append(LOG4CXX_STR(","));
+	output.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
 		output.append(ppIndentL1);
 	}
 
-	appendQuotedEscapedString(output, "logger");
-	output.append(": ");
+	appendQuotedEscapedString(output, LOG4CXX_STR("logger"));
+	output.append(LOG4CXX_STR(": "));
 	appendQuotedEscapedString(output, event->getLoggerName());
-	output.append(",");
-	output.append(prettyPrint ? "\n" : " ");
+	output.append(LOG4CXX_STR(","));
+	output.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
 		output.append(ppIndentL1);
 	}
 
-	appendQuotedEscapedString(output, "message");
-	output.append(": ");
+	appendQuotedEscapedString(output, LOG4CXX_STR("message"));
+	output.append(LOG4CXX_STR(": "));
 	appendQuotedEscapedString(output, event->getMessage());
 
 	appendSerializedMDC(output, event);
-
 	appendSerializedNDC(output, event);
 
-
 	if (locationInfo)
 	{
-		output.append(",");
-		output.append(prettyPrint ? "\n" : " ");
+		output.append(LOG4CXX_STR(","));
+		output.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 		appendSerializedLocationInfo(output, event, p);
 	}
 
-	output.append(prettyPrint ? "\n" : " ");
-	output.append("}");
+	output.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
+	output.append(LOG4CXX_STR("}"));
 	output.append(LOG4CXX_EOL);
-
 }
 
 void JSONLayout::appendQuotedEscapedString(LogString& buf,
@@ -147,7 +144,6 @@ void JSONLayout::appendQuotedEscapedString(LogString& buf,
 		0x5c    /* \\ backslash         */
 	};
 
-
 	size_t start = 0;
 	size_t found = input.find_first_of(specialChars, start);
 
@@ -226,13 +222,11 @@ void JSONLayout::appendQuotedEscapedString(LogString& buf,
 
 	/* add trailing quote */
 	buf.push_back(0x22);
-
 }
 
 void JSONLayout::appendSerializedMDC(LogString& buf,
 	const LoggingEventPtr& event) const
 {
-
 	LoggingEvent::KeySet keys = event->getMDCKeySet();
 
 	if (keys.empty())
@@ -240,17 +234,17 @@ void JSONLayout::appendSerializedMDC(LogString& buf,
 		return;
 	}
 
-	buf.append(",");
-	buf.append(prettyPrint ? "\n" : " ");
+	buf.append(LOG4CXX_STR(","));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
 		buf.append(ppIndentL1);
 	}
 
-	appendQuotedEscapedString(buf, "context_map");
-	buf.append(": {");
-	buf.append(prettyPrint ? "\n" : " ");
+	appendQuotedEscapedString(buf, LOG4CXX_STR("context_map"));
+	buf.append(LOG4CXX_STR(": {"));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	for (LoggingEvent::KeySet::iterator it = keys.begin();
 		it != keys.end(); ++it)
@@ -261,7 +255,7 @@ void JSONLayout::appendSerializedMDC(LogString& buf,
 		}
 
 		appendQuotedEscapedString(buf, *it);
-		buf.append(": ");
+		buf.append(LOG4CXX_STR(": "));
 		LogString value;
 		event->getMDC(*it, value);
 		appendQuotedEscapedString(buf, value);
@@ -269,12 +263,12 @@ void JSONLayout::appendSerializedMDC(LogString& buf,
 		/* if this isn't the last k:v pair, we need a comma */
 		if (it + 1 != keys.end())
 		{
-			buf.append(",");
-			buf.append(prettyPrint ? "\n" : " ");
+			buf.append(LOG4CXX_STR(","));
+			buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 		}
 		else
 		{
-			buf.append(prettyPrint ? "\n" : " ");
+			buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 		}
 	}
 
@@ -283,14 +277,12 @@ void JSONLayout::appendSerializedMDC(LogString& buf,
 		buf.append(ppIndentL1);
 	}
 
-	buf.append("}");
-
+	buf.append(LOG4CXX_STR("}"));
 }
 
 void JSONLayout::appendSerializedNDC(LogString& buf,
 	const LoggingEventPtr& event) const
 {
-
 	LogString ndcVal;
 
 	if (!event->getNDC(ndcVal))
@@ -298,17 +290,17 @@ void JSONLayout::appendSerializedNDC(LogString& buf,
 		return;
 	}
 
-	buf.append(",");
-	buf.append(prettyPrint ? "\n" : " ");
+	buf.append(LOG4CXX_STR(","));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
 		buf.append(ppIndentL1);
 	}
 
-	appendQuotedEscapedString(buf, "context_stack");
-	buf.append(": [");
-	buf.append(prettyPrint ? "\n" : " ");
+	appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack"));
+	buf.append(LOG4CXX_STR(": ["));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
@@ -316,29 +308,27 @@ void JSONLayout::appendSerializedNDC(LogString& buf,
 	}
 
 	appendQuotedEscapedString(buf, ndcVal);
-	buf.append(prettyPrint ? "\n" : " ");
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
 		buf.append(ppIndentL1);
 	}
 
-	buf.append("]");
-
+	buf.append(LOG4CXX_STR("]"));
 }
 
 void JSONLayout::appendSerializedLocationInfo(LogString& buf,
 	const LoggingEventPtr& event, Pool& p) const
 {
-
 	if (prettyPrint)
 	{
 		buf.append(ppIndentL1);
 	}
 
-	appendQuotedEscapedString(buf, "location_info");
-	buf.append(": {");
-	buf.append(prettyPrint ? "\n" : " ");
+	appendQuotedEscapedString(buf, LOG4CXX_STR("location_info"));
+	buf.append(LOG4CXX_STR(": {"));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 	const LocationInfo& locInfo = event->getLocationInformation();
 
 	if (prettyPrint)
@@ -346,53 +336,54 @@ void JSONLayout::appendSerializedLocationInfo(LogString& buf,
 		buf.append(ppIndentL2);
 	}
 
-	appendQuotedEscapedString(buf, "file");
-	buf.append(": ");
+	appendQuotedEscapedString(buf, LOG4CXX_STR("file"));
+	buf.append(LOG4CXX_STR(": "));
 	LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName());
 	appendQuotedEscapedString(buf, fileName);
-	buf.append(",");
-	buf.append(prettyPrint ? "\n" : " ");
+	buf.append(LOG4CXX_STR(","));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
 		buf.append(ppIndentL2);
 	}
 
-	appendQuotedEscapedString(buf, "line");
-	buf.append(": ");
+	appendQuotedEscapedString(buf, LOG4CXX_STR("line"));
+	buf.append(LOG4CXX_STR(": "));
 	LogString lineNumber;
 	StringHelper::toString(locInfo.getLineNumber(), p, lineNumber);
 	appendQuotedEscapedString(buf, lineNumber);
-	buf.append(",");
-	buf.append(prettyPrint ? "\n" : " ");
+	buf.append(LOG4CXX_STR(","));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
 		buf.append(ppIndentL2);
 	}
 
-	appendQuotedEscapedString(buf, "class");
-	buf.append(": ");
-	appendQuotedEscapedString(buf, locInfo.getClassName());
-	buf.append(",");
-	buf.append(prettyPrint ? "\n" : " ");
+	appendQuotedEscapedString(buf, LOG4CXX_STR("class"));
+	buf.append(LOG4CXX_STR(": "));
+	LOG4CXX_DECODE_CHAR(className, locInfo.getClassName());
+	appendQuotedEscapedString(buf, className);
+	buf.append(LOG4CXX_STR(","));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
 		buf.append(ppIndentL2);
 	}
 
-	appendQuotedEscapedString(buf, "method");
-	buf.append(": ");
-	appendQuotedEscapedString(buf, locInfo.getMethodName());
-	buf.append(prettyPrint ? "\n" : " ");
+	appendQuotedEscapedString(buf, LOG4CXX_STR("method"));
+	buf.append(LOG4CXX_STR(": "));
+	LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName());
+	appendQuotedEscapedString(buf, methodName);
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
 		buf.append(ppIndentL1);
 	}
 
-	buf.append("}");
-
+	buf.append(LOG4CXX_STR("}"));
 }
 
diff --git a/src/test/cpp/jsonlayouttest.cpp b/src/test/cpp/jsonlayouttest.cpp
index 88862da..de1d074 100644
--- a/src/test/cpp/jsonlayouttest.cpp
+++ b/src/test/cpp/jsonlayouttest.cpp
@@ -101,24 +101,23 @@ public:
 	 */
 	void testAppendQuotedEscapedStringWithPrintableChars()
 	{
-
-		LogString s1("foo");                  /*  foo */
+		LogString s1(LOG4CXX_STR("foo"));	/*  foo */
 		LogString s2;
-		appendQuotedEscapedString(s2, s1);    /*  "foo"  */
-		LOGUNIT_ASSERT_EQUAL("\"foo\"", s2);
+		appendQuotedEscapedString(s2, s1);	/*  "foo"  */
+		LOGUNIT_ASSERT_EQUAL(LOG4CXX_STR("\"foo\""), s2);
 
 		LogString s3;
-		appendQuotedEscapedString(s3, s2);    /*  "\"foo\""  */
-		LOGUNIT_ASSERT_EQUAL("\"\\\"foo\\\"\"", s3);
+		appendQuotedEscapedString(s3, s2);	/*  "\"foo\""  */
+		LOGUNIT_ASSERT_EQUAL(LOG4CXX_STR("\"\\\"foo\\\"\""), s3);
 
-		LogString t1("bar\"baz");             /*  bar"baz */
+		LogString t1(LOG4CXX_STR("bar\"baz"));	/*  bar"baz */
 		LogString t2;
-		appendQuotedEscapedString(t2, t1);    /*  "bar\"baz"  */
-		LOGUNIT_ASSERT_EQUAL("\"bar\\\"baz\"", t2);
+		appendQuotedEscapedString(t2, t1);		/*  "bar\"baz"  */
+		LOGUNIT_ASSERT_EQUAL(LOG4CXX_STR("\"bar\\\"baz\""), t2);
 
 		LogString t3;
-		appendQuotedEscapedString(t3, t2);    /*  "\"bar\\\"baz\""    */
-		LOGUNIT_ASSERT_EQUAL("\"\\\"bar\\\\\\\"baz\\\"\"", t3);
+		appendQuotedEscapedString(t3, t2);		/*  "\"bar\\\"baz\""    */
+		LOGUNIT_ASSERT_EQUAL(LOG4CXX_STR("\"\\\"bar\\\\\\\"baz\\\"\""), t3);
 	}
 
 	/**
@@ -126,37 +125,40 @@ public:
 	 */
 	void testAppendQuotedEscapedStringWithControlChars()
 	{
-
-		LogString bs = {0x08};
-		LogString bs_expected = {0x22, 0x5c, 'b', 0x22};      /* "\b" */
+		logchar bs[] = {0x08, 0x00};
+		logchar bs_expected[] = {0x22, 0x5c, 'b', 0x22, 0x00};      /* "\b" */
 		LogString bs_escaped;
+
 		appendQuotedEscapedString(bs_escaped, bs);
 		LOGUNIT_ASSERT_EQUAL(bs_expected, bs_escaped);
 
-		LogString tab = {0x09};
-		LogString tab_expected = {0x22, 0x5c, 't', 0x22};     /* "\t" */
+		logchar tab[] = {0x09, 0x00};
+		logchar tab_expected[] = {0x22, 0x5c, 't', 0x22, 0x00};     /* "\t" */
 		LogString tab_escaped;
+
 		appendQuotedEscapedString(tab_escaped, tab);
 		LOGUNIT_ASSERT_EQUAL(tab_expected, tab_escaped);
 
-		LogString newline = {0x0a};
-		LogString newline_expected = {0x22, 0x5c, 'n', 0x22}; /* "\n" */
+		logchar newline[] = {0x0a, 0x00};
+		logchar newline_expected[] = {0x22, 0x5c, 'n', 0x22, 0x00}; /* "\n" */
 		LogString newline_escaped;
+
 		appendQuotedEscapedString(newline_escaped, newline);
 		LOGUNIT_ASSERT_EQUAL(newline_expected, newline_escaped);
 
-		LogString ff = {0x0c};
-		LogString ff_expected = {0x22, 0x5c, 'f', 0x22};      /* "\f" */
+		logchar ff[] = {0x0c, 0x00};
+		logchar ff_expected[] = {0x22, 0x5c, 'f', 0x22, 0x00};      /* "\f" */
 		LogString ff_escaped;
+
 		appendQuotedEscapedString(ff_escaped, ff);
 		LOGUNIT_ASSERT_EQUAL(ff_expected, ff_escaped);
 
-		LogString cr = {0x0d};
-		LogString cr_expected = {0x22, 0x5c, 'r', 0x22};      /* "\r" */
+		logchar cr[] = {0x0d, 0x00};
+		logchar cr_expected[] = {0x22, 0x5c, 'r', 0x22, 0x00};      /* "\r" */
 		LogString cr_escaped;
+
 		appendQuotedEscapedString(cr_escaped, cr);
 		LOGUNIT_ASSERT_EQUAL(cr_expected, cr_escaped);
-
 	}
 
 	/**
@@ -164,7 +166,6 @@ public:
 	 */
 	void testAppendSerializedMDC()
 	{
-
 		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
 			Level::getInfo(),
 			LOG4CXX_STR("A message goes here."),
@@ -174,13 +175,11 @@ public:
 		MDC::put("key2", "value2");
 
 		LogString output1;
-		LogString expected1 = ", \"context_map\": { "
-			"\"key1\": \"value1\", \"key2\": \"value2\" }";
+		LogString expected1 = LOG4CXX_STR(", \"context_map\": { "
+			"\"key1\": \"value1\", \"key2\": \"value2\" }");
 
 		appendSerializedMDC(output1, event1);
-
 		LOGUNIT_ASSERT_EQUAL(expected1, output1);
-
 	}
 
 	/**
@@ -188,7 +187,6 @@ public:
 	 */
 	void testAppendSerializedMDCWithPrettyPrint()
 	{
-
 		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
 			Level::getInfo(),
 			LOG4CXX_STR("A message goes here."),
@@ -198,33 +196,34 @@ public:
 		MDC::put("key2", "value2");
 
 		LogString output1;
-
 		LogString expected1;
-		expected1.append(",\n")
-		.append(ppIndentL1)
-		.append("\"context_map\": {\n")
-		.append(ppIndentL2)
-		.append("\"key1\": \"value1\",\n")
-		.append(ppIndentL2)
-		.append("\"key2\": \"value2\"\n")
-		.append(ppIndentL1)
-		.append("}");
+
+		expected1
+			.append(LOG4CXX_STR(","))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL1)
+			.append(LOG4CXX_STR("\"context_map\": {"))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL2)
+			.append(LOG4CXX_STR("\"key1\": \"value1\","))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL2)
+			.append(LOG4CXX_STR("\"key2\": \"value2\""))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL1)
+			.append(LOG4CXX_STR("}"));
 
 		setPrettyPrint(true);
 		appendSerializedMDC(output1, event1);
 
 		LOGUNIT_ASSERT_EQUAL(expected1, output1);
-
 	}
 
-
-
 	/**
 	 * Tests appendSerializedNDC.
 	 */
 	void testAppendSerializedNDC()
 	{
-
 		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
 			Level::getInfo(),
 			LOG4CXX_STR("A message goes here."),
@@ -235,21 +234,17 @@ public:
 		NDC::push("three");
 
 		LogString output1;
-		LogString expected1 = ", \"context_stack\": [ \"one two three\" ]";
+		LogString expected1 = LOG4CXX_STR(", \"context_stack\": [ \"one two three\" ]");
 
 		appendSerializedNDC(output1, event1);
-
 		LOGUNIT_ASSERT_EQUAL(expected1, output1);
-
 	}
 
-
 	/**
 	 * Tests appendSerializedNDC with prettyPrint set to true.
 	 */
 	void testAppendSerializedNDCWithPrettyPrint()
 	{
-
 		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
 			Level::getInfo(),
 			LOG4CXX_STR("A message goes here."),
@@ -261,20 +256,23 @@ public:
 
 		LogString output1;
 		LogString expected1;
-		expected1.append(",\n")
-		.append(ppIndentL1)
-		.append("\"context_stack\": [\n")
-		.append(ppIndentL2)
-		.append("\"one two three\"\n")
-		.append(ppIndentL1)
-		.append("]");
 
-		setPrettyPrint(true);
+		expected1
+			.append(LOG4CXX_STR(","))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL1)
+			.append(LOG4CXX_STR("\"context_stack\": ["))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL2)
+			.append(LOG4CXX_STR("\"one two three\""))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL1)
+			.append(LOG4CXX_STR("]"));
 
+		setPrettyPrint(true);
 		appendSerializedNDC(output1, event1);
 
 		LOGUNIT_ASSERT_EQUAL(expected1, output1);
-
 	}
 
 	/**
@@ -291,16 +289,16 @@ public:
 
 		LogString output1;
 		LogString expected1;
-		expected1.append("\"location_info\": { ")
-		.append("\"file\": \"FooFile\", ")
-		.append("\"line\": \"42\", ")
-		.append("\"class\": \"\", ")
-		.append("\"method\": \"BarFunc\" }");
 
-		appendSerializedLocationInfo(output1, event1, p);
+		expected1
+			.append(LOG4CXX_STR("\"location_info\": { "))
+			.append(LOG4CXX_STR("\"file\": \"FooFile\", "))
+			.append(LOG4CXX_STR("\"line\": \"42\", "))
+			.append(LOG4CXX_STR("\"class\": \"\", "))
+			.append(LOG4CXX_STR("\"method\": \"BarFunc\" }"));
 
+		appendSerializedLocationInfo(output1, event1, p);
 		LOGUNIT_ASSERT_EQUAL(expected1, output1);
-
 	}
 
 	/**
@@ -308,7 +306,6 @@ public:
 	 */
 	void testAppendSerializedLocationInfoWithPrettyPrint()
 	{
-
 		Pool p;
 
 		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
@@ -318,34 +315,37 @@ public:
 
 		LogString output1;
 		LogString expected1;
-		expected1.append(ppIndentL1)
-		.append("\"location_info\": {\n")
-		.append(ppIndentL2)
-		.append("\"file\": \"FooFile\",\n")
-		.append(ppIndentL2)
-		.append("\"line\": \"42\",\n")
-		.append(ppIndentL2)
-		.append("\"class\": \"\",\n")
-		.append(ppIndentL2)
-		.append("\"method\": \"BarFunc\"\n")
-		.append(ppIndentL1)
-		.append("}");
+
+		expected1
+			.append(ppIndentL1)
+			.append(LOG4CXX_STR("\"location_info\": {"))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL2)
+			.append(LOG4CXX_STR("\"file\": \"FooFile\","))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL2)
+			.append(LOG4CXX_STR("\"line\": \"42\","))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL2)
+			.append(LOG4CXX_STR("\"class\": \"\","))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL2)
+			.append(LOG4CXX_STR("\"method\": \"BarFunc\""))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL1)
+			.append(LOG4CXX_STR("}"));
 
 		setPrettyPrint(true);
 		appendSerializedLocationInfo(output1, event1, p);
 
 		LOGUNIT_ASSERT_EQUAL(expected1, output1);
-
 	}
 
-
-
 	/**
 	 * Tests format.
 	 */
 	void testFormat()
 	{
-
 		Pool p;
 
 		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
@@ -367,33 +367,33 @@ public:
 		LogString output1;
 		LogString expected1;
 
-		expected1.append("{ \"timestamp\": \"")
-		.append(timestamp)
-		.append("\", ")
-		.append("\"level\": \"INFO\", ")
-		.append("\"logger\": \"Logger\", ")
-		.append("\"message\": \"A message goes here.\"");
+		expected1
+			.append(LOG4CXX_STR("{ \"timestamp\": \""))
+			.append(timestamp)
+			.append(LOG4CXX_STR("\", "))
+			.append(LOG4CXX_STR("\"level\": \"INFO\", "))
+			.append(LOG4CXX_STR("\"logger\": \"Logger\", "))
+			.append(LOG4CXX_STR("\"message\": \"A message goes here.\""));
 
 		setLocationInfo(true);
 
 		appendSerializedMDC(expected1, event1);
 		appendSerializedNDC(expected1, event1);
-		expected1.append(", ");
+		expected1.append(LOG4CXX_STR(", "));
 		appendSerializedLocationInfo(expected1, event1, p);
 
-		expected1.append(" }\n");
-
+		expected1.append(LOG4CXX_STR(" }"));
+		expected1.append(LOG4CXX_EOL);
 		format(output1, event1, p);
 
 		LOGUNIT_ASSERT_EQUAL(expected1, output1);
-
 	}
+
 	/**
 	 * Tests format with PrettyPrint set to true.
 	 */
 	void testFormatWithPrettyPrint()
 	{
-
 		Pool p;
 
 		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
@@ -415,36 +415,40 @@ public:
 		LogString output1;
 		LogString expected1;
 
-		expected1.append("{\n")
-		.append(ppIndentL1)
-		.append("\"timestamp\": \"")
-		.append(timestamp)
-		.append("\",\n")
-		.append(ppIndentL1)
-		.append("\"level\": \"INFO\",\n")
-		.append(ppIndentL1)
-		.append("\"logger\": \"Logger\",\n")
-		.append(ppIndentL1)
-		.append("\"message\": \"A message goes here.\"");
-
+		expected1
+			.append(LOG4CXX_STR("{"))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL1)
+			.append(LOG4CXX_STR("\"timestamp\": \""))
+			.append(timestamp)
+			.append(LOG4CXX_STR("\","))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL1)
+			.append(LOG4CXX_STR("\"level\": \"INFO\","))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL1)
+			.append(LOG4CXX_STR("\"logger\": \"Logger\","))
+			.append(LOG4CXX_EOL)
+			.append(ppIndentL1)
+			.append(LOG4CXX_STR("\"message\": \"A message goes here.\""));
 
 		setPrettyPrint(true);
 		setLocationInfo(true);
 
 		appendSerializedMDC(expected1, event1);
 		appendSerializedNDC(expected1, event1);
-		expected1.append(",\n");
+		expected1.append(LOG4CXX_STR(","));
+		expected1.append(LOG4CXX_EOL);
 		appendSerializedLocationInfo(expected1, event1, p);
 
-		expected1.append("\n}\n");
-
+		expected1.append(LOG4CXX_EOL);
+		expected1.append(LOG4CXX_STR("}"));
+		expected1.append(LOG4CXX_EOL);
 		format(output1, event1, p);
 
 		LOGUNIT_ASSERT_EQUAL(expected1, output1);
-
 	}
 
-
 	/**
 	 * Tests getLocationInfo and setLocationInfo.
 	 */
@@ -470,7 +474,6 @@ public:
 		layout.setPrettyPrint(false);
 		LOGUNIT_ASSERT_EQUAL(false, layout.getPrettyPrint());
 	}
-
 };