From 7e2f607d1246cd9495581f9c56afd4c579539f11 Mon Sep 17 00:00:00 2001 From: Stephen Webb Date: Wed, 2 Aug 2023 17:44:43 +1000 Subject: [PATCH] Include multiprocessrollingfileappender when the cmake var LOG4CXX_MULTIPROCESS_ROLLING_FILE_APPENDER is ON --- src/main/cpp/CMakeLists.txt | 8 ++++---- src/main/cpp/multiprocessrollingfileappender.cpp | 10 +++++++--- .../log4cxx/rolling/multiprocessrollingfileappender.h | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/cpp/CMakeLists.txt b/src/main/cpp/CMakeLists.txt index be187a7bd..c67c9ddab 100644 --- a/src/main/cpp/CMakeLists.txt +++ b/src/main/cpp/CMakeLists.txt @@ -30,7 +30,7 @@ add_dependencies(log4cxx configure_log4cxx) set(extra_classes "") if(LOG4CXX_NETWORKING_SUPPORT) - set(extra_classes ${extra_classes} + list(APPEND extra_classes datagrampacket.cpp datagramsocket.cpp aprdatagramsocket.cpp @@ -47,14 +47,14 @@ if(LOG4CXX_NETWORKING_SUPPORT) ) endif() -if() - set(extra_classes ${extra_classes} +if(LOG4CXX_MULTIPROCESS_ROLLING_FILE_APPENDER) + list(APPEND extra_classes multiprocessrollingfileappender.cpp ) endif() if(${ENABLE_FMT_LAYOUT}) - set(extra_classes ${extra_classes} + list(APPEND extra_classes fmtlayout.cpp ) endif() diff --git a/src/main/cpp/multiprocessrollingfileappender.cpp b/src/main/cpp/multiprocessrollingfileappender.cpp index 29b02592d..c6ee5004e 100644 --- a/src/main/cpp/multiprocessrollingfileappender.cpp +++ b/src/main/cpp/multiprocessrollingfileappender.cpp @@ -242,13 +242,17 @@ bool MultiprocessRollingFileAppender::rolloverInternal(Pool& p) if (stat == APR_SUCCESS) { - snprintf(szUid, MAX_FILE_LEN, "%u", uid); +#ifdef WIN32 + snprintf(szUid, MAX_FILE_LEN, "%p", uid); +#else + snprintf(szUid, MAX_FILE_LEN, "%u", (unsigned int)uid); +#endif } log4cxx::filesystem::path path = szDirName; - const LogString lockname = path.parent_path() / (path.filename().string() + szUid + ".lock"); + const auto lockname = path.parent_path() / (path.filename().string() + szUid + ".lock"); apr_file_t* lock_file; - stat = apr_file_open(&lock_file, lockname.c_str(), APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, p.getAPRPool()); + stat = apr_file_open(&lock_file, lockname.string().c_str(), APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, p.getAPRPool()); if (stat != APR_SUCCESS) { diff --git a/src/main/include/log4cxx/rolling/multiprocessrollingfileappender.h b/src/main/include/log4cxx/rolling/multiprocessrollingfileappender.h index 1d79385b8..a37c895ab 100644 --- a/src/main/include/log4cxx/rolling/multiprocessrollingfileappender.h +++ b/src/main/include/log4cxx/rolling/multiprocessrollingfileappender.h @@ -71,7 +71,7 @@ class LOG4CXX_EXPORT MultiprocessRollingFileAppender : public FileAppender File is truncated with no backup files created. */ - bool rollover(helpers::Pool& p) override; + bool rollover(helpers::Pool& p); protected: