Skip to content

Commit

Permalink
Include multiprocessrollingfileappender when the cmake var LOG4CXX_MU…
Browse files Browse the repository at this point in the history
…LTIPROCESS_ROLLING_FILE_APPENDER is ON
  • Loading branch information
stephen-webb committed Aug 2, 2023
1 parent f0473b5 commit 7e2f607
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
10 changes: 7 additions & 3 deletions src/main/cpp/multiprocessrollingfileappender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class LOG4CXX_EXPORT MultiprocessRollingFileAppender : public FileAppender
<code>File</code> is truncated with no backup files created.
*/
bool rollover(helpers::Pool& p) override;
bool rollover(helpers::Pool& p);

protected:

Expand Down

0 comments on commit 7e2f607

Please sign in to comment.