From 5c23488f45054c0c00dfd276f5c32e0fc2de2539 Mon Sep 17 00:00:00 2001 From: Robert Middleton Date: Tue, 23 Dec 2025 17:07:11 -0500 Subject: [PATCH 1/3] refactor apr classes to start apr being optional --- CMakeLists.txt | 20 ++- src/CMakeLists.txt | 18 ++- src/main/cpp/CMakeLists.txt | 7 +- src/main/cpp/aprinitializer.cpp | 17 ++- src/main/cpp/charsetdecoder.cpp | 19 +-- src/main/cpp/charsetencoder.cpp | 35 ++--- src/main/include/log4cxx/log4cxx.h.in | 2 + src/test/cpp/CMakeLists.txt | 8 +- src/test/cpp/logunit.cpp | 8 +- src/test/cpp/util/binarycompare.cpp | 64 ++++++++- src/test/cpp/util/transformer.cpp | 183 +++++--------------------- src/test/cpp/util/transformer.h | 7 +- 12 files changed, 186 insertions(+), 202 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7db4e1eb0..06ae89be2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,13 +58,19 @@ if(ENABLE_COVERAGE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") endif() -# Find Apache Runtime -option(APR_STATIC "Link to the APR static library" OFF) -find_package(APR REQUIRED) - -# Find Apache Runtime Utilities -option(APU_STATIC "Link to the APR-Util static library" OFF) -find_package(APR-Util REQUIRED) +option(ENABLE_APR "Enable APR for cross-platform support" ON) +if(ENABLE_APR) + set(LOG4CXX_ENABLE_APR 1) + # Find Apache Runtime + option(APR_STATIC "Link to the APR static library" OFF) + #find_package(APR REQUIRED) + + # Find Apache Runtime Utilities + option(APU_STATIC "Link to the APR-Util static library" OFF) + #find_package(APR-Util REQUIRED) +else() + set(LOG4CXX_ENABLE_APR 0) +endif(ENABLE_APR) if(NOT MSVC) # The pthread library is used to name threads and mask signals diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 868a1273c..6b61ae1d7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,9 +19,21 @@ include(${CMAKE_CURRENT_LIST_DIR}/cmake/boost-fallback/boost-fallback.cmake) include(${CMAKE_CURRENT_LIST_DIR}/cmake/compiler-features/check-compiler-support.cmake) add_subdirectory(main) -target_compile_definitions(log4cxx PRIVATE ${LOG4CXX_COMPILE_DEFINITIONS} ${APR_COMPILE_DEFINITIONS} ${APR_UTIL_COMPILE_DEFINITIONS} ) -target_include_directories(log4cxx INTERFACE $ PRIVATE ${APR_INCLUDE_DIR} ${APR_UTIL_INCLUDE_DIR}) -target_link_libraries(log4cxx PRIVATE ${APR_UTIL_LIBRARIES} ${EXPAT_LIBRARIES} ${APR_LIBRARIES} ${APR_SYSTEM_LIBS}) +target_compile_definitions(log4cxx PRIVATE + ${LOG4CXX_COMPILE_DEFINITIONS} + $<$:${APR_COMPILE_DEFINITIONS}> + $<$:${APR_UTIL_COMPILE_DEFINITIONS}> +) +target_include_directories(log4cxx INTERFACE $ PRIVATE + $<$:${APR_INCLUDE_DIR}> + $<$:${APR_UTIL_INCLUDE_DIR}> +) +target_link_libraries(log4cxx PRIVATE + $<$:${APR_UTIL_LIBRARIES}> + ${EXPAT_LIBRARIES} + $<$:${APR_LIBRARIES}> + $<$:${APR_SYSTEM_LIBS}> +) if(HAS_LIBESMTP) target_include_directories(log4cxx PRIVATE ${ESMTP_INCLUDE_DIR}) target_link_libraries(log4cxx PRIVATE ${ESMTP_LIBRARIES}) diff --git a/src/main/cpp/CMakeLists.txt b/src/main/cpp/CMakeLists.txt index 8a2526f46..17264e057 100644 --- a/src/main/cpp/CMakeLists.txt +++ b/src/main/cpp/CMakeLists.txt @@ -70,6 +70,12 @@ if(${ENABLE_FMT_LAYOUT}) ) endif() +if(${ENABLE_APR}) + list(APPEND extra_classes + dbappender.cpp + ) +endif() + target_sources(log4cxx PRIVATE action.cpp @@ -98,7 +104,6 @@ target_sources(log4cxx date.cpp dateformat.cpp datepatternconverter.cpp - dbappender.cpp defaultconfigurator.cpp defaultloggerfactory.cpp defaultrepositoryselector.cpp diff --git a/src/main/cpp/aprinitializer.cpp b/src/main/cpp/aprinitializer.cpp index 36119e2a6..6f11aea1c 100644 --- a/src/main/cpp/aprinitializer.cpp +++ b/src/main/cpp/aprinitializer.cpp @@ -19,16 +19,19 @@ #define LOG4CXX 1 #endif #include -#include #include #include -#include #include #include #include #include #include +#ifdef LOG4CXX_ENABLE_APR +#include +#include +#endif + using namespace LOG4CXX_NS::helpers; using namespace LOG4CXX_NS; @@ -81,11 +84,15 @@ struct apr_environment { apr_environment() { +#ifdef LOG4CXX_ENABLE_APR apr_initialize(); +#endif } ~apr_environment() { +#ifdef LOG4CXX_ENABLE_APR apr_terminate(); +#endif } }; @@ -95,12 +102,14 @@ struct apr_environment APRInitializer::APRInitializer() : m_priv(std::make_unique()) { - apr_pool_create(&m_priv->p, NULL); - m_priv->startTime = Date::currentTime(); +#ifdef LOG4CXX_ENABLE_APR + apr_pool_create(&m_priv->p, NULL); #if APR_HAS_THREADS apr_status_t stat = apr_threadkey_private_create(&m_priv->tlsKey, tlsDestructImpl, m_priv->p); assert(stat == APR_SUCCESS); #endif +#endif + m_priv->startTime = Date::currentTime(); } APRInitializer::~APRInitializer() diff --git a/src/main/cpp/charsetdecoder.cpp b/src/main/cpp/charsetdecoder.cpp index ed79d4404..3a3e9e5dd 100644 --- a/src/main/cpp/charsetdecoder.cpp +++ b/src/main/cpp/charsetdecoder.cpp @@ -22,17 +22,20 @@ #include #include #include -#include #if !defined(LOG4CXX) #define LOG4CXX 1 #endif #include #include -#include #include #include #include +#ifdef LOG4CXX_ENABLE_APR +#include +#include +#endif + using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; @@ -255,7 +258,7 @@ class TrivialCharsetDecoder : public CharsetDecoder in.position(in.position() + remaining); } - return APR_SUCCESS; + return 0; } @@ -355,7 +358,7 @@ class ISOLatinCharsetDecoder : public CharsetDecoder in.position(in.limit()); } - return APR_SUCCESS; + return 0; } @@ -386,7 +389,7 @@ class USASCIICharsetDecoder : public CharsetDecoder virtual log4cxx_status_t decode(ByteBuffer& in, LogString& out) { - log4cxx_status_t stat = APR_SUCCESS; + log4cxx_status_t stat = 0; if (in.remaining() > 0) { @@ -405,7 +408,7 @@ class USASCIICharsetDecoder : public CharsetDecoder } else { - stat = APR_BADARG; + stat = 1; // APR_BADARG break; } } @@ -434,7 +437,7 @@ class LocaleCharsetDecoder : public CharsetDecoder } log4cxx_status_t decode(ByteBuffer& in, LogString& out) override { - log4cxx_status_t result = APR_SUCCESS; + log4cxx_status_t result = 0; const char* p = in.current(); size_t i = in.position(); size_t remain = in.limit() - i; @@ -460,7 +463,7 @@ class LocaleCharsetDecoder : public CharsetDecoder } if (static_cast(-1) == n) // decoding error? { - result = APR_BADARG; + result = 1; // APR_BADARG break; } if (static_cast(-2) == n) // incomplete sequence? diff --git a/src/main/cpp/charsetencoder.cpp b/src/main/cpp/charsetencoder.cpp index b08e277b2..0123e9008 100644 --- a/src/main/cpp/charsetencoder.cpp +++ b/src/main/cpp/charsetencoder.cpp @@ -18,22 +18,25 @@ #include #include #include -#include #include #include #include - #if !defined(LOG4CXX) #define LOG4CXX 1 #endif - #include -#include + #include #ifdef LOG4CXX_HAS_WCSTOMBS #include #endif +#include + +#ifdef LOG4CXX_ENABLE_APR +#include +#include +#endif using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; @@ -226,7 +229,7 @@ class USASCIICharsetEncoder : public CharsetEncoder LogString::const_iterator& iter, ByteBuffer& out) { - log4cxx_status_t stat = APR_SUCCESS; + log4cxx_status_t stat = 0; if (iter != in.end()) { @@ -242,7 +245,7 @@ class USASCIICharsetEncoder : public CharsetEncoder else { iter = prev; - stat = APR_BADARG; + stat = 1; // APR_BADARG break; } } @@ -270,7 +273,7 @@ class ISOLatinCharsetEncoder : public CharsetEncoder LogString::const_iterator& iter, ByteBuffer& out) { - log4cxx_status_t stat = APR_SUCCESS; + log4cxx_status_t stat = 0; if (iter != in.end()) { @@ -286,7 +289,7 @@ class ISOLatinCharsetEncoder : public CharsetEncoder else { iter = prev; - stat = APR_BADARG; + stat = 1; // APR_BADARG break; } } @@ -331,7 +334,7 @@ class TrivialCharsetEncoder : public CharsetEncoder out.position(out.position() + requested * sizeof(logchar)); } - return APR_SUCCESS; + return 0; } private: @@ -397,13 +400,13 @@ class UTF16BECharsetEncoder : public CharsetEncoder if (sv == 0xFFFF) { - return APR_BADARG; + return 1; // APR_BADARG; } Transcoder::encodeUTF16BE(sv, out); } - return APR_SUCCESS; + return 0; } private: @@ -432,13 +435,13 @@ class UTF16LECharsetEncoder : public CharsetEncoder if (sv == 0xFFFF) { - return APR_BADARG; + return 1; // APR_BADARG; } Transcoder::encodeUTF16LE(sv, out); } - return APR_SUCCESS; + return 0; } private: UTF16LECharsetEncoder(const UTF16LECharsetEncoder&); @@ -460,7 +463,7 @@ class LocaleCharsetEncoder : public CharsetEncoder , ByteBuffer& out ) override { - log4cxx_status_t result = APR_SUCCESS; + log4cxx_status_t result = 0; #if !LOG4CXX_CHARSET_EBCDIC char* current = out.current(); size_t remain = out.remaining(); @@ -482,7 +485,7 @@ class LocaleCharsetEncoder : public CharsetEncoder auto n = std::wcrtomb(current, ch, &this->state); if (static_cast(-1) == n) // not a valid wide character? { - result = APR_BADARG; + result = 1; // APR_BADARG break; } remain -= n; @@ -612,7 +615,7 @@ void CharsetEncoder::encode(CharsetEncoderPtr& enc, { log4cxx_status_t stat = enc->encode(src, iter, dst); - if (stat != APR_SUCCESS && iter != src.end()) + if (stat != 0 && iter != src.end()) { #if LOG4CXX_LOGCHAR_IS_WCHAR || LOG4CXX_LOGCHAR_IS_UNICHAR iter++; diff --git a/src/main/include/log4cxx/log4cxx.h.in b/src/main/include/log4cxx/log4cxx.h.in index 4e6c29311..f4d596f20 100644 --- a/src/main/include/log4cxx/log4cxx.h.in +++ b/src/main/include/log4cxx/log4cxx.h.in @@ -104,6 +104,8 @@ __pragma( warning( pop ) ) #define LOG4CXX_NS @LOG4CXX_NS@ +#cmakedefine LOG4CXX_ENABLE_APR + namespace LOG4CXX_NS { /** diff --git a/src/test/cpp/CMakeLists.txt b/src/test/cpp/CMakeLists.txt index 4eb99f7d7..95ed45157 100644 --- a/src/test/cpp/CMakeLists.txt +++ b/src/test/cpp/CMakeLists.txt @@ -131,9 +131,13 @@ foreach(testName IN LISTS ALL_LOG4CXX_TESTS) target_link_libraries(${testName} PRIVATE MockCoreFoundation) endif() endif() - target_compile_definitions(${testName} PRIVATE ${TEST_COMPILE_DEFINITIONS} ${TESTING_DEPENDENCY_COMPILE_DEFINITIONS} ) + target_compile_definitions(${testName} PRIVATE ${TEST_COMPILE_DEFINITIONS} ${TESTING_DEPENDENCY_COMPILE_DEFINITIONS} $<$:LOG4CXX_TESTING_APR>) target_include_directories(${testName} PRIVATE ${CMAKE_CURRENT_LIST_DIR} $) - target_link_libraries(${testName} PRIVATE testingFramework testingUtilities log4cxx ${APR_LIBRARIES} ${APR_SYSTEM_LIBS} Threads::Threads ${ODBC_LIBRARIES} ) + target_link_libraries(${testName} PRIVATE testingFramework testingUtilities log4cxx + $<$:${APR_LIBRARIES}> + $<$:${APR_SYSTEM_LIBS}> + Threads::Threads ${ODBC_LIBRARIES} + ) if(HAS_LIBESMTP) target_link_libraries(${testName} PRIVATE ${ESMTP_LIBRARIES}) endif() diff --git a/src/test/cpp/logunit.cpp b/src/test/cpp/logunit.cpp index ce03206a9..6769214da 100644 --- a/src/test/cpp/logunit.cpp +++ b/src/test/cpp/logunit.cpp @@ -17,7 +17,9 @@ #include "logunit.h" +#ifdef LOG4CXX_TESTING_APR #include +#endif #include #include #include @@ -35,8 +37,9 @@ void initialize() { printf("LC_CTYPE: %s\n", ctype); } - +#ifdef LOG4CXX_TESTING_APR apr_initialize(); +#endif } extern const char** testlist; @@ -66,8 +69,9 @@ abts_suite* abts_run_suites(abts_suite* suite) suite = iter->second->run(suite); } } - +#ifdef LOG4CXX_TESTING_APR apr_terminate(); +#endif return suite; } diff --git a/src/test/cpp/util/binarycompare.cpp b/src/test/cpp/util/binarycompare.cpp index 5752ccbcb..9c44d950b 100644 --- a/src/test/cpp/util/binarycompare.cpp +++ b/src/test/cpp/util/binarycompare.cpp @@ -15,16 +15,21 @@ */ #include "binarycompare.h" -#include #include #include "../logunit.h" + +#ifdef LOG4CXX_TESTING_APR +#include #include #include +#endif +#include using namespace log4cxx; using namespace log4cxx::util; using namespace log4cxx::helpers; +#ifdef LOG4CXX_TESTING_APR void BinaryCompare::compare(const char* filename1, const char* filename2) { @@ -91,3 +96,60 @@ void BinaryCompare::compare(const char* filename1, } } } +#else +void BinaryCompare::compare(const char* filename1, + const char* filename2) +{ + Pool p; + std::fstream file1(filename1, std::ios_base::in | std::ios_base::binary); + std::fstream file2(filename2, std::ios_base::in | std::ios_base::binary); + + if (!file1.is_open()) + { + LOGUNIT_FAIL(std::string("Unable to open ") + filename1); + } + + if (!file2.is_open()) + { + LOGUNIT_FAIL(std::string("Unable to open ") + filename2); + } + + constexpr int BUFFER_SIZE = 1024; + char contents1[BUFFER_SIZE]; + char contents2[BUFFER_SIZE]; + memset(contents1, 0, BUFFER_SIZE); + memset(contents2, 0, BUFFER_SIZE); + + file1.read(contents1, BUFFER_SIZE); + file2.read(contents2, BUFFER_SIZE); + + if (file1.fail()) + { + LOGUNIT_FAIL(std::string("Unable to read ") + filename1); + } + + if (file2.fail()) + { + LOGUNIT_FAIL(std::string("Unable to read ") + filename2); + } + + for (int i = 0; i < BUFFER_SIZE; i++) + { + if (contents1[i] != contents2[i]) + { + std::string msg("Contents differ at position "); + msg += std::to_string(i); + msg += ": ["; + msg += filename1; + msg += "] has "; + msg += std::to_string(i); + msg += ", ["; + msg += filename2; + msg += "] has "; + msg += std::to_string(i); + msg += "."; + LOGUNIT_FAIL(msg); + } + } +} +#endif diff --git a/src/test/cpp/util/transformer.cpp b/src/test/cpp/util/transformer.cpp index 96ed877ba..81c5d5ba2 100644 --- a/src/test/cpp/util/transformer.cpp +++ b/src/test/cpp/util/transformer.cpp @@ -18,24 +18,14 @@ #include "transformer.h" #include #include -#include -#include -#include -#include #include #include +#include +#include using namespace log4cxx; using namespace log4cxx::helpers; -#if !defined(APR_FOPEN_READ) - #define APR_FOPEN_READ APR_READ - #define APR_FOPEN_CREATE APR_CREATE - #define APR_FOPEN_WRITE APR_WRITE - #define APR_FOPEN_TRUNCATE APR_TRUNCATE - #define APR_FOPEN_APPEND APR_APPEND -#endif - void Transformer::transform(const File& in, const File& out, const std::vector& filters) { @@ -68,51 +58,15 @@ void Transformer::transform(const File& in, const File& out, void Transformer::copyFile(const File& in, const File& out) { - Pool p; - apr_pool_t* pool = p.getAPRPool(); - - - // - // fairly naive file copy code - // - // - apr_file_t* child_out; - apr_int32_t flags = APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_TRUNCATE; - apr_status_t stat = out.open(&child_out, flags, APR_OS_DEFAULT, p); - assert(stat == APR_SUCCESS); - - apr_file_t* in_file; - stat = in.open(&in_file, APR_FOPEN_READ, APR_OS_DEFAULT, p); - assert(stat == APR_SUCCESS); - apr_size_t bufsize = 32000; - void* buf = apr_palloc(pool, bufsize); - apr_size_t bytesRead = bufsize; - - while (stat == 0 && bytesRead == bufsize) - { - stat = apr_file_read(in_file, buf, &bytesRead); - - if (stat == 0 && bytesRead > 0) - { - stat = apr_file_write(child_out, buf, &bytesRead); - assert(stat == APR_SUCCESS); - } - } - - stat = apr_file_close(child_out); - assert(stat == APR_SUCCESS); + bool stat = std::filesystem::copy_file(in.getPath(), out.getPath()); + assert(stat); } void Transformer::createSedCommandFile(const std::string& regexName, - const log4cxx::Filter::PatternList& patterns, - apr_pool_t* pool) + const log4cxx::Filter::PatternList& patterns) { - apr_file_t* regexFile; - apr_status_t stat = apr_file_open(®exFile, - regexName.c_str(), - APR_FOPEN_WRITE | APR_FOPEN_CREATE | APR_FOPEN_TRUNCATE, APR_OS_DEFAULT, - pool); - assert(stat == APR_SUCCESS); + std::fstream regexFile(regexName, std::ios::out | std::ios::binary | std::ios::trunc); + assert(regexFile.is_open()); std::string tmp; @@ -139,28 +93,18 @@ void Transformer::createSedCommandFile(const std::string& regexName, tmp.append(sedSanitizer(iter->first)); tmp.append(1, 'Q'); tmp.append(sedSanitizer(iter->second)); - tmp.append("Qg\n"); - apr_file_puts(tmp.c_str(), regexFile); - } - - apr_file_close(regexFile); + tmp.append("Qg\n"); + regexFile << tmp.c_str(); + } } void Transformer::transform(const File& in, const File& out, const log4cxx::Filter::PatternList& patterns) { - // - // if no patterns just copy the file - // - if (patterns.size() == 0) - { - copyFile(in, out); - } - else - { - Pool p; - apr_pool_t* pool = p.getAPRPool(); + copyFile(in, out); + if(patterns.size() > 0) + { // // write the regex's to a temporary file since they // may get mangled if passed as parameters @@ -168,89 +112,24 @@ void Transformer::transform(const File& in, const File& out, std::string regexName; Transcoder::encode(in.getPath(), regexName); regexName.append(".sed"); - createSedCommandFile(regexName, patterns, pool); - - - // - // prepare to launch sed - // - // - apr_procattr_t* attr = NULL; - apr_status_t stat = apr_procattr_create(&attr, pool); - assert(stat == APR_SUCCESS); - - stat = apr_procattr_io_set(attr, APR_NO_PIPE, APR_FULL_BLOCK, - APR_FULL_BLOCK); - assert(stat == APR_SUCCESS); - - // - // find the program on the path - // - stat = apr_procattr_cmdtype_set(attr, APR_PROGRAM_PATH); - assert(stat == APR_SUCCESS); - - // - // build the argument list - // using Q as regex separator on s command - // - const char** args = (const char**) - apr_palloc(pool, 5 * sizeof(*args)); - int i = 0; - - // - // not well documented - // but the first arg is a duplicate of the executable name - // - args[i++] = "sed"; - - - std::string regexArg("-f"); - regexArg.append(regexName); - args[i++] = apr_pstrdup(pool, regexArg.c_str()); - - // - // specify the input file - args[i++] = Transcoder::encode(in.getPath(), p); - args[i] = NULL; - - - - // - // set the output stream to the filtered file - // - apr_file_t* child_out; - apr_int32_t flags = APR_FOPEN_READ | APR_FOPEN_WRITE | - APR_FOPEN_CREATE | APR_FOPEN_TRUNCATE; - stat = out.open(&child_out, flags, APR_OS_DEFAULT, p); - assert(stat == APR_SUCCESS); - - stat = apr_procattr_child_out_set(attr, child_out, NULL); - assert(stat == APR_SUCCESS); - - // - // redirect the child's error stream to this processes' error stream - // - apr_file_t* child_err; - stat = apr_file_open_stderr(&child_err, pool); - assert(stat == 0); - stat = apr_procattr_child_err_set(attr, child_err, NULL); - assert(stat == APR_SUCCESS); - - - - apr_proc_t pid; - stat = apr_proc_create(&pid, "sed", args, NULL, attr, pool); - - if (stat != APR_SUCCESS) - { - puts("Error invoking sed, sed must be on the path in order to run unit tests"); - } - - assert(stat == APR_SUCCESS); - - apr_proc_wait(&pid, NULL, NULL, APR_WAIT); - stat = apr_file_close(child_out); - assert(stat == APR_SUCCESS); + createSedCommandFile(regexName, patterns); + + std::vector exec_args; + exec_args.push_back("sed"); + exec_args.push_back("-i"); // edit in-place + exec_args.push_back("-f"); + exec_args.push_back(regexName); + exec_args.push_back(out.getPath()); + + std::string sed_command; + for(const std::string& str : exec_args){ + sed_command.append(str); + sed_command.append(" "); + } + + // execute sed using the default shell on the system + int status = std::system(sed_command.c_str()); + assert(status == 0); } diff --git a/src/test/cpp/util/transformer.h b/src/test/cpp/util/transformer.h index e7ac49e52..a5bed6756 100644 --- a/src/test/cpp/util/transformer.h +++ b/src/test/cpp/util/transformer.h @@ -21,10 +21,6 @@ #include "filter.h" #include -extern "C" { - struct apr_pool_t; -} - namespace LOG4CXX_NS { class File; @@ -47,8 +43,7 @@ class Transformer static void copyFile(const File& in, const File& out); static void createSedCommandFile(const std::string& regexName, - const log4cxx::Filter::PatternList& patterns, - apr_pool_t* pool); + const log4cxx::Filter::PatternList& patterns); }; } From 4c6a8793d475224b373f9f6e2a1738bf84ae35d1 Mon Sep 17 00:00:00 2001 From: Robert Middleton Date: Fri, 30 Jan 2026 19:20:21 -0500 Subject: [PATCH 2/3] more removal of pool --- src/main/cpp/action.cpp | 4 +- src/main/cpp/appenderattachableimpl.cpp | 4 +- src/main/cpp/appenderskeleton.cpp | 8 +- src/main/cpp/aprinitializer.cpp | 2 +- src/main/cpp/asyncappender.cpp | 38 ++- src/main/cpp/bufferedwriter.cpp | 16 +- src/main/cpp/bytearrayoutputstream.cpp | 6 +- src/main/cpp/cacheddateformat.cpp | 20 +- src/main/cpp/classnamepatternconverter.cpp | 3 +- src/main/cpp/colorendpatternconverter.cpp | 3 +- src/main/cpp/colorstartpatternconverter.cpp | 26 +-- src/main/cpp/consoleappender.cpp | 14 +- src/main/cpp/cyclicbuffer.cpp | 10 +- src/main/cpp/dateformat.cpp | 4 +- src/main/cpp/datepatternconverter.cpp | 17 +- src/main/cpp/defaultconfigurator.cpp | 13 +- src/main/cpp/exception.cpp | 19 +- src/main/cpp/fallbackerrorhandler.cpp | 2 +- src/main/cpp/file.cpp | 180 ++++----------- src/main/cpp/fileappender.cpp | 30 ++- src/main/cpp/fileinputstream.cpp | 64 ++---- src/main/cpp/filelocationpatternconverter.cpp | 3 +- src/main/cpp/fileoutputstream.cpp | 99 +++----- src/main/cpp/filerenameaction.cpp | 4 +- src/main/cpp/filewatchdog.cpp | 16 +- src/main/cpp/filter.cpp | 2 +- src/main/cpp/filterbasedtriggeringpolicy.cpp | 4 +- src/main/cpp/fixedwindowrollingpolicy.cpp | 34 ++- src/main/cpp/gzcompressaction.cpp | 216 +++++++++--------- src/main/cpp/inputstreamreader.cpp | 4 +- src/main/cpp/integerpatternconverter.cpp | 5 +- src/main/cpp/manualtriggeringpolicy.cpp | 2 +- src/main/cpp/odbcappender.cpp | 16 +- src/main/cpp/onlyonceerrorhandler.cpp | 2 +- src/main/cpp/outputstreamwriter.cpp | 16 +- src/main/cpp/patternlayout.cpp | 15 +- src/main/cpp/rollingpolicybase.cpp | 7 +- src/main/cpp/simpledateformat.cpp | 38 ++- src/main/cpp/sizebasedtriggeringpolicy.cpp | 2 +- src/main/cpp/smtpappender.cpp | 10 +- src/main/cpp/socketappenderskeleton.cpp | 34 ++- src/main/cpp/stringhelper.cpp | 4 +- src/main/cpp/syslogappender.cpp | 13 +- src/main/cpp/systemerrwriter.cpp | 6 +- src/main/cpp/systemoutwriter.cpp | 14 +- src/main/cpp/telnetappender.cpp | 23 +- src/main/cpp/writerappender.cpp | 25 +- src/main/cpp/zipcompressaction.cpp | 174 +++++++------- src/main/include/log4cxx/appender.h | 3 +- src/main/include/log4cxx/appenderskeleton.h | 8 +- src/main/include/log4cxx/asyncappender.h | 5 +- src/main/include/log4cxx/consoleappender.h | 2 +- src/main/include/log4cxx/db/odbcappender.h | 20 +- src/main/include/log4cxx/file.h | 50 ++-- src/main/include/log4cxx/fileappender.h | 14 +- .../log4cxx/helpers/appenderattachableimpl.h | 3 +- .../include/log4cxx/helpers/bufferedwriter.h | 6 +- .../log4cxx/helpers/bytearrayoutputstream.h | 6 +- .../log4cxx/helpers/cacheddateformat.h | 18 +- src/main/include/log4cxx/helpers/dateformat.h | 10 +- .../log4cxx/helpers/fileoutputstream.h | 11 +- .../log4cxx/helpers/inputstreamreader.h | 6 +- .../log4cxx/helpers/onlyonceerrorhandler.h | 2 +- .../include/log4cxx/helpers/outputstream.h | 6 +- .../log4cxx/helpers/outputstreamwriter.h | 6 +- src/main/include/log4cxx/helpers/reader.h | 10 +- .../log4cxx/helpers/simpledateformat.h | 3 +- .../log4cxx/helpers/strftimedateformat.h | 3 +- .../include/log4cxx/helpers/stringhelper.h | 7 +- .../include/log4cxx/helpers/systemerrwriter.h | 10 +- .../include/log4cxx/helpers/systemoutwriter.h | 10 +- src/main/include/log4cxx/helpers/writer.h | 6 +- src/main/include/log4cxx/log4cxx.h.in | 6 +- src/main/include/log4cxx/net/smtpappender.h | 6 +- .../log4cxx/net/socketappenderskeleton.h | 8 +- src/main/include/log4cxx/net/syslogappender.h | 4 +- src/main/include/log4cxx/net/telnetappender.h | 6 +- .../pattern/classnamepatternconverter.h | 3 +- .../pattern/colorendpatternconverter.h | 3 +- .../pattern/colorstartpatternconverter.h | 3 +- .../log4cxx/pattern/datepatternconverter.h | 9 +- .../pattern/filelocationpatternconverter.h | 3 +- .../log4cxx/pattern/integerpatternconverter.h | 3 +- .../pattern/loggingeventpatternconverter.h | 9 +- .../log4cxx/pattern/patternconverter.h | 6 +- src/main/include/log4cxx/patternlayout.h | 2 +- .../log4cxx/private/appenderskeleton_priv.h | 1 - .../log4cxx/private/writerappender_priv.h | 2 +- src/main/include/log4cxx/rolling/action.h | 4 +- .../log4cxx/rolling/filerenameaction.h | 2 +- .../rolling/filterbasedtriggeringpolicy.h | 7 +- .../rolling/fixedwindowrollingpolicy.h | 15 +- .../log4cxx/rolling/gzcompressaction.h | 2 +- .../log4cxx/rolling/manualtriggeringpolicy.h | 2 +- .../include/log4cxx/rolling/rollingpolicy.h | 12 +- .../log4cxx/rolling/rollingpolicybase.h | 7 +- .../rolling/sizebasedtriggeringpolicy.h | 2 +- .../log4cxx/rolling/zipcompressaction.h | 2 +- src/main/include/log4cxx/spi/filter.h | 2 +- src/main/include/log4cxx/spi/optionhandler.h | 2 +- .../log4cxx/varia/fallbackerrorhandler.h | 2 +- src/main/include/log4cxx/writerappender.h | 10 +- src/test/cpp/util/compare.cpp | 23 +- src/test/cpp/util/compare.h | 3 +- src/test/cpp/vectorappender.cpp | 2 +- src/test/cpp/vectorappender.h | 2 +- 106 files changed, 695 insertions(+), 976 deletions(-) diff --git a/src/main/cpp/action.cpp b/src/main/cpp/action.cpp index ccc31d4a5..e9defc200 100644 --- a/src/main/cpp/action.cpp +++ b/src/main/cpp/action.cpp @@ -41,7 +41,7 @@ Action::~Action() /** * {@inheritDoc} */ -void Action::run(LOG4CXX_NS::helpers::Pool& pool1) +void Action::run() { std::lock_guard lock(m_priv->mutex); @@ -49,7 +49,7 @@ void Action::run(LOG4CXX_NS::helpers::Pool& pool1) { try { - execute(pool1); + execute(); } catch (std::exception& ex) { diff --git a/src/main/cpp/appenderattachableimpl.cpp b/src/main/cpp/appenderattachableimpl.cpp index 304b7061c..ee57165c5 100644 --- a/src/main/cpp/appenderattachableimpl.cpp +++ b/src/main/cpp/appenderattachableimpl.cpp @@ -96,7 +96,7 @@ void AppenderAttachableImpl::addAppender(const AppenderPtr newAppender) m_priv = std::make_unique(AppenderList{newAppender}); } -int AppenderAttachableImpl::appendLoopOnAppenders(const spi::LoggingEventPtr& event, Pool& p) +int AppenderAttachableImpl::appendLoopOnAppenders(const spi::LoggingEventPtr& event) { int result = 0; if (m_priv) @@ -104,7 +104,7 @@ int AppenderAttachableImpl::appendLoopOnAppenders(const spi::LoggingEventPtr& ev auto allAppenders = m_priv->getAppenders(); for (auto& appender : *allAppenders) { - appender->doAppend(event, p); + appender->doAppend(event); ++result; } } diff --git a/src/main/cpp/appenderskeleton.cpp b/src/main/cpp/appenderskeleton.cpp index 7f63cd0fe..3b0ab572d 100644 --- a/src/main/cpp/appenderskeleton.cpp +++ b/src/main/cpp/appenderskeleton.cpp @@ -88,14 +88,14 @@ bool AppenderSkeleton::isAsSevereAsThreshold(const LevelPtr& level) const return ((level == 0) || level->isGreaterOrEqual(m_priv->threshold)); } -void AppenderSkeleton::doAppend(const spi::LoggingEventPtr& event, Pool& pool1) +void AppenderSkeleton::doAppend(const spi::LoggingEventPtr& event) { std::lock_guard lock(m_priv->mutex); - doAppendImpl(event, pool1); + doAppendImpl(event); } -void AppenderSkeleton::doAppendImpl(const spi::LoggingEventPtr& event, Pool& pool) +void AppenderSkeleton::doAppendImpl(const spi::LoggingEventPtr& event) { if (m_priv->closed) { @@ -104,7 +104,7 @@ void AppenderSkeleton::doAppendImpl(const spi::LoggingEventPtr& event, Pool& poo } else if (isAsSevereAsThreshold(event->getLevel()) && isAccepted(event)) { - append(event, pool); + append(event); } } diff --git a/src/main/cpp/aprinitializer.cpp b/src/main/cpp/aprinitializer.cpp index 6f11aea1c..8ae85d3f6 100644 --- a/src/main/cpp/aprinitializer.cpp +++ b/src/main/cpp/aprinitializer.cpp @@ -44,7 +44,7 @@ using IdentifiedObject = std::pair; struct APRInitializer::APRInitializerPrivate{ APRInitializerPrivate() : p(0), - startTime(0), + startTime(std::chrono::system_clock::now()), tlsKey(0){ } diff --git a/src/main/cpp/asyncappender.cpp b/src/main/cpp/asyncappender.cpp index 8443d46fc..b8bc3a397 100644 --- a/src/main/cpp/asyncappender.cpp +++ b/src/main/cpp/asyncappender.cpp @@ -104,12 +104,11 @@ class DiscardSummary * * @return the new event. */ - LoggingEventPtr createEvent(Pool& p); + LoggingEventPtr createEvent(); #if LOG4CXX_ABI_VERSION <= 15 static - ::LOG4CXX_NS::spi::LoggingEventPtr createEvent(::LOG4CXX_NS::helpers::Pool& p, - size_t discardedCount); + ::LOG4CXX_NS::spi::LoggingEventPtr createEvent(size_t discardedCount); #endif /** @@ -297,16 +296,16 @@ void AsyncAppender::setOption(const LogString& option, } -void AsyncAppender::doAppend(const spi::LoggingEventPtr& event, Pool& pool1) +void AsyncAppender::doAppend(const spi::LoggingEventPtr& event) { - doAppendImpl(event, pool1); + doAppendImpl(event); } -void AsyncAppender::append(const spi::LoggingEventPtr& event, Pool& p) +void AsyncAppender::append(const spi::LoggingEventPtr& event) { if (priv->bufferSize <= 0) { - priv->appenders.appendLoopOnAppenders(event, p); + priv->appenders.appendLoopOnAppenders(event); return; } @@ -535,10 +534,10 @@ void DiscardSummary::add(const LoggingEventPtr& event) ++this->count; } -LoggingEventPtr DiscardSummary::createEvent(Pool& p) +LoggingEventPtr DiscardSummary::createEvent() { LogString msg(LOG4CXX_STR("Discarded ")); - StringHelper::toString(this->count, p, msg); + StringHelper::toString(this->count, msg); msg.append(LOG4CXX_STR(" messages ") + this->reason + LOG4CXX_STR(" including: ")); msg.append(this->maxEvent->getRenderedMessage()); return std::make_shared @@ -551,11 +550,10 @@ LoggingEventPtr DiscardSummary::createEvent(Pool& p) #if LOG4CXX_ABI_VERSION <= 15 ::LOG4CXX_NS::spi::LoggingEventPtr -DiscardSummary::createEvent(::LOG4CXX_NS::helpers::Pool& p, - size_t discardedCount) +DiscardSummary::createEvent(size_t discardedCount) { LogString msg(LOG4CXX_STR("Discarded ")); - StringHelper::toString(discardedCount, p, msg); + StringHelper::toString(discardedCount, msg); msg.append(LOG4CXX_STR(" messages due to a full event buffer")); return std::make_shared( @@ -577,8 +575,7 @@ void AsyncAppender::dispatch() bool isActive = true; while (isActive) - { - Pool p; + { LoggingEventList events; events.reserve(priv->bufferSize); for (int count = 0; count < 2 && priv->dispatchedCount == priv->commitCount; ++count) @@ -608,7 +605,7 @@ void AsyncAppender::dispatch() blockedCount += priv->blockedCount; for (auto& discardItem : priv->discardMap) { - events.push_back(discardItem.second.createEvent(p)); + events.push_back(discardItem.second.createEvent()); discardCount += discardItem.second.getCount(); } priv->discardMap.clear(); @@ -618,7 +615,7 @@ void AsyncAppender::dispatch() { try { - priv->appenders.appendLoopOnAppenders(item, p); + priv->appenders.appendLoopOnAppenders(item); } catch (std::exception& ex) { @@ -640,8 +637,7 @@ void AsyncAppender::dispatch() ++iterationCount; } if (LogLog::isDebugEnabled()) - { - Pool p; + { LogString msg(LOG4CXX_STR("[") + getName() + LOG4CXX_STR("] AsyncAppender")); #ifdef _DEBUG msg += LOG4CXX_STR(" iterationCount "); @@ -654,14 +650,14 @@ void AsyncAppender::dispatch() StringHelper::toString(priv->commitCount, p, msg); #endif msg += LOG4CXX_STR(" dispatchedCount "); - StringHelper::toString(priv->dispatchedCount, p, msg); + StringHelper::toString(priv->dispatchedCount, msg); msg += LOG4CXX_STR(" discardCount "); - StringHelper::toString(discardCount, p, msg); + StringHelper::toString(discardCount, msg); msg += LOG4CXX_STR(" pendingCountHistogram"); for (auto item : pendingCountHistogram) { msg += logchar(' '); - StringHelper::toString(item, p, msg); + StringHelper::toString(item, msg); } LogLog::debug(msg); } diff --git a/src/main/cpp/bufferedwriter.cpp b/src/main/cpp/bufferedwriter.cpp index 0b9f70cb1..927ca85b8 100644 --- a/src/main/cpp/bufferedwriter.cpp +++ b/src/main/cpp/bufferedwriter.cpp @@ -49,32 +49,32 @@ BufferedWriter::~BufferedWriter() { } -void BufferedWriter::close(Pool& p) +void BufferedWriter::close() { - flush(p); - m_priv->out->close(p); + flush(); + m_priv->out->close(); } -void BufferedWriter::flush(Pool& p) +void BufferedWriter::flush() { if (m_priv->buf.length() > 0) { - m_priv->out->write(m_priv->buf, p); + m_priv->out->write(m_priv->buf); m_priv->buf.erase(m_priv->buf.begin(), m_priv->buf.end()); } } -void BufferedWriter::write(const LogString& str, Pool& p) +void BufferedWriter::write(const LogString& str) { if (m_priv->buf.length() + str.length() > m_priv->sz) { - m_priv->out->write(m_priv->buf, p); + m_priv->out->write(m_priv->buf); m_priv->buf.erase(m_priv->buf.begin(), m_priv->buf.end()); } if (str.length() > m_priv->sz) { - m_priv->out->write(str, p); + m_priv->out->write(str); } else { diff --git a/src/main/cpp/bytearrayoutputstream.cpp b/src/main/cpp/bytearrayoutputstream.cpp index 8df3c2e69..1e42dfcb0 100644 --- a/src/main/cpp/bytearrayoutputstream.cpp +++ b/src/main/cpp/bytearrayoutputstream.cpp @@ -39,15 +39,15 @@ ByteArrayOutputStream::~ByteArrayOutputStream() { } -void ByteArrayOutputStream::close(Pool& /* p */) +void ByteArrayOutputStream::close() { } -void ByteArrayOutputStream::flush(Pool& /* p */) +void ByteArrayOutputStream::flush() { } -void ByteArrayOutputStream::write(ByteBuffer& buf, Pool& /* p */ ) +void ByteArrayOutputStream::write(ByteBuffer& buf) { size_t sz = m_priv->array.size(); m_priv->array.resize(sz + buf.remaining()); diff --git a/src/main/cpp/cacheddateformat.cpp b/src/main/cpp/cacheddateformat.cpp index 197f94cf6..d7a37be9b 100644 --- a/src/main/cpp/cacheddateformat.cpp +++ b/src/main/cpp/cacheddateformat.cpp @@ -151,11 +151,11 @@ CachedDateFormat::~CachedDateFormat() {} */ int CachedDateFormat::findMillisecondStart( log4cxx_time_t time, const LogString& formatted, - const DateFormatPtr& formatter, - Pool& pool) + const DateFormatPtr& formatter) { - log4cxx_time_t slotBegin = (time / 1000000) * 1000000; + uint64_t slotBegin = (std::chrono::duration_cast(time.time_since_epoch()) / 1000000) * 1000000; + uint64_t time_u64 = std::chrono::duration_cast(time.time_since_epoch()); if (slotBegin > time) { @@ -175,7 +175,7 @@ int CachedDateFormat::findMillisecondStart( } LogString plusMagic; - formatter->format(plusMagic, slotBegin + magic, pool); + formatter->format(plusMagic, slotBegin + magic); /** * If the string lengths differ then @@ -199,7 +199,7 @@ int CachedDateFormat::findMillisecondStart( millisecondFormat(millis, formattedMillis, 0); LogString plusZero; - formatter->format(plusZero, slotBegin, pool); + formatter->format(plusZero, slotBegin); // Test if the next 1..3 characters match the magic string, main problem is that magic // available millis in formatted can overlap. Therefore the current i is not always the @@ -240,7 +240,7 @@ int CachedDateFormat::findMillisecondStart( * @param now Number of milliseconds after midnight 1 Jan 1970 GMT. * @param sbuf the string buffer to write to */ -void CachedDateFormat::format(LogString& buf, log4cxx_time_t now, Pool& p) const +void CachedDateFormat::format(LogString& buf, log4cxx_time_t now) const { // @@ -288,7 +288,7 @@ void CachedDateFormat::format(LogString& buf, log4cxx_time_t now, Pool& p) const // could not use previous value. // Call underlying formatter to format date. m_priv->cache.erase(m_priv->cache.begin(), m_priv->cache.end()); - m_priv->formatter->format(m_priv->cache, now, p); + m_priv->formatter->format(m_priv->cache, now); buf.append(m_priv->cache); m_priv->previousTime = now; m_priv->slotBegin = (m_priv->previousTime / 1000000) * 1000000; @@ -304,7 +304,7 @@ void CachedDateFormat::format(LogString& buf, log4cxx_time_t now, Pool& p) const // if (m_priv->millisecondStart >= 0) { - m_priv->millisecondStart = findMillisecondStart(now, m_priv->cache, m_priv->formatter, p); + m_priv->millisecondStart = findMillisecondStart(now, m_priv->cache, m_priv->formatter); } } @@ -340,9 +340,9 @@ void CachedDateFormat::setTimeZone(const TimeZonePtr& timeZone) -void CachedDateFormat::numberFormat(LogString& s, int n, Pool& p) const +void CachedDateFormat::numberFormat(LogString& s, int n) const { - m_priv->formatter->numberFormat(s, n, p); + m_priv->formatter->numberFormat(s, n); } diff --git a/src/main/cpp/classnamepatternconverter.cpp b/src/main/cpp/classnamepatternconverter.cpp index 27226aafc..767723fea 100644 --- a/src/main/cpp/classnamepatternconverter.cpp +++ b/src/main/cpp/classnamepatternconverter.cpp @@ -48,8 +48,7 @@ PatternConverterPtr ClassNamePatternConverter::newInstance( void ClassNamePatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& /* p */) const + LogString& toAppendTo) const { int initialLength = (int)toAppendTo.length(); append(toAppendTo, event->getLocationInformation().getClassName()); diff --git a/src/main/cpp/colorendpatternconverter.cpp b/src/main/cpp/colorendpatternconverter.cpp index 6f9ac19ec..4bda11468 100644 --- a/src/main/cpp/colorendpatternconverter.cpp +++ b/src/main/cpp/colorendpatternconverter.cpp @@ -43,8 +43,7 @@ PatternConverterPtr ColorEndPatternConverter::newInstance( void ColorEndPatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& p) const + LogString& toAppendTo) const { // Reset all colors on the output(code 0) diff --git a/src/main/cpp/colorstartpatternconverter.cpp b/src/main/cpp/colorstartpatternconverter.cpp index daef2db2d..d634b85d8 100644 --- a/src/main/cpp/colorstartpatternconverter.cpp +++ b/src/main/cpp/colorstartpatternconverter.cpp @@ -31,7 +31,7 @@ IMPLEMENT_LOG4CXX_OBJECT(ColorStartPatternConverter) #define priv static_cast(m_priv.get()) -static LogString colorToANSISequence(const LogString& color, bool isForeground, Pool& pool){ +static LogString colorToANSISequence(const LogString& color, bool isForeground){ int numberToConvert = 0; if(StringHelper::equalsIgnoreCase(color, LOG4CXX_STR("BLACK"), LOG4CXX_STR("black"))){ @@ -59,11 +59,11 @@ static LogString colorToANSISequence(const LogString& color, bool isForeground, if( isForeground == false ){ numberToConvert += 10; } - StringHelper::toString(numberToConvert, pool, ret); + StringHelper::toString(numberToConvert, ret); return ret; } -static LogString graphicsModeToANSISequence(const LogString& graphicsMode, Pool& pool){ +static LogString graphicsModeToANSISequence(const LogString& graphicsMode){ int numberToConvert = 0; if(StringHelper::equalsIgnoreCase(graphicsMode, LOG4CXX_STR("BOLD"), LOG4CXX_STR("bold"))){ @@ -86,11 +86,11 @@ static LogString graphicsModeToANSISequence(const LogString& graphicsMode, Pool& return LOG4CXX_STR(""); } LogString ret; - StringHelper::toString(numberToConvert, pool, ret); + StringHelper::toString(numberToConvert, ret); return ret; } -static LogString convertSingleSequence(const LogString& sequence, Pool& pool){ +static LogString convertSingleSequence(const LogString& sequence){ LogString strInParens; bool inParens = false; bool hasParens = false; @@ -124,11 +124,11 @@ static LogString convertSingleSequence(const LogString& sequence, Pool& pool){ if(StringHelper::startsWith(sequence, LOG4CXX_STR("fg("))){ // Parse foreground - return colorToANSISequence(strInParens, true, pool); + return colorToANSISequence(strInParens, true); }else if(StringHelper::startsWith(sequence, LOG4CXX_STR("bg("))){ - return colorToANSISequence(strInParens, false, pool); + return colorToANSISequence(strInParens, false); }else{ - return graphicsModeToANSISequence(sequence, pool); + return graphicsModeToANSISequence(sequence); } } @@ -160,8 +160,7 @@ PatternConverterPtr ColorStartPatternConverter::newInstance( void ColorStartPatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& p) const + LogString& toAppendTo) const { LOG4CXX_NS::LevelPtr lvl = event->getLevel(); @@ -222,8 +221,7 @@ void ColorStartPatternConverter::setTraceColor(const LogString& color){ } void ColorStartPatternConverter::parseColor(const LogString& color, LogString* result){ - LogString lower = StringHelper::toLowerCase(color); - Pool pool; + LogString lower = StringHelper::toLowerCase(color); // If the color we are trying to parse is blank, clear our result if(StringHelper::trim(color).empty() || @@ -256,7 +254,7 @@ void ColorStartPatternConverter::parseColor(const LogString& color, LogString* r LogString tmp; for( size_t x = 0; x < color.size(); x++ ){ if(color[x] == '|' ){ - LogString toAppend = convertSingleSequence(tmp, pool); + LogString toAppend = convertSingleSequence(tmp); tmp.clear(); if(!toAppend.empty()){ result->push_back(';'); @@ -266,7 +264,7 @@ void ColorStartPatternConverter::parseColor(const LogString& color, LogString* r tmp.push_back(color[x]); } } - LogString toAppend = convertSingleSequence(tmp, pool); + LogString toAppend = convertSingleSequence(tmp); tmp.clear(); if(!toAppend.empty()){ result->push_back(';'); diff --git a/src/main/cpp/consoleappender.cpp b/src/main/cpp/consoleappender.cpp index 9e5b5b831..f4caedf71 100644 --- a/src/main/cpp/consoleappender.cpp +++ b/src/main/cpp/consoleappender.cpp @@ -48,19 +48,17 @@ ConsoleAppender::ConsoleAppender() ConsoleAppender::ConsoleAppender(const LayoutPtr& layout) : WriterAppender (std::make_unique(getSystemOut())) { - setLayout(layout); - Pool p; + setLayout(layout); setWriter(std::make_shared()); - WriterAppender::activateOptions(p); + WriterAppender::activateOptions(); } ConsoleAppender::ConsoleAppender(const LayoutPtr& layout, const LogString& target) : WriterAppender (std::make_unique(target)) { setLayout(layout); - setTarget(target); - Pool p; - ConsoleAppender::activateOptions(p); + setTarget(target); + ConsoleAppender::activateOptions(); } ConsoleAppender::~ConsoleAppender() @@ -112,7 +110,7 @@ void ConsoleAppender::targetWarn(const LogString& val) LogLog::warn(LOG4CXX_STR("Using previously set target, System.out by default.")); } -void ConsoleAppender::activateOptions(Pool& p) +void ConsoleAppender::activateOptions() { if (StringHelper::equalsIgnoreCase(_priv->target, LOG4CXX_STR("SYSTEM.OUT"), LOG4CXX_STR("system.out"))) @@ -127,7 +125,7 @@ void ConsoleAppender::activateOptions(Pool& p) setWriter(writer1); } - WriterAppender::activateOptions(p); + WriterAppender::activateOptions(); } void ConsoleAppender::setOption(const LogString& option, const LogString& value) diff --git a/src/main/cpp/cyclicbuffer.cpp b/src/main/cpp/cyclicbuffer.cpp index b27653c04..b3b9d4fff 100644 --- a/src/main/cpp/cyclicbuffer.cpp +++ b/src/main/cpp/cyclicbuffer.cpp @@ -47,9 +47,8 @@ CyclicBuffer::CyclicBuffer(int maxSize1) { if (maxSize1 < 1) { - LogString msg(LOG4CXX_STR("The maxSize argument (")); - Pool p; - StringHelper::toString(maxSize1, p, msg); + LogString msg(LOG4CXX_STR("The maxSize argument (")); + StringHelper::toString(maxSize1, msg); msg.append(LOG4CXX_STR(") is not a positive integer.")); throw IllegalArgumentException(msg); } @@ -128,9 +127,8 @@ void CyclicBuffer::resize(int newSize) { if (newSize < 0) { - LogString msg(LOG4CXX_STR("Negative array size [")); - Pool p; - StringHelper::toString(newSize, p, msg); + LogString msg(LOG4CXX_STR("Negative array size [")); + StringHelper::toString(newSize, msg); msg.append(LOG4CXX_STR("] not allowed.")); throw IllegalArgumentException(msg); } diff --git a/src/main/cpp/dateformat.cpp b/src/main/cpp/dateformat.cpp index b2a91e98c..25b8a3513 100644 --- a/src/main/cpp/dateformat.cpp +++ b/src/main/cpp/dateformat.cpp @@ -29,9 +29,9 @@ DateFormat::~DateFormat() {} void DateFormat::setTimeZone(const TimeZonePtr&) {} -void DateFormat::numberFormat(LogString& s, int n, Pool& p) const +void DateFormat::numberFormat(LogString& s, int n) const { - StringHelper::toString(n, p, s); + StringHelper::toString(n, s); } DateFormat::DateFormat() {} diff --git a/src/main/cpp/datepatternconverter.cpp b/src/main/cpp/datepatternconverter.cpp index 9f20d9cec..5e4314b92 100644 --- a/src/main/cpp/datepatternconverter.cpp +++ b/src/main/cpp/datepatternconverter.cpp @@ -146,10 +146,9 @@ PatternConverterPtr DatePatternConverter::newInstance( void DatePatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& p) const + LogString& toAppendTo) const { - priv->df->format(toAppendTo, event->getTimeStamp(), p); + priv->df->format(toAppendTo, event->getTimeStamp()); } /** @@ -157,14 +156,13 @@ void DatePatternConverter::format( */ void DatePatternConverter::format( const ObjectPtr& obj, - LogString& toAppendTo, - Pool& p) const + LogString& toAppendTo) const { DatePtr date = LOG4CXX_NS::cast(obj); if (date != NULL) { - format(date, toAppendTo, p); + format(date, toAppendTo); } else { @@ -172,7 +170,7 @@ void DatePatternConverter::format( if (event != NULL) { - format(event, toAppendTo, p); + format(event, toAppendTo); } } } @@ -184,8 +182,7 @@ void DatePatternConverter::format( */ void DatePatternConverter::format( const DatePtr& date, - LogString& toAppendTo, - Pool& p) const + LogString& toAppendTo) const { - priv->df->format(toAppendTo, date->getTime(), p); + priv->df->format(toAppendTo, date->getTime()); } diff --git a/src/main/cpp/defaultconfigurator.cpp b/src/main/cpp/defaultconfigurator.cpp index c34f3d64c..6e0b4813a 100644 --- a/src/main/cpp/defaultconfigurator.cpp +++ b/src/main/cpp/defaultconfigurator.cpp @@ -42,9 +42,8 @@ void DefaultConfigurator::setConfigurationFileName(const LogString& path) void DefaultConfigurator::setConfigurationWatchSeconds(int seconds) { - Pool p; LogString strSeconds; - StringHelper::toString(seconds, p, strSeconds); + StringHelper::toString(seconds, strSeconds); Configurator::properties().setProperty(LOG4CXX_STR("LOG4CXX_CONFIGURATION_WATCH_SECONDS"), strSeconds); } @@ -59,7 +58,6 @@ void DefaultConfigurator::configure(LoggerRepositoryPtr repository) { LogString configurationFileName = getConfigurationFileName(); - Pool pool; File configuration; if (configurationFileName.empty()) @@ -81,7 +79,7 @@ void DefaultConfigurator::configure(LoggerRepositoryPtr repository) debugMsg.append(names[i]); LogLog::debug(debugMsg); } - if (candidate.exists(pool)) + if (candidate.exists()) { configuration = candidate; break; @@ -93,7 +91,7 @@ void DefaultConfigurator::configure(LoggerRepositoryPtr repository) configuration.setPath(configurationFileName); } - if (configuration.exists(pool)) + if (configuration.exists()) { if (LogLog::isDebugEnabled()) { @@ -192,8 +190,7 @@ DefaultConfigurator::configureFromFile(const std::vector& directories { auto result = std::tuple { ConfigurationStatus::NotConfigured, LogString() }; - auto r = LogManager::getLoggerRepository(); - Pool pool; + auto r = LogManager::getLoggerRepository(); for (auto& dir : directories ) { @@ -205,7 +202,7 @@ DefaultConfigurator::configureFromFile(const std::vector& directories if (LogLog::isDebugEnabled()) LogLog::debug(LOG4CXX_STR("Checking file ") + candidate_str); - if (candidate.exists(pool)) + if (candidate.exists()) { std::get<1>(result) = candidate_str; configure(r); diff --git a/src/main/cpp/exception.cpp b/src/main/cpp/exception.cpp index 0ef952ab1..fe8cb7d9b 100644 --- a/src/main/cpp/exception.cpp +++ b/src/main/cpp/exception.cpp @@ -19,10 +19,10 @@ #include #include #include +#include #include #include #include -#include using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; @@ -106,8 +106,7 @@ RuntimeException& RuntimeException::operator=(const RuntimeException& src) LogString RuntimeException::formatMessage(log4cxx_status_t stat) { LogString s(LOG4CXX_STR("RuntimeException: return code = ")); - Pool p; - StringHelper::toString(stat, p, s); + StringHelper::toString(stat, s); return s; } @@ -183,13 +182,12 @@ LogString IOException::formatMessage(log4cxx_status_t stat) LogString Exception::makeMessage(const LogString& type, log4cxx_status_t stat) { LogString s = type; - char err_buff[1024] = {0}; - apr_strerror(stat, err_buff, sizeof(err_buff)); - if (0 == err_buff[0] || 0 == strncmp(err_buff, "APR does not understand", 23)) + char err_buff[1024] = {0}; + strerror_r(stat, err_buff, sizeof(err_buff)); + if (0 == err_buff[0]) { - s.append(LOG4CXX_STR(": error code ")); - Pool p; - StringHelper::toString(stat, p, s); + s.append(LOG4CXX_STR(": error code ")); + StringHelper::toString(stat, s); } else { @@ -294,8 +292,7 @@ InterruptedException& InterruptedException::operator=(const InterruptedException LogString InterruptedException::formatMessage(log4cxx_status_t stat) { LogString s(LOG4CXX_STR("InterruptedException: stat = ")); - Pool p; - StringHelper::toString(stat, p, s); + StringHelper::toString(stat, s); return s; } diff --git a/src/main/cpp/fallbackerrorhandler.cpp b/src/main/cpp/fallbackerrorhandler.cpp index 3d5f2bef2..ac89a88be 100644 --- a/src/main/cpp/fallbackerrorhandler.cpp +++ b/src/main/cpp/fallbackerrorhandler.cpp @@ -132,7 +132,7 @@ void FallbackErrorHandler::setBackupAppender(const AppenderPtr& backup1) } -void FallbackErrorHandler::activateOptions(Pool&) +void FallbackErrorHandler::activateOptions() { } diff --git a/src/main/cpp/file.cpp b/src/main/cpp/file.cpp index 12cf96b31..ac03996bf 100644 --- a/src/main/cpp/file.cpp +++ b/src/main/cpp/file.cpp @@ -17,12 +17,11 @@ #include #include -#include -#include #include -#include #include #include +#include +#include using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; @@ -43,7 +42,7 @@ struct File::FilePrivate{ {} LogString path; - bool autoDelete; + bool autoDelete; }; File::File() : @@ -135,9 +134,8 @@ File& File::operator=(const File& src) File::~File() { - if(m_priv->autoDelete){ - Pool p; - deleteFile(p); + if(m_priv->autoDelete){ + deleteFile(); } } @@ -166,174 +164,78 @@ LogString File::getName() const return m_priv->path; } -char* File::getPath(Pool& p) const +log4cxx_status_t File::open(std::fstream* file_stream, int flags, int perm) const { - int style = APR_FILEPATH_ENCODING_UNKNOWN; - apr_filepath_encoding(&style, p.getAPRPool()); - char* retval = NULL; - - if (style == APR_FILEPATH_ENCODING_UTF8) - { - retval = Transcoder::encodeUTF8(m_priv->path, p); - } - else - { - retval = Transcoder::encode(m_priv->path, p); - } - - return retval; + file_stream->open(m_priv->path); + if(file_stream->is_open()){ + return 0; + } + return -1; } -log4cxx_status_t File::open(apr_file_t** file, int flags, - int perm, Pool& p) const +bool File::exists() const { - return apr_file_open(file, getPath(p), flags, perm, p.getAPRPool()); + return std::filesystem::exists(m_priv->path); } - - -bool File::exists(Pool& p) const +bool File::deleteFile() const { - apr_finfo_t finfo; - apr_status_t rv = apr_stat(&finfo, getPath(p), - 0, p.getAPRPool()); - return rv == APR_SUCCESS; + return std::filesystem::remove(m_priv->path); } -char* File::convertBackSlashes(char* src) +bool File::renameTo(const File& dest) const { - for (char* c = src; *c != 0; c++) - { - if (*c == '\\') - { - *c = '/'; - } - } - - return src; + std::error_code ec; + std::filesystem::rename(m_priv->path, dest.getPath(), ec); + if(ec){ + return false; + } + return true; } -bool File::deleteFile(Pool& p) const -{ - apr_status_t rv = apr_file_remove(convertBackSlashes(getPath(p)), - p.getAPRPool()); - return rv == APR_SUCCESS; -} -bool File::renameTo(const File& dest, Pool& p) const +size_t File::length() const { - apr_status_t rv = apr_file_rename(convertBackSlashes(getPath(p)), - convertBackSlashes(dest.getPath(p)), - p.getAPRPool()); - return rv == APR_SUCCESS; + return std::filesystem::file_size(m_priv->path); } -size_t File::length(Pool& pool) const +log4cxx_time_t File::lastModified() const { - apr_finfo_t finfo; - apr_status_t rv = apr_stat(&finfo, getPath(pool), - APR_FINFO_SIZE, pool.getAPRPool()); - - if (rv == APR_SUCCESS) - { - return (size_t) finfo.size; - } - - return 0; + return std::filesystem::last_write_time(m_priv->path); } -log4cxx_time_t File::lastModified(Pool& pool) const +std::vector File::list() const { - apr_finfo_t finfo; - apr_status_t rv = apr_stat(&finfo, getPath(pool), - APR_FINFO_MTIME, pool.getAPRPool()); - - if (rv == APR_SUCCESS) - { - return finfo.mtime; - } + std::vector filenames; - return 0; -} + if(!std::filesystem::is_directory(m_priv->path)){ + return filenames; + } + for(auto const& dir_entry : std::filesystem::directory_iterator(m_priv->path)){ + LogString filename; + const std::filesystem::path file_path = dir_entry.path(); -std::vector File::list(Pool& p) const -{ - apr_dir_t* dir; - apr_finfo_t entry; - std::vector filenames; - - apr_status_t stat = apr_dir_open(&dir, - convertBackSlashes(getPath(p)), - p.getAPRPool()); + Transcoder::decode(file_path.filename(), filename); - if (stat == APR_SUCCESS) - { - int style = APR_FILEPATH_ENCODING_UNKNOWN; - apr_filepath_encoding(&style, p.getAPRPool()); - stat = apr_dir_read(&entry, APR_FINFO_DIRENT, dir); - - while (stat == APR_SUCCESS) - { - if (entry.name != NULL) - { - LogString filename; - - if (style == APR_FILEPATH_ENCODING_UTF8) - { - Transcoder::decodeUTF8(entry.name, filename); - } - else - { - Transcoder::decode(entry.name, filename); - } - - filenames.push_back(filename); - } - - stat = apr_dir_read(&entry, APR_FINFO_DIRENT, dir); - } - - stat = apr_dir_close(dir); - } + filenames.push_back(filename); + } return filenames; } -LogString File::getParent(Pool&) const +LogString File::getParent() const { - LogString::size_type slashPos = m_priv->path.rfind(LOG4CXX_STR('/')); - LogString::size_type backPos = m_priv->path.rfind(LOG4CXX_STR('\\')); - - if (slashPos == LogString::npos) - { - slashPos = backPos; - } - else - { - if (backPos != LogString::npos && backPos > slashPos) - { - slashPos = backPos; - } - } - - LogString parent; - - if (slashPos != LogString::npos && slashPos > 0) - { - parent.assign(m_priv->path, 0, slashPos); - } + LogString parent = std::filesystem::path(m_priv->path).parent_path(); return parent; } -bool File::mkdirs(Pool& p) const +bool File::mkdirs() const { - apr_status_t stat = apr_dir_make_recursive(convertBackSlashes(getPath(p)), - APR_OS_DEFAULT, p.getAPRPool()); - return stat == APR_SUCCESS; + return std::filesystem::create_directories(m_priv->path); } void File::setAutoDelete(bool autoDelete){ diff --git a/src/main/cpp/fileappender.cpp b/src/main/cpp/fileappender.cpp index b2350c73c..5e1007e63 100644 --- a/src/main/cpp/fileappender.cpp +++ b/src/main/cpp/fileappender.cpp @@ -52,8 +52,7 @@ FileAppender::FileAppender ) : WriterAppender(std::make_unique(layout1, fileName1, append1, bufferedIO1, bufferSize1)) { - Pool p; - activateOptions(p); + activateOptions(); } FileAppender::FileAppender @@ -63,15 +62,13 @@ FileAppender::FileAppender ) : WriterAppender(std::make_unique(layout1, fileName1, append1, false)) { - Pool p; - activateOptions(p); + activateOptions(); } FileAppender::FileAppender(const LayoutPtr& layout1, const LogString& fileName1) : WriterAppender(std::make_unique(layout1, fileName1)) { - Pool p; - activateOptions(p); + activateOptions(); } FileAppender::FileAppender(std::unique_ptr priv) @@ -154,13 +151,13 @@ void FileAppender::setOption(const LogString& option, } } -void FileAppender::activateOptions(Pool& p) +void FileAppender::activateOptions() { std::lock_guard lock(_priv->mutex); - activateOptionsInternal(p); + activateOptionsInternal(); } -void FileAppender::activateOptionsInternal(Pool& p) +void FileAppender::activateOptionsInternal() { int errors = 0; @@ -168,7 +165,7 @@ void FileAppender::activateOptionsInternal(Pool& p) { try { - setFileInternal(_priv->fileName, _priv->fileAppend, _priv->bufferedIO, _priv->bufferSize, p); + setFileInternal(_priv->fileName, _priv->fileAppend, _priv->bufferedIO, _priv->bufferSize); } catch (IOException& e) { @@ -191,7 +188,7 @@ void FileAppender::activateOptionsInternal(Pool& p) if (errors == 0) { - WriterAppender::activateOptions(p); + WriterAppender::activateOptions(); if (auto p = _priv->taskManager.lock()) p->value().removePeriodicTask(getName()); @@ -288,8 +285,7 @@ void FileAppender::setFileInternal( const LogString& filename, bool append1, bool bufferedIO1, - size_t bufferSize1, - Pool& p) + size_t bufferSize1) { // It does not make sense to have immediate flush and bufferedIO. if (bufferedIO1) @@ -311,7 +307,7 @@ void FileAppender::setFileInternal( { File outFile; outFile.setPath(filename); - writeBOM = !outFile.exists(p); + writeBOM = !outFile.exists(); } else { @@ -327,14 +323,14 @@ void FileAppender::setFileInternal( } catch (IOException&) { - LogString parentName = File().setPath(filename).getParent(p); + LogString parentName = File().setPath(filename).getParent(); if (!parentName.empty()) { File parentDir; parentDir.setPath(parentName); - if (!parentDir.exists(p) && parentDir.mkdirs(p)) + if (!parentDir.exists() && parentDir.mkdirs()) { outStream = std::make_shared(filename, append1); } @@ -373,7 +369,7 @@ void FileAppender::setFileInternal( _priv->bufferedIO = bufferedIO1; _priv->fileName = filename; _priv->bufferSize = (int)bufferSize1; - writeHeader(p); + writeHeader(); } diff --git a/src/main/cpp/fileinputstream.cpp b/src/main/cpp/fileinputstream.cpp index 3a1ac0911..df322a6fb 100644 --- a/src/main/cpp/fileinputstream.cpp +++ b/src/main/cpp/fileinputstream.cpp @@ -20,17 +20,16 @@ #include #include #include -#include +#include using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; struct FileInputStream::FileInputStreamPrivate { - FileInputStreamPrivate() : fileptr(nullptr) {} + FileInputStreamPrivate(){} - Pool pool; - apr_file_t* fileptr; + std::fstream m_fstream; }; IMPLEMENT_LOG4CXX_OBJECT(FileInputStream) @@ -51,13 +50,12 @@ FileInputStream::FileInputStream(const logchar* filename) : void FileInputStream::open(const LogString& filename) { - apr_fileperms_t perm = APR_OS_DEFAULT; - apr_int32_t flags = APR_READ; - apr_status_t stat = File().setPath(filename).open(&m_priv->fileptr, flags, perm, m_priv->pool); - if (stat != APR_SUCCESS) + bool success = File().setPath(filename).open(&m_priv->m_fstream, 0, 0); + + if (!success) { - throw IOException(filename, stat); + throw IOException(filename); } } @@ -65,56 +63,42 @@ void FileInputStream::open(const LogString& filename) FileInputStream::FileInputStream(const File& aFile) : m_priv(std::make_unique()) { - apr_fileperms_t perm = APR_OS_DEFAULT; - apr_int32_t flags = APR_READ; - apr_status_t stat = aFile.open(&m_priv->fileptr, flags, perm, m_priv->pool); + bool success = File().setPath(aFile.getName()).open(&m_priv->m_fstream, 0, 0); - if (stat != APR_SUCCESS) - { - throw IOException(aFile.getName(), stat); - } + if (!success) + { + throw IOException(aFile.getName()); + } } FileInputStream::~FileInputStream() { - if (m_priv->fileptr) - { - apr_file_close(m_priv->fileptr); - } + close(); } void FileInputStream::close() { - apr_status_t stat = apr_file_close(m_priv->fileptr); - - if (stat == APR_SUCCESS) - { - m_priv->fileptr = NULL; - } - else - { - throw IOException(stat); - } + if (m_priv->m_fstream.is_open()) + { + m_priv->m_fstream.close(); + } } int FileInputStream::read(ByteBuffer& buf) { - apr_size_t bytesRead = buf.remaining(); - apr_status_t stat = apr_file_read(m_priv->fileptr, buf.current(), &bytesRead); + size_t bytesRead = buf.remaining(); + size_t before_read = m_priv->m_fstream.tellg(); + m_priv->m_fstream.read(buf.current(), bytesRead); + size_t after_read = m_priv->m_fstream.tellg(); int retval = -1; - if (!APR_STATUS_IS_EOF(stat)) - { - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - + if (!m_priv->m_fstream.eof()) + { buf.position(buf.position() + bytesRead); - retval = (int)bytesRead; + retval = (int)(after_read - before_read); } return retval; diff --git a/src/main/cpp/filelocationpatternconverter.cpp b/src/main/cpp/filelocationpatternconverter.cpp index efb406646..4bd277594 100644 --- a/src/main/cpp/filelocationpatternconverter.cpp +++ b/src/main/cpp/filelocationpatternconverter.cpp @@ -41,8 +41,7 @@ PatternConverterPtr FileLocationPatternConverter::newInstance( void FileLocationPatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& /* p */ ) const + LogString& toAppendTo ) const { append(toAppendTo, event->getLocationInformation().getFileName()); } diff --git a/src/main/cpp/fileoutputstream.cpp b/src/main/cpp/fileoutputstream.cpp index d75634f57..b053be877 100644 --- a/src/main/cpp/fileoutputstream.cpp +++ b/src/main/cpp/fileoutputstream.cpp @@ -20,17 +20,16 @@ #include #include #include -#include +#include using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; struct FileOutputStream::FileOutputStreamPrivate { - FileOutputStreamPrivate() : fileptr(nullptr) {} + FileOutputStreamPrivate(){} - Pool pool; - apr_file_t* fileptr; + std::ofstream file_out; }; IMPLEMENT_LOG4CXX_OBJECT(FileOutputStream) @@ -38,98 +37,58 @@ IMPLEMENT_LOG4CXX_OBJECT(FileOutputStream) FileOutputStream::FileOutputStream(const LogString& filename, bool append) : m_priv(std::make_unique()) { - m_priv->fileptr = open(filename, append, m_priv->pool); + open(m_priv->file_out, filename, append); } FileOutputStream::FileOutputStream(const logchar* filename, bool append) : m_priv(std::make_unique()) { - m_priv->fileptr = open(filename, append, m_priv->pool); + open(m_priv->file_out, filename, append); } -apr_file_t* FileOutputStream::open(const LogString& filename, - bool append, Pool& pool) +bool FileOutputStream::open(std::ofstream& fout, const LogString& filename, + bool append) { - apr_fileperms_t perm = APR_OS_DEFAULT; - apr_int32_t flags = APR_WRITE | APR_CREATE; - - if (append) - { - flags |= APR_APPEND; - } - else - { - flags |= APR_TRUNCATE; - } - - File fn; - fn.setPath(filename); - apr_file_t* fileptr = 0; - apr_status_t stat = fn.open(&fileptr, flags, perm, pool); - - if (stat != APR_SUCCESS) - { - throw IOException(filename, stat); - } - - return fileptr; + auto open_mode = std::ios_base::out; + if(!append){ + open_mode |= std::ios_base::trunc; + }else{ + open_mode |= std::ios_base::ate; + } + fout.open(filename.c_str(), open_mode); + if(!fout.is_open()){ + throw IOException(filename); + } + + return true; } FileOutputStream::~FileOutputStream() { - if (m_priv->fileptr) - { - apr_file_close(m_priv->fileptr); - } } -void FileOutputStream::close(Pool& /* p */) +void FileOutputStream::close() { - if (m_priv->fileptr) + if (m_priv->file_out.is_open()) { - apr_status_t stat = apr_file_close(m_priv->fileptr); - - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - - m_priv->fileptr = NULL; + m_priv->file_out.close(); } } -void FileOutputStream::flush(Pool& /* p */) +void FileOutputStream::flush() { + m_priv->file_out.flush(); } -void FileOutputStream::write(ByteBuffer& buf, Pool& /* p */ ) +void FileOutputStream::write(ByteBuffer& buf) { - if (m_priv->fileptr == NULL) - { - throw NullPointerException(LOG4CXX_STR("FileOutputStream")); - } - - size_t nbytes = buf.remaining(); - size_t pos = buf.position(); + size_t nbytes = buf.remaining(); const char* data = buf.data(); - while (nbytes > 0) - { - apr_status_t stat = apr_file_write( - m_priv->fileptr, data + pos, &nbytes); - - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - - pos += nbytes; - buf.position(pos); - nbytes = buf.remaining(); - } + m_priv->file_out.write(data, nbytes); } -apr_file_t* FileOutputStream::getFilePtr() const{ - return m_priv->fileptr; +std::ofstream* FileOutputStream::getFilePtr() const{ + return &m_priv->file_out; } diff --git a/src/main/cpp/filerenameaction.cpp b/src/main/cpp/filerenameaction.cpp index c0d2d3e64..9973b74fb 100644 --- a/src/main/cpp/filerenameaction.cpp +++ b/src/main/cpp/filerenameaction.cpp @@ -46,7 +46,7 @@ FileRenameAction::FileRenameAction(const File& toRename, { } -bool FileRenameAction::execute(LOG4CXX_NS::helpers::Pool& pool1) const +bool FileRenameAction::execute() const { - return priv->source.renameTo(priv->destination, pool1); + return priv->source.renameTo(priv->destination); } diff --git a/src/main/cpp/filewatchdog.cpp b/src/main/cpp/filewatchdog.cpp index 80d3a3a32..62ecb0586 100644 --- a/src/main/cpp/filewatchdog.cpp +++ b/src/main/cpp/filewatchdog.cpp @@ -34,7 +34,7 @@ long FileWatchdog::DEFAULT_DELAY = 60000; struct FileWatchdog::FileWatchdogPrivate{ FileWatchdogPrivate(const File& file1) : - file(file1), delay(DEFAULT_DELAY), lastModif(0), + file(file1), delay(DEFAULT_DELAY), warnedAlready(false), taskName{ LOG4CXX_STR("WatchDog_") + file1.getName() } { } @@ -49,7 +49,7 @@ struct FileWatchdog::FileWatchdogPrivate{ The delay to observe between every check. By default set DEFAULT_DELAY.*/ long delay; - log4cxx_time_t lastModif; + std::chrono::time_point lastModif; bool warnedAlready; LogString taskName; ThreadUtility::ManagerWeakPtr taskManager; @@ -101,10 +101,9 @@ void FileWatchdog::checkAndConfigure() msg += m_priv->file.getPath(); msg += LOG4CXX_STR("]"); LogLog::debug(msg); - } - Pool pool1; + } - if (!m_priv->file.exists(pool1)) + if (!m_priv->file.exists()) { if (!m_priv->warnedAlready) { @@ -116,7 +115,7 @@ void FileWatchdog::checkAndConfigure() } else { - auto thisMod = m_priv->file.lastModified(pool1); + auto thisMod = m_priv->file.lastModified(); if (thisMod > m_priv->lastModif) { @@ -134,12 +133,11 @@ void FileWatchdog::start() if (!taskManager->value().hasPeriodicTask(m_priv->taskName)) { if (LogLog::isDebugEnabled()) - { - Pool p; + { LogString msg(LOG4CXX_STR("Checking [")); msg += m_priv->file.getPath(); msg += LOG4CXX_STR("] at "); - StringHelper::toString((int)m_priv->delay, p, msg); + StringHelper::toString((int)m_priv->delay, msg); msg += LOG4CXX_STR(" ms interval"); LogLog::debug(msg); } diff --git a/src/main/cpp/filter.cpp b/src/main/cpp/filter.cpp index c0d8fb2b5..2ffce973c 100644 --- a/src/main/cpp/filter.cpp +++ b/src/main/cpp/filter.cpp @@ -45,7 +45,7 @@ void Filter::setNext(const FilterPtr& newNext) m_priv->next = newNext; } -void Filter::activateOptions(Pool&) +void Filter::activateOptions() { } diff --git a/src/main/cpp/filterbasedtriggeringpolicy.cpp b/src/main/cpp/filterbasedtriggeringpolicy.cpp index ca7131cd5..af4cf6eeb 100644 --- a/src/main/cpp/filterbasedtriggeringpolicy.cpp +++ b/src/main/cpp/filterbasedtriggeringpolicy.cpp @@ -111,11 +111,11 @@ LOG4CXX_NS::spi::FilterPtr& FilterBasedTriggeringPolicy::getFilter() /** * Prepares the instance for use. */ -void FilterBasedTriggeringPolicy::activateOptions(LOG4CXX_NS::helpers::Pool& p) +void FilterBasedTriggeringPolicy::activateOptions() { for (LOG4CXX_NS::spi::FilterPtr f = m_priv->headFilter; f != NULL; f = f->getNext()) { - f->activateOptions(p); + f->activateOptions(); } } diff --git a/src/main/cpp/fixedwindowrollingpolicy.cpp b/src/main/cpp/fixedwindowrollingpolicy.cpp index 78b5c7a70..b8bbf3d8a 100644 --- a/src/main/cpp/fixedwindowrollingpolicy.cpp +++ b/src/main/cpp/fixedwindowrollingpolicy.cpp @@ -99,9 +99,9 @@ void FixedWindowRollingPolicy::setOption(const LogString& option, /** * {@inheritDoc} */ -void FixedWindowRollingPolicy::activateOptions(Pool& p) +void FixedWindowRollingPolicy::activateOptions() { - RollingPolicyBase::activateOptions(p); + RollingPolicyBase::activateOptions(); if (priv->maxIndex < priv->minIndex) { @@ -129,8 +129,7 @@ void FixedWindowRollingPolicy::activateOptions(Pool& p) */ RolloverDescriptionPtr FixedWindowRollingPolicy::initialize( const LogString& currentActiveFile, - const bool append, - Pool& pool) + const bool append) { LogString newActiveFile(currentActiveFile); priv->explicitActiveFile = false; @@ -145,7 +144,7 @@ RolloverDescriptionPtr FixedWindowRollingPolicy::initialize( { LogString buf; ObjectPtr obj = std::make_shared(priv->minIndex); - formatFileName(obj, buf, pool); + formatFileName(obj, buf); newActiveFile = buf; } @@ -159,8 +158,7 @@ RolloverDescriptionPtr FixedWindowRollingPolicy::initialize( */ RolloverDescriptionPtr FixedWindowRollingPolicy::rollover( const LogString& currentActiveFile, - const bool append, - Pool& pool) + const bool append) { RolloverDescriptionPtr desc; @@ -176,14 +174,14 @@ RolloverDescriptionPtr FixedWindowRollingPolicy::rollover( purgeStart++; } - if (!purge(purgeStart, priv->maxIndex, pool)) + if (!purge(purgeStart, priv->maxIndex)) { return desc; } LogString buf; ObjectPtr obj = std::make_shared(purgeStart); - formatFileName(obj, buf, pool); + formatFileName(obj, buf); LogString renameTo(buf); LogString compressedName(renameTo); @@ -191,8 +189,8 @@ RolloverDescriptionPtr FixedWindowRollingPolicy::rollover( if(getCreateIntermediateDirectories()){ File compressedFile(compressedName); - File compressedParent (compressedFile.getParent(pool)); - compressedParent.mkdirs(pool); + File compressedParent (compressedFile.getParent()); + compressedParent.mkdirs(); } if (StringHelper::endsWith(renameTo, LOG4CXX_STR(".gz"))) @@ -254,7 +252,7 @@ int FixedWindowRollingPolicy::getMinIndex() const * index will be deleted if needed. * @return true if purge was successful and rollover should be attempted. */ -bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex, Pool& p) const +bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex) const { int suffixLength = 0; @@ -282,21 +280,21 @@ bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex, Pool& p) const toRenameBase.setPath(lowFilename.substr(0, lowFilename.length() - suffixLength)); File* toRename = &toRenameCompressed; bool isBase = false; - bool exists = toRenameCompressed.exists(p); + bool exists = toRenameCompressed.exists(); if (suffixLength > 0) { if (exists) { - if (toRenameBase.exists(p)) + if (toRenameBase.exists()) { - toRenameBase.deleteFile(p); + toRenameBase.deleteFile(); } } else { toRename = &toRenameBase; - exists = toRenameBase.exists(p); + exists = toRenameBase.exists(); isBase = true; } } @@ -309,7 +307,7 @@ bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex, Pool& p) const // if that fails then abandon purge if (i == highIndex) { - if (!toRename->deleteFile(p)) + if (!toRename->deleteFile()) { return false; } @@ -352,7 +350,7 @@ bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex, Pool& p) const try { - if (!(*iter)->execute(p)) + if (!(*iter)->execute()) { return false; } diff --git a/src/main/cpp/gzcompressaction.cpp b/src/main/cpp/gzcompressaction.cpp index 8b30690f1..a5322befd 100644 --- a/src/main/cpp/gzcompressaction.cpp +++ b/src/main/cpp/gzcompressaction.cpp @@ -16,8 +16,6 @@ */ #include -#include -#include #include #include #include @@ -54,115 +52,115 @@ GZCompressAction::GZCompressAction(const File& src, GZCompressAction::~GZCompressAction() {} -bool GZCompressAction::execute(LOG4CXX_NS::helpers::Pool& p) const +bool GZCompressAction::execute() const { - if (priv->source.exists(p)) + if (priv->source.exists()) { - apr_pool_t* aprpool = p.getAPRPool(); - apr_procattr_t* attr; - apr_status_t stat = apr_procattr_create(&attr, aprpool); - - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - - stat = apr_procattr_io_set(attr, APR_NO_PIPE, APR_FULL_BLOCK, APR_FULL_BLOCK); - - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - - stat = apr_procattr_cmdtype_set(attr, APR_PROGRAM_PATH); - - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - - // - // set child process output to destination file - // - apr_file_t* child_out; - apr_int32_t flags = APR_FOPEN_READ | APR_FOPEN_WRITE | - APR_FOPEN_CREATE | APR_FOPEN_TRUNCATE; - stat = priv->destination.open(&child_out, flags, APR_OS_DEFAULT, p); - - if (stat != APR_SUCCESS) - { - throw IOException(priv->destination.getName(), stat); - } - - stat = apr_procattr_child_out_set(attr, child_out, NULL); - - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - - // - // redirect the child's error stream to this processes' error stream - // - apr_file_t* child_err; - stat = apr_file_open_stderr(&child_err, aprpool); - - if (stat == APR_SUCCESS) - { - stat = apr_procattr_child_err_set(attr, child_err, NULL); - - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - } - - priv->destination.setAutoDelete(true); - - const char** args = (const char**) - apr_palloc(aprpool, 4 * sizeof(*args)); - int i = 0; - args[i++] = "gzip"; - args[i++] = "-c"; - args[i++] = Transcoder::encode(priv->source.getPath(), p); - args[i++] = NULL; - - apr_proc_t pid; - stat = apr_proc_create(&pid, "gzip", args, NULL, attr, aprpool); - - if (stat != APR_SUCCESS) - { - LogLog::warn(LOG4CXX_STR("Failed to fork gzip during log rotation; leaving log file uncompressed")); - if (priv->throwIOExceptionOnForkFailure) - throw IOException(LOG4CXX_STR("gzip"), stat); - /* If we fail here (to create the gzip child process), - * skip the compression and consider the rotation to be - * otherwise successful. The caller has already rotated - * the log file (`source` here refers to the - * uncompressed, rotated path, and `destination` the - * same path with `.gz` appended). Remove the empty - * destination file and leave source as-is. - */ - stat = apr_file_close(child_out); - return true; - } - - apr_proc_wait(&pid, NULL, NULL, APR_WAIT); - stat = apr_file_close(child_out); - - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - - priv->destination.setAutoDelete(false); - - if (priv->deleteSource) - { - priv->source.deleteFile(p); - } - - return true; +// apr_pool_t* aprpool = p.getAPRPool(); +// apr_procattr_t* attr; +// apr_status_t stat = apr_procattr_create(&attr, aprpool); + +// if (stat != APR_SUCCESS) +// { +// throw IOException(stat); +// } + +// stat = apr_procattr_io_set(attr, APR_NO_PIPE, APR_FULL_BLOCK, APR_FULL_BLOCK); + +// if (stat != APR_SUCCESS) +// { +// throw IOException(stat); +// } + +// stat = apr_procattr_cmdtype_set(attr, APR_PROGRAM_PATH); + +// if (stat != APR_SUCCESS) +// { +// throw IOException(stat); +// } + +// // +// // set child process output to destination file +// // +// apr_file_t* child_out; +// apr_int32_t flags = APR_FOPEN_READ | APR_FOPEN_WRITE | +// APR_FOPEN_CREATE | APR_FOPEN_TRUNCATE; +// stat = priv->destination.open(&child_out, flags, APR_OS_DEFAULT, p); + +// if (stat != APR_SUCCESS) +// { +// throw IOException(priv->destination.getName(), stat); +// } + +// stat = apr_procattr_child_out_set(attr, child_out, NULL); + +// if (stat != APR_SUCCESS) +// { +// throw IOException(stat); +// } + +// // +// // redirect the child's error stream to this processes' error stream +// // +// apr_file_t* child_err; +// stat = apr_file_open_stderr(&child_err, aprpool); + +// if (stat == APR_SUCCESS) +// { +// stat = apr_procattr_child_err_set(attr, child_err, NULL); + +// if (stat != APR_SUCCESS) +// { +// throw IOException(stat); +// } +// } + +// priv->destination.setAutoDelete(true); + +// const char** args = (const char**) +// apr_palloc(aprpool, 4 * sizeof(*args)); +// int i = 0; +// args[i++] = "gzip"; +// args[i++] = "-c"; +// args[i++] = Transcoder::encode(priv->source.getPath(), p); +// args[i++] = NULL; + +// apr_proc_t pid; +// stat = apr_proc_create(&pid, "gzip", args, NULL, attr, aprpool); + +// if (stat != APR_SUCCESS) +// { +// LogLog::warn(LOG4CXX_STR("Failed to fork gzip during log rotation; leaving log file uncompressed")); +// if (priv->throwIOExceptionOnForkFailure) +// throw IOException(LOG4CXX_STR("gzip"), stat); +// /* If we fail here (to create the gzip child process), +// * skip the compression and consider the rotation to be +// * otherwise successful. The caller has already rotated +// * the log file (`source` here refers to the +// * uncompressed, rotated path, and `destination` the +// * same path with `.gz` appended). Remove the empty +// * destination file and leave source as-is. +// */ +// stat = apr_file_close(child_out); +// return true; +// } + +// apr_proc_wait(&pid, NULL, NULL, APR_WAIT); +// stat = apr_file_close(child_out); + +// if (stat != APR_SUCCESS) +// { +// throw IOException(stat); +// } + +// priv->destination.setAutoDelete(false); + +// if (priv->deleteSource) +// { +// priv->source.deleteFile(); +// } + +// return true; } return false; diff --git a/src/main/cpp/inputstreamreader.cpp b/src/main/cpp/inputstreamreader.cpp index e300202aa..54b12d26e 100644 --- a/src/main/cpp/inputstreamreader.cpp +++ b/src/main/cpp/inputstreamreader.cpp @@ -67,12 +67,12 @@ InputStreamReader::~InputStreamReader() { } -void InputStreamReader::close(Pool& ) +void InputStreamReader::close() { m_priv->in->close(); } -LogString InputStreamReader::read(Pool& p) +LogString InputStreamReader::read() { const size_t BUFSIZE = 4096; ByteBuffer buf(p.pstralloc(BUFSIZE), BUFSIZE); diff --git a/src/main/cpp/integerpatternconverter.cpp b/src/main/cpp/integerpatternconverter.cpp index 3e8d3c584..1960ae315 100644 --- a/src/main/cpp/integerpatternconverter.cpp +++ b/src/main/cpp/integerpatternconverter.cpp @@ -41,13 +41,12 @@ PatternConverterPtr IntegerPatternConverter::newInstance( void IntegerPatternConverter::format( const ObjectPtr& obj, - LogString& toAppendTo, - Pool& p) const + LogString& toAppendTo) const { IntegerPtr i = LOG4CXX_NS::cast(obj); if (i != NULL) { - StringHelper::toString(i->intValue(), p, toAppendTo); + StringHelper::toString(i->intValue(), toAppendTo); } } diff --git a/src/main/cpp/manualtriggeringpolicy.cpp b/src/main/cpp/manualtriggeringpolicy.cpp index eeb9ef1ee..2234c129f 100644 --- a/src/main/cpp/manualtriggeringpolicy.cpp +++ b/src/main/cpp/manualtriggeringpolicy.cpp @@ -37,7 +37,7 @@ bool ManualTriggeringPolicy::isTriggeringEvent(Appender* /* appender */, return false; } -void ManualTriggeringPolicy::activateOptions(Pool& /* p */ ) +void ManualTriggeringPolicy::activateOptions( ) { } diff --git a/src/main/cpp/odbcappender.cpp b/src/main/cpp/odbcappender.cpp index 24a2c528a..6ba873027 100644 --- a/src/main/cpp/odbcappender.cpp +++ b/src/main/cpp/odbcappender.cpp @@ -66,8 +66,7 @@ using namespace LOG4CXX_NS::spi; using namespace LOG4CXX_NS::pattern; SQLException::SQLException(short fHandleType, - void* hInput, const char* prolog, - LOG4CXX_NS::helpers::Pool& p) + void* hInput, const char* prolog) : Exception(formatMessage(fHandleType, hInput, prolog, p)) { } @@ -84,7 +83,7 @@ SQLException::SQLException(const SQLException& src) } const char* SQLException::formatMessage(short fHandleType, - void* hInput, const char* prolog, LOG4CXX_NS::helpers::Pool& p) + void* hInput, const char* prolog) { std::string strReturn(prolog); strReturn.append(" - "); @@ -110,7 +109,8 @@ const char* SQLException::formatMessage(short fHandleType, strReturn.append("log4cxx built without ODBC support"); #endif - return apr_pstrdup((apr_pool_t*) p.getAPRPool(), strReturn.c_str()); +// return apr_pstrdup((apr_pool_t*) p.getAPRPool(), strReturn.c_str()); + return nullptr; } @@ -212,7 +212,7 @@ bool ODBCAppender::requiresLayout() const return false; } -void ODBCAppender::activateOptions(LOG4CXX_NS::helpers::Pool&) +void ODBCAppender::activateOptions() { #if !LOG4CXX_HAVE_ODBC LogLog::error(LOG4CXX_STR("Can not activate ODBCAppender unless compiled with ODBC support.")); @@ -254,7 +254,7 @@ void ODBCAppender::activateOptions(LOG4CXX_NS::helpers::Pool&) } -void ODBCAppender::append(const spi::LoggingEventPtr& event, LOG4CXX_NS::helpers::Pool& p) +void ODBCAppender::append(const spi::LoggingEventPtr& event) { #if LOG4CXX_HAVE_ODBC _priv->buffer.push_back(event); @@ -268,12 +268,12 @@ void ODBCAppender::append(const spi::LoggingEventPtr& event, LOG4CXX_NS::helpers } #if LOG4CXX_ABI_VERSION <= 15 -LogString ODBCAppender::getLogStatement(const spi::LoggingEventPtr& event, LOG4CXX_NS::helpers::Pool& p) const +LogString ODBCAppender::getLogStatement(const spi::LoggingEventPtr& event) const { return LogString(); } -void ODBCAppender::execute(const LogString& sql, LOG4CXX_NS::helpers::Pool& p) +void ODBCAppender::execute(const LogString& sql) { } #endif diff --git a/src/main/cpp/onlyonceerrorhandler.cpp b/src/main/cpp/onlyonceerrorhandler.cpp index ebc07abdd..96da60c74 100644 --- a/src/main/cpp/onlyonceerrorhandler.cpp +++ b/src/main/cpp/onlyonceerrorhandler.cpp @@ -41,7 +41,7 @@ void OnlyOnceErrorHandler::setLogger(const LoggerPtr&) { } -void OnlyOnceErrorHandler::activateOptions(Pool&) +void OnlyOnceErrorHandler::activateOptions() { } diff --git a/src/main/cpp/outputstreamwriter.cpp b/src/main/cpp/outputstreamwriter.cpp index 659a6c8b7..945eb82e7 100644 --- a/src/main/cpp/outputstreamwriter.cpp +++ b/src/main/cpp/outputstreamwriter.cpp @@ -71,24 +71,24 @@ OutputStreamWriter::~OutputStreamWriter() { } -void OutputStreamWriter::close(Pool& p) +void OutputStreamWriter::close() { - m_priv->out->close(p); + m_priv->out->close(); } -void OutputStreamWriter::flush(Pool& p) +void OutputStreamWriter::flush() { - m_priv->out->flush(p); + m_priv->out->flush(); } -void OutputStreamWriter::write(const LogString& str, Pool& p) +void OutputStreamWriter::write(const LogString& str) { if (str.empty()) return; if (CharsetEncoder::isTriviallyCopyable(str, m_priv->enc)) { ByteBuffer buf((char*)str.data(), str.size() * sizeof (logchar)); - m_priv->out->write(buf, p); + m_priv->out->write(buf); } else { @@ -113,14 +113,14 @@ void OutputStreamWriter::write(const LogString& str, Pool& p) { CharsetEncoder::encode(m_priv->enc, str, iter, buf); buf.flip(); - m_priv->out->write(buf, p); + m_priv->out->write(buf); buf.clear(); } CharsetEncoder::encode(m_priv->enc, str, iter, buf); m_priv->enc->flush(buf); buf.flip(); - m_priv->out->write(buf, p); + m_priv->out->write(buf); } } diff --git a/src/main/cpp/patternlayout.cpp b/src/main/cpp/patternlayout.cpp index 68d43c5eb..f9a0f1910 100644 --- a/src/main/cpp/patternlayout.cpp +++ b/src/main/cpp/patternlayout.cpp @@ -105,22 +105,19 @@ Constructs a PatternLayout using the supplied conversion pattern. PatternLayout::PatternLayout(const LogString& pattern) : m_priv(std::make_unique(pattern)) { - Pool pool; - activateOptions(pool); + activateOptions(); } PatternLayout::~PatternLayout() {} void PatternLayout::setConversionPattern(const LogString& pattern) { - m_priv->conversionPattern = pattern; - Pool pool; - activateOptions(pool); + m_priv->conversionPattern = pattern; + activateOptions(); } void PatternLayout::format(LogString& output, - const spi::LoggingEventPtr& event, - Pool& pool) const + const spi::LoggingEventPtr& event) const { auto& lsMsg = event->getRenderedMessage(); output.reserve(m_priv->expectedPatternLength + lsMsg.size()); @@ -133,7 +130,7 @@ void PatternLayout::format(LogString& output, converterIter++, formatterIter++) { int startField = (int)output.length(); - (*converterIter)->format(event, output, pool); + (*converterIter)->format(event, output); (*formatterIter)->format(startField, output); } @@ -179,7 +176,7 @@ void PatternLayout::setOption(const LogString& option, const LogString& value) } } -void PatternLayout::activateOptions(Pool&) +void PatternLayout::activateOptions() { LogString pat(m_priv->conversionPattern); diff --git a/src/main/cpp/rollingpolicybase.cpp b/src/main/cpp/rollingpolicybase.cpp index e6630412b..9d71be1f9 100644 --- a/src/main/cpp/rollingpolicybase.cpp +++ b/src/main/cpp/rollingpolicybase.cpp @@ -47,7 +47,7 @@ RollingPolicyBase::~RollingPolicyBase() { } -void RollingPolicyBase::activateOptions(LOG4CXX_NS::helpers::Pool& /* pool */) +void RollingPolicyBase::activateOptions() { if (m_priv->fileNamePatternStr.length() > 0) { @@ -111,8 +111,7 @@ void RollingPolicyBase::parseFileNamePattern() */ void RollingPolicyBase::formatFileName( const ObjectPtr& obj, - LogString& toAppendTo, - Pool& pool) const + LogString& toAppendTo) const { std::vector::const_iterator formatterIter = m_priv->patternFields.begin(); @@ -123,7 +122,7 @@ void RollingPolicyBase::formatFileName( converterIter++, formatterIter++) { auto startField = toAppendTo.length(); - (*converterIter)->format(obj, toAppendTo, pool); + (*converterIter)->format(obj, toAppendTo); (*formatterIter)->format((int)startField, toAppendTo); } } diff --git a/src/main/cpp/simpledateformat.cpp b/src/main/cpp/simpledateformat.cpp index 150177526..77698842a 100644 --- a/src/main/cpp/simpledateformat.cpp +++ b/src/main/cpp/simpledateformat.cpp @@ -17,8 +17,6 @@ #include #include -#include -#include #include #include #include @@ -87,12 +85,10 @@ class PatternToken /** * Appends the formatted content to the string. * @param s string to which format contribution is appended. - * @param date exploded date/time. - * @param p memory pool. + * @param date exploded date/time. */ virtual void format(LogString& s, - const apr_time_exp_t& date, - LOG4CXX_NS::helpers::Pool& p) const = 0; + const apr_time_exp_t& date) const = 0; protected: @@ -206,7 +202,7 @@ class LiteralToken : public PatternToken { } - void format( LogString& s, const apr_time_exp_t&, Pool& /* p */ ) const + void format( LogString& s, const apr_time_exp_t&) const { s.append( count, ch ); } @@ -225,7 +221,7 @@ class EraToken : public PatternToken { } - void format(LogString& s, const apr_time_exp_t& /* tm */, Pool& /* p */ ) const + void format(LogString& s, const apr_time_exp_t& /* tm */) const { s.append(1, (logchar) 0x41 /* 'A' */); s.append(1, (logchar) 0x44 /* 'D' */); @@ -243,11 +239,11 @@ class NumericToken : public PatternToken virtual int getField( const apr_time_exp_t& tm ) const = 0; - void format( LogString& s, const apr_time_exp_t& tm, Pool& p ) const + void format( LogString& s, const apr_time_exp_t& tm ) const { size_t initialLength = s.length(); - StringHelper::toString( getField( tm ), p, s ); + StringHelper::toString( getField( tm ), s ); size_t finalLength = s.length(); if ( initialLength + width > finalLength ) @@ -300,7 +296,7 @@ class AbbreviatedMonthNameToken : public PatternToken renderFacet(locale, PatternToken::incrementMonth, 'b', 0x62, "%b", names); } - void format(LogString& s, const apr_time_exp_t& tm, Pool& /* p */ ) const + void format(LogString& s, const apr_time_exp_t& tm) const { s.append( names[tm.tm_mon] ); } @@ -319,7 +315,7 @@ class FullMonthNameToken : public PatternToken renderFacet(locale, PatternToken::incrementMonth, 'B', 0x42, "%B", names); } - void format( LogString& s, const apr_time_exp_t& tm, Pool& /* p */ ) const + void format( LogString& s, const apr_time_exp_t& tm) const { s.append( names[tm.tm_mon] ); } @@ -413,7 +409,7 @@ class AbbreviatedDayNameToken : public PatternToken renderFacet(locale, PatternToken::incrementDay, 'a', 0x61, "%a", names); } - void format( LogString& s, const apr_time_exp_t& tm, Pool& /* p */ ) const + void format( LogString& s, const apr_time_exp_t& tm ) const { s.append( names[tm.tm_wday] ); } @@ -433,7 +429,7 @@ class FullDayNameToken : public PatternToken renderFacet(locale, PatternToken::incrementDay, 'A', 0x41, "%A", names); } - void format( LogString& s, const apr_time_exp_t& tm, Pool& /* p */ ) const + void format( LogString& s, const apr_time_exp_t& tm) const { s.append( names[tm.tm_wday] ); } @@ -549,7 +545,7 @@ class AMPMToken : public PatternToken renderFacet(locale, PatternToken::incrementHalfDay, 'p', 0x70, "%p", names); } - void format( LogString& s, const apr_time_exp_t& tm, Pool& /* p */ ) const + void format( LogString& s, const apr_time_exp_t& tm) const { s.append( names[tm.tm_hour / 12] ); } @@ -567,7 +563,7 @@ class GeneralTimeZoneToken : public PatternToken { } - void format( LogString& s, const apr_time_exp_t&, Pool& /* p */ ) const + void format( LogString& s, const apr_time_exp_t&) const { s.append(timeZone->getID()); } @@ -590,7 +586,7 @@ class RFC822TimeZoneToken : public PatternToken { } - void format( LogString& s, const apr_time_exp_t& tm, Pool& p ) const + void format( LogString& s, const apr_time_exp_t& tm) const { if ( tm.tm_gmtoff == 0 ) { @@ -610,14 +606,14 @@ class RFC822TimeZoneToken : public PatternToken } LogString hours; - StringHelper::toString( off / 3600, p, hours ); + StringHelper::toString( off / 3600, hours ); if( hours.size() == 1 ){ s.push_back( '0' ); } s.append(hours); LogString min; - StringHelper::toString( ( off % 3600 ) / 60, p, min ); + StringHelper::toString( ( off % 3600 ) / 60, min ); if( min.size() == 1 ){ s.push_back( '0' ); } @@ -838,7 +834,7 @@ SimpleDateFormat::~SimpleDateFormat() } -void SimpleDateFormat::format( LogString& s, log4cxx_time_t time, Pool& p ) const +void SimpleDateFormat::format( LogString& s, log4cxx_time_t time ) const { apr_time_exp_t exploded; apr_status_t stat = m_priv->timeZone->explode( & exploded, time ); @@ -847,7 +843,7 @@ void SimpleDateFormat::format( LogString& s, log4cxx_time_t time, Pool& p ) cons { for ( PatternTokenList::const_iterator iter = m_priv->pattern.begin(); iter != m_priv->pattern.end(); iter++ ) { - ( * iter )->format( s, exploded, p ); + ( * iter )->format( s, exploded ); } } } diff --git a/src/main/cpp/sizebasedtriggeringpolicy.cpp b/src/main/cpp/sizebasedtriggeringpolicy.cpp index 64788fa76..099c37963 100644 --- a/src/main/cpp/sizebasedtriggeringpolicy.cpp +++ b/src/main/cpp/sizebasedtriggeringpolicy.cpp @@ -48,7 +48,7 @@ void SizeBasedTriggeringPolicy::setMaxFileSize(size_t l) maxFileSize = l; } -void SizeBasedTriggeringPolicy::activateOptions(Pool& /* p */) +void SizeBasedTriggeringPolicy::activateOptions() { } diff --git a/src/main/cpp/smtpappender.cpp b/src/main/cpp/smtpappender.cpp index 752d25db3..220205498 100644 --- a/src/main/cpp/smtpappender.cpp +++ b/src/main/cpp/smtpappender.cpp @@ -586,7 +586,7 @@ bool SMTPAppender::asciiCheck(const LogString& value, const LogString& field) /** Activate the specified options, such as the smtp host, the recipient, from, etc. */ -void SMTPAppender::activateOptions(Pool& p) +void SMTPAppender::activateOptions() { bool activate = true; @@ -629,7 +629,7 @@ void SMTPAppender::activateOptions(Pool& p) if (activate) { - AppenderSkeleton::activateOptions(p); + AppenderSkeleton::activateOptions(); } } @@ -637,7 +637,7 @@ void SMTPAppender::activateOptions(Pool& p) Perform SMTPAppender specific appending actions, mainly adding the event to a cyclic buffer and checking if the event triggers an e-mail to be sent. */ -void SMTPAppender::append(const spi::LoggingEventPtr& event, Pool& p) +void SMTPAppender::append(const spi::LoggingEventPtr& event) { if (!checkEntryConditions()) { @@ -651,7 +651,7 @@ void SMTPAppender::append(const spi::LoggingEventPtr& event, Pool& p) if (_priv->evaluator->isTriggeringEvent(event)) { - sendBuffer(p); + sendBuffer(); } } @@ -730,7 +730,7 @@ void SMTPAppender::setBcc(const LogString& addressStr) /** Send the contents of the cyclic buffer as an e-mail message. */ -void SMTPAppender::sendBuffer(Pool& p) +void SMTPAppender::sendBuffer() { #if LOG4CXX_HAVE_LIBESMTP diff --git a/src/main/cpp/socketappenderskeleton.cpp b/src/main/cpp/socketappenderskeleton.cpp index a0bdecfaf..c664a7447 100644 --- a/src/main/cpp/socketappenderskeleton.cpp +++ b/src/main/cpp/socketappenderskeleton.cpp @@ -61,19 +61,19 @@ SocketAppenderSkeleton::~SocketAppenderSkeleton() finalize(); } -void SocketAppenderSkeleton::activateOptions(Pool& p) +void SocketAppenderSkeleton::activateOptions() { - AppenderSkeleton::activateOptions(p); + AppenderSkeleton::activateOptions(); connect(p); } void SocketAppenderSkeleton::close() { _priv->stopMonitor(); - cleanUp(_priv->pool); + cleanUp(); } -void SocketAppenderSkeleton::connect(Pool& p) +void SocketAppenderSkeleton::connect() { if (_priv->address == 0) { @@ -90,7 +90,7 @@ void SocketAppenderSkeleton::connect(Pool& p) { LogString msg(LOG4CXX_STR("Connecting to [") + _priv->address->toString() + LOG4CXX_STR(":")); - StringHelper::toString(_priv->port, p, msg); + StringHelper::toString(_priv->port, msg); msg += LOG4CXX_STR("]."); LogLog::debug(msg); } @@ -139,23 +139,20 @@ void SocketAppenderSkeleton::fireConnector() std::lock_guard lock(_priv->mutex); if (_priv->taskName.empty()) { - Pool p; _priv->taskName = _priv->name + LOG4CXX_STR(":") + _priv->address->toString() + LOG4CXX_STR(":"); - StringHelper::toString(_priv->port, p, _priv->taskName); + StringHelper::toString(_priv->port, _priv->taskName); } auto taskManager = ThreadUtility::instancePtr(); if (!taskManager->value().hasPeriodicTask(_priv->taskName)) { - Pool p; if (LogLog::isDebugEnabled()) { - Pool p; LogString msg(LOG4CXX_STR("Waiting ")); - StringHelper::toString(_priv->reconnectionDelay, p, msg); + StringHelper::toString(_priv->reconnectionDelay, msg); msg += LOG4CXX_STR(" ms before retrying [") + _priv->address->toString() + LOG4CXX_STR(":"); - StringHelper::toString(_priv->port, p, msg); + StringHelper::toString(_priv->port, msg); msg += LOG4CXX_STR("]."); LogLog::debug(msg); } @@ -175,8 +172,7 @@ void SocketAppenderSkeleton::retryConnect() pManager->value().removePeriodicTask(_priv->taskName); } else - { - Pool p; + { SocketPtr socket; try { @@ -184,17 +180,17 @@ void SocketAppenderSkeleton::retryConnect() { LogString msg(LOG4CXX_STR("Attempting connection to [") + _priv->address->toString() + LOG4CXX_STR(":")); - StringHelper::toString(_priv->port, p, msg); + StringHelper::toString(_priv->port, msg); msg += LOG4CXX_STR("]."); LogLog::debug(msg); } socket = Socket::create(_priv->address, _priv->port); - setSocket(socket, p); + setSocket(socket); if (LogLog::isDebugEnabled()) { LogString msg(LOG4CXX_STR("Connection established to [") + _priv->address->toString() + LOG4CXX_STR(":")); - StringHelper::toString(_priv->port, p, msg); + StringHelper::toString(_priv->port, msg); msg += LOG4CXX_STR("]."); LogLog::debug(msg); } @@ -212,7 +208,7 @@ void SocketAppenderSkeleton::retryConnect() { LogString msg(LOG4CXX_STR("Could not connect to [") + _priv->address->toString() + LOG4CXX_STR(":")); - StringHelper::toString(_priv->port, p, msg); + StringHelper::toString(_priv->port, msg); msg += LOG4CXX_STR("]."); LogLog::warn(msg, e); } @@ -222,10 +218,10 @@ void SocketAppenderSkeleton::retryConnect() if (LogLog::isDebugEnabled()) { LogString msg(LOG4CXX_STR("Waiting ")); - StringHelper::toString(_priv->reconnectionDelay, p, msg); + StringHelper::toString(_priv->reconnectionDelay, msg); msg += LOG4CXX_STR(" ms before retrying [") + _priv->address->toString() + LOG4CXX_STR(":"); - StringHelper::toString(_priv->port, p, msg); + StringHelper::toString(_priv->port, msg); msg += LOG4CXX_STR("]."); LogLog::debug(msg); } diff --git a/src/main/cpp/stringhelper.cpp b/src/main/cpp/stringhelper.cpp index 17321e034..0fd6f45bc 100644 --- a/src/main/cpp/stringhelper.cpp +++ b/src/main/cpp/stringhelper.cpp @@ -151,7 +151,7 @@ void StringHelper::toString(bool val, LogString& dst) } -void StringHelper::toString(int64_t n, Pool& pool, LogString& dst) +void StringHelper::toString(int64_t n, LogString& dst) { #if LOG4CXX_LOGCHAR_IS_WCHAR dst.append(std::to_wstring(n)); @@ -161,7 +161,7 @@ void StringHelper::toString(int64_t n, Pool& pool, LogString& dst) } -void StringHelper::toString(size_t n, Pool& pool, LogString& dst) +void StringHelper::toString(size_t n, LogString& dst) { #if LOG4CXX_LOGCHAR_IS_WCHAR dst.append(std::to_wstring(n)); diff --git a/src/main/cpp/syslogappender.cpp b/src/main/cpp/syslogappender.cpp index aee1ae800..34220bf12 100644 --- a/src/main/cpp/syslogappender.cpp +++ b/src/main/cpp/syslogappender.cpp @@ -82,10 +82,9 @@ void SyslogAppender::initSyslogFacilityStr() _priv->facilityStr = getFacilityString(_priv->syslogFacility); if (_priv->facilityStr.empty()) - { - Pool p; + { LogString msg(LOG4CXX_STR("\"")); - StringHelper::toString(_priv->syslogFacility, p, msg); + StringHelper::toString(_priv->syslogFacility, msg); msg.append(LOG4CXX_STR("\" is an unknown syslog facility. Defaulting to \"USER\".")); LogLog::warn(msg); _priv->syslogFacility = LOG_USER; @@ -271,7 +270,7 @@ int SyslogAppender::getFacility( } } -void SyslogAppender::append(const spi::LoggingEventPtr& event, Pool& p) +void SyslogAppender::append(const spi::LoggingEventPtr& event) { if (!isAsSevereAsThreshold(event->getLevel())) { @@ -280,7 +279,7 @@ void SyslogAppender::append(const spi::LoggingEventPtr& event, Pool& p) LogString msg; std::string encoded; - _priv->layout->format(msg, event, p); + _priv->layout->format(msg, event); Transcoder::encode(msg, encoded); @@ -355,7 +354,7 @@ void SyslogAppender::append(const spi::LoggingEventPtr& event, Pool& p) for (auto const& item : packets) { LogString sbuf(1, 0x3C /* '<' */); - StringHelper::toString((_priv->syslogFacility | event->getLevel()->getSyslogEquivalent()), p, sbuf); + StringHelper::toString((_priv->syslogFacility | event->getLevel()->getSyslogEquivalent()), sbuf); sbuf.append(1, (logchar) 0x3E /* '>' */); if (_priv->facilityPrinting) @@ -368,7 +367,7 @@ void SyslogAppender::append(const spi::LoggingEventPtr& event, Pool& p) } } -void SyslogAppender::activateOptions(Pool&) +void SyslogAppender::activateOptions() { } diff --git a/src/main/cpp/systemerrwriter.cpp b/src/main/cpp/systemerrwriter.cpp index 97f0d1081..f459e4252 100644 --- a/src/main/cpp/systemerrwriter.cpp +++ b/src/main/cpp/systemerrwriter.cpp @@ -37,16 +37,16 @@ SystemErrWriter::~SystemErrWriter() { } -void SystemErrWriter::close(Pool& /* p */) +void SystemErrWriter::close() { } -void SystemErrWriter::flush(Pool& /* p */) +void SystemErrWriter::flush() { flush(); } -void SystemErrWriter::write(const LogString& str, Pool& /* p */) +void SystemErrWriter::write(const LogString& str) { write(str); } diff --git a/src/main/cpp/systemoutwriter.cpp b/src/main/cpp/systemoutwriter.cpp index d4b40b58b..e7f56c51a 100644 --- a/src/main/cpp/systemoutwriter.cpp +++ b/src/main/cpp/systemoutwriter.cpp @@ -37,18 +37,18 @@ SystemOutWriter::~SystemOutWriter() { } -void SystemOutWriter::close(Pool& /* p */ ) +void SystemOutWriter::close() { } -void SystemOutWriter::flush(Pool& /* p */ ) +void SystemOutWriter::flush() { - flush(); + flush(); } -void SystemOutWriter::write(const LogString& str, Pool& /* p */ ) +void SystemOutWriter::write(const LogString& str) { - write(str); + write(str); } bool SystemOutWriter::isWide() @@ -62,7 +62,7 @@ bool SystemOutWriter::isWide() #endif } -void SystemOutWriter::write(const LogString& str) +void SystemOutWriter::write_raw(const LogString& str) { #if LOG4CXX_WCHAR_T_API @@ -78,7 +78,7 @@ void SystemOutWriter::write(const LogString& str) fputs(msg.c_str(), stdout); } -void SystemOutWriter::flush() +void SystemOutWriter::flush_raw() { fflush(stdout); } diff --git a/src/main/cpp/telnetappender.cpp b/src/main/cpp/telnetappender.cpp index cc3b14394..52eff768a 100644 --- a/src/main/cpp/telnetappender.cpp +++ b/src/main/cpp/telnetappender.cpp @@ -110,7 +110,7 @@ TelnetAppender::~TelnetAppender() finalize(); } -void TelnetAppender::activateOptions(Pool& /* p */) +void TelnetAppender::activateOptions() { if (_priv->serverSocket == NULL) { @@ -203,7 +203,7 @@ void TelnetAppender::write(ByteBuffer& buf) } } -void TelnetAppender::writeStatus(const SocketPtr& socket, const LogString& msg, Pool& p) +void TelnetAppender::writeStatus(const SocketPtr& socket, const LogString& msg) { size_t bytesSize = msg.size() * 2; char* bytes = p.pstralloc(bytesSize); @@ -220,7 +220,7 @@ void TelnetAppender::writeStatus(const SocketPtr& socket, const LogString& msg, } } -void TelnetAppender::append(const spi::LoggingEventPtr& event, Pool& p) +void TelnetAppender::append(const spi::LoggingEventPtr& event) { size_t count = _priv->activeConnections; @@ -228,7 +228,7 @@ void TelnetAppender::append(const spi::LoggingEventPtr& event, Pool& p) { LogString msg; if (_priv->layout) - _priv->layout->format(msg, event, p); + _priv->layout->format(msg, event); else msg = event->getRenderedMessage(); msg.append(LOG4CXX_STR("\r\n")); @@ -273,9 +273,8 @@ void TelnetAppender::acceptConnections() bool done = _priv->closed; if (done) - { - Pool p; - writeStatus(newClient, LOG4CXX_STR("Log closed.\r\n"), p); + { + writeStatus(newClient, LOG4CXX_STR("Log closed.\r\n")); newClient->close(); break; @@ -284,9 +283,8 @@ void TelnetAppender::acceptConnections() size_t count = _priv->activeConnections; if (count >= _priv->connections.size()) - { - Pool p; - writeStatus(newClient, LOG4CXX_STR("Too many connections.\r\n"), p); + { + writeStatus(newClient, LOG4CXX_STR("Too many connections.\r\n")); newClient->close(); } else @@ -307,11 +305,10 @@ void TelnetAppender::acceptConnections() } } - Pool p; LogString oss(LOG4CXX_STR("TelnetAppender v1.0 (")); - StringHelper::toString((int) count + 1, p, oss); + StringHelper::toString((int) count + 1, oss); oss += LOG4CXX_STR(" active connections)\r\n\r\n"); - writeStatus(newClient, oss, p); + writeStatus(newClient, oss); } } catch (InterruptedIOException&) diff --git a/src/main/cpp/writerappender.cpp b/src/main/cpp/writerappender.cpp index 1be53e871..ab7e0aff8 100644 --- a/src/main/cpp/writerappender.cpp +++ b/src/main/cpp/writerappender.cpp @@ -40,8 +40,7 @@ WriterAppender::WriterAppender() : WriterAppender::WriterAppender(const LayoutPtr& layout, helpers::WriterPtr& writer) : AppenderSkeleton (std::make_unique(layout, writer)) { - Pool p; - activateOptions(p); + activateOptions(); } WriterAppender::WriterAppender(const LayoutPtr& layout) @@ -68,7 +67,7 @@ WriterAppender::~WriterAppender() finalize(); } -void WriterAppender::activateOptions(Pool& p) +void WriterAppender::activateOptions() { int errors = 0; @@ -96,7 +95,7 @@ void WriterAppender::activateOptions(Pool& p) -void WriterAppender::append(const spi::LoggingEventPtr& event, Pool& pool1) +void WriterAppender::append(const spi::LoggingEventPtr& event) { if (!checkEntryConditions()) @@ -104,7 +103,7 @@ void WriterAppender::append(const spi::LoggingEventPtr& event, Pool& pool1) return; } - subAppend(event, pool1); + subAppend(event); } /** @@ -172,8 +171,8 @@ void WriterAppender::closeWriter() // Using the object's pool since this is a one-shot operation // and pool is likely to be reclaimed soon when appender is destructed. // - writeFooter(_priv->pool); - _priv->writer->close(_priv->pool); + writeFooter(); + _priv->writer->close(); _priv->writer = 0; } catch (IOException& e) @@ -234,10 +233,10 @@ void WriterAppender::setEncoding(const LogString& enc) _priv->encoding = enc; } -void WriterAppender::subAppend(const spi::LoggingEventPtr& event, Pool& p) +void WriterAppender::subAppend(const spi::LoggingEventPtr& event) { LogString msg; - _priv->layout->format(msg, event, p); + _priv->layout->format(msg, event); if (_priv->writer != NULL) { @@ -251,17 +250,17 @@ void WriterAppender::subAppend(const spi::LoggingEventPtr& event, Pool& p) } -void WriterAppender::writeFooter(Pool& p) +void WriterAppender::writeFooter() { if (_priv->layout != NULL) { LogString foot; - _priv->layout->appendFooter(foot, p); - _priv->writer->write(foot, p); + _priv->layout->appendFooter(foot); + _priv->writer->write(foot); } } -void WriterAppender::writeHeader(Pool& p) +void WriterAppender::writeHeader() { if (_priv->layout != NULL) { diff --git a/src/main/cpp/zipcompressaction.cpp b/src/main/cpp/zipcompressaction.cpp index febb20041..64baba1a1 100644 --- a/src/main/cpp/zipcompressaction.cpp +++ b/src/main/cpp/zipcompressaction.cpp @@ -52,98 +52,98 @@ ZipCompressAction::ZipCompressAction(const File& src, { } -bool ZipCompressAction::execute(LOG4CXX_NS::helpers::Pool& p) const +bool ZipCompressAction::execute() const { - if (!priv->source.exists(p)) + if (!priv->source.exists()) { return false; } - apr_pool_t* aprpool = p.getAPRPool(); - apr_procattr_t* attr; - apr_status_t stat = apr_procattr_create(&attr, aprpool); - - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - - stat = apr_procattr_io_set(attr, APR_NO_PIPE, APR_NO_PIPE, APR_FULL_BLOCK); - - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - - stat = apr_procattr_cmdtype_set(attr, APR_PROGRAM_PATH); - - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - - // - // redirect the child's error stream to this processes' error stream - // - apr_file_t* child_err; - stat = apr_file_open_stderr(&child_err, aprpool); - - if (stat == APR_SUCCESS) - { - stat = apr_procattr_child_err_set(attr, child_err, NULL); - - if (stat != APR_SUCCESS) - { - throw IOException(stat); - } - } - - const char** args = (const char**) - apr_palloc(aprpool, 5 * sizeof(*args)); - int i = 0; - - args[i++] = "zip"; - args[i++] = "-q"; - args[i++] = Transcoder::encode(priv->destination.getPath(), p); - args[i++] = Transcoder::encode(priv->source.getPath(), p); - args[i++] = NULL; - - if (priv->destination.exists(p)) - { - priv->destination.deleteFile(p); - } - - apr_proc_t pid; - stat = apr_proc_create(&pid, "zip", args, NULL, attr, aprpool); - - if (stat != APR_SUCCESS) - { - LogLog::warn(LOG4CXX_STR("Failed to fork zip during log rotation; leaving log file uncompressed")); - if (priv->throwIOExceptionOnForkFailure) - throw IOException(LOG4CXX_STR("zip"), stat); - /* If we fail here (to create the zip child process), - * skip the compression and consider the rotation to be - * otherwise successful. The caller has already rotated - * the log file (`source` here refers to the - * uncompressed, rotated path, and `destination` the - * same path with `.zip` appended). Remove the empty - * destination file and leave source as-is. - */ - return true; - } - - int exitCode; - apr_proc_wait(&pid, &exitCode, NULL, APR_WAIT); - - if (exitCode != APR_SUCCESS) - { - throw IOException(exitCode); - } - - if (priv->deleteSource) - { - priv->source.deleteFile(p); - } +// apr_pool_t* aprpool = p.getAPRPool(); +// apr_procattr_t* attr; +// apr_status_t stat = apr_procattr_create(&attr, aprpool); + +// if (stat != APR_SUCCESS) +// { +// throw IOException(stat); +// } + +// stat = apr_procattr_io_set(attr, APR_NO_PIPE, APR_NO_PIPE, APR_FULL_BLOCK); + +// if (stat != APR_SUCCESS) +// { +// throw IOException(stat); +// } + +// stat = apr_procattr_cmdtype_set(attr, APR_PROGRAM_PATH); + +// if (stat != APR_SUCCESS) +// { +// throw IOException(stat); +// } + +// // +// // redirect the child's error stream to this processes' error stream +// // +// apr_file_t* child_err; +// stat = apr_file_open_stderr(&child_err, aprpool); + +// if (stat == APR_SUCCESS) +// { +// stat = apr_procattr_child_err_set(attr, child_err, NULL); + +// if (stat != APR_SUCCESS) +// { +// throw IOException(stat); +// } +// } + +// const char** args = (const char**) +// apr_palloc(aprpool, 5 * sizeof(*args)); +// int i = 0; + +// args[i++] = "zip"; +// args[i++] = "-q"; +// args[i++] = Transcoder::encode(priv->destination.getPath(), p); +// args[i++] = Transcoder::encode(priv->source.getPath(), p); +// args[i++] = NULL; + +// if (priv->destination.exists()) +// { +// priv->destination.deleteFile(); +// } + +// apr_proc_t pid; +// stat = apr_proc_create(&pid, "zip", args, NULL, attr, aprpool); + +// if (stat != APR_SUCCESS) +// { +// LogLog::warn(LOG4CXX_STR("Failed to fork zip during log rotation; leaving log file uncompressed")); +// if (priv->throwIOExceptionOnForkFailure) +// throw IOException(LOG4CXX_STR("zip"), stat); +// /* If we fail here (to create the zip child process), +// * skip the compression and consider the rotation to be +// * otherwise successful. The caller has already rotated +// * the log file (`source` here refers to the +// * uncompressed, rotated path, and `destination` the +// * same path with `.zip` appended). Remove the empty +// * destination file and leave source as-is. +// */ +// return true; +// } + +// int exitCode; +// apr_proc_wait(&pid, &exitCode, NULL, APR_WAIT); + +// if (exitCode != APR_SUCCESS) +// { +// throw IOException(exitCode); +// } + +// if (priv->deleteSource) +// { +// priv->source.deleteFile(); +// } return true; } diff --git a/src/main/include/log4cxx/appender.h b/src/main/include/log4cxx/appender.h index 8e74552e6..0340bb36c 100644 --- a/src/main/include/log4cxx/appender.h +++ b/src/main/include/log4cxx/appender.h @@ -84,8 +84,7 @@ class LOG4CXX_EXPORT Appender : Loggers will call the doAppend method of appender implementations in order to log. */ - virtual void doAppend(const spi::LoggingEventPtr& event, - LOG4CXX_NS::helpers::Pool& pool) = 0; + virtual void doAppend(const spi::LoggingEventPtr& event) = 0; /** diff --git a/src/main/include/log4cxx/appenderskeleton.h b/src/main/include/log4cxx/appenderskeleton.h index 302603719..cc55e7fa2 100644 --- a/src/main/include/log4cxx/appenderskeleton.h +++ b/src/main/include/log4cxx/appenderskeleton.h @@ -48,14 +48,14 @@ class LOG4CXX_EXPORT AppenderSkeleton : method to perform actual logging. See also AppenderSkeleton::doAppend method. */ - virtual void append(const spi::LoggingEventPtr& event, helpers::Pool& p) = 0; + virtual void append(const spi::LoggingEventPtr& event) = 0; /** * Compare \c event level against the appender threshold and check that \c event is accepted. * If \c event is accepted, delegate log output to the subclass implementation of * the AppenderSkeleton#append method. * */ - void doAppendImpl(const spi::LoggingEventPtr& event, helpers::Pool& pool); + void doAppendImpl(const spi::LoggingEventPtr& event); /** * Does no attached filter deny \c event or does an attached filter accept \c event? @@ -85,7 +85,7 @@ class LOG4CXX_EXPORT AppenderSkeleton : No action is performed in this implementation. */ - void activateOptions(helpers::Pool& /* pool */) override {} + void activateOptions() override {} /** \copybrief spi::OptionHandler::setOption() @@ -157,7 +157,7 @@ class LOG4CXX_EXPORT AppenderSkeleton : * * Reimplement this method in your appender if you use a different concurrency control technique. * */ - void doAppend(const spi::LoggingEventPtr& event, helpers::Pool& pool) override; + void doAppend(const spi::LoggingEventPtr& event) override; /** Set the {@link spi::ErrorHandler ErrorHandler} for this Appender. diff --git a/src/main/include/log4cxx/asyncappender.h b/src/main/include/log4cxx/asyncappender.h index 6e3212fec..0522ffaa3 100644 --- a/src/main/include/log4cxx/asyncappender.h +++ b/src/main/include/log4cxx/asyncappender.h @@ -123,15 +123,14 @@ class LOG4CXX_EXPORT AsyncAppender : /** * Call AppenderSkeleton#doAppendImpl without acquiring a lock. */ - void doAppend(const spi::LoggingEventPtr& event, - helpers::Pool& pool1) override; + void doAppend(const spi::LoggingEventPtr& event) override; /** * Add \c event to a ring buffer. * The behaviour when the ring buffer is full * is controlled by the [Blocking property](@ref BlockingProperty) value. */ - void append(const spi::LoggingEventPtr& event, helpers::Pool& p) override; + void append(const spi::LoggingEventPtr& event) override; /** Close this AsyncAppender by interrupting the diff --git a/src/main/include/log4cxx/consoleappender.h b/src/main/include/log4cxx/consoleappender.h index 328ea8090..5e6c438f5 100644 --- a/src/main/include/log4cxx/consoleappender.h +++ b/src/main/include/log4cxx/consoleappender.h @@ -87,7 +87,7 @@ class LOG4CXX_EXPORT ConsoleAppender : public WriterAppender No action is performed in this implementation. */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; /** \copybrief WriterAppender::setOption() diff --git a/src/main/include/log4cxx/db/odbcappender.h b/src/main/include/log4cxx/db/odbcappender.h index 5a58cb3c9..8642ceddc 100644 --- a/src/main/include/log4cxx/db/odbcappender.h +++ b/src/main/include/log4cxx/db/odbcappender.h @@ -179,27 +179,25 @@ class LOG4CXX_EXPORT ODBCAppender : public AppenderSkeleton /** Activate the specified options. */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; /** * Adds the event to the buffer. When full the buffer is flushed. */ - void append(const spi::LoggingEventPtr& event, helpers::Pool&) override; + void append(const spi::LoggingEventPtr& event) override; protected: #if LOG4CXX_ABI_VERSION <= 15 /** * To be removed. */ - LogString getLogStatement(const spi::LoggingEventPtr& event, - helpers::Pool& p) const; + LogString getLogStatement(const spi::LoggingEventPtr& event) const; /** * * To be removed. * */ - virtual void execute(const LogString& sql, - LOG4CXX_NS::helpers::Pool& p) /*throw(SQLException)*/; + virtual void execute(const LogString& sql) /*throw(SQLException)*/; #endif /** * Override this to return the connection to a pool, or to clean up the @@ -216,7 +214,7 @@ class LOG4CXX_EXPORT ODBCAppender : public AppenderSkeleton * By default this creates a single connection which is held open * until the object is garbage collected. */ - virtual SQLHDBC getConnection(LOG4CXX_NS::helpers::Pool& p) /*throw(SQLException)*/; + virtual SQLHDBC getConnection() /*throw(SQLException)*/; /** * Closes the appender, flushing the buffer first then closing the default @@ -232,7 +230,7 @@ class LOG4CXX_EXPORT ODBCAppender : public AppenderSkeleton * * If a statement fails the LoggingEvent stays in the buffer! */ - virtual void flushBuffer(LOG4CXX_NS::helpers::Pool& p); + virtual void flushBuffer(); /** * Does this appender require a layout? @@ -269,11 +267,9 @@ class LOG4CXX_EXPORT ODBCAppender : public AppenderSkeleton ODBCAppender(const ODBCAppender&); ODBCAppender& operator=(const ODBCAppender&); #if LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR_T || defined(WIN32) || defined(_WIN32) - static void encode(wchar_t** dest, const LogString& src, - LOG4CXX_NS::helpers::Pool& p); + static void encode(wchar_t** dest, const LogString& src); #endif - static void encode(unsigned short** dest, const LogString& src, - LOG4CXX_NS::helpers::Pool& p); + static void encode(unsigned short** dest, const LogString& src); protected: struct ODBCAppenderPriv; diff --git a/src/main/include/log4cxx/file.h b/src/main/include/log4cxx/file.h index 3f2ab8067..7a611f47e 100644 --- a/src/main/include/log4cxx/file.h +++ b/src/main/include/log4cxx/file.h @@ -20,18 +20,13 @@ #include #include - -extern "C" { - struct apr_file_t; - struct apr_finfo_t; -} +#include namespace LOG4CXX_NS { namespace helpers { class Transcoder; -class Pool; } /** @@ -99,23 +94,20 @@ class LOG4CXX_EXPORT File ~File(); /** - * Determines if file exists. - * @param p pool. + * Determines if file exists. * @return true if file exists. */ - bool exists(LOG4CXX_NS::helpers::Pool& p) const; + bool exists() const; /** * Determines length of file. May not be accurate if file is current open. - * @param p pool. * @return length of file. */ - size_t length(LOG4CXX_NS::helpers::Pool& p) const; + size_t length() const; /** - * Determines last modification date. - * @param p pool. + * Determines last modification date. * @return length of file. */ - log4cxx_time_t lastModified(LOG4CXX_NS::helpers::Pool& p) const; + log4cxx_time_t lastModified() const; /** * Get final portion of file path. * @return file name. @@ -132,49 +124,45 @@ class LOG4CXX_EXPORT File File& setPath(const LogString&); /** - * Open file. See apr_file_open for details. - * @param file APR file handle. + * Open file. See apr_file_open for details. * @param flags flags. - * @param perm permissions. - * @param p pool. + * @param perm permissions. * @return APR_SUCCESS if successful. */ - log4cxx_status_t open(apr_file_t** file, int flags, - int perm, LOG4CXX_NS::helpers::Pool& p) const; + log4cxx_status_t open(std::fstream* fstream, int flags, + int perm) const; /** * List files if current file is a directory. * @param p pool. * @return list of files in this directory, operation of non-directory returns empty list. */ - std::vector list(LOG4CXX_NS::helpers::Pool& p) const; + std::vector list() const; /** - * Delete file. - * @param p pool. + * Delete file. * @return true if file successfully deleted. */ - bool deleteFile(LOG4CXX_NS::helpers::Pool& p) const; + bool deleteFile() const; /** * Rename file. - * @param dest new path for file. - * @param p pool. + * @param dest new path for file. * @return true if file successfully renamed. */ - bool renameTo(const File& dest, LOG4CXX_NS::helpers::Pool& p) const; + bool renameTo(const File& dest) const; /** * Get path of parent directory. * @param p pool. * @return path of parent directory. */ - LogString getParent(LOG4CXX_NS::helpers::Pool& p) const; + LogString getParent() const; /** * Make directories recursively. * @param p pool. * @return true if all requested directories existed or have been created. */ - bool mkdirs(LOG4CXX_NS::helpers::Pool& p) const; + bool mkdirs() const; /** * Set the file to be deleted when this object is destroyed. @@ -191,9 +179,7 @@ class LOG4CXX_EXPORT File bool getAutoDelete() const; private: - LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(FilePrivate, m_priv) - static char* convertBackSlashes(char*); - char* getPath(LOG4CXX_NS::helpers::Pool& p) const; + LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(FilePrivate, m_priv) }; } // namespace log4cxx diff --git a/src/main/include/log4cxx/fileappender.h b/src/main/include/log4cxx/fileappender.h index eb72f58d9..9f523db83 100644 --- a/src/main/include/log4cxx/fileappender.h +++ b/src/main/include/log4cxx/fileappender.h @@ -26,10 +26,6 @@ namespace LOG4CXX_NS { -namespace helpers -{ -class Pool; -} /** * FileAppender appends log events to a file. @@ -123,7 +119,7 @@ class LOG4CXX_EXPORT FileAppender : public WriterAppender If there was already an opened file, then the previous file is closed first. */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; /** \copybrief AppenderSkeleton::setOption() @@ -219,7 +215,7 @@ class LOG4CXX_EXPORT FileAppender : public WriterAppender static LogString stripDuplicateBackslashes(const LogString& name); protected: - void activateOptionsInternal(helpers::Pool& p); + void activateOptionsInternal(); /** Sets and opens the file where the log output will @@ -238,12 +234,10 @@ class LOG4CXX_EXPORT FileAppender : public WriterAppender @param append If true will append to fileName. Otherwise will truncate fileName. @param bufferedIO Do we do bufferedIO? - @param bufferSize How big should the IO buffer be? - @param p memory pool for operation. + @param bufferSize How big should the IO buffer be? */ void setFileInternal(const LogString& file, bool append, - bool bufferedIO, size_t bufferSize, - helpers::Pool& p); + bool bufferedIO, size_t bufferSize); void setFileInternal(const LogString& file); diff --git a/src/main/include/log4cxx/helpers/appenderattachableimpl.h b/src/main/include/log4cxx/helpers/appenderattachableimpl.h index 289512e94..a4d3378ad 100644 --- a/src/main/include/log4cxx/helpers/appenderattachableimpl.h +++ b/src/main/include/log4cxx/helpers/appenderattachableimpl.h @@ -66,8 +66,7 @@ class LOG4CXX_EXPORT AppenderAttachableImpl : /** Call the doAppend method on all attached appenders. */ - int appendLoopOnAppenders(const spi::LoggingEventPtr& event, - LOG4CXX_NS::helpers::Pool& p); + int appendLoopOnAppenders(const spi::LoggingEventPtr& event); /** * Get all previously added appenders as an Enumeration. diff --git a/src/main/include/log4cxx/helpers/bufferedwriter.h b/src/main/include/log4cxx/helpers/bufferedwriter.h index 36ae80e3e..7a5f146da 100644 --- a/src/main/include/log4cxx/helpers/bufferedwriter.h +++ b/src/main/include/log4cxx/helpers/bufferedwriter.h @@ -46,9 +46,9 @@ class LOG4CXX_EXPORT BufferedWriter : public Writer BufferedWriter(WriterPtr& out, size_t sz); virtual ~BufferedWriter(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(const LogString& str, Pool& p) override; + void close() override; + void flush() override; + void write(const LogString& str) override; WriterPtr getWriter() const; private: diff --git a/src/main/include/log4cxx/helpers/bytearrayoutputstream.h b/src/main/include/log4cxx/helpers/bytearrayoutputstream.h index 0335914da..15161fb90 100644 --- a/src/main/include/log4cxx/helpers/bytearrayoutputstream.h +++ b/src/main/include/log4cxx/helpers/bytearrayoutputstream.h @@ -48,9 +48,9 @@ class LOG4CXX_EXPORT ByteArrayOutputStream : public OutputStream ByteArrayOutputStream(); virtual ~ByteArrayOutputStream(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(ByteBuffer& buf, Pool& p) override; + void close() override; + void flush() override; + void write(ByteBuffer& buf) override; ByteList toByteArray() const; private: diff --git a/src/main/include/log4cxx/helpers/cacheddateformat.h b/src/main/include/log4cxx/helpers/cacheddateformat.h index 772ead2e8..3878e8e4b 100644 --- a/src/main/include/log4cxx/helpers/cacheddateformat.h +++ b/src/main/include/log4cxx/helpers/cacheddateformat.h @@ -100,27 +100,23 @@ class LOG4CXX_EXPORT CachedDateFormat : public LOG4CXX_NS::helpers::DateFormat * Finds start of millisecond field in formatted time. * @param time long time, must be integral number of seconds * @param formatted String corresponding formatted string - * @param formatter DateFormat date format - * @param pool pool. + * @param formatter DateFormat date format * @return int position in string of first digit of milliseconds, * -1 indicates no millisecond field, -2 indicates unrecognized * field (likely RelativeTimeDateFormat) */ static int findMillisecondStart( log4cxx_time_t time, const LogString& formatted, - const LOG4CXX_NS::helpers::DateFormatPtr& formatter, - LOG4CXX_NS::helpers::Pool& pool); + const LOG4CXX_NS::helpers::DateFormatPtr& formatter); /** * Formats a Date into a date/time string. * * @param date the date to format. - * @param sbuf the string buffer to write to. - * @param p memory pool. + * @param sbuf the string buffer to write to. */ virtual void format(LogString& sbuf, - log4cxx_time_t date, - LOG4CXX_NS::helpers::Pool& p) const; + log4cxx_time_t date) const; private: /** @@ -148,12 +144,10 @@ class LOG4CXX_EXPORT CachedDateFormat : public LOG4CXX_NS::helpers::DateFormat /** * Format an integer consistent with the format method. * @param s string to which the numeric string is appended. - * @param n integer value. - * @param p memory pool used during formatting. + * @param n integer value. */ virtual void numberFormat(LogString& s, - int n, - LOG4CXX_NS::helpers::Pool& p) const; + int n) const; /** * Gets maximum cache validity for the specified SimpleDateTime diff --git a/src/main/include/log4cxx/helpers/dateformat.h b/src/main/include/log4cxx/helpers/dateformat.h index 8a8278832..725ab841c 100644 --- a/src/main/include/log4cxx/helpers/dateformat.h +++ b/src/main/include/log4cxx/helpers/dateformat.h @@ -46,10 +46,9 @@ class LOG4CXX_EXPORT DateFormat : public Object /** * Formats an log4cxx_time_t into a date/time string. * @param s string to which the date/time string is appended. - * @param tm date to be formatted. - * @param p memory pool used during formatting. + * @param tm date to be formatted. */ - virtual void format(LogString& s, log4cxx_time_t tm, LOG4CXX_NS::helpers::Pool& p) const = 0; + virtual void format(LogString& s, log4cxx_time_t tm) const = 0; /** * Sets the time zone. @@ -60,12 +59,11 @@ class LOG4CXX_EXPORT DateFormat : public Object /** * Format an integer consistent with the format method. * @param s string to which the numeric string is appended. - * @param n integer value. - * @param p memory pool used during formatting. + * @param n integer value. * @remarks This method is used by CachedDateFormat to * format the milliseconds. */ - virtual void numberFormat(LogString& s, int n, LOG4CXX_NS::helpers::Pool& p) const; + virtual void numberFormat(LogString& s, int n) const; protected: diff --git a/src/main/include/log4cxx/helpers/fileoutputstream.h b/src/main/include/log4cxx/helpers/fileoutputstream.h index a1b15c4e0..ed09c33da 100644 --- a/src/main/include/log4cxx/helpers/fileoutputstream.h +++ b/src/main/include/log4cxx/helpers/fileoutputstream.h @@ -47,18 +47,17 @@ class LOG4CXX_EXPORT FileOutputStream : public OutputStream FileOutputStream(const logchar* filename, bool append = false); virtual ~FileOutputStream(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(ByteBuffer& buf, Pool& p) override; + void close() override; + void flush() override; + void write(ByteBuffer& buf) override; - apr_file_t* getFilePtr() const; + std::ofstream* getFilePtr() const; private: FileOutputStream(const FileOutputStream&) = delete; FileOutputStream(FileOutputStream&&) = delete; FileOutputStream& operator=(const FileOutputStream&) = delete; - static apr_file_t* open(const LogString& fn, bool append, - LOG4CXX_NS::helpers::Pool& p); + static bool open(std::ofstream& fout, const LogString& fn, bool append); }; LOG4CXX_PTR_DEF(FileOutputStream); diff --git a/src/main/include/log4cxx/helpers/inputstreamreader.h b/src/main/include/log4cxx/helpers/inputstreamreader.h index 822748aa6..32fc094cd 100644 --- a/src/main/include/log4cxx/helpers/inputstreamreader.h +++ b/src/main/include/log4cxx/helpers/inputstreamreader.h @@ -68,16 +68,14 @@ class LOG4CXX_EXPORT InputStreamReader : public Reader /** * Closes the stream. - * - * @param p The memory pool associated with the reader. */ - void close(Pool& p) override; + void close() override; /** * @return The complete stream contents as a LogString. * @param p The memory pool associated with the reader. */ - LogString read(Pool& p) override; + LogString read() override; /** * @return The name of the character encoding being used by this stream. diff --git a/src/main/include/log4cxx/helpers/onlyonceerrorhandler.h b/src/main/include/log4cxx/helpers/onlyonceerrorhandler.h index 211116681..63d580d86 100644 --- a/src/main/include/log4cxx/helpers/onlyonceerrorhandler.h +++ b/src/main/include/log4cxx/helpers/onlyonceerrorhandler.h @@ -69,7 +69,7 @@ class LOG4CXX_EXPORT OnlyOnceErrorHandler : No action is performed in this implementation. */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; /** \copybrief spi::OptionHandler::setOption() diff --git a/src/main/include/log4cxx/helpers/outputstream.h b/src/main/include/log4cxx/helpers/outputstream.h index 95d20bf5f..368b20f7b 100644 --- a/src/main/include/log4cxx/helpers/outputstream.h +++ b/src/main/include/log4cxx/helpers/outputstream.h @@ -43,9 +43,9 @@ class LOG4CXX_EXPORT OutputStream : public Object virtual ~OutputStream(); public: - virtual void close(Pool& p) = 0; - virtual void flush(Pool& p) = 0; - virtual void write(ByteBuffer& buf, Pool& p) = 0; + virtual void close() = 0; + virtual void flush() = 0; + virtual void write(ByteBuffer& buf) = 0; private: OutputStream(const OutputStream&); diff --git a/src/main/include/log4cxx/helpers/outputstreamwriter.h b/src/main/include/log4cxx/helpers/outputstreamwriter.h index 547744b96..cb5729f98 100644 --- a/src/main/include/log4cxx/helpers/outputstreamwriter.h +++ b/src/main/include/log4cxx/helpers/outputstreamwriter.h @@ -53,9 +53,9 @@ class LOG4CXX_EXPORT OutputStreamWriter : public Writer OutputStreamWriter(LOG4CXX_16_CONST OutputStreamPtr& out, LOG4CXX_16_CONST CharsetEncoderPtr& enc); ~OutputStreamWriter(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(const LogString& str, Pool& p) override; + void close() override; + void flush() override; + void write(const LogString& str) override; LogString getEncoding() const; OutputStreamPtr getOutputStreamPtr() const; diff --git a/src/main/include/log4cxx/helpers/reader.h b/src/main/include/log4cxx/helpers/reader.h index 1c5d2bdbe..e4b080851 100644 --- a/src/main/include/log4cxx/helpers/reader.h +++ b/src/main/include/log4cxx/helpers/reader.h @@ -48,16 +48,14 @@ class LOG4CXX_EXPORT Reader : public Object public: /** - * Closes the stream. - * @param p The memory pool associated with the reader. + * Closes the stream. */ - virtual void close(Pool& p) = 0; + virtual void close() = 0; /** - * @return The complete stream contents as a LogString. - * @param p The memory pool associated with the reader. + * @return The complete stream contents as a LogString. */ - virtual LogString read(Pool& p) = 0; + virtual LogString read() = 0; private: Reader(const Reader&); diff --git a/src/main/include/log4cxx/helpers/simpledateformat.h b/src/main/include/log4cxx/helpers/simpledateformat.h index 5d8730ea1..b2d63861f 100644 --- a/src/main/include/log4cxx/helpers/simpledateformat.h +++ b/src/main/include/log4cxx/helpers/simpledateformat.h @@ -85,8 +85,7 @@ class LOG4CXX_EXPORT SimpleDateFormat : public DateFormat ~SimpleDateFormat(); virtual void format(LogString& s, - log4cxx_time_t tm, - LOG4CXX_NS::helpers::Pool& p) const; + log4cxx_time_t tm) const; /** * Set time zone. diff --git a/src/main/include/log4cxx/helpers/strftimedateformat.h b/src/main/include/log4cxx/helpers/strftimedateformat.h index 44fd12056..4366313bd 100644 --- a/src/main/include/log4cxx/helpers/strftimedateformat.h +++ b/src/main/include/log4cxx/helpers/strftimedateformat.h @@ -43,8 +43,7 @@ class LOG4CXX_EXPORT StrftimeDateFormat : public DateFormat ~StrftimeDateFormat(); virtual void format(LogString& s, - log4cxx_time_t tm, - LOG4CXX_NS::helpers::Pool& p) const; + log4cxx_time_t tm) const; /** * Set time zone. diff --git a/src/main/include/log4cxx/helpers/stringhelper.h b/src/main/include/log4cxx/helpers/stringhelper.h index cc9edf391..d25c567e0 100644 --- a/src/main/include/log4cxx/helpers/stringhelper.h +++ b/src/main/include/log4cxx/helpers/stringhelper.h @@ -26,7 +26,6 @@ namespace LOG4CXX_NS { namespace helpers { -class Pool; /** String manipulation routines */ @@ -45,9 +44,9 @@ class LOG4CXX_EXPORT StringHelper static int toInt(const LogString& s); static int64_t toInt64(const LogString& s); - static void toString(int i, LOG4CXX_NS::helpers::Pool& pool, LogString& dst); - static void toString(int64_t i, LOG4CXX_NS::helpers::Pool& pool, LogString& dst); - static void toString(size_t i, LOG4CXX_NS::helpers::Pool& pool, LogString& dst); + static void toString(int i, LogString& dst); + static void toString(int64_t i, LogString& dst); + static void toString(size_t i, LogString& dst); static void toString(bool val, LogString& dst); diff --git a/src/main/include/log4cxx/helpers/systemerrwriter.h b/src/main/include/log4cxx/helpers/systemerrwriter.h index 076291db2..0bd3ba3c7 100644 --- a/src/main/include/log4cxx/helpers/systemerrwriter.h +++ b/src/main/include/log4cxx/helpers/systemerrwriter.h @@ -40,12 +40,12 @@ class LOG4CXX_EXPORT SystemErrWriter : public Writer SystemErrWriter(); virtual ~SystemErrWriter(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(const LogString& str, Pool& p) override; + void close() override; + void flush() override; + void write(const LogString& str) override; - static void write(const LogString& str); - static void flush(); + static void write_raw(const LogString& str); + static void flush_raw(); private: SystemErrWriter(const SystemErrWriter&); diff --git a/src/main/include/log4cxx/helpers/systemoutwriter.h b/src/main/include/log4cxx/helpers/systemoutwriter.h index 039a16165..81a695794 100644 --- a/src/main/include/log4cxx/helpers/systemoutwriter.h +++ b/src/main/include/log4cxx/helpers/systemoutwriter.h @@ -40,12 +40,12 @@ class LOG4CXX_EXPORT SystemOutWriter : public Writer SystemOutWriter(); ~SystemOutWriter(); - void close(Pool& p) override; - void flush(Pool& p) override; - void write(const LogString& str, Pool& p) override; + void close() override; + void flush() override; + void write(const LogString& str) override; - static void write(const LogString& str); - static void flush(); + static void write_raw(const LogString& str); + static void flush_raw(); private: SystemOutWriter(const SystemOutWriter&); SystemOutWriter& operator=(const SystemOutWriter&); diff --git a/src/main/include/log4cxx/helpers/writer.h b/src/main/include/log4cxx/helpers/writer.h index a45293161..9970aab46 100644 --- a/src/main/include/log4cxx/helpers/writer.h +++ b/src/main/include/log4cxx/helpers/writer.h @@ -43,9 +43,9 @@ class LOG4CXX_EXPORT Writer : public Object virtual ~Writer(); public: - virtual void close(Pool& p) = 0; - virtual void flush(Pool& p) = 0; - virtual void write(const LogString& str, Pool& p) = 0; + virtual void close() = 0; + virtual void flush() = 0; + virtual void write(const LogString& str) = 0; private: Writer(const Writer&); diff --git a/src/main/include/log4cxx/log4cxx.h.in b/src/main/include/log4cxx/log4cxx.h.in index f4d596f20..cdd9829f9 100644 --- a/src/main/include/log4cxx/log4cxx.h.in +++ b/src/main/include/log4cxx/log4cxx.h.in @@ -106,12 +106,14 @@ __pragma( warning( pop ) ) #cmakedefine LOG4CXX_ENABLE_APR +#include + namespace LOG4CXX_NS { /** - * log4cxx_time_t - holds the number of microseconds since 1970-01-01 + * log4cxx_time_t - a point in time */ -typedef int64_t log4cxx_time_t; +typedef std::chrono::time_point log4cxx_time_t; typedef int log4cxx_status_t; diff --git a/src/main/include/log4cxx/net/smtpappender.h b/src/main/include/log4cxx/net/smtpappender.h index e9059ee19..23c5bfebc 100644 --- a/src/main/include/log4cxx/net/smtpappender.h +++ b/src/main/include/log4cxx/net/smtpappender.h @@ -141,13 +141,13 @@ class LOG4CXX_EXPORT SMTPAppender : public AppenderSkeleton
  • a non-ascii character is detected where not permitted
  • . */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; /** Perform SMTPAppender specific appending actions, mainly adding the event to a cyclic buffer and checking if the event triggers an e-mail to be sent. */ - void append(const spi::LoggingEventPtr& event, helpers::Pool& p) override; + void append(const spi::LoggingEventPtr& event) override; void close() override; @@ -176,7 +176,7 @@ class LOG4CXX_EXPORT SMTPAppender : public AppenderSkeleton /** Send the contents of the cyclic buffer as an e-mail message. */ - void sendBuffer(LOG4CXX_NS::helpers::Pool& p); + void sendBuffer(); /** diff --git a/src/main/include/log4cxx/net/socketappenderskeleton.h b/src/main/include/log4cxx/net/socketappenderskeleton.h index ea45b0ab4..fad8a8a12 100644 --- a/src/main/include/log4cxx/net/socketappenderskeleton.h +++ b/src/main/include/log4cxx/net/socketappenderskeleton.h @@ -56,7 +56,7 @@ class LOG4CXX_EXPORT SocketAppenderSkeleton : public AppenderSkeleton Connects to the specified RemoteHost and Port. */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; void close() override; @@ -144,16 +144,16 @@ class LOG4CXX_EXPORT SocketAppenderSkeleton : public AppenderSkeleton protected: SocketAppenderSkeleton(std::unique_ptr priv); - virtual void setSocket(LOG4CXX_NS::helpers::SocketPtr& socket, LOG4CXX_NS::helpers::Pool& p) = 0; + virtual void setSocket(LOG4CXX_NS::helpers::SocketPtr& socket) = 0; - virtual void cleanUp(LOG4CXX_NS::helpers::Pool& p) = 0; + virtual void cleanUp(p) = 0; virtual int getDefaultDelay() const = 0; virtual int getDefaultPort() const = 0; private: - void connect(LOG4CXX_NS::helpers::Pool& p); + void connect(); /** The Connector will reconnect when the server becomes available again. It does this by attempting to open a new connection every diff --git a/src/main/include/log4cxx/net/syslogappender.h b/src/main/include/log4cxx/net/syslogappender.h index e4c2e8081..05d6f3d70 100644 --- a/src/main/include/log4cxx/net/syslogappender.h +++ b/src/main/include/log4cxx/net/syslogappender.h @@ -73,14 +73,14 @@ class LOG4CXX_EXPORT SyslogAppender : public AppenderSkeleton */ static int getFacility(const LogString& facilityName); - void append(const spi::LoggingEventPtr& event, helpers::Pool& p) override; + void append(const spi::LoggingEventPtr& event) override; /** \copybrief AppenderSkeleton::activateOptions() No action is performed in this implementation. */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; /** \copybrief AppenderSkeleton::setOption() diff --git a/src/main/include/log4cxx/net/telnetappender.h b/src/main/include/log4cxx/net/telnetappender.h index ce5985af9..77f176704 100644 --- a/src/main/include/log4cxx/net/telnetappender.h +++ b/src/main/include/log4cxx/net/telnetappender.h @@ -89,7 +89,7 @@ class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton Create the socket handler and wait for connections. */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; /** @@ -157,7 +157,7 @@ class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton protected: /** Send \c event to each connected client. */ - void append(const spi::LoggingEventPtr& event, helpers::Pool& p) override; + void append(const spi::LoggingEventPtr& event) override; private: // prevent copy and assignment statements @@ -165,7 +165,7 @@ class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton TelnetAppender& operator=(const TelnetAppender&); void write(helpers::ByteBuffer&); - void writeStatus(const helpers::SocketPtr& socket, const LogString& msg, helpers::Pool& p); + void writeStatus(const helpers::SocketPtr& socket, const LogString& msg); void acceptConnections(); struct TelnetAppenderPriv; diff --git a/src/main/include/log4cxx/pattern/classnamepatternconverter.h b/src/main/include/log4cxx/pattern/classnamepatternconverter.h index cacf0a40a..a8b94694c 100644 --- a/src/main/include/log4cxx/pattern/classnamepatternconverter.h +++ b/src/main/include/log4cxx/pattern/classnamepatternconverter.h @@ -58,8 +58,7 @@ class LOG4CXX_EXPORT ClassNamePatternConverter : public NamePatternConverter using NamePatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } diff --git a/src/main/include/log4cxx/pattern/colorendpatternconverter.h b/src/main/include/log4cxx/pattern/colorendpatternconverter.h index 394eaf5e9..15e1ca7b3 100644 --- a/src/main/include/log4cxx/pattern/colorendpatternconverter.h +++ b/src/main/include/log4cxx/pattern/colorendpatternconverter.h @@ -55,8 +55,7 @@ class LOG4CXX_EXPORT ColorEndPatternConverter using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } diff --git a/src/main/include/log4cxx/pattern/colorstartpatternconverter.h b/src/main/include/log4cxx/pattern/colorstartpatternconverter.h index 8f225768a..5153400f7 100644 --- a/src/main/include/log4cxx/pattern/colorstartpatternconverter.h +++ b/src/main/include/log4cxx/pattern/colorstartpatternconverter.h @@ -57,8 +57,7 @@ class LOG4CXX_EXPORT ColorStartPatternConverter using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; void setFatalColor(const LogString& color); void setErrorColor(const LogString& color); diff --git a/src/main/include/log4cxx/pattern/datepatternconverter.h b/src/main/include/log4cxx/pattern/datepatternconverter.h index 371bd0a41..c1a8a0fb5 100644 --- a/src/main/include/log4cxx/pattern/datepatternconverter.h +++ b/src/main/include/log4cxx/pattern/datepatternconverter.h @@ -79,8 +79,7 @@ class LOG4CXX_EXPORT DatePatternConverter : public LoggingEventPatternConverter * Append to \c output a textual version of the timestamp in \c event. */ void format(const spi::LoggingEventPtr& event, - LogString& output, - helpers::Pool& p) const override; + LogString& output) const override; /** * Append to \c output a textual version of the date or timestamp in \c obj. @@ -88,15 +87,13 @@ class LOG4CXX_EXPORT DatePatternConverter : public LoggingEventPatternConverter * Nothing is added to \c output if \c obj does not point to a Date or spi::LoggingEvent. */ void format(const helpers::ObjectPtr& obj, - LogString& output, - helpers::Pool& p) const override; + LogString& output) const override; /** * Append to \c toAppendTo a textual version of \c date. */ void format(const helpers::DatePtr& date, - LogString& toAppendTo, - helpers::Pool& p) const; + LogString& toAppendTo) const; }; LOG4CXX_PTR_DEF(DatePatternConverter); diff --git a/src/main/include/log4cxx/pattern/filelocationpatternconverter.h b/src/main/include/log4cxx/pattern/filelocationpatternconverter.h index b68b7bcda..2d274b876 100644 --- a/src/main/include/log4cxx/pattern/filelocationpatternconverter.h +++ b/src/main/include/log4cxx/pattern/filelocationpatternconverter.h @@ -55,8 +55,7 @@ class LOG4CXX_EXPORT FileLocationPatternConverter using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } diff --git a/src/main/include/log4cxx/pattern/integerpatternconverter.h b/src/main/include/log4cxx/pattern/integerpatternconverter.h index f5c775d83..0c486b84c 100644 --- a/src/main/include/log4cxx/pattern/integerpatternconverter.h +++ b/src/main/include/log4cxx/pattern/integerpatternconverter.h @@ -52,8 +52,7 @@ class LOG4CXX_EXPORT IntegerPatternConverter : public PatternConverter const std::vector& options); void format(const helpers::ObjectPtr& obj, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; LOG4CXX_PTR_DEF(IntegerPatternConverter); diff --git a/src/main/include/log4cxx/pattern/loggingeventpatternconverter.h b/src/main/include/log4cxx/pattern/loggingeventpatternconverter.h index 76bb0bd6d..91c2860b2 100644 --- a/src/main/include/log4cxx/pattern/loggingeventpatternconverter.h +++ b/src/main/include/log4cxx/pattern/loggingeventpatternconverter.h @@ -57,17 +57,14 @@ class LOG4CXX_EXPORT LoggingEventPatternConverter : public PatternConverter /** * Formats an event into a string buffer. * @param event event to format, may not be null. - * @param toAppendTo string buffer to which the formatted event will be appended. May not be null. - * @param p pool for memory allocations needing during format. + * @param toAppendTo string buffer to which the formatted event will be appended. May not be null. */ virtual void format( const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const = 0; + LogString& toAppendTo) const = 0; void format(const helpers::ObjectPtr& obj, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; /** * Normally pattern converters are not meant to handle Exceptions although diff --git a/src/main/include/log4cxx/pattern/patternconverter.h b/src/main/include/log4cxx/pattern/patternconverter.h index 9bcf8c845..160c357b1 100644 --- a/src/main/include/log4cxx/pattern/patternconverter.h +++ b/src/main/include/log4cxx/pattern/patternconverter.h @@ -68,12 +68,10 @@ class LOG4CXX_EXPORT PatternConverter : public virtual helpers::Object /** * Formats an object into a string buffer. * @param obj event to format, may not be null. - * @param toAppendTo string buffer to which the formatted event will be appended. May not be null. - * @param p pool for any allocations necessary during formatting. + * @param toAppendTo string buffer to which the formatted event will be appended. May not be null. */ virtual void format(const helpers::ObjectPtr& obj, - LogString& toAppendTo, - helpers::Pool& p) const = 0; + LogString& toAppendTo) const = 0; /** * This method returns the name of the conversion pattern. diff --git a/src/main/include/log4cxx/patternlayout.h b/src/main/include/log4cxx/patternlayout.h index e11917bff..bf03655dc 100644 --- a/src/main/include/log4cxx/patternlayout.h +++ b/src/main/include/log4cxx/patternlayout.h @@ -484,7 +484,7 @@ class LOG4CXX_EXPORT PatternLayout : public Layout Calls createPatternParser */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; /** \copybrief spi::OptionHandler::setOption() diff --git a/src/main/include/log4cxx/private/appenderskeleton_priv.h b/src/main/include/log4cxx/private/appenderskeleton_priv.h index cba7bec45..a7f90a580 100644 --- a/src/main/include/log4cxx/private/appenderskeleton_priv.h +++ b/src/main/include/log4cxx/private/appenderskeleton_priv.h @@ -68,7 +68,6 @@ struct AppenderSkeleton::AppenderSkeletonPrivate */ bool closed; - LOG4CXX_NS::helpers::Pool pool; mutable std::recursive_mutex mutex; bool warnedClosed = false; diff --git a/src/main/include/log4cxx/private/writerappender_priv.h b/src/main/include/log4cxx/private/writerappender_priv.h index c9484299b..de1def482 100644 --- a/src/main/include/log4cxx/private/writerappender_priv.h +++ b/src/main/include/log4cxx/private/writerappender_priv.h @@ -53,7 +53,7 @@ struct WriterAppender::WriterAppenderPriv : public AppenderSkeleton::AppenderSke { std::lock_guard lock(mutex); if (writer) - writer->flush(pool); + writer->flush(); } /** diff --git a/src/main/include/log4cxx/rolling/action.h b/src/main/include/log4cxx/rolling/action.h index c89077f92..8ae6933f4 100644 --- a/src/main/include/log4cxx/rolling/action.h +++ b/src/main/include/log4cxx/rolling/action.h @@ -55,9 +55,9 @@ class Action : public virtual LOG4CXX_NS::helpers::Object * * @return true if successful. */ - virtual bool execute(LOG4CXX_NS::helpers::Pool& pool) const = 0; + virtual bool execute() const = 0; - void run(LOG4CXX_NS::helpers::Pool& pool); + void run(); void close(); diff --git a/src/main/include/log4cxx/rolling/filerenameaction.h b/src/main/include/log4cxx/rolling/filerenameaction.h index e17c8d99c..9ef6164be 100644 --- a/src/main/include/log4cxx/rolling/filerenameaction.h +++ b/src/main/include/log4cxx/rolling/filerenameaction.h @@ -49,7 +49,7 @@ class FileRenameAction : public Action * * @return true if successful. */ - bool execute(LOG4CXX_NS::helpers::Pool& pool) const override; + bool execute() const override; }; LOG4CXX_PTR_DEF(FileRenameAction); diff --git a/src/main/include/log4cxx/rolling/filterbasedtriggeringpolicy.h b/src/main/include/log4cxx/rolling/filterbasedtriggeringpolicy.h index 8ff908eeb..5b708aaf3 100644 --- a/src/main/include/log4cxx/rolling/filterbasedtriggeringpolicy.h +++ b/src/main/include/log4cxx/rolling/filterbasedtriggeringpolicy.h @@ -29,11 +29,6 @@ namespace LOG4CXX_NS class File; -namespace helpers -{ -class Pool; -} - namespace rolling { @@ -105,7 +100,7 @@ class LOG4CXX_EXPORT FilterBasedTriggeringPolicy : public TriggeringPolicy Activates all attached filters. */ - void activateOptions(helpers::Pool&) override; + void activateOptions() override; /** \copybrief spi::OptionHandler::setOption() diff --git a/src/main/include/log4cxx/rolling/fixedwindowrollingpolicy.h b/src/main/include/log4cxx/rolling/fixedwindowrollingpolicy.h index 13e54da45..afd4405b0 100644 --- a/src/main/include/log4cxx/rolling/fixedwindowrollingpolicy.h +++ b/src/main/include/log4cxx/rolling/fixedwindowrollingpolicy.h @@ -26,11 +26,6 @@ namespace LOG4CXX_NS { -namespace helpers -{ -class Pool; -} - namespace rolling { @@ -83,7 +78,7 @@ class LOG4CXX_EXPORT FixedWindowRollingPolicy : public RollingPolicyBase */ enum { MAX_WINDOW_SIZE = 12 }; - bool purge(int purgeStart, int maxIndex, LOG4CXX_NS::helpers::Pool& p) const; + bool purge(int purgeStart, int maxIndex) const; public: @@ -97,7 +92,7 @@ class LOG4CXX_EXPORT FixedWindowRollingPolicy : public RollingPolicyBase \sa RollingPolicyBase::activateOptions() */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; /** \copybrief RollingPolicyBase::setOption() @@ -126,16 +121,14 @@ class LOG4CXX_EXPORT FixedWindowRollingPolicy : public RollingPolicyBase */ RolloverDescriptionPtr initialize( const LogString& currentActiveFile, - const bool append, - helpers::Pool& pool) override; + const bool append) override; /** * {@inheritDoc} */ RolloverDescriptionPtr rollover( const LogString& currentActiveFile, - const bool append, - helpers::Pool& pool) override; + const bool append) override; protected: /** diff --git a/src/main/include/log4cxx/rolling/gzcompressaction.h b/src/main/include/log4cxx/rolling/gzcompressaction.h index 92184f5dd..18b7ae0c5 100644 --- a/src/main/include/log4cxx/rolling/gzcompressaction.h +++ b/src/main/include/log4cxx/rolling/gzcompressaction.h @@ -50,7 +50,7 @@ class GZCompressAction : public Action * * @return true if successful. */ - bool execute(LOG4CXX_NS::helpers::Pool& pool) const override; + bool execute() const override; /** * Set to true to throw an IOException on a fork failure. By default, this diff --git a/src/main/include/log4cxx/rolling/manualtriggeringpolicy.h b/src/main/include/log4cxx/rolling/manualtriggeringpolicy.h index abdffdf02..859ed0514 100644 --- a/src/main/include/log4cxx/rolling/manualtriggeringpolicy.h +++ b/src/main/include/log4cxx/rolling/manualtriggeringpolicy.h @@ -72,7 +72,7 @@ class LOG4CXX_EXPORT ManualTriggeringPolicy : public TriggeringPolicy No action is performed in this implementation. */ - void activateOptions(helpers::Pool&) override; + void activateOptions() override; /** \copybrief spi::OptionHandler::setOption() diff --git a/src/main/include/log4cxx/rolling/rollingpolicy.h b/src/main/include/log4cxx/rolling/rollingpolicy.h index 9d2dcc046..3eec13f9f 100644 --- a/src/main/include/log4cxx/rolling/rollingpolicy.h +++ b/src/main/include/log4cxx/rolling/rollingpolicy.h @@ -50,16 +50,14 @@ class LOG4CXX_EXPORT RollingPolicy : * Initialize the policy and return any initial actions for rolling file appender. * * @param currentActiveFile current value of RollingFileAppender.getFile(). - * @param append current value of RollingFileAppender.getAppend(). - * @param pool pool for memory allocations during call. + * @param append current value of RollingFileAppender.getAppend(). * @return Description of the initialization, may be null to indicate * no initialization needed. * @throws SecurityException if denied access to log files. */ virtual RolloverDescriptionPtr initialize( const LogString& currentActiveFile, - const bool append, - LOG4CXX_NS::helpers::Pool& pool) = 0; + const bool append) = 0; /** * Prepare for a rollover. This method is called prior to @@ -68,16 +66,14 @@ class LOG4CXX_EXPORT RollingPolicy : * after close of current log file. * * @param currentActiveFile file name for current active log file. - * @param append current value of the parent FileAppender.getAppend(). - * @param pool pool for memory allocations during call. + * @param append current value of the parent FileAppender.getAppend(). * @return Description of pending rollover, may be null to indicate no rollover * at this time. * @throws SecurityException if denied access to log files. */ virtual RolloverDescriptionPtr rollover( const LogString& currentActiveFile, - const bool append, - LOG4CXX_NS::helpers::Pool& pool) = 0; + const bool append) = 0; }; LOG4CXX_PTR_DEF(RollingPolicy); diff --git a/src/main/include/log4cxx/rolling/rollingpolicybase.h b/src/main/include/log4cxx/rolling/rollingpolicybase.h index 9399286f5..a5a0d0c0d 100644 --- a/src/main/include/log4cxx/rolling/rollingpolicybase.h +++ b/src/main/include/log4cxx/rolling/rollingpolicybase.h @@ -64,7 +64,7 @@ class LOG4CXX_EXPORT RollingPolicyBase : \sa RollingPolicy::activateOptions() */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; /** A map from a name to the object implementing the (date or index) formatting. @@ -114,11 +114,10 @@ class LOG4CXX_EXPORT RollingPolicyBase : * Format file name. * * @param obj object to be evaluted in formatting, may not be null. - * @param buf string buffer to which formatted file name is appended, may not be null. - * @param p memory pool. + * @param buf string buffer to which formatted file name is appended, may not be null. */ void formatFileName(const helpers::ObjectPtr& obj, - LogString& buf, helpers::Pool& p) const; + LogString& buf) const; LOG4CXX_NS::pattern::PatternConverterPtr getIntegerPatternConverter() const; LOG4CXX_NS::pattern::PatternConverterPtr getDatePatternConverter() const; diff --git a/src/main/include/log4cxx/rolling/sizebasedtriggeringpolicy.h b/src/main/include/log4cxx/rolling/sizebasedtriggeringpolicy.h index f26effc55..4c01bf209 100644 --- a/src/main/include/log4cxx/rolling/sizebasedtriggeringpolicy.h +++ b/src/main/include/log4cxx/rolling/sizebasedtriggeringpolicy.h @@ -79,7 +79,7 @@ class LOG4CXX_EXPORT SizeBasedTriggeringPolicy : public TriggeringPolicy No action is performed in this implementation. */ - void activateOptions(helpers::Pool&) override; + void activateOptions() override; /** \copybrief spi::OptionHandler::setOption() diff --git a/src/main/include/log4cxx/rolling/zipcompressaction.h b/src/main/include/log4cxx/rolling/zipcompressaction.h index fd3d0a374..1cbc71a6c 100644 --- a/src/main/include/log4cxx/rolling/zipcompressaction.h +++ b/src/main/include/log4cxx/rolling/zipcompressaction.h @@ -49,7 +49,7 @@ class ZipCompressAction : public Action * * @return true if successful. */ - bool execute(LOG4CXX_NS::helpers::Pool& pool) const override; + bool execute() const override; /** * Set to true to throw an IOException on a fork failure. By default, this diff --git a/src/main/include/log4cxx/spi/filter.h b/src/main/include/log4cxx/spi/filter.h index 04163a189..593867410 100644 --- a/src/main/include/log4cxx/spi/filter.h +++ b/src/main/include/log4cxx/spi/filter.h @@ -107,7 +107,7 @@ class LOG4CXX_EXPORT Filter : public virtual OptionHandler No action is performed in this implementation. */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; /** \copybrief spi::OptionHandler::setOption() diff --git a/src/main/include/log4cxx/spi/optionhandler.h b/src/main/include/log4cxx/spi/optionhandler.h index 7ae414ad9..731d19961 100644 --- a/src/main/include/log4cxx/spi/optionhandler.h +++ b/src/main/include/log4cxx/spi/optionhandler.h @@ -49,7 +49,7 @@ class LOG4CXX_EXPORT OptionHandler : public virtual helpers::Object the File and Append options both of which are ambigous until the other is also set. */ - virtual void activateOptions(helpers::Pool& p) = 0; + virtual void activateOptions() = 0; /** diff --git a/src/main/include/log4cxx/varia/fallbackerrorhandler.h b/src/main/include/log4cxx/varia/fallbackerrorhandler.h index a2ac5b6b5..71072bc2a 100644 --- a/src/main/include/log4cxx/varia/fallbackerrorhandler.h +++ b/src/main/include/log4cxx/varia/fallbackerrorhandler.h @@ -65,7 +65,7 @@ class LOG4CXX_EXPORT FallbackErrorHandler : No action is performed in this implementation. */ - void activateOptions(helpers::Pool& p) override; + void activateOptions() override; /** \copybrief spi::OptionHandler::setOption() */ diff --git a/src/main/include/log4cxx/writerappender.h b/src/main/include/log4cxx/writerappender.h index c46450963..bbd4d0aa4 100644 --- a/src/main/include/log4cxx/writerappender.h +++ b/src/main/include/log4cxx/writerappender.h @@ -58,7 +58,7 @@ class LOG4CXX_EXPORT WriterAppender : public AppenderSkeleton Derived appenders should override this method if option structure requires it. */ - void activateOptions(helpers::Pool& pool) override; + void activateOptions() override; /** If the ImmediateFlush option is set to @@ -92,7 +92,7 @@ class LOG4CXX_EXPORT WriterAppender : public AppenderSkeleton layout. */ - void append(const spi::LoggingEventPtr& event, helpers::Pool& p) override; + void append(const spi::LoggingEventPtr& event) override; protected: @@ -173,18 +173,18 @@ class LOG4CXX_EXPORT WriterAppender : public AppenderSkeleton /** Actual writing occurs here. */ - virtual void subAppend(const spi::LoggingEventPtr& event, helpers::Pool& p); + virtual void subAppend(const spi::LoggingEventPtr& event); /** Write a footer as produced by the embedded layout's Layout#appendFooter method. */ - virtual void writeFooter(helpers::Pool& p); + virtual void writeFooter(); /** Write a header as produced by the embedded layout's Layout#appendHeader method. */ - virtual void writeHeader(helpers::Pool& p); + virtual void writeHeader(); /** * Set the writer. Mutex must already be held. diff --git a/src/test/cpp/util/compare.cpp b/src/test/cpp/util/compare.cpp index d71f5471a..7e1d1b257 100644 --- a/src/test/cpp/util/compare.cpp +++ b/src/test/cpp/util/compare.cpp @@ -28,15 +28,13 @@ using namespace log4cxx::helpers; bool Compare::compare(const File& file1, const File& file2) { - Pool pool; InputStreamPtr fileIn1 = InputStreamPtr( new FileInputStream(file1) ); InputStreamReaderPtr reader1 = InputStreamReaderPtr( new InputStreamReader(fileIn1) ); - LogString in1(reader1->read(pool)); + LogString in1(reader1->read()); - Pool pool2; InputStreamPtr fileIn2 = InputStreamPtr( new FileInputStream(file2) ); InputStreamReaderPtr reader2 = InputStreamReaderPtr( new InputStreamReader(fileIn2) ); - LogString in2(reader2->read(pool2)); + LogString in2(reader2->read()); LogString back1(in1); LogString back2(in2); @@ -61,7 +59,7 @@ bool Compare::compare(const File& file1, const File& file2) msg += LOG4CXX_STR("] and ["); msg += file2.getPath(); msg += LOG4CXX_STR("] differ on line "); - StringHelper::toString(lineCounter, pool, msg); + StringHelper::toString(lineCounter, msg); msg += LOG4CXX_EOL; msg += LOG4CXX_STR("One reads: ["); msg += s1; @@ -73,8 +71,8 @@ bool Compare::compare(const File& file1, const File& file2) msg += LOG4CXX_EOL; emit(msg); - outputFile(file1, back1, pool); - outputFile(file2, back2, pool); + outputFile(file1, back1); + outputFile(file2, back2); return false; } @@ -90,8 +88,8 @@ bool Compare::compare(const File& file1, const File& file2) msg += LOG4CXX_STR("]."); msg += LOG4CXX_EOL; emit(msg); - outputFile(file1, back1, pool); - outputFile(file2, back2, pool); + outputFile(file1, back1); + outputFile(file2, back2); return false; } @@ -100,8 +98,7 @@ bool Compare::compare(const File& file1, const File& file2) } void Compare::outputFile(const File& file, - const LogString& contents, - log4cxx::helpers::Pool& pool) + const LogString& contents) { int lineCounter = 0; emit(LOG4CXX_STR("--------------------------------")); @@ -118,7 +115,7 @@ void Compare::outputFile(const File& file, { lineCounter++; LogString line; - StringHelper::toString(lineCounter, pool, line); + StringHelper::toString(lineCounter, line); emit(line); if (lineCounter < 10) @@ -145,7 +142,7 @@ void Compare::outputFile(const File& file, void Compare::emit(const LogString& s1) { - SystemOutWriter::write(s1); + SystemOutWriter::write_raw(s1); } diff --git a/src/test/cpp/util/compare.h b/src/test/cpp/util/compare.h index be807c66d..602c40cf6 100644 --- a/src/test/cpp/util/compare.h +++ b/src/test/cpp/util/compare.h @@ -34,8 +34,7 @@ class Compare private: /// Prints file on the console. static void outputFile(const File& file, - const LogString& contents, - log4cxx::helpers::Pool& pool); + const LogString& contents); static void emit(const LogString& line); static bool getline(LogString& buf, LogString& line); diff --git a/src/test/cpp/vectorappender.cpp b/src/test/cpp/vectorappender.cpp index e01dbad89..d2309d9ee 100644 --- a/src/test/cpp/vectorappender.cpp +++ b/src/test/cpp/vectorappender.cpp @@ -23,7 +23,7 @@ using namespace log4cxx::helpers; IMPLEMENT_LOG4CXX_OBJECT(VectorAppender) -void VectorAppender::append(const spi::LoggingEventPtr& event, Pool& /*p*/) +void VectorAppender::append(const spi::LoggingEventPtr& event) { if (0 < this->appendMillisecondDelay) std::this_thread::sleep_for( std::chrono::milliseconds( this->appendMillisecondDelay ) ); diff --git a/src/test/cpp/vectorappender.h b/src/test/cpp/vectorappender.h index 0d379fd40..edc936a7e 100644 --- a/src/test/cpp/vectorappender.h +++ b/src/test/cpp/vectorappender.h @@ -43,7 +43,7 @@ class VectorAppender : public AppenderSkeleton This method is called by the AppenderSkeleton#doAppend method. */ - void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) override; + void append(const spi::LoggingEventPtr& event) override; const std::vector& getVector() const { From 478a84c5a92f84b3d9a694d61519e566c060a2a5 Mon Sep 17 00:00:00 2001 From: Robert Middleton Date: Fri, 6 Mar 2026 20:25:57 -0500 Subject: [PATCH 3/3] some more pool removals --- src/main/cpp/CMakeLists.txt | 8 +-- src/main/cpp/cacheddateformat.cpp | 30 ++++++----- src/main/cpp/date.cpp | 14 ++--- src/main/cpp/file.cpp | 2 +- src/main/cpp/fileappender.cpp | 2 +- src/main/cpp/filewatchdog.cpp | 4 +- src/main/cpp/fixedwindowrollingpolicy.cpp | 4 +- src/main/cpp/fulllocationpatternconverter.cpp | 5 +- src/main/cpp/htmllayout.cpp | 13 +++-- src/main/cpp/inputstreamreader.cpp | 3 +- src/main/cpp/jsonlayout.cpp | 13 +++-- src/main/cpp/layout.cpp | 9 ++-- src/main/cpp/levelpatternconverter.cpp | 3 +- src/main/cpp/linelocationpatternconverter.cpp | 5 +- .../cpp/lineseparatorpatternconverter.cpp | 6 +-- src/main/cpp/literalpatternconverter.cpp | 6 +-- src/main/cpp/logger.cpp | 25 ++++----- src/main/cpp/loggerpatternconverter.cpp | 3 +- src/main/cpp/loggingevent.cpp | 8 +-- src/main/cpp/loggingeventpatternconverter.cpp | 5 +- src/main/cpp/loglog.cpp | 4 +- src/main/cpp/mdcpatternconverter.cpp | 3 +- src/main/cpp/messagepatternconverter.cpp | 6 +-- .../cpp/methodlocationpatternconverter.cpp | 3 +- src/main/cpp/ndcpatternconverter.cpp | 3 +- src/main/cpp/optionconverter.cpp | 5 +- src/main/cpp/properties.cpp | 5 +- src/main/cpp/propertiespatternconverter.cpp | 3 +- src/main/cpp/propertyconfigurator.cpp | 17 +++--- src/main/cpp/propertysetter.cpp | 19 +++---- src/main/cpp/relativetimedateformat.cpp | 7 ++- src/main/cpp/relativetimepatternconverter.cpp | 7 ++- src/main/cpp/rollingfileappender.cpp | 52 +++++++++---------- .../cpp/shortfilelocationpatternconverter.cpp | 3 +- src/main/cpp/simpledateformat.cpp | 1 - src/main/cpp/simplelayout.cpp | 3 +- src/main/cpp/threadpatternconverter.cpp | 3 +- .../cpp/threadusernamepatternconverter.cpp | 3 +- .../throwableinformationpatternconverter.cpp | 3 +- src/main/cpp/timebasedrollingpolicy.cpp | 9 ++-- src/main/cpp/xmllayout.cpp | 7 ++- src/main/cpp/xmlsocketappender.cpp | 22 ++++---- .../include/log4cxx/config/propertysetter.h | 18 +++---- src/main/include/log4cxx/file.h | 2 +- src/main/include/log4cxx/helpers/date.h | 5 +- .../log4cxx/helpers/relativetimedateformat.h | 3 +- src/main/include/log4cxx/htmllayout.h | 9 ++-- src/main/include/log4cxx/jsonlayout.h | 6 +-- src/main/include/log4cxx/layout.h | 6 +-- src/main/include/log4cxx/logger.h | 2 +- .../log4cxx/net/socketappenderskeleton.h | 2 +- .../include/log4cxx/net/xmlsocketappender.h | 6 +-- .../pattern/fulllocationpatternconverter.h | 3 +- .../log4cxx/pattern/levelpatternconverter.h | 3 +- .../pattern/linelocationpatternconverter.h | 3 +- .../pattern/lineseparatorpatternconverter.h | 6 +-- .../log4cxx/pattern/literalpatternconverter.h | 6 +-- .../log4cxx/pattern/loggerpatternconverter.h | 3 +- .../log4cxx/pattern/mdcpatternconverter.h | 3 +- .../log4cxx/pattern/messagepatternconverter.h | 3 +- .../pattern/methodlocationpatternconverter.h | 3 +- .../log4cxx/pattern/ndcpatternconverter.h | 3 +- .../pattern/propertiespatternconverter.h | 3 +- .../pattern/relativetimepatternconverter.h | 3 +- .../shortfilelocationpatternconverter.h | 3 +- .../log4cxx/pattern/threadpatternconverter.h | 3 +- .../pattern/threadusernamepatternconverter.h | 3 +- .../throwableinformationpatternconverter.h | 3 +- src/main/include/log4cxx/patternlayout.h | 3 +- .../log4cxx/rolling/rollingfileappender.h | 8 +-- .../log4cxx/rolling/timebasedrollingpolicy.h | 16 +++--- src/main/include/log4cxx/simplelayout.h | 5 +- src/main/include/log4cxx/xml/xmllayout.h | 5 +- 73 files changed, 219 insertions(+), 287 deletions(-) diff --git a/src/main/cpp/CMakeLists.txt b/src/main/cpp/CMakeLists.txt index 17264e057..f8556c41a 100644 --- a/src/main/cpp/CMakeLists.txt +++ b/src/main/cpp/CMakeLists.txt @@ -72,7 +72,10 @@ endif() if(${ENABLE_APR}) list(APPEND extra_classes - dbappender.cpp + dbappender.cpp + inetaddress.cpp + odbcappender.cpp + pool.cpp ) endif() @@ -126,7 +129,6 @@ target_sources(log4cxx hexdump.cpp hierarchy.cpp htmllayout.cpp - inetaddress.cpp inputstream.cpp inputstreamreader.cpp integer.cpp @@ -164,7 +166,6 @@ target_sources(log4cxx mdcpatternconverter.cpp ndcpatternconverter.cpp nteventlogappender.cpp - odbcappender.cpp onlyonceerrorhandler.cpp optionconverter.cpp outputdebugstringappender.cpp @@ -173,7 +174,6 @@ target_sources(log4cxx patternconverter.cpp patternlayout.cpp patternparser.cpp - pool.cpp properties.cpp propertiespatternconverter.cpp propertyconfigurator.cpp diff --git a/src/main/cpp/cacheddateformat.cpp b/src/main/cpp/cacheddateformat.cpp index d7a37be9b..17503d7be 100644 --- a/src/main/cpp/cacheddateformat.cpp +++ b/src/main/cpp/cacheddateformat.cpp @@ -21,6 +21,7 @@ #include #include #include +#include using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; @@ -33,7 +34,7 @@ struct CachedDateFormat::CachedDateFormatPriv millisecondStart(0), slotBegin(std::numeric_limits::min()), cache(50, 0x20), - expiration(expiration1), + expiration(std::chrono::microseconds(expiration1)), previousTime(std::numeric_limits::min()) {} @@ -65,7 +66,7 @@ struct CachedDateFormat::CachedDateFormatPriv * Typically 1, use cache for duplicate requests only, or * 1000000, use cache for requests within the same integral second. */ - const int expiration; + const std::chrono::microseconds expiration; /** * Date requested in previous conversion. @@ -154,15 +155,15 @@ int CachedDateFormat::findMillisecondStart( const DateFormatPtr& formatter) { - uint64_t slotBegin = (std::chrono::duration_cast(time.time_since_epoch()) / 1000000) * 1000000; - uint64_t time_u64 = std::chrono::duration_cast(time.time_since_epoch()); + std::chrono::milliseconds slotBegin((std::chrono::duration_cast(time.time_since_epoch()).count() / 1000000) * 1000000); + std::chrono::milliseconds time_ms(std::chrono::duration_cast(time.time_since_epoch()).count()); - if (slotBegin > time) + if (slotBegin > time_ms) { - slotBegin -= 1000000; + slotBegin -= std::chrono::milliseconds(1000000); } - int millis = (int) (time - slotBegin) / 1000; + int millis = (time_ms - slotBegin).count() / 1000; // the magic numbers are in microseconds int magic = magic1; @@ -175,7 +176,8 @@ int CachedDateFormat::findMillisecondStart( } LogString plusMagic; - formatter->format(plusMagic, slotBegin + magic); + std::chrono::milliseconds ms_val(slotBegin + std::chrono::milliseconds(magic)); + formatter->format(plusMagic, log4cxx_time_t(ms_val)); /** * If the string lengths differ then @@ -199,7 +201,8 @@ int CachedDateFormat::findMillisecondStart( millisecondFormat(millis, formattedMillis, 0); LogString plusZero; - formatter->format(plusZero, slotBegin); + std::chrono::system_clock::time_point tp(slotBegin); + formatter->format(plusZero, tp); // Test if the next 1..3 characters match the magic string, main problem is that magic // available millis in formatted can overlap. Therefore the current i is not always the @@ -264,14 +267,14 @@ void CachedDateFormat::format(LogString& buf, log4cxx_time_t now) const // as the last request and a shorter expiration was not requested. if (now < m_priv->slotBegin + m_priv->expiration && now >= m_priv->slotBegin - && now < m_priv->slotBegin + 1000000L) + && now < m_priv->slotBegin + std::chrono::microseconds(1000000L)) { // // if there was a millisecond field then update it // if (m_priv->millisecondStart >= 0) { - millisecondFormat((int) ((now - m_priv->slotBegin) / 1000), m_priv->cache, m_priv->millisecondStart); + millisecondFormat((int) ((now - m_priv->slotBegin) / std::chrono::milliseconds(1000)), m_priv->cache, m_priv->millisecondStart); } // @@ -291,11 +294,12 @@ void CachedDateFormat::format(LogString& buf, log4cxx_time_t now) const m_priv->formatter->format(m_priv->cache, now); buf.append(m_priv->cache); m_priv->previousTime = now; - m_priv->slotBegin = (m_priv->previousTime / 1000000) * 1000000; + // TODO fixme + //m_priv->slotBegin = (m_priv->previousTime / std::chrono::nanoseconds(1000000)) * std::chrono::nanoseconds(1000000); if (m_priv->slotBegin > m_priv->previousTime) { - m_priv->slotBegin -= 1000000; + m_priv->slotBegin -= std::chrono::nanoseconds(1000000); } // diff --git a/src/main/cpp/date.cpp b/src/main/cpp/date.cpp index 3c987d0eb..2ae7db028 100644 --- a/src/main/cpp/date.cpp +++ b/src/main/cpp/date.cpp @@ -44,20 +44,22 @@ Date::~Date() { } -log4cxx_time_t Date::getMicrosecondsPerDay() +std::chrono::microseconds Date::getMicrosecondsPerDay() { - return 86400000000ull; + auto day_duration = std::chrono::hours(24); + return std::chrono::duration_cast(day_duration); } -log4cxx_time_t Date::getMicrosecondsPerSecond() +std::chrono::microseconds Date::getMicrosecondsPerSecond() { - return LOG4CXX_USEC_PER_SEC; + auto day_duration = std::chrono::seconds(1); + return std::chrono::duration_cast(day_duration); } log4cxx_time_t Date::getNextSecond() const { - return ((time / LOG4CXX_USEC_PER_SEC) + 1) * LOG4CXX_USEC_PER_SEC; + return time + std::chrono::seconds(1); } void Date::setGetCurrentTimeFunction(GetCurrentTimeFn fn){ @@ -69,5 +71,5 @@ log4cxx_time_t Date::currentTime(){ } log4cxx_time_t Date::getCurrentTimeStd(){ - return std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + return std::chrono::system_clock::now(); } diff --git a/src/main/cpp/file.cpp b/src/main/cpp/file.cpp index ac03996bf..e2a22b449 100644 --- a/src/main/cpp/file.cpp +++ b/src/main/cpp/file.cpp @@ -200,7 +200,7 @@ size_t File::length() const } -log4cxx_time_t File::lastModified() const +std::filesystem::file_time_type File::lastModified() const { return std::filesystem::last_write_time(m_priv->path); } diff --git a/src/main/cpp/fileappender.cpp b/src/main/cpp/fileappender.cpp index 5e1007e63..991222a18 100644 --- a/src/main/cpp/fileappender.cpp +++ b/src/main/cpp/fileappender.cpp @@ -353,7 +353,7 @@ void FileAppender::setFileInternal( { char bom[] = { (char) 0xFE, (char) 0xFF }; ByteBuffer buf(bom, 2); - outStream->write(buf, p); + outStream->write(buf); } WriterPtr newWriter(createWriter(outStream)); diff --git a/src/main/cpp/filewatchdog.cpp b/src/main/cpp/filewatchdog.cpp index 62ecb0586..d00362c1d 100644 --- a/src/main/cpp/filewatchdog.cpp +++ b/src/main/cpp/filewatchdog.cpp @@ -49,7 +49,7 @@ struct FileWatchdog::FileWatchdogPrivate{ The delay to observe between every check. By default set DEFAULT_DELAY.*/ long delay; - std::chrono::time_point lastModif; + std::filesystem::file_time_type lastModif; bool warnedAlready; LogString taskName; ThreadUtility::ManagerWeakPtr taskManager; @@ -165,5 +165,5 @@ void FileWatchdog::setDelay(long delay1){ void FileWatchdog::setFile(const File& filename) { m_priv->file = filename; - m_priv->lastModif = 0; + m_priv->lastModif = std::filesystem::file_time_type(); } diff --git a/src/main/cpp/fixedwindowrollingpolicy.cpp b/src/main/cpp/fixedwindowrollingpolicy.cpp index b8bbf3d8a..6b4f8f72b 100644 --- a/src/main/cpp/fixedwindowrollingpolicy.cpp +++ b/src/main/cpp/fixedwindowrollingpolicy.cpp @@ -259,7 +259,7 @@ bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex) const std::vector renames; LogString buf; ObjectPtr obj = std::make_shared(lowIndex); - formatFileName(obj, buf, p); + formatFileName(obj, buf); LogString lowFilename(buf); @@ -320,7 +320,7 @@ bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex) const // add a rename action to the list buf.erase(buf.begin(), buf.end()); obj = std::make_shared(i + 1); - formatFileName(obj, buf, p); + formatFileName(obj, buf); LogString highFilename(buf); LogString renameTo(highFilename); diff --git a/src/main/cpp/fulllocationpatternconverter.cpp b/src/main/cpp/fulllocationpatternconverter.cpp index 505052759..37672fd33 100644 --- a/src/main/cpp/fulllocationpatternconverter.cpp +++ b/src/main/cpp/fulllocationpatternconverter.cpp @@ -43,13 +43,12 @@ PatternConverterPtr FullLocationPatternConverter::newInstance( void FullLocationPatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& p) const + LogString& toAppendTo) const { append(toAppendTo, event->getLocationInformation().getFileName()); toAppendTo.append(1, (logchar) 0x28 /* '(' */); StringHelper::toString( event->getLocationInformation().getLineNumber(), - p, toAppendTo); + toAppendTo); toAppendTo.append(1, (logchar) 0x29 /* ')' */); } diff --git a/src/main/cpp/htmllayout.cpp b/src/main/cpp/htmllayout.cpp index bcfce2f18..ee4f8ef3c 100644 --- a/src/main/cpp/htmllayout.cpp +++ b/src/main/cpp/htmllayout.cpp @@ -81,8 +81,7 @@ void HTMLLayout::setOption(const LogString& option, } void HTMLLayout::format(LogString& output, - const spi::LoggingEventPtr& event, - Pool& p) const + const spi::LoggingEventPtr& event) const { auto& lsMsg = event->getRenderedMessage(); output.reserve(m_priv->expectedPatternLength + lsMsg.size()); @@ -91,7 +90,7 @@ void HTMLLayout::format(LogString& output, output.append(LOG4CXX_EOL); output.append(LOG4CXX_STR("")); - m_priv->dateFormat.format(output, event->getTimeStamp(), p); + m_priv->dateFormat.format(output, event->getTimeStamp()); output.append(LOG4CXX_STR("")); @@ -145,7 +144,7 @@ void HTMLLayout::format(LogString& output, if (line != 0) { - StringHelper::toString(line, p, output); + StringHelper::toString(line, output); } output.append(LOG4CXX_STR("")); @@ -173,7 +172,7 @@ void HTMLLayout::format(LogString& output, } } -void HTMLLayout::appendHeader(LogString& output, Pool& p) +void HTMLLayout::appendHeader(LogString& output) { output.append(LOG4CXX_STR("dateFormat.format(output, Date::currentTime(), p); + m_priv->dateFormat.format(output, Date::currentTime()); output.append(LOG4CXX_STR("
    ")); output.append(LOG4CXX_EOL); @@ -238,7 +237,7 @@ void HTMLLayout::appendHeader(LogString& output, Pool& p) output.append(LOG4CXX_EOL); } -void HTMLLayout::appendFooter(LogString& output, Pool& /* pool */ ) +void HTMLLayout::appendFooter(LogString& output) { output.append(LOG4CXX_STR("")); output.append(LOG4CXX_EOL); diff --git a/src/main/cpp/inputstreamreader.cpp b/src/main/cpp/inputstreamreader.cpp index 54b12d26e..2aefa4ef6 100644 --- a/src/main/cpp/inputstreamreader.cpp +++ b/src/main/cpp/inputstreamreader.cpp @@ -75,7 +75,8 @@ void InputStreamReader::close() LogString InputStreamReader::read() { const size_t BUFSIZE = 4096; - ByteBuffer buf(p.pstralloc(BUFSIZE), BUFSIZE); + char buffer[BUFSIZE] = {0}; + ByteBuffer buf(buffer, BUFSIZE); LogString output; // read whole file diff --git a/src/main/cpp/jsonlayout.cpp b/src/main/cpp/jsonlayout.cpp index 547123590..c41ab058c 100644 --- a/src/main/cpp/jsonlayout.cpp +++ b/src/main/cpp/jsonlayout.cpp @@ -104,7 +104,7 @@ LogString JSONLayout::getContentType() const return LOG4CXX_STR("application/json"); } -void JSONLayout::activateOptions(helpers::Pool& /* p */) +void JSONLayout::activateOptions() { m_priv->expectedPatternLength = getFormattedEventCharacterCount() * 2; } @@ -129,8 +129,7 @@ void JSONLayout::setOption(const LogString& option, const LogString& value) } void JSONLayout::format(LogString& output, - const spi::LoggingEventPtr& event, - Pool& p) const + const spi::LoggingEventPtr& event) const { auto& lsMsg = event->getRenderedMessage(); output.reserve(m_priv->expectedPatternLength + lsMsg.size()); @@ -143,7 +142,7 @@ void JSONLayout::format(LogString& output, } output.append(LOG4CXX_STR("\"timestamp\": \"")); - m_priv->dateFormat.format(output, event->getTimeStamp(), p); + m_priv->dateFormat.format(output, event->getTimeStamp()); output.append(LOG4CXX_STR("\",")); output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); @@ -197,7 +196,7 @@ void JSONLayout::format(LogString& output, { output.append(LOG4CXX_STR(",")); output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); - appendSerializedLocationInfo(output, event, p); + appendSerializedLocationInfo(output, event); } output.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); @@ -397,7 +396,7 @@ void JSONLayout::appendSerializedNDC(LogString& buf, } void JSONLayout::appendSerializedLocationInfo(LogString& buf, - const LoggingEventPtr& event, Pool& p) const + const LoggingEventPtr& event) const { if (m_priv->prettyPrint) { @@ -429,7 +428,7 @@ void JSONLayout::appendSerializedLocationInfo(LogString& buf, appendQuotedEscapedString(buf, LOG4CXX_STR("line")); buf.append(LOG4CXX_STR(": ")); LogString lineNumber; - StringHelper::toString(locInfo.getLineNumber(), p, lineNumber); + StringHelper::toString(locInfo.getLineNumber(), lineNumber); appendQuotedEscapedString(buf, lineNumber); buf.append(LOG4CXX_STR(",")); buf.append(m_priv->prettyPrint ? LOG4CXX_EOL : LOG4CXX_STR(" ")); diff --git a/src/main/cpp/layout.cpp b/src/main/cpp/layout.cpp index d06d0dd70..8b4a0992e 100644 --- a/src/main/cpp/layout.cpp +++ b/src/main/cpp/layout.cpp @@ -30,9 +30,9 @@ LogString Layout::getContentType() const return LOG4CXX_STR("text/plain"); } -void Layout::appendHeader(LogString&, LOG4CXX_NS::helpers::Pool&) {} +void Layout::appendHeader(LogString&) {} -void Layout::appendFooter(LogString&, LOG4CXX_NS::helpers::Pool&) {} +void Layout::appendFooter(LogString&) {} /** * The expected length of a formatted event excluding the message text @@ -45,8 +45,7 @@ size_t Layout::getFormattedEventCharacterCount() const , LOG4CXX_LOCATION , LogString() ); - LogString text; - Pool pool; - format(text, exampleEvent, pool); + LogString text; + format(text, exampleEvent); return text.size(); } diff --git a/src/main/cpp/levelpatternconverter.cpp b/src/main/cpp/levelpatternconverter.cpp index 137543fce..6b05b863a 100644 --- a/src/main/cpp/levelpatternconverter.cpp +++ b/src/main/cpp/levelpatternconverter.cpp @@ -44,8 +44,7 @@ PatternConverterPtr LevelPatternConverter::newInstance( void LevelPatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - LOG4CXX_NS::helpers::Pool& /* p */) const + LogString& toAppendTo) const { toAppendTo.append(event->getLevel()->toString()); } diff --git a/src/main/cpp/linelocationpatternconverter.cpp b/src/main/cpp/linelocationpatternconverter.cpp index bf1f42f94..6d1d61b5d 100644 --- a/src/main/cpp/linelocationpatternconverter.cpp +++ b/src/main/cpp/linelocationpatternconverter.cpp @@ -43,10 +43,9 @@ PatternConverterPtr LineLocationPatternConverter::newInstance( void LineLocationPatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& p) const + LogString& toAppendTo) const { StringHelper::toString( event->getLocationInformation().getLineNumber(), - p, toAppendTo); + toAppendTo); } diff --git a/src/main/cpp/lineseparatorpatternconverter.cpp b/src/main/cpp/lineseparatorpatternconverter.cpp index 871ccaec0..5713f84f0 100644 --- a/src/main/cpp/lineseparatorpatternconverter.cpp +++ b/src/main/cpp/lineseparatorpatternconverter.cpp @@ -42,16 +42,14 @@ PatternConverterPtr LineSeparatorPatternConverter::newInstance( void LineSeparatorPatternConverter::format( const LoggingEventPtr& /* event */, - LogString& toAppendTo, - Pool& /* p */) const + LogString& toAppendTo) const { toAppendTo.append(LOG4CXX_EOL); } void LineSeparatorPatternConverter::format( const ObjectPtr& /* event */, - LogString& toAppendTo, - Pool& /* p */) const + LogString& toAppendTo) const { toAppendTo.append(LOG4CXX_EOL); } diff --git a/src/main/cpp/literalpatternconverter.cpp b/src/main/cpp/literalpatternconverter.cpp index a71617d2e..b9869ebc3 100644 --- a/src/main/cpp/literalpatternconverter.cpp +++ b/src/main/cpp/literalpatternconverter.cpp @@ -62,16 +62,14 @@ PatternConverterPtr LiteralPatternConverter::newInstance( void LiteralPatternConverter::format( const LoggingEventPtr& /* event */, - LogString& toAppendTo, - Pool& /* p */) const + LogString& toAppendTo) const { toAppendTo.append(priv->literal); } void LiteralPatternConverter::format( const ObjectPtr& /* event */, - LogString& toAppendTo, - Pool& /* p */) const + LogString& toAppendTo) const { toAppendTo.append(priv->literal); } diff --git a/src/main/cpp/logger.cpp b/src/main/cpp/logger.cpp index 935d8bdda..cedab34ec 100644 --- a/src/main/cpp/logger.cpp +++ b/src/main/cpp/logger.cpp @@ -141,7 +141,7 @@ void Logger::reconfigure( const AppenderList& newList, bool newAdditivity ) replaceAppenders(newList); } -void Logger::callAppenders(const spi::LoggingEventPtr& event, Pool& p) const +void Logger::callAppenders(const spi::LoggingEventPtr& event) const { int writes = 0; @@ -149,7 +149,7 @@ void Logger::callAppenders(const spi::LoggingEventPtr& event, Pool& p) const logger != 0; logger = logger->m_priv->parent.get()) { - writes += logger->m_priv->aai.appendLoopOnAppenders(event, p); + writes += logger->m_priv->aai.appendLoopOnAppenders(event); if (!logger->m_priv->additive) { @@ -178,8 +178,7 @@ void Logger::addEvent(const LevelPtr& level, helpers::AsyncBuffer&& messageAppen if (!getHierarchy()) // Has removeHierarchy() been called? return; auto event = std::make_shared(m_priv->name, level, location, std::move(messageAppender)); - Pool p; - callAppenders(event, p); + callAppenders(event); } void Logger::addEvent(const LevelPtr& level, std::string&& message, const LocationInfo& location) const @@ -192,8 +191,7 @@ void Logger::addEvent(const LevelPtr& level, std::string&& message, const Locati LOG4CXX_DECODE_CHAR(msg, message); auto event = std::make_shared(m_priv->name, level, location, std::move(msg)); #endif - Pool p; - callAppenders(event, p); + callAppenders(event); } void Logger::addFatalEvent(std::string&& message, const LocationInfo& location) const @@ -267,8 +265,7 @@ void Logger::forcedLog(const LevelPtr& level, const std::string& message, LOG4CXX_DECODE_CHAR(msg, message); auto event = std::make_shared(m_priv->name, level, location, std::move(msg)); #endif - Pool p; - callAppenders(event, p); + callAppenders(event); } void Logger::forcedLog(const LevelPtr& level1, const std::string& message) const @@ -281,8 +278,7 @@ void Logger::addEventLS(const LevelPtr& level, LogString&& message, const Locati if (!getHierarchy()) // Has removeHierarchy() been called? return; auto event = std::make_shared(m_priv->name, level, location, std::move(message)); - Pool p; - callAppenders(event, p); + callAppenders(event); } void Logger::forcedLogLS(const LevelPtr& level1, const LogString& message, @@ -291,8 +287,7 @@ void Logger::forcedLogLS(const LevelPtr& level1, const LogString& message, if (!getHierarchy()) // Has removeHierarchy() been called? return; auto event = std::make_shared(m_priv->name, level1, message, location); - Pool p; - callAppenders(event, p); + callAppenders(event); } @@ -840,8 +835,7 @@ void Logger::addEvent(const LevelPtr& level, std::wstring&& message, const Locat LOG4CXX_DECODE_WCHAR(msg, message); auto event = std::make_shared(m_priv->name, level, location, std::move(msg)); #endif - Pool p; - callAppenders(event, p); + callAppenders(event); } void Logger::addFatalEvent(std::wstring&& message, const LocationInfo& location) const @@ -885,8 +879,7 @@ void Logger::forcedLog(const LevelPtr& level, const std::wstring& message, LOG4CXX_DECODE_WCHAR(msg, message); auto event = std::make_shared(m_priv->name, level, location, std::move(msg)); #endif - Pool p; - callAppenders(event, p); + callAppenders(event); } void Logger::forcedLog(const LevelPtr& level1, const std::wstring& message) const diff --git a/src/main/cpp/loggerpatternconverter.cpp b/src/main/cpp/loggerpatternconverter.cpp index 70e9aa1ba..f6897f4c8 100644 --- a/src/main/cpp/loggerpatternconverter.cpp +++ b/src/main/cpp/loggerpatternconverter.cpp @@ -48,8 +48,7 @@ PatternConverterPtr LoggerPatternConverter::newInstance( void LoggerPatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& /* p */ ) const + LogString& toAppendTo) const { int initialLength = (int)toAppendTo.length(); toAppendTo.append(event->getLoggerName()); diff --git a/src/main/cpp/loggingevent.cpp b/src/main/cpp/loggingevent.cpp index ceae144ce..90ebe963f 100644 --- a/src/main/cpp/loggingevent.cpp +++ b/src/main/cpp/loggingevent.cpp @@ -40,7 +40,7 @@ using namespace LOG4CXX_NS::helpers; struct LoggingEvent::LoggingEventPrivate { LoggingEventPrivate(const ThreadSpecificData::NamePairPtr p = ThreadSpecificData::getNames()) : - timeStamp(0), + timeStamp(), pNames(p) { } @@ -57,7 +57,7 @@ struct LoggingEvent::LoggingEventPrivate message(std::move(message1)), timeStamp(Date::currentTime()), locationInfo(locationInfo1), - chronoTimeStamp(std::chrono::microseconds(timeStamp)), + chronoTimeStamp(timeStamp), pNames(p) { } @@ -73,7 +73,7 @@ struct LoggingEvent::LoggingEventPrivate , level(level1) , timeStamp(Date::currentTime()) , locationInfo(locationInfo1) - , chronoTimeStamp(std::chrono::microseconds(timeStamp)) + , chronoTimeStamp(timeStamp) , pNames(p) , messageAppender(std::move(messageAppenderArg)) { @@ -89,7 +89,7 @@ struct LoggingEvent::LoggingEventPrivate message(message1), timeStamp(Date::currentTime()), locationInfo(locationInfo1), - chronoTimeStamp(std::chrono::microseconds(timeStamp)), + chronoTimeStamp(timeStamp), pNames(p) { } diff --git a/src/main/cpp/loggingeventpatternconverter.cpp b/src/main/cpp/loggingeventpatternconverter.cpp index 13f9a9505..c8959e635 100644 --- a/src/main/cpp/loggingeventpatternconverter.cpp +++ b/src/main/cpp/loggingeventpatternconverter.cpp @@ -41,14 +41,13 @@ LoggingEventPatternConverter::LoggingEventPatternConverter(std::unique_ptr(obj); if (le != NULL) { - format(le, output, p); + format(le, output); } } diff --git a/src/main/cpp/loglog.cpp b/src/main/cpp/loglog.cpp index 678939b0f..1370ddfeb 100644 --- a/src/main/cpp/loglog.cpp +++ b/src/main/cpp/loglog.cpp @@ -206,7 +206,7 @@ void LogLog::emit_log(const LogString& prefix, const LogString& msg, const LogSt out.append(suffix); out.append(1, (logchar) 0x0A); - SystemErrWriter::write(out); + SystemErrWriter::write_raw(out); } void LogLog::emit_log(const LogString& prefix, const std::exception& ex, const LogString& suffix) @@ -227,5 +227,5 @@ void LogLog::emit_log(const LogString& prefix, const std::exception& ex, const L out.append(suffix); out.append(1, (logchar) 0x0A); - SystemErrWriter::write(out); + SystemErrWriter::write_raw(out); } diff --git a/src/main/cpp/mdcpatternconverter.cpp b/src/main/cpp/mdcpatternconverter.cpp index 25db86b8a..f68218acd 100644 --- a/src/main/cpp/mdcpatternconverter.cpp +++ b/src/main/cpp/mdcpatternconverter.cpp @@ -47,8 +47,7 @@ PatternConverterPtr MDCPatternConverter::newInstance( void MDCPatternConverter::format ( const spi::LoggingEventPtr& event - , LogString& toAppendTo - , helpers::Pool& /* p */ + , LogString& toAppendTo ) const { size_t startIndex = toAppendTo.size(); diff --git a/src/main/cpp/messagepatternconverter.cpp b/src/main/cpp/messagepatternconverter.cpp index 6b0712ff8..c31966c93 100644 --- a/src/main/cpp/messagepatternconverter.cpp +++ b/src/main/cpp/messagepatternconverter.cpp @@ -44,8 +44,7 @@ class QuotedMessagePatternConverter : public LoggingEventPatternConverter // Duplicate any quote character in the event message void format ( const spi::LoggingEventPtr& event - , LogString& toAppendTo - , helpers::Pool& p + , LogString& toAppendTo ) const override { auto& input = event->getRenderedMessage(); @@ -80,8 +79,7 @@ PatternConverterPtr MessagePatternConverter::newInstance( void MessagePatternConverter::format ( const spi::LoggingEventPtr& event - , LogString& toAppendTo - , helpers::Pool& /* p */ + , LogString& toAppendTo ) const { toAppendTo.append(event->getRenderedMessage()); diff --git a/src/main/cpp/methodlocationpatternconverter.cpp b/src/main/cpp/methodlocationpatternconverter.cpp index 2e479c8be..3e31fafdc 100644 --- a/src/main/cpp/methodlocationpatternconverter.cpp +++ b/src/main/cpp/methodlocationpatternconverter.cpp @@ -42,8 +42,7 @@ PatternConverterPtr MethodLocationPatternConverter::newInstance( void MethodLocationPatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& /* p */ ) const + LogString& toAppendTo) const { append(toAppendTo, event->getLocationInformation().getMethodName()); } diff --git a/src/main/cpp/ndcpatternconverter.cpp b/src/main/cpp/ndcpatternconverter.cpp index 6b05759ce..2f4d08481 100644 --- a/src/main/cpp/ndcpatternconverter.cpp +++ b/src/main/cpp/ndcpatternconverter.cpp @@ -42,8 +42,7 @@ PatternConverterPtr NDCPatternConverter::newInstance( void NDCPatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& /* p */) const + LogString& toAppendTo) const { if (!event->getNDC(toAppendTo)) { diff --git a/src/main/cpp/optionconverter.cpp b/src/main/cpp/optionconverter.cpp index 17fc221db..cc8a75c69 100644 --- a/src/main/cpp/optionconverter.cpp +++ b/src/main/cpp/optionconverter.cpp @@ -105,9 +105,8 @@ LogString substVarsSafely(const LogString& val, helpers::Properties& props, cons { LogString msg(1, (logchar) 0x22 /* '\"' */); msg.append(val); - msg.append(LOG4CXX_STR("\" has no closing brace. Opening brace at position ")); - helpers::Pool p; - helpers::StringHelper::toString(j, p, msg); + msg.append(LOG4CXX_STR("\" has no closing brace. Opening brace at position ")); + helpers::StringHelper::toString(j, msg); msg.append(1, (logchar) 0x2E /* '.' */); throw helpers::IllegalArgumentException(msg); } diff --git a/src/main/cpp/properties.cpp b/src/main/cpp/properties.cpp index dfa72f839..b3a2d23fb 100644 --- a/src/main/cpp/properties.cpp +++ b/src/main/cpp/properties.cpp @@ -441,9 +441,8 @@ LogString Properties::get(const LogString& key) const void Properties::load(InputStreamPtr inStream) { - Pool pool; auto lineReader = std::make_shared(inStream, CharsetDecoder::getISOLatinDecoder()); - LogString contents = lineReader->read(pool); + LogString contents = lineReader->read(); properties->clear(); PropertyParser parser; parser.parse(contents, *this); @@ -466,4 +465,4 @@ std::vector Properties::propertyNames() const bool Properties::isEmpty() const { return properties->empty(); -} \ No newline at end of file +} diff --git a/src/main/cpp/propertiespatternconverter.cpp b/src/main/cpp/propertiespatternconverter.cpp index ef9c35216..4f7346604 100644 --- a/src/main/cpp/propertiespatternconverter.cpp +++ b/src/main/cpp/propertiespatternconverter.cpp @@ -69,8 +69,7 @@ PatternConverterPtr PropertiesPatternConverter::newInstance( void PropertiesPatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& /* p */) const + LogString& toAppendTo) const { if (priv->option.length() == 0) { diff --git a/src/main/cpp/propertyconfigurator.cpp b/src/main/cpp/propertyconfigurator.cpp index 9c1fdd24c..da567b91c 100644 --- a/src/main/cpp/propertyconfigurator.cpp +++ b/src/main/cpp/propertyconfigurator.cpp @@ -285,9 +285,8 @@ void PropertyConfigurator::configureLoggerFactory(helpers::Properties& props) #endif ); - m_priv->loggerFactory = LOG4CXX_NS::cast( instance ); - Pool p; - PropertySetter::setProperties(m_priv->loggerFactory, props, LOG4CXX_STR("log4j.factory."), p); + m_priv->loggerFactory = LOG4CXX_NS::cast( instance ); + PropertySetter::setProperties(m_priv->loggerFactory, props, LOG4CXX_STR("log4j.factory.")); } } @@ -508,9 +507,7 @@ AppenderPtr PropertyConfigurator::parseAppender( appender->setName(appenderName); if (appender->instanceof(OptionHandler::getStaticClass())) - { - Pool p; - + { if (appender->requiresLayout()) { LayoutPtr layout; @@ -528,7 +525,7 @@ AppenderPtr PropertyConfigurator::parseAppender( + LOG4CXX_STR(" options for [") + appenderName + LOG4CXX_STR("]")); } - PropertySetter::setProperties(layout, props, layoutPrefix + LOG4CXX_STR("."), p); + PropertySetter::setProperties(layout, props, layoutPrefix + LOG4CXX_STR(".")); if (LogLog::isDebugEnabled()) { LogLog::debug((LogString) LOG4CXX_STR("End of parsing for [") @@ -557,7 +554,7 @@ AppenderPtr PropertyConfigurator::parseAppender( LogLog::debug((LogString) LOG4CXX_STR("Parsing ") + RollingPolicy::getStaticClass().getName() + LOG4CXX_STR(" options for [") + appenderName + LOG4CXX_STR("]")); } - PropertySetter::setProperties(rollingPolicy, props, rollingPolicyKey + LOG4CXX_STR("."), p); + PropertySetter::setProperties(rollingPolicy, props, rollingPolicyKey + LOG4CXX_STR(".")); } } @@ -578,12 +575,12 @@ AppenderPtr PropertyConfigurator::parseAppender( LogLog::debug((LogString) LOG4CXX_STR("Parsing ") + TriggeringPolicy::getStaticClass().getName() + LOG4CXX_STR(" options for [") + appenderName + LOG4CXX_STR("]")); } - PropertySetter::setProperties(triggeringPolicy, props, triggeringPolicyKey + LOG4CXX_STR("."), p); + PropertySetter::setProperties(triggeringPolicy, props, triggeringPolicyKey + LOG4CXX_STR(".")); } } } - PropertySetter::setProperties(appender, props, prefix + LOG4CXX_STR("."), p); + PropertySetter::setProperties(appender, props, prefix + LOG4CXX_STR(".")); if (LogLog::isDebugEnabled()) { LogLog::debug((LogString) LOG4CXX_STR("Parsed [") diff --git a/src/main/cpp/propertysetter.cpp b/src/main/cpp/propertysetter.cpp index bc1a028bd..76453784d 100644 --- a/src/main/cpp/propertysetter.cpp +++ b/src/main/cpp/propertysetter.cpp @@ -37,16 +37,14 @@ PropertySetter::PropertySetter(const helpers::ObjectPtr& obj1) : obj(obj1) void PropertySetter::setProperties(const helpers::ObjectPtr& obj, helpers::Properties& properties, - const LogString& prefix, - Pool& p) + const LogString& prefix) { - PropertySetter(obj).setProperties(properties, prefix, p); + PropertySetter(obj).setProperties(properties, prefix); } void PropertySetter::setProperties(helpers::Properties& properties, - const LogString& prefix, - Pool& p) + const LogString& prefix) { size_t len = prefix.length(); @@ -71,16 +69,15 @@ void PropertySetter::setProperties(helpers::Properties& properties, continue; } - setProperty(key, value, p); + setProperty(key, value); } } - activate(p); + activate(); } void PropertySetter::setProperty(const LogString& option, - const LogString& value, - Pool&) + const LogString& value) { if (value.empty()) { @@ -99,11 +96,11 @@ void PropertySetter::setProperty(const LogString& option, } } -void PropertySetter::activate(Pool& p) +void PropertySetter::activate() { if (obj != 0 && obj->instanceof(OptionHandler::getStaticClass())) { OptionHandlerPtr handler = LOG4CXX_NS::cast(obj); - handler->activateOptions(p); + handler->activateOptions(); } } diff --git a/src/main/cpp/relativetimedateformat.cpp b/src/main/cpp/relativetimedateformat.cpp index 612460b6f..cf8bc18c1 100644 --- a/src/main/cpp/relativetimedateformat.cpp +++ b/src/main/cpp/relativetimedateformat.cpp @@ -28,9 +28,8 @@ LOG4CXX_NS::helpers::RelativeTimeDateFormat::RelativeTimeDateFormat() void LOG4CXX_NS::helpers::RelativeTimeDateFormat::format( LogString& s, - log4cxx_time_t date, - Pool& p) const + log4cxx_time_t date) const { - int64_t interval = (date - startTime) / int64_t(1000); - StringHelper::toString(interval, p, s); + int64_t interval = std::chrono::duration_cast(date - startTime).count(); + StringHelper::toString(interval, s); } diff --git a/src/main/cpp/relativetimepatternconverter.cpp b/src/main/cpp/relativetimepatternconverter.cpp index eaf23e5fd..f29b5037e 100644 --- a/src/main/cpp/relativetimepatternconverter.cpp +++ b/src/main/cpp/relativetimepatternconverter.cpp @@ -43,10 +43,9 @@ PatternConverterPtr RelativeTimePatternConverter::newInstance( void RelativeTimePatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& p) const + LogString& toAppendTo) const { - log4cxx_time_t delta = (event->getTimeStamp() - LoggingEvent::getStartTime()) / 1000; - StringHelper::toString(delta, p, toAppendTo); + int64_t delta = std::chrono::duration_cast(event->getTimeStamp() - LoggingEvent::getStartTime()).count(); + StringHelper::toString(delta, toAppendTo); } diff --git a/src/main/cpp/rollingfileappender.cpp b/src/main/cpp/rollingfileappender.cpp index 4112864c9..7dbd825b2 100644 --- a/src/main/cpp/rollingfileappender.cpp +++ b/src/main/cpp/rollingfileappender.cpp @@ -175,7 +175,7 @@ void RollingFileAppender::setDatePattern(const LogString& newPattern) /** * Prepare instance of use. */ -void RollingFileAppender::activateOptions(Pool& p) +void RollingFileAppender::activateOptions() { if (!_priv->rollingPolicy) { @@ -208,13 +208,13 @@ void RollingFileAppender::activateOptions(Pool& p) { std::lock_guard lock(_priv->mutex); - _priv->triggeringPolicy->activateOptions(p); - _priv->rollingPolicy->activateOptions(p); + _priv->triggeringPolicy->activateOptions(); + _priv->rollingPolicy->activateOptions(); try { RolloverDescriptionPtr rollover1 = - _priv->rollingPolicy->initialize(getFile(), getAppend(), p); + _priv->rollingPolicy->initialize(getFile(), getAppend()); if (rollover1 != NULL) { @@ -275,13 +275,13 @@ void RollingFileAppender::activateOptions(Pool& p) * @return true if rollover performed. */ -bool RollingFileAppender::rollover(Pool& p) +bool RollingFileAppender::rollover() { std::lock_guard lock(_priv->mutex); - return rolloverInternal(p); + return rolloverInternal(); } -bool RollingFileAppender::rolloverInternal(Pool& p) +bool RollingFileAppender::rolloverInternal() { // // can't roll without a policy @@ -292,7 +292,7 @@ bool RollingFileAppender::rolloverInternal(Pool& p) { try { - RolloverDescriptionPtr rollover1(_priv->rollingPolicy->rollover(this->getFile(), this->getAppend(), p)); + RolloverDescriptionPtr rollover1(_priv->rollingPolicy->rollover(this->getFile(), this->getAppend())); if (rollover1 != NULL) { @@ -308,7 +308,7 @@ bool RollingFileAppender::rolloverInternal(Pool& p) try { - success = rollover1->getSynchronous()->execute(p); + success = rollover1->getSynchronous()->execute(); } catch (std::exception& ex) { @@ -325,7 +325,7 @@ bool RollingFileAppender::rolloverInternal(Pool& p) appendToExisting = rollover1->getAppend(); if (appendToExisting) { - _priv->fileLength = File().setPath(rollover1->getActiveFileName()).length(p); + _priv->fileLength = File().setPath(rollover1->getActiveFileName()).length(); } else { @@ -338,7 +338,7 @@ bool RollingFileAppender::rolloverInternal(Pool& p) { try { - asyncAction->execute(p); + asyncAction->execute(); } catch (std::exception& ex) { @@ -349,14 +349,14 @@ bool RollingFileAppender::rolloverInternal(Pool& p) } } } - setFileInternal(rollover1->getActiveFileName(), appendToExisting, _priv->bufferedIO, _priv->bufferSize, p); + setFileInternal(rollover1->getActiveFileName(), appendToExisting, _priv->bufferedIO, _priv->bufferSize); } else { closeWriter(); setFileInternal(rollover1->getActiveFileName()); // Call activateOptions to create any intermediate directories(if required) - FileAppender::activateOptionsInternal(p); + FileAppender::activateOptionsInternal(); OutputStreamPtr os = std::make_shared ( rollover1->getActiveFileName() , rollover1->getAppend() @@ -371,7 +371,7 @@ bool RollingFileAppender::rolloverInternal(Pool& p) try { - success = rollover1->getSynchronous()->execute(p); + success = rollover1->getSynchronous()->execute(); } catch (std::exception& ex) { @@ -386,7 +386,7 @@ bool RollingFileAppender::rolloverInternal(Pool& p) { if (rollover1->getAppend()) { - _priv->fileLength = File().setPath(rollover1->getActiveFileName()).length(p); + _priv->fileLength = File().setPath(rollover1->getActiveFileName()).length(); } else { @@ -397,11 +397,11 @@ bool RollingFileAppender::rolloverInternal(Pool& p) if (asyncAction != NULL) { - asyncAction->execute(p); + asyncAction->execute(); } } - writeHeader(p); + writeHeader(); } return true; } @@ -422,7 +422,7 @@ bool RollingFileAppender::rolloverInternal(Pool& p) /** * {@inheritDoc} */ -void RollingFileAppender::subAppend(const LoggingEventPtr& event, Pool& p) +void RollingFileAppender::subAppend(const LoggingEventPtr& event) { // The rollover check must precede actual writing. This is the // only correct behavior for time driven triggers. @@ -438,7 +438,7 @@ void RollingFileAppender::subAppend(const LoggingEventPtr& event, Pool& p) try { _priv->_event = event; - rolloverInternal(p); + rolloverInternal(); } catch (std::exception& ex) { @@ -449,7 +449,7 @@ void RollingFileAppender::subAppend(const LoggingEventPtr& event, Pool& p) } } - FileAppender::subAppend(event, p); + FileAppender::subAppend(event); } /** @@ -531,26 +531,26 @@ class CountingOutputStream : public OutputStream /** * {@inheritDoc} */ - void close(Pool& p) override + void close() override { - os->close(p); + os->close(); rfa = 0; } /** * {@inheritDoc} */ - void flush(Pool& p) override + void flush() override { - os->flush(p); + os->flush(); } /** * {@inheritDoc} */ - void write(ByteBuffer& buf, Pool& p) override + void write(ByteBuffer& buf) override { - os->write(buf, p); + os->write(buf); if (rfa != 0) { diff --git a/src/main/cpp/shortfilelocationpatternconverter.cpp b/src/main/cpp/shortfilelocationpatternconverter.cpp index 0bd2ed88c..acd1dee61 100644 --- a/src/main/cpp/shortfilelocationpatternconverter.cpp +++ b/src/main/cpp/shortfilelocationpatternconverter.cpp @@ -40,7 +40,6 @@ PatternConverterPtr ShortFileLocationPatternConverter::newInstance( void ShortFileLocationPatternConverter::format( const LoggingEventPtr &event, - LogString &toAppendTo, - Pool & /* p */ ) const { + LogString &toAppendTo) const { append(toAppendTo, event->getLocationInformation().getShortFileName()); } diff --git a/src/main/cpp/simpledateformat.cpp b/src/main/cpp/simpledateformat.cpp index 77698842a..b0832d454 100644 --- a/src/main/cpp/simpledateformat.cpp +++ b/src/main/cpp/simpledateformat.cpp @@ -25,7 +25,6 @@ #define LOG4CXX 1 #endif #include -#include using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; diff --git a/src/main/cpp/simplelayout.cpp b/src/main/cpp/simplelayout.cpp index 17e3b27c0..a8be73836 100644 --- a/src/main/cpp/simplelayout.cpp +++ b/src/main/cpp/simplelayout.cpp @@ -27,8 +27,7 @@ IMPLEMENT_LOG4CXX_OBJECT(SimpleLayout) void SimpleLayout::format(LogString& output, - const spi::LoggingEventPtr& event, - LOG4CXX_NS::helpers::Pool&) const + const spi::LoggingEventPtr& event) const { output.append(event->getLevel()->toString()); output.append(LOG4CXX_STR(" - ")); diff --git a/src/main/cpp/threadpatternconverter.cpp b/src/main/cpp/threadpatternconverter.cpp index 18c054df5..be7a8e74a 100644 --- a/src/main/cpp/threadpatternconverter.cpp +++ b/src/main/cpp/threadpatternconverter.cpp @@ -42,8 +42,7 @@ PatternConverterPtr ThreadPatternConverter::newInstance( void ThreadPatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& /* p */) const + LogString& toAppendTo) const { toAppendTo.append(event->getThreadName()); } diff --git a/src/main/cpp/threadusernamepatternconverter.cpp b/src/main/cpp/threadusernamepatternconverter.cpp index 621393b15..dff959e12 100644 --- a/src/main/cpp/threadusernamepatternconverter.cpp +++ b/src/main/cpp/threadusernamepatternconverter.cpp @@ -42,8 +42,7 @@ PatternConverterPtr ThreadUsernamePatternConverter::newInstance( void ThreadUsernamePatternConverter::format( const LoggingEventPtr& event, - LogString& toAppendTo, - Pool& /* p */) const + LogString& toAppendTo) const { toAppendTo.append(event->getThreadUserName()); } diff --git a/src/main/cpp/throwableinformationpatternconverter.cpp b/src/main/cpp/throwableinformationpatternconverter.cpp index 45e4fafe4..0e095af1e 100644 --- a/src/main/cpp/throwableinformationpatternconverter.cpp +++ b/src/main/cpp/throwableinformationpatternconverter.cpp @@ -66,8 +66,7 @@ PatternConverterPtr ThrowableInformationPatternConverter::newInstance( void ThrowableInformationPatternConverter::format( const LoggingEventPtr& /* event */, - LogString& /* toAppendTo */, - Pool& /* p */) const + LogString& /* toAppendTo */) const { } diff --git a/src/main/cpp/timebasedrollingpolicy.cpp b/src/main/cpp/timebasedrollingpolicy.cpp index 0df5ae739..62b919f93 100644 --- a/src/main/cpp/timebasedrollingpolicy.cpp +++ b/src/main/cpp/timebasedrollingpolicy.cpp @@ -30,7 +30,6 @@ #include #include #include -#include using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::rolling; @@ -69,17 +68,17 @@ struct TimeBasedRollingPolicy::TimeBasedRollingPolicyPrivate{ /** * mmap pointer */ - apr_mmap_t* _mmap; +// apr_mmap_t* _mmap; /* * pool for mmap handler * */ - LOG4CXX_NS::helpers::Pool _mmapPool; +// LOG4CXX_NS::helpers::Pool _mmapPool; /** * mmap file descriptor */ - apr_file_t* _file_map; +// apr_file_t* _file_map; /** * mmap file name @@ -89,7 +88,7 @@ struct TimeBasedRollingPolicy::TimeBasedRollingPolicyPrivate{ /* * lock file handle * */ - apr_file_t* _lock_file; +// apr_file_t* _lock_file; /** * Check nextCheck if it has already been set diff --git a/src/main/cpp/xmllayout.cpp b/src/main/cpp/xmllayout.cpp index e26be6c84..a72cfe4dc 100644 --- a/src/main/cpp/xmllayout.cpp +++ b/src/main/cpp/xmllayout.cpp @@ -75,15 +75,14 @@ void XMLLayout::setOption(const LogString& option, } void XMLLayout::format(LogString& output, - const spi::LoggingEventPtr& event, - Pool& p) const + const spi::LoggingEventPtr& event) const { auto& lsMsg = event->getRenderedMessage(); output.reserve(m_priv->expectedPatternLength + lsMsg.size()); output.append(LOG4CXX_STR("getLoggerName()); output.append(LOG4CXX_STR("\" timestamp=\"")); - StringHelper::toString(event->getTimeStamp() / 1000L, p, output); + StringHelper::toString(event->getTimeStamp() / 1000L, output); output.append(LOG4CXX_STR("\" level=\"")); Transform::appendEscapingTags(output, event->getLevel()->toString()); output.append(LOG4CXX_STR("\" thread=\"")); @@ -121,7 +120,7 @@ void XMLLayout::format(LogString& output, LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName()); Transform::appendEscapingTags(output, fileName); output.append(LOG4CXX_STR("\" line=\"")); - StringHelper::toString(locInfo.getLineNumber(), p, output); + StringHelper::toString(locInfo.getLineNumber(), output); output.append(LOG4CXX_STR("\"/>")); output.append(LOG4CXX_EOL); } diff --git a/src/main/cpp/xmlsocketappender.cpp b/src/main/cpp/xmlsocketappender.cpp index f097ebd4a..df07a1acf 100644 --- a/src/main/cpp/xmlsocketappender.cpp +++ b/src/main/cpp/xmlsocketappender.cpp @@ -69,17 +69,15 @@ XMLSocketAppender::XMLSocketAppender() XMLSocketAppender::XMLSocketAppender(InetAddressPtr address1, int port1) : SocketAppenderSkeleton(std::make_unique(address1, port1, DEFAULT_RECONNECTION_DELAY)) { - _priv->layout = std::make_shared(); - Pool p; - activateOptions(p); + _priv->layout = std::make_shared(); + activateOptions(); } XMLSocketAppender::XMLSocketAppender(const LogString& host, int port1) : SocketAppenderSkeleton(std::make_unique(host, port1, DEFAULT_RECONNECTION_DELAY)) { - _priv->layout = std::make_shared(); - Pool p; - activateOptions(p); + _priv->layout = std::make_shared(); + activateOptions(); } XMLSocketAppender::~XMLSocketAppender() @@ -98,7 +96,7 @@ int XMLSocketAppender::getDefaultPort() const return DEFAULT_PORT; } -void XMLSocketAppender::setSocket(LOG4CXX_NS::helpers::SocketPtr& socket, Pool& p) +void XMLSocketAppender::setSocket(LOG4CXX_NS::helpers::SocketPtr& socket) { OutputStreamPtr os = std::make_shared(socket); CharsetEncoderPtr charset(CharsetEncoder::getUTF8Encoder()); @@ -106,7 +104,7 @@ void XMLSocketAppender::setSocket(LOG4CXX_NS::helpers::SocketPtr& socket, Pool& _priv->writer = std::make_shared(os, charset); } -void XMLSocketAppender::cleanUp(Pool& p) +void XMLSocketAppender::cleanUp() { if (_priv->writer) { @@ -121,17 +119,17 @@ void XMLSocketAppender::cleanUp(Pool& p) } } -void XMLSocketAppender::append(const spi::LoggingEventPtr& event, LOG4CXX_NS::helpers::Pool& p) +void XMLSocketAppender::append(const spi::LoggingEventPtr& event) { if (_priv->writer) { LogString output; - _priv->layout->format(output, event, p); + _priv->layout->format(output, event); try { - _priv->writer->write(output, p); - _priv->writer->flush(p); + _priv->writer->write(output); + _priv->writer->flush(); } catch (std::exception& e) { diff --git a/src/main/include/log4cxx/config/propertysetter.h b/src/main/include/log4cxx/config/propertysetter.h index 072a3278f..5bd430039 100644 --- a/src/main/include/log4cxx/config/propertysetter.h +++ b/src/main/include/log4cxx/config/propertysetter.h @@ -38,7 +38,6 @@ namespace LOG4CXX_NS namespace helpers { class Properties; -class Pool; } namespace config @@ -80,21 +79,18 @@ class LOG4CXX_EXPORT PropertySetter @param obj The object to configure. @param properties A java.util.Properties containing keys and values. - @param prefix Only keys having the specified prefix will be set. - @param p pool to use for any allocations required during call. + @param prefix Only keys having the specified prefix will be set. */ static void setProperties(const helpers::ObjectPtr& obj, helpers::Properties& properties, - const LogString& prefix, - LOG4CXX_NS::helpers::Pool& p); + const LogString& prefix); /** Set the properites for the object that match the prefix passed as parameter. */ void setProperties(helpers::Properties& properties, - const LogString& prefix, - LOG4CXX_NS::helpers::Pool& p); + const LogString& prefix); /** Set a property on this PropertySetter's Object. If the underlying @@ -102,14 +98,12 @@ class LOG4CXX_EXPORT PropertySetter {@link spi::OptionHandler#setOption setOption} method is called. @param option name of the property - @param value String value of the property - @param p pool to use for any allocations required during call. + @param value String value of the property */ void setProperty(const LogString& option, - const LogString& value, - LOG4CXX_NS::helpers::Pool& p); + const LogString& value); - void activate(LOG4CXX_NS::helpers::Pool& p); + void activate(); }; // class PropertySetter } // namespace config; } // namespace log4cxx diff --git a/src/main/include/log4cxx/file.h b/src/main/include/log4cxx/file.h index 7a611f47e..33c5e5c91 100644 --- a/src/main/include/log4cxx/file.h +++ b/src/main/include/log4cxx/file.h @@ -107,7 +107,7 @@ class LOG4CXX_EXPORT File * Determines last modification date. * @return length of file. */ - log4cxx_time_t lastModified() const; + std::filesystem::file_time_type lastModified() const; /** * Get final portion of file path. * @return file name. diff --git a/src/main/include/log4cxx/helpers/date.h b/src/main/include/log4cxx/helpers/date.h index 4b01ebcbb..9e157a78d 100644 --- a/src/main/include/log4cxx/helpers/date.h +++ b/src/main/include/log4cxx/helpers/date.h @@ -21,6 +21,7 @@ #include #include #include +#include namespace LOG4CXX_NS { @@ -57,8 +58,8 @@ class LOG4CXX_EXPORT Date : public Object log4cxx_time_t getNextSecond() const; - static log4cxx_time_t getMicrosecondsPerDay(); - static log4cxx_time_t getMicrosecondsPerSecond(); + static std::chrono::microseconds getMicrosecondsPerDay(); + static std::chrono::microseconds getMicrosecondsPerSecond(); static log4cxx_time_t getCurrentTimeStd(); static log4cxx_time_t currentTime(); diff --git a/src/main/include/log4cxx/helpers/relativetimedateformat.h b/src/main/include/log4cxx/helpers/relativetimedateformat.h index 6d32c6e6a..66b495131 100644 --- a/src/main/include/log4cxx/helpers/relativetimedateformat.h +++ b/src/main/include/log4cxx/helpers/relativetimedateformat.h @@ -34,8 +34,7 @@ class LOG4CXX_EXPORT RelativeTimeDateFormat : public DateFormat public: RelativeTimeDateFormat(); virtual void format(LogString& s, - log4cxx_time_t tm, - LOG4CXX_NS::helpers::Pool& p) const; + log4cxx_time_t tm) const; private: log4cxx_time_t startTime; diff --git a/src/main/include/log4cxx/htmllayout.h b/src/main/include/log4cxx/htmllayout.h index 0f72225f1..05930e877 100644 --- a/src/main/include/log4cxx/htmllayout.h +++ b/src/main/include/log4cxx/htmllayout.h @@ -83,7 +83,7 @@ class LOG4CXX_EXPORT HTMLLayout : public Layout No action is performed in this implementation. */ - void activateOptions(helpers::Pool& /* p */) override {} + void activateOptions() override {} /** \copybrief spi::OptionHandler::setOption() @@ -95,18 +95,17 @@ class LOG4CXX_EXPORT HTMLLayout : public Layout */ void setOption(const LogString& option, const LogString& value) override; - void format(LogString& output, - const spi::LoggingEventPtr& event, helpers::Pool& pool) const override; + void format(LogString& output, const spi::LoggingEventPtr& event) const override; /** Append appropriate HTML headers. */ - void appendHeader(LogString& output, helpers::Pool& pool) override; + void appendHeader(LogString& output) override; /** Append the appropriate HTML footers. */ - void appendFooter(LogString& output, helpers::Pool& pool) override; + void appendFooter(LogString& output) override; /** The HTML layout handles the throwable contained in logging diff --git a/src/main/include/log4cxx/jsonlayout.h b/src/main/include/log4cxx/jsonlayout.h index 31e47c14d..9ddb0f455 100644 --- a/src/main/include/log4cxx/jsonlayout.h +++ b/src/main/include/log4cxx/jsonlayout.h @@ -40,7 +40,7 @@ class LOG4CXX_EXPORT JSONLayout : public Layout void appendSerializedNDC(LogString& buf, const spi::LoggingEventPtr& event) const; void appendSerializedLocationInfo(LogString& buf, - const spi::LoggingEventPtr& event, LOG4CXX_NS::helpers::Pool& p) const; + const spi::LoggingEventPtr& event) const; public: static void appendItem(const LogString& item, LogString& toAppendTo); @@ -105,7 +105,7 @@ class LOG4CXX_EXPORT JSONLayout : public Layout No action is performed in this implementation. */ - void activateOptions(helpers::Pool& /* p */) override; + void activateOptions() override; /** \copybrief spi::OptionHandler::setOption() @@ -119,7 +119,7 @@ class LOG4CXX_EXPORT JSONLayout : public Layout void setOption(const LogString& option, const LogString& value) override; void format(LogString& output, - const spi::LoggingEventPtr& event, helpers::Pool& pool) const override; + const spi::LoggingEventPtr& event) const override; /** The JSON layout handles the throwable contained in logging diff --git a/src/main/include/log4cxx/layout.h b/src/main/include/log4cxx/layout.h index c3931a872..a04ef3e73 100644 --- a/src/main/include/log4cxx/layout.h +++ b/src/main/include/log4cxx/layout.h @@ -45,7 +45,7 @@ class LOG4CXX_EXPORT Layout : Implement this method to create your own layout format. */ virtual void format(LogString& output, - const spi::LoggingEventPtr& event, LOG4CXX_NS::helpers::Pool& pool) const = 0; + const spi::LoggingEventPtr& event) const = 0; /** Returns the content type output by this layout. The base class @@ -57,13 +57,13 @@ class LOG4CXX_EXPORT Layout : Append the header for the layout format. The base class does nothing. */ - virtual void appendHeader(LogString& output, LOG4CXX_NS::helpers::Pool& p); + virtual void appendHeader(LogString& output); /** Append the footer for the layout format. The base class does nothing. */ - virtual void appendFooter(LogString& output, LOG4CXX_NS::helpers::Pool& p); + virtual void appendFooter(LogString& output); /** If the layout handles the throwable object contained within diff --git a/src/main/include/log4cxx/logger.h b/src/main/include/log4cxx/logger.h index 4078615da..ac4e232a3 100644 --- a/src/main/include/log4cxx/logger.h +++ b/src/main/include/log4cxx/logger.h @@ -98,7 +98,7 @@ class LOG4CXX_EXPORT Logger @param event the event to log. @param p memory pool for any allocations needed to process request. */ - void callAppenders(const spi::LoggingEventPtr& event, helpers::Pool& p) const; + void callAppenders(const spi::LoggingEventPtr& event) const; /** Close all attached appenders implementing the AppenderAttachable diff --git a/src/main/include/log4cxx/net/socketappenderskeleton.h b/src/main/include/log4cxx/net/socketappenderskeleton.h index fad8a8a12..3cf1aba61 100644 --- a/src/main/include/log4cxx/net/socketappenderskeleton.h +++ b/src/main/include/log4cxx/net/socketappenderskeleton.h @@ -146,7 +146,7 @@ class LOG4CXX_EXPORT SocketAppenderSkeleton : public AppenderSkeleton virtual void setSocket(LOG4CXX_NS::helpers::SocketPtr& socket) = 0; - virtual void cleanUp(p) = 0; + virtual void cleanUp() = 0; virtual int getDefaultDelay() const = 0; diff --git a/src/main/include/log4cxx/net/xmlsocketappender.h b/src/main/include/log4cxx/net/xmlsocketappender.h index 44dd01dbf..04ccfbf1e 100644 --- a/src/main/include/log4cxx/net/xmlsocketappender.h +++ b/src/main/include/log4cxx/net/xmlsocketappender.h @@ -135,15 +135,15 @@ class LOG4CXX_EXPORT XMLSocketAppender : public SocketAppenderSkeleton protected: - void setSocket(LOG4CXX_NS::helpers::SocketPtr& socket, helpers::Pool& p) override; + void setSocket(LOG4CXX_NS::helpers::SocketPtr& socket) override; - void cleanUp(helpers::Pool& p) override; + void cleanUp() override; int getDefaultDelay() const override; int getDefaultPort() const override; - void append(const spi::LoggingEventPtr& event, helpers::Pool& pool) override; + void append(const spi::LoggingEventPtr& event) override; private: // prevent copy and assignment statements diff --git a/src/main/include/log4cxx/pattern/fulllocationpatternconverter.h b/src/main/include/log4cxx/pattern/fulllocationpatternconverter.h index 7c696cd8d..873470484 100644 --- a/src/main/include/log4cxx/pattern/fulllocationpatternconverter.h +++ b/src/main/include/log4cxx/pattern/fulllocationpatternconverter.h @@ -55,8 +55,7 @@ class LOG4CXX_EXPORT FullLocationPatternConverter using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } diff --git a/src/main/include/log4cxx/pattern/levelpatternconverter.h b/src/main/include/log4cxx/pattern/levelpatternconverter.h index 1b3be654c..c2b15ae1e 100644 --- a/src/main/include/log4cxx/pattern/levelpatternconverter.h +++ b/src/main/include/log4cxx/pattern/levelpatternconverter.h @@ -54,8 +54,7 @@ class LOG4CXX_EXPORT LevelPatternConverter : public LoggingEventPatternConverter using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; LogString getStyleClass(const helpers::ObjectPtr& e) const override; }; diff --git a/src/main/include/log4cxx/pattern/linelocationpatternconverter.h b/src/main/include/log4cxx/pattern/linelocationpatternconverter.h index 32514dee5..23b61572d 100644 --- a/src/main/include/log4cxx/pattern/linelocationpatternconverter.h +++ b/src/main/include/log4cxx/pattern/linelocationpatternconverter.h @@ -55,8 +55,7 @@ class LOG4CXX_EXPORT LineLocationPatternConverter using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } diff --git a/src/main/include/log4cxx/pattern/lineseparatorpatternconverter.h b/src/main/include/log4cxx/pattern/lineseparatorpatternconverter.h index a0b499526..472967e38 100644 --- a/src/main/include/log4cxx/pattern/lineseparatorpatternconverter.h +++ b/src/main/include/log4cxx/pattern/lineseparatorpatternconverter.h @@ -55,12 +55,10 @@ class LOG4CXX_EXPORT LineSeparatorPatternConverter using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; void format(const helpers::ObjectPtr& obj, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } diff --git a/src/main/include/log4cxx/pattern/literalpatternconverter.h b/src/main/include/log4cxx/pattern/literalpatternconverter.h index 19ba6a97e..76752ecba 100644 --- a/src/main/include/log4cxx/pattern/literalpatternconverter.h +++ b/src/main/include/log4cxx/pattern/literalpatternconverter.h @@ -50,12 +50,10 @@ class LOG4CXX_EXPORT LiteralPatternConverter : public LoggingEventPatternConvert using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; void format(const helpers::ObjectPtr& obj, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } diff --git a/src/main/include/log4cxx/pattern/loggerpatternconverter.h b/src/main/include/log4cxx/pattern/loggerpatternconverter.h index f91e74525..afed93f1d 100644 --- a/src/main/include/log4cxx/pattern/loggerpatternconverter.h +++ b/src/main/include/log4cxx/pattern/loggerpatternconverter.h @@ -55,8 +55,7 @@ class LOG4CXX_EXPORT LoggerPatternConverter : public NamePatternConverter using NamePatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } diff --git a/src/main/include/log4cxx/pattern/mdcpatternconverter.h b/src/main/include/log4cxx/pattern/mdcpatternconverter.h index f3ce34f64..281acecd5 100644 --- a/src/main/include/log4cxx/pattern/mdcpatternconverter.h +++ b/src/main/include/log4cxx/pattern/mdcpatternconverter.h @@ -54,8 +54,7 @@ class LOG4CXX_EXPORT MDCPatternConverter : public LoggingEventPatternConverter void format ( const spi::LoggingEventPtr& event - , LogString& toAppendTo - , helpers::Pool& p + , LogString& toAppendTo ) const override; }; } diff --git a/src/main/include/log4cxx/pattern/messagepatternconverter.h b/src/main/include/log4cxx/pattern/messagepatternconverter.h index b9e9a3a33..6f837a42d 100644 --- a/src/main/include/log4cxx/pattern/messagepatternconverter.h +++ b/src/main/include/log4cxx/pattern/messagepatternconverter.h @@ -54,8 +54,7 @@ class LOG4CXX_EXPORT MessagePatternConverter : public LoggingEventPatternConvert using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } } diff --git a/src/main/include/log4cxx/pattern/methodlocationpatternconverter.h b/src/main/include/log4cxx/pattern/methodlocationpatternconverter.h index 572301af0..ec7f2ddbc 100644 --- a/src/main/include/log4cxx/pattern/methodlocationpatternconverter.h +++ b/src/main/include/log4cxx/pattern/methodlocationpatternconverter.h @@ -55,8 +55,7 @@ class LOG4CXX_EXPORT MethodLocationPatternConverter using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } } diff --git a/src/main/include/log4cxx/pattern/ndcpatternconverter.h b/src/main/include/log4cxx/pattern/ndcpatternconverter.h index e00f8fc8b..4fa145489 100644 --- a/src/main/include/log4cxx/pattern/ndcpatternconverter.h +++ b/src/main/include/log4cxx/pattern/ndcpatternconverter.h @@ -54,8 +54,7 @@ class LOG4CXX_EXPORT NDCPatternConverter : public LoggingEventPatternConverter using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } } diff --git a/src/main/include/log4cxx/pattern/propertiespatternconverter.h b/src/main/include/log4cxx/pattern/propertiespatternconverter.h index e24a26861..1d6c3275c 100644 --- a/src/main/include/log4cxx/pattern/propertiespatternconverter.h +++ b/src/main/include/log4cxx/pattern/propertiespatternconverter.h @@ -67,8 +67,7 @@ class LOG4CXX_EXPORT PropertiesPatternConverter using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - LOG4CXX_NS::helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } } diff --git a/src/main/include/log4cxx/pattern/relativetimepatternconverter.h b/src/main/include/log4cxx/pattern/relativetimepatternconverter.h index 028ec0181..bb9f5ba7e 100644 --- a/src/main/include/log4cxx/pattern/relativetimepatternconverter.h +++ b/src/main/include/log4cxx/pattern/relativetimepatternconverter.h @@ -58,8 +58,7 @@ class LOG4CXX_EXPORT RelativeTimePatternConverter : public LoggingEventPatternCo void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - LOG4CXX_NS::helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } } diff --git a/src/main/include/log4cxx/pattern/shortfilelocationpatternconverter.h b/src/main/include/log4cxx/pattern/shortfilelocationpatternconverter.h index 1f5bcd33e..9f7b79fbf 100644 --- a/src/main/include/log4cxx/pattern/shortfilelocationpatternconverter.h +++ b/src/main/include/log4cxx/pattern/shortfilelocationpatternconverter.h @@ -58,8 +58,7 @@ class LOG4CXX_EXPORT ShortFileLocationPatternConverter using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } diff --git a/src/main/include/log4cxx/pattern/threadpatternconverter.h b/src/main/include/log4cxx/pattern/threadpatternconverter.h index 0292f4c82..8e74e5d69 100644 --- a/src/main/include/log4cxx/pattern/threadpatternconverter.h +++ b/src/main/include/log4cxx/pattern/threadpatternconverter.h @@ -54,8 +54,7 @@ class LOG4CXX_EXPORT ThreadPatternConverter : public LoggingEventPatternConverte using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } } diff --git a/src/main/include/log4cxx/pattern/threadusernamepatternconverter.h b/src/main/include/log4cxx/pattern/threadusernamepatternconverter.h index fc18813ba..7c4f17aa1 100644 --- a/src/main/include/log4cxx/pattern/threadusernamepatternconverter.h +++ b/src/main/include/log4cxx/pattern/threadusernamepatternconverter.h @@ -43,8 +43,7 @@ class LOG4CXX_EXPORT ThreadUsernamePatternConverter : public LoggingEventPattern const std::vector& options); void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - LOG4CXX_NS::helpers::Pool& p) const override; + LogString& toAppendTo) const override; }; } diff --git a/src/main/include/log4cxx/pattern/throwableinformationpatternconverter.h b/src/main/include/log4cxx/pattern/throwableinformationpatternconverter.h index 549009742..aa2e7aa61 100644 --- a/src/main/include/log4cxx/pattern/throwableinformationpatternconverter.h +++ b/src/main/include/log4cxx/pattern/throwableinformationpatternconverter.h @@ -60,8 +60,7 @@ class LOG4CXX_EXPORT ThrowableInformationPatternConverter using LoggingEventPatternConverter::format; void format(const spi::LoggingEventPtr& event, - LogString& toAppendTo, - helpers::Pool& p) const override; + LogString& toAppendTo) const override; /** * This converter obviously handles throwables. diff --git a/src/main/include/log4cxx/patternlayout.h b/src/main/include/log4cxx/patternlayout.h index bf03655dc..938be1604 100644 --- a/src/main/include/log4cxx/patternlayout.h +++ b/src/main/include/log4cxx/patternlayout.h @@ -526,8 +526,7 @@ class LOG4CXX_EXPORT PatternLayout : public Layout * Produces a formatted string as specified by the conversion pattern. */ void format( LogString& output, - const spi::LoggingEventPtr& event, - helpers::Pool& pool) const override; + const spi::LoggingEventPtr& event) const override; protected: virtual LOG4CXX_NS::pattern::PatternMap getFormatSpecifiers(); diff --git a/src/main/include/log4cxx/rolling/rollingfileappender.h b/src/main/include/log4cxx/rolling/rollingfileappender.h index e34916a32..877dba4c8 100644 --- a/src/main/include/log4cxx/rolling/rollingfileappender.h +++ b/src/main/include/log4cxx/rolling/rollingfileappender.h @@ -152,7 +152,7 @@ class LOG4CXX_EXPORT RollingFileAppender : public FileAppender \sa FileAppender::activateOptions() */ - void activateOptions(helpers::Pool& pool ) override; + void activateOptions() override; /** Implements the configured roll over behaviour. @@ -168,16 +168,16 @@ class LOG4CXX_EXPORT RollingFileAppender : public FileAppender File is truncated with no backup files created. */ - bool rollover(LOG4CXX_NS::helpers::Pool& p); + bool rollover(); protected: /** Actual writing occurs here. */ - void subAppend(const spi::LoggingEventPtr& event, helpers::Pool& p) override; + void subAppend(const spi::LoggingEventPtr& event) override; - bool rolloverInternal(LOG4CXX_NS::helpers::Pool& p); + bool rolloverInternal(); public: /** diff --git a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h index 8d4628c0d..c350cc588 100755 --- a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h +++ b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h @@ -161,7 +161,7 @@ class LOG4CXX_EXPORT TimeBasedRollingPolicy : public virtual RollingPolicyBase, \sa RollingPolicyBase::activateOptions() */ - void activateOptions(helpers::Pool& ) override; + void activateOptions() override; void setMultiprocess(bool multiprocess); @@ -170,16 +170,14 @@ class LOG4CXX_EXPORT TimeBasedRollingPolicy : public virtual RollingPolicyBase, */ RolloverDescriptionPtr initialize( const LogString& currentActiveFile, - const bool append, - helpers::Pool& pool) override; + const bool append) override; /** * {@inheritDoc} */ RolloverDescriptionPtr rollover( const LogString& currentActiveFile, - const bool append, - helpers::Pool& pool) override; + const bool append) override; /** * Determines if a rollover may be appropriate at this time. If @@ -232,17 +230,17 @@ class LOG4CXX_EXPORT TimeBasedRollingPolicy : public virtual RollingPolicyBase, /** * Generate mmap file */ - int createMMapFile(const std::string& lastfilename, LOG4CXX_NS::helpers::Pool& pool); + int createMMapFile(const std::string& lastfilename); /** * Detect if the mmap file is empty */ - bool isMapFileEmpty(LOG4CXX_NS::helpers::Pool& pool); + bool isMapFileEmpty(); /** * init MMapFile */ - void initMMapFile(const LogString& lastFileName, LOG4CXX_NS::helpers::Pool& pool); + void initMMapFile(const LogString& lastFileName); /** * lock MMapFile @@ -257,7 +255,7 @@ class LOG4CXX_EXPORT TimeBasedRollingPolicy : public virtual RollingPolicyBase, /** * create MMapFile/lockFile */ - const std::string createFile(const std::string& filename, const std::string& suffix, LOG4CXX_NS::helpers::Pool& pool); + const std::string createFile(const std::string& filename, const std::string& suffix); }; diff --git a/src/main/include/log4cxx/simplelayout.h b/src/main/include/log4cxx/simplelayout.h index 20d909022..8a2e47d42 100644 --- a/src/main/include/log4cxx/simplelayout.h +++ b/src/main/include/log4cxx/simplelayout.h @@ -50,8 +50,7 @@ class LOG4CXX_EXPORT SimpleLayout : public Layout */ void format(LogString& output, - const spi::LoggingEventPtr& event, - helpers::Pool& pool) const override; + const spi::LoggingEventPtr& event) const override; /** The SimpleLayout does not handle the throwable contained within @@ -68,7 +67,7 @@ class LOG4CXX_EXPORT SimpleLayout : public Layout No action is performed in this implementation. */ - void activateOptions(helpers::Pool& /* p */) override {} + void activateOptions() override {} /** \copybrief spi::OptionHandler::setOption() diff --git a/src/main/include/log4cxx/xml/xmllayout.h b/src/main/include/log4cxx/xml/xmllayout.h index 40484941a..b69e389f3 100644 --- a/src/main/include/log4cxx/xml/xmllayout.h +++ b/src/main/include/log4cxx/xml/xmllayout.h @@ -102,7 +102,7 @@ class LOG4CXX_EXPORT XMLLayout : public Layout No action is performed in this implementation. */ - void activateOptions(helpers::Pool& /* p */) override { } + void activateOptions() override { } /** \copybrief spi::OptionHandler::setOption() @@ -120,8 +120,7 @@ class LOG4CXX_EXPORT XMLLayout : public Layout * in conformance with the log4cxx.dtd. **/ void format(LogString& output, - const spi::LoggingEventPtr& event, - helpers::Pool& p) const override; + const spi::LoggingEventPtr& event) const override; /** The XMLLayout prints and does not ignore exceptions. Hence the