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/06/08 06:13:43 UTC

(logging-log4cxx) 01/01: Fix compilation errors when using LOG4CXX_CHAR=unicode

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

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

commit a68bca371a917881045f83dc93b45b6f2eedb184
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Mon Jun 8 16:13:19 2026 +1000

    Fix compilation errors when using LOG4CXX_CHAR=unicode
---
 .github/workflows/log4cxx-ubuntu.yml | 5 +++--
 src/main/cpp/asyncbuffer.cpp         | 4 +++-
 src/main/cpp/smtpappender.cpp        | 2 +-
 src/main/cpp/threadutility.cpp       | 8 ++++----
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/log4cxx-ubuntu.yml b/.github/workflows/log4cxx-ubuntu.yml
index 71899d10..56faadac 100644
--- a/.github/workflows/log4cxx-ubuntu.yml
+++ b/.github/workflows/log4cxx-ubuntu.yml
@@ -37,7 +37,7 @@ jobs:
             multithread: OFF
             exitevents: OFF
             fuzzers: OFF
-            logchar: utf-8
+            logchar: unicode
             next_abi: OFF
           - name: ubuntu22-clang
             os: ubuntu-22.04
@@ -107,6 +107,7 @@ jobs:
       run: |
         ROOT=`pwd`
         set -x
+        [ ${{ matrix.logchar }} == unicode ] && OPTIONAL_API=-DLOG4CXX_UNICHAR=1
         cmake \
           -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
           -DLOG4CXX_TEST_ONLY_BUILD=1 \
@@ -116,7 +117,7 @@ jobs:
           -DLOG4CXX_MULTIPROCESS_ROLLING_FILE_APPENDER=${{ matrix.multiprocess }} \
           -DLOG4CXX_EVENTS_AT_EXIT=${{ matrix.exitevents }} \
           -DBUILD_FUZZERS=${{ matrix.fuzzers }} \
-          -DLOG4CXX_CHAR=${{ matrix.logchar }} \
+          -DLOG4CXX_CHAR=${{ matrix.logchar }} $OPTIONAL_API \
           -DLOG4CXX_BUILD_NEXT_ABI=${{ matrix.next_abi }} \
           -DCMAKE_INSTALL_PREFIX=$ROOT/lib \
           -S $ROOT/main \
diff --git a/src/main/cpp/asyncbuffer.cpp b/src/main/cpp/asyncbuffer.cpp
index 56c6d425..54d72708 100644
--- a/src/main/cpp/asyncbuffer.cpp
+++ b/src/main/cpp/asyncbuffer.cpp
@@ -159,7 +159,7 @@ void AsyncBuffer::renderMessage(LogCharMessageBuffer& msg) const
 				LOG4CXX_DECODE_WCHAR(lsMsg, wideBuf.extract_str(wideBuf));
 				msg << lsMsg;
 			}
-#else // !LOG4CXX_LOGCHAR_IS_UTF8
+#elif LOG4CXX_LOGCHAR_IS_WCHAR
 			if (auto pRenderer = std::get_if<WideMessageBufferAppender>(&renderer))
 				(*pRenderer)(msg);
 			else
@@ -169,6 +169,8 @@ void AsyncBuffer::renderMessage(LogCharMessageBuffer& msg) const
 				LOG4CXX_DECODE_CHAR(lsMsg, narrowBuf.extract_str(narrowBuf));
 				msg << lsMsg;
 			}
+#else
+			msg << LOG4CXX_STR("Unichar is not supported");
 #endif // !LOG4CXX_LOGCHAR_IS_UTF8
 		}
 #else // !LOG4CXX_CONCEPTS
diff --git a/src/main/cpp/smtpappender.cpp b/src/main/cpp/smtpappender.cpp
index 496c3d53..079d85fa 100644
--- a/src/main/cpp/smtpappender.cpp
+++ b/src/main/cpp/smtpappender.cpp
@@ -54,7 +54,7 @@ namespace
 // owns SMTP wire-format sanitization (see SMTPSession::toAscii, which silently
 // rewrites non-ASCII to '?'); strip CR/LF in the public setters so the same
 // boundary is enforced regardless of how the value reaches the appender.
-LogString stripSmtpControl(const LogString& value, const logchar* field)
+LogString stripSmtpControl(const LogString& value, const LogString& field)
 {
 	if (value.find_first_of(LOG4CXX_STR("\r\n")) == LogString::npos)
 	{
diff --git a/src/main/cpp/threadutility.cpp b/src/main/cpp/threadutility.cpp
index 4ea4c078..acdd57e4 100644
--- a/src/main/cpp/threadutility.cpp
+++ b/src/main/cpp/threadutility.cpp
@@ -189,7 +189,7 @@ void ThreadUtility::preThreadBlockSignals()
 
 	if ( pthread_sigmask(SIG_SETMASK, &set, &old_mask) < 0 )
 	{
-		LOGLOG_ERROR( LOG4CXX_STR("Unable to set thread sigmask") );
+		LogLog::error( LOG4CXX_STR("Unable to set thread sigmask") );
 		sigmask_valid = false;
 	}
 	else
@@ -207,7 +207,7 @@ void ThreadUtility::threadStartedNameThread(LogString threadName,
 #if LOG4CXX_HAS_PTHREAD_SETNAME && !(defined(_WIN32) && defined(_LIBCPP_VERSION))
 	LOG4CXX_ENCODE_CHAR(sthreadName, threadName);
 	if (pthread_setname_np(static_cast<pthread_t>(nativeHandle), sthreadName.c_str()) < 0) {
-		LOGLOG_ERROR(LOG4CXX_STR("unable to set thread name"));
+		LogLog::error(LOG4CXX_STR("Unable to set thread name"));
 	}
 #elif defined(_WIN32)
 	typedef HRESULT (WINAPI *TSetThreadDescription)(HANDLE, PCWSTR);
@@ -227,7 +227,7 @@ void ThreadUtility::threadStartedNameThread(LogString threadName,
 	{
 		LOG4CXX_ENCODE_WCHAR(wthreadName, threadName);
 		if(FAILED(win32Func.SetThreadDescription(static_cast<HANDLE>(nativeHandle), wthreadName.c_str())))
-			LOGLOG_ERROR( LOG4CXX_STR("unable to set thread name") );
+			LogLog::error( LOG4CXX_STR(Unable to set thread name") );
 	}
 #endif
 }
@@ -241,7 +241,7 @@ void ThreadUtility::postThreadUnblockSignals()
 	{
 		if ( pthread_sigmask(SIG_SETMASK, &old_mask, nullptr) < 0 )
 		{
-			LOGLOG_ERROR( LOG4CXX_STR("Unable to set thread sigmask") );
+			LogLog::error( LOG4CXX_STR("Unable to set thread sigmask") );
 		}
 	}