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/22 19:59:26 UTC

[logging-log4cxx] branch ghpr_13 updated (f4311c2 -> 82024ff)

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

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


    from f4311c2  Added some debugging to the failing tests.
     new 753797a  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 only the tests succeed on Windows.
     new 82024ff  Removed debugging output, replaced "\n" with LOG4CXX_EOL to get in line with the other code and added 0x00 to the raw arrays of logchars or appending strings didn't work.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/cpp/jsonlayout.cpp     |  36 +++++++-------
 src/test/cpp/jsonlayouttest.cpp | 103 ++++++++++++++++++++++------------------
 2 files changed, 74 insertions(+), 65 deletions(-)


[logging-log4cxx] 02/02: Removed debugging output, replaced "\n" with LOG4CXX_EOL to get in line with the other code and added 0x00 to the raw arrays of logchars or appending strings didn't work.

Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 82024ff5650bca32428f5f1385707d77d877ebf4
Author: Thorsten Schöning <ts...@am-soft.de>
AuthorDate: Tue Oct 22 21:59:14 2019 +0200

    Removed debugging output, replaced "\n" with LOG4CXX_EOL to get in line with the other code and added 0x00 to the raw arrays of logchars or appending strings didn't work.
---
 src/test/cpp/jsonlayouttest.cpp | 103 ++++++++++++++++++++++------------------
 1 file changed, 56 insertions(+), 47 deletions(-)

diff --git a/src/test/cpp/jsonlayouttest.cpp b/src/test/cpp/jsonlayouttest.cpp
index 2cc7419..a23aa2e 100644
--- a/src/test/cpp/jsonlayouttest.cpp
+++ b/src/test/cpp/jsonlayouttest.cpp
@@ -125,35 +125,38 @@ public:
 	 */
 	void testAppendQuotedEscapedStringWithControlChars()
 	{
-        // TODO fails
-		return;
-		logchar bs[] = {0x08};
-		logchar 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);
 
-		logchar tab[] = {0x09};
-		logchar 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);
 
-		logchar newline[] = {0x0a};
-		logchar 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);
 
-		logchar ff[] = {0x0c};
-		logchar 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);
 
-		logchar cr[] = {0x0d};
-		logchar 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);
 	}
@@ -196,13 +199,17 @@ public:
 		LogString expected1;
 
 		expected1
-		.append(LOG4CXX_STR(",\n"))
+		.append(LOG4CXX_STR(","))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL1)
-		.append(LOG4CXX_STR("\"context_map\": {\n"))
+		.append(LOG4CXX_STR("\"context_map\": {"))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL2)
-		.append(LOG4CXX_STR("\"key1\": \"value1\",\n"))
+		.append(LOG4CXX_STR("\"key1\": \"value1\","))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL2)
-		.append(LOG4CXX_STR("\"key2\": \"value2\"\n"))
+		.append(LOG4CXX_STR("\"key2\": \"value2\""))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL1)
 		.append(LOG4CXX_STR("}"));
 
@@ -251,11 +258,14 @@ public:
 		LogString expected1;
 
 		expected1
-		.append(LOG4CXX_STR(",\n"))
+		.append(LOG4CXX_STR(","))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL1)
-		.append(LOG4CXX_STR("\"context_stack\": [\n"))
+		.append(LOG4CXX_STR("\"context_stack\": ["))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL2)
-		.append(LOG4CXX_STR("\"one two three\"\n"))
+		.append(LOG4CXX_STR("\"one two three\""))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL1)
 		.append(LOG4CXX_STR("]"));
 
@@ -308,15 +318,20 @@ public:
 
 		expected1
 		.append(ppIndentL1)
-		.append(LOG4CXX_STR("\"location_info\": {\n"))
+		.append(LOG4CXX_STR("\"location_info\": {"))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL2)
-		.append(LOG4CXX_STR("\"file\": \"FooFile\",\n"))
+		.append(LOG4CXX_STR("\"file\": \"FooFile\","))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL2)
-		.append(LOG4CXX_STR("\"line\": \"42\",\n"))
+		.append(LOG4CXX_STR("\"line\": \"42\","))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL2)
-		.append(LOG4CXX_STR("\"class\": \"\",\n"))
+		.append(LOG4CXX_STR("\"class\": \"\","))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL2)
-		.append(LOG4CXX_STR("\"method\": \"BarFunc\"\n"))
+		.append(LOG4CXX_STR("\"method\": \"BarFunc\""))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL1)
 		.append(LOG4CXX_STR("}"));
 
@@ -331,7 +346,6 @@ public:
 	 */
 	void testFormat()
 	{
-        // TODO fails
 		Pool p;
 
 		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
@@ -368,13 +382,10 @@ public:
 		expected1.append(LOG4CXX_STR(", "));
 		appendSerializedLocationInfo(expected1, event1, p);
 
-		expected1.append(LOG4CXX_STR(" }\n"));
+		expected1.append(LOG4CXX_STR(" }"));
+		expected1.append(LOG4CXX_EOL);
 		format(output1, event1, p);
-std::wcout << L"\n";
-std::wcout << L"---" << expected1.c_str() << L"---\n";
-std::wcout << L"---" << output1.c_str() << L"---\n";
-std::cout << expected1.length() << "\n";
-std::cout << output1.length() << "\n";
+
 		LOGUNIT_ASSERT_EQUAL(expected1, output1);
 	}
 
@@ -383,8 +394,6 @@ std::cout << output1.length() << "\n";
 	 */
 	void testFormatWithPrettyPrint()
 	{
-		// TODO fails
-		return;
 		Pool p;
 
 		LoggingEventPtr event1 = new LoggingEvent(LOG4CXX_STR("Logger"),
@@ -407,15 +416,19 @@ std::cout << output1.length() << "\n";
 		LogString expected1;
 
 		expected1
-		.append(LOG4CXX_STR("{\n"))
+		.append(LOG4CXX_STR("{"))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL1)
 		.append(LOG4CXX_STR("\"timestamp\": \""))
 		.append(timestamp)
-		.append(LOG4CXX_STR("\",\n"))
+		.append(LOG4CXX_STR("\","))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL1)
-		.append(LOG4CXX_STR("\"level\": \"INFO\",\n"))
+		.append(LOG4CXX_STR("\"level\": \"INFO\","))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL1)
-		.append(LOG4CXX_STR("\"logger\": \"Logger\",\n"))
+		.append(LOG4CXX_STR("\"logger\": \"Logger\","))
+		.append(LOG4CXX_EOL)
 		.append(ppIndentL1)
 		.append(LOG4CXX_STR("\"message\": \"A message goes here.\""));
 
@@ -424,19 +437,15 @@ std::cout << output1.length() << "\n";
 
 		appendSerializedMDC(expected1, event1);
 		appendSerializedNDC(expected1, event1);
-		expected1.append(LOG4CXX_STR(",\n"));
+		expected1.append(LOG4CXX_STR(","));
+		expected1.append(LOG4CXX_EOL);
 		appendSerializedLocationInfo(expected1, event1, p);
 
-		expected1.append(LOG4CXX_STR("\n}\n"));
+		expected1.append(LOG4CXX_EOL);
+		expected1.append(LOG4CXX_STR("}"));
+		expected1.append(LOG4CXX_EOL);
 		format(output1, event1, p);
-#include <log4cxx/helpers/stringhelper.h>
-std::wcout << L"\n";
-std::wcout << L"---" << expected1.c_str() << L"---\n";
-std::wcout << L"---" << output1.c_str() << L"---\n";
-std::cout << expected1.length() << "\n";
-std::cout << output1.length() << "\n";
-std::cout << expected1.length() << "\n";
-std::cout << StringHelper::trim(output1).length() << "\n";
+
 		LOGUNIT_ASSERT_EQUAL(expected1, output1);
 	}
 


[logging-log4cxx] 01/02: 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 only the tests succeed on Windows.

Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 753797ac448f96b00777d20e92b4a1428aba857b
Author: Thorsten Schöning <ts...@am-soft.de>
AuthorDate: Tue Oct 22 21:57:40 2019 +0200

    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 only the tests succeed on Windows.
---
 src/main/cpp/jsonlayout.cpp | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/main/cpp/jsonlayout.cpp b/src/main/cpp/jsonlayout.cpp
index 816c8d2..a2e72c3 100644
--- a/src/main/cpp/jsonlayout.cpp
+++ b/src/main/cpp/jsonlayout.cpp
@@ -64,7 +64,7 @@ void JSONLayout::format(LogString& output,
 	Pool& p) const
 {
 	output.append(LOG4CXX_STR("{"));
-	output.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	output.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
@@ -77,7 +77,7 @@ void JSONLayout::format(LogString& output,
 	dateFormat.format(timestamp, event->getTimeStamp(), p);
 	appendQuotedEscapedString(output, timestamp);
 	output.append(LOG4CXX_STR(","));
-	output.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	output.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
@@ -90,7 +90,7 @@ void JSONLayout::format(LogString& output,
 	event->getLevel()->toString(level);
 	appendQuotedEscapedString(output, level);
 	output.append(LOG4CXX_STR(","));
-	output.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	output.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
@@ -101,7 +101,7 @@ void JSONLayout::format(LogString& output,
 	output.append(LOG4CXX_STR(": "));
 	appendQuotedEscapedString(output, event->getLoggerName());
 	output.append(LOG4CXX_STR(","));
-	output.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	output.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
@@ -118,11 +118,11 @@ void JSONLayout::format(LogString& output,
 	if (locationInfo)
 	{
 		output.append(LOG4CXX_STR(","));
-		output.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+		output.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 		appendSerializedLocationInfo(output, event, p);
 	}
 
-	output.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	output.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 	output.append(LOG4CXX_STR("}"));
 	output.append(LOG4CXX_EOL);
 }
@@ -235,7 +235,7 @@ void JSONLayout::appendSerializedMDC(LogString& buf,
 	}
 
 	buf.append(LOG4CXX_STR(","));
-	buf.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
@@ -244,7 +244,7 @@ void JSONLayout::appendSerializedMDC(LogString& buf,
 
 	appendQuotedEscapedString(buf, LOG4CXX_STR("context_map"));
 	buf.append(LOG4CXX_STR(": {"));
-	buf.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	for (LoggingEvent::KeySet::iterator it = keys.begin();
 		it != keys.end(); ++it)
@@ -264,11 +264,11 @@ void JSONLayout::appendSerializedMDC(LogString& buf,
 		if (it + 1 != keys.end())
 		{
 			buf.append(LOG4CXX_STR(","));
-			buf.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+			buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 		}
 		else
 		{
-			buf.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+			buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 		}
 	}
 
@@ -291,7 +291,7 @@ void JSONLayout::appendSerializedNDC(LogString& buf,
 	}
 
 	buf.append(LOG4CXX_STR(","));
-	buf.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
@@ -300,7 +300,7 @@ void JSONLayout::appendSerializedNDC(LogString& buf,
 
 	appendQuotedEscapedString(buf, LOG4CXX_STR("context_stack"));
 	buf.append(LOG4CXX_STR(": ["));
-	buf.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
@@ -308,7 +308,7 @@ void JSONLayout::appendSerializedNDC(LogString& buf,
 	}
 
 	appendQuotedEscapedString(buf, ndcVal);
-	buf.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
@@ -328,7 +328,7 @@ void JSONLayout::appendSerializedLocationInfo(LogString& buf,
 
 	appendQuotedEscapedString(buf, LOG4CXX_STR("location_info"));
 	buf.append(LOG4CXX_STR(": {"));
-	buf.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 	const LocationInfo& locInfo = event->getLocationInformation();
 
 	if (prettyPrint)
@@ -341,7 +341,7 @@ void JSONLayout::appendSerializedLocationInfo(LogString& buf,
 	LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName());
 	appendQuotedEscapedString(buf, fileName);
 	buf.append(LOG4CXX_STR(","));
-	buf.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
@@ -354,7 +354,7 @@ void JSONLayout::appendSerializedLocationInfo(LogString& buf,
 	StringHelper::toString(locInfo.getLineNumber(), p, lineNumber);
 	appendQuotedEscapedString(buf, lineNumber);
 	buf.append(LOG4CXX_STR(","));
-	buf.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
@@ -366,7 +366,7 @@ void JSONLayout::appendSerializedLocationInfo(LogString& buf,
 	LOG4CXX_DECODE_CHAR(className, locInfo.getClassName());
 	appendQuotedEscapedString(buf, className);
 	buf.append(LOG4CXX_STR(","));
-	buf.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{
@@ -377,7 +377,7 @@ void JSONLayout::appendSerializedLocationInfo(LogString& buf,
 	buf.append(LOG4CXX_STR(": "));
 	LOG4CXX_DECODE_CHAR(methodName, locInfo.getMethodName());
 	appendQuotedEscapedString(buf, methodName);
-	buf.append(prettyPrint ? LOG4CXX_STR("\n") : LOG4CXX_STR(" "));
+	buf.append(prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" "));
 
 	if (prettyPrint)
 	{