Merge branch 'master' into cpp11-and-better
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b728ff7..63c83e4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,6 +23,8 @@
# Find Apache Runtime Utilities
find_package(APR-Util REQUIRED)
+find_package( Threads REQUIRED )
+
# Find expat for XML parsing
find_package(EXPAT REQUIRED)
diff --git a/src/main/cpp/CMakeLists.txt b/src/main/cpp/CMakeLists.txt
index 213ece5..08b7deb 100644
--- a/src/main/cpp/CMakeLists.txt
+++ b/src/main/cpp/CMakeLists.txt
@@ -28,7 +28,6 @@
class.cpp
classnamepatternconverter.cpp
classregistration.cpp
- condition.cpp
configurator.cpp
consoleappender.cpp
cyclicbuffer.cpp
@@ -92,7 +91,6 @@
messagebuffer.cpp
messagepatternconverter.cpp
methodlocationpatternconverter.cpp
- mutex.cpp
nameabbreviator.cpp
namepatternconverter.cpp
ndc.cpp
@@ -140,14 +138,12 @@
stringhelper.cpp
stringmatchfilter.cpp
stringtokenizer.cpp
- synchronized.cpp
syslogappender.cpp
syslogwriter.cpp
system.cpp
systemerrwriter.cpp
systemoutwriter.cpp
telnetappender.cpp
- threadcxx.cpp
threadlocal.cpp
threadpatternconverter.cpp
threadspecificdata.cpp
@@ -168,3 +164,5 @@
VERSION ${LIBLOG4CXX_LIB_VERSION}
SOVERSION ${LIBLOG4CXX_LIB_SOVERSION}
)
+target_compile_features(log4cxx PUBLIC
+ cxx_std_17)
diff --git a/src/main/cpp/action.cpp b/src/main/cpp/action.cpp
index ee347e4..b4b3851 100644
--- a/src/main/cpp/action.cpp
+++ b/src/main/cpp/action.cpp
@@ -16,7 +16,6 @@
*/
#include <log4cxx/logstring.h>
#include <log4cxx/rolling/action.h>
-#include <log4cxx/helpers/synchronized.h>
using namespace log4cxx;
using namespace log4cxx::rolling;
@@ -27,8 +26,7 @@
Action::Action() :
complete(false),
interrupted(false),
- pool(),
- mutex(pool)
+ pool()
{
}
@@ -41,7 +39,7 @@
*/
void Action::run(log4cxx::helpers::Pool& pool1)
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
if (!interrupted)
{
@@ -64,7 +62,7 @@
*/
void Action::close()
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
interrupted = true;
}
diff --git a/src/main/cpp/appenderattachableimpl.cpp b/src/main/cpp/appenderattachableimpl.cpp
index ad85216..7dbad3d 100644
--- a/src/main/cpp/appenderattachableimpl.cpp
+++ b/src/main/cpp/appenderattachableimpl.cpp
@@ -29,8 +29,7 @@
AppenderAttachableImpl::AppenderAttachableImpl(Pool& pool)
- : appenderList(),
- mutex(pool)
+ : appenderList()
{
}
diff --git a/src/main/cpp/appenderskeleton.cpp b/src/main/cpp/appenderskeleton.cpp
index 42c1999..18febbc 100644
--- a/src/main/cpp/appenderskeleton.cpp
+++ b/src/main/cpp/appenderskeleton.cpp
@@ -21,9 +21,6 @@
#include <log4cxx/helpers/onlyonceerrorhandler.h>
#include <log4cxx/level.h>
#include <log4cxx/helpers/stringhelper.h>
-#include <log4cxx/helpers/synchronized.h>
-#include <apr_atomic.h>
-
using namespace log4cxx;
using namespace log4cxx::spi;
@@ -39,10 +36,9 @@
errorHandler(new OnlyOnceErrorHandler()),
headFilter(),
tailFilter(),
- pool(),
- SHARED_MUTEX_INIT(mutex, pool)
+ pool()
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
closed = false;
}
@@ -53,10 +49,9 @@
errorHandler(new OnlyOnceErrorHandler()),
headFilter(),
tailFilter(),
- pool(),
- SHARED_MUTEX_INIT(mutex, pool)
+ pool()
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
closed = false;
}
@@ -84,7 +79,7 @@
void AppenderSkeleton::addFilter(const spi::FilterPtr& newFilter)
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
if (headFilter == 0)
{
@@ -99,7 +94,7 @@
void AppenderSkeleton::clearFilters()
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
headFilter = tailFilter = 0;
}
@@ -110,7 +105,7 @@
void AppenderSkeleton::doAppend(const spi::LoggingEventPtr& event, Pool& pool1)
{
- LOCK_W sync(mutex);
+ std::shared_lock lock(mutex);
doAppendImpl(event, pool1);
}
@@ -153,7 +148,7 @@
void AppenderSkeleton::setErrorHandler(const spi::ErrorHandlerPtr& errorHandler1)
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
if (errorHandler1 == 0)
{
@@ -169,7 +164,7 @@
void AppenderSkeleton::setThreshold(const LevelPtr& threshold1)
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
this->threshold = threshold1;
}
diff --git a/src/main/cpp/aprinitializer.cpp b/src/main/cpp/aprinitializer.cpp
index ccb7241..5c4fdd7 100644
--- a/src/main/cpp/aprinitializer.cpp
+++ b/src/main/cpp/aprinitializer.cpp
@@ -25,7 +25,6 @@
#include <log4cxx/helpers/threadspecificdata.h>
#include <apr_thread_mutex.h>
#include <apr_thread_proc.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/helpers/filewatchdog.h>
using namespace log4cxx::helpers;
@@ -42,7 +41,7 @@
}
}
-APRInitializer::APRInitializer() : p(0), mutex(0), startTime(0), tlsKey(0)
+APRInitializer::APRInitializer() : p(0), startTime(0), tlsKey(0)
{
apr_initialize();
apr_pool_create(&p, NULL);
@@ -50,8 +49,7 @@
startTime = apr_time_now();
#if APR_HAS_THREADS
apr_status_t stat = apr_threadkey_private_create(&tlsKey, tlsDestruct, p);
- assert(stat == APR_SUCCESS);
- stat = apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_NESTED, p);
+ assert(stat == APR_SUCCESS);
assert(stat == APR_SUCCESS);
#endif
}
@@ -60,7 +58,7 @@
{
{
#if APR_HAS_THREADS
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
apr_threadkey_private_delete(tlsKey);
#endif
@@ -105,7 +103,7 @@
{
APRInitializer& instance(getInstance());
#if APR_HAS_THREADS
- synchronized sync(instance.mutex);
+ std::unique_lock lock(instance.mutex);
#endif
instance.watchdogs.push_back(watchdog);
}
@@ -114,7 +112,7 @@
{
APRInitializer& instance(getInstance());
#if APR_HAS_THREADS
- synchronized sync(instance.mutex);
+ std::unique_lock lock(instance.mutex);
#endif
for (std::list<FileWatchdog*>::iterator iter = instance.watchdogs.begin();
diff --git a/src/main/cpp/asyncappender.cpp b/src/main/cpp/asyncappender.cpp
index 20b80b7..987182f 100644
--- a/src/main/cpp/asyncappender.cpp
+++ b/src/main/cpp/asyncappender.cpp
@@ -27,8 +27,6 @@
#include <apr_thread_proc.h>
#include <apr_thread_mutex.h>
#include <apr_thread_cond.h>
-#include <log4cxx/helpers/condition.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/helpers/stringhelper.h>
#include <apr_atomic.h>
#include <log4cxx/helpers/optionconverter.h>
@@ -44,10 +42,7 @@
AsyncAppender::AsyncAppender()
: AppenderSkeleton(),
- buffer(),
- bufferMutex(pool),
- bufferNotFull(pool),
- bufferNotEmpty(pool),
+ buffer(),
discardMap(new DiscardMap()),
bufferSize(DEFAULT_BUFFER_SIZE),
appenders(new AppenderAttachableImpl(pool)),
@@ -55,9 +50,7 @@
locationInfo(false),
blocking(true)
{
-#if APR_HAS_THREADS
- dispatcher.run(dispatch, this);
-#endif
+ dispatcher = std::thread( &AsyncAppender::dispatch, this );
}
AsyncAppender::~AsyncAppender()
@@ -78,7 +71,7 @@
void AsyncAppender::addAppender(const AppenderPtr& newAppender)
{
- synchronized sync(appenders->getMutex());
+ std::unique_lock lock(appenders->getMutex());
appenders->addAppender(newAppender);
}
@@ -109,25 +102,23 @@
void AsyncAppender::doAppend(const spi::LoggingEventPtr& event, Pool& pool1)
{
- LOCK_R sync(mutex);
+ std::shared_lock lock(mutex);
doAppendImpl(event, pool1);
}
void AsyncAppender::append(const spi::LoggingEventPtr& event, Pool& p)
{
-#if APR_HAS_THREADS
-
//
// if dispatcher has died then
// append subsequent events synchronously
//
- if (!dispatcher.isAlive() || bufferSize <= 0)
+ if (!dispatcher.joinable() || bufferSize <= 0)
{
- synchronized sync(appenders->getMutex());
+ std::unique_lock lock(appenders->getMutex());
appenders->appendLoopOnAppenders(event, p);
return;
- }
+ }
// Set the NDC and thread name for the calling thread as these
// LoggingEvent fields were not set at event creation time.
@@ -138,8 +129,8 @@
event->getMDCCopy();
- {
- synchronized sync(bufferMutex);
+ {
+ std::unique_lock lock(bufferMutex);
while (true)
{
@@ -151,7 +142,7 @@
if (previousSize == 0)
{
- bufferNotEmpty.signalAll();
+ bufferNotEmpty.notify_all();
}
break;
@@ -167,12 +158,12 @@
bool discard = true;
if (blocking
- && !Thread::interrupted()
- && !dispatcher.isCurrentThread())
+ //&& !Thread::interrupted()
+ && (dispatcher.get_id() != std::this_thread::get_id()) )
{
try
{
- bufferNotFull.await(bufferMutex);
+ bufferNotFull.wait(lock);
discard = false;
}
catch (InterruptedException&)
@@ -181,7 +172,7 @@
// reset interrupt status so
// calling code can see interrupt on
// their next wait or sleep.
- Thread::currentThreadInterrupt();
+ //Thread::currentThreadInterrupt();
}
}
@@ -208,38 +199,24 @@
}
}
}
-#else
- synchronized sync(appenders->getMutex());
- appenders->appendLoopOnAppenders(event, p);
-#endif
}
void AsyncAppender::close()
{
{
- synchronized sync(bufferMutex);
+ std::unique_lock lock(bufferMutex);
closed = true;
- bufferNotEmpty.signalAll();
- bufferNotFull.signalAll();
+ bufferNotEmpty.notify_all();
+ bufferNotFull.notify_all();
}
-#if APR_HAS_THREADS
-
- try
- {
- dispatcher.join();
- }
- catch (InterruptedException& e)
- {
- Thread::currentThreadInterrupt();
- LogLog::error(LOG4CXX_STR("Got an InterruptedException while waiting for the dispatcher to finish,"), e);
- }
-
-#endif
+ if( dispatcher.joinable() ){
+ dispatcher.join();
+ }
{
- synchronized sync(appenders->getMutex());
+ std::unique_lock lock(appenders->getMutex());
AppenderList appenderList = appenders->getAllAppenders();
for (AppenderList::iterator iter = appenderList.begin();
@@ -253,19 +230,19 @@
AppenderList AsyncAppender::getAllAppenders() const
{
- synchronized sync(appenders->getMutex());
+ std::unique_lock lock(appenders->getMutex());
return appenders->getAllAppenders();
}
AppenderPtr AsyncAppender::getAppender(const LogString& n) const
{
- synchronized sync(appenders->getMutex());
+ std::unique_lock lock(appenders->getMutex());
return appenders->getAppender(n);
}
bool AsyncAppender::isAttached(const AppenderPtr& appender) const
{
- synchronized sync(appenders->getMutex());
+ std::unique_lock lock(appenders->getMutex());
return appenders->isAttached(appender);
}
@@ -276,19 +253,19 @@
void AsyncAppender::removeAllAppenders()
{
- synchronized sync(appenders->getMutex());
+ std::unique_lock lock(appenders->getMutex());
appenders->removeAllAppenders();
}
void AsyncAppender::removeAppender(const AppenderPtr& appender)
{
- synchronized sync(appenders->getMutex());
+ std::unique_lock lock(appenders->getMutex());
appenders->removeAppender(appender);
}
void AsyncAppender::removeAppender(const LogString& n)
{
- synchronized sync(appenders->getMutex());
+ std::unique_lock lock(appenders->getMutex());
appenders->removeAppender(n);
}
@@ -310,9 +287,9 @@
throw IllegalArgumentException(LOG4CXX_STR("size argument must be non-negative"));
}
- synchronized sync(bufferMutex);
+ std::unique_lock lock(bufferMutex);
bufferSize = (size < 1) ? 1 : size;
- bufferNotFull.signalAll();
+ bufferNotFull.notify_all();
}
int AsyncAppender::getBufferSize() const
@@ -322,9 +299,9 @@
void AsyncAppender::setBlocking(bool value)
{
- synchronized sync(bufferMutex);
+ std::unique_lock lock(bufferMutex);
blocking = value;
- bufferNotFull.signalAll();
+ bufferNotFull.notify_all();
}
bool AsyncAppender::getBlocking() const
@@ -387,10 +364,8 @@
LocationInfo::getLocationUnavailable());
}
-#if APR_HAS_THREADS
-void* LOG4CXX_THREAD_FUNC AsyncAppender::dispatch(apr_thread_t* /*thread*/, void* data)
+void AsyncAppender::dispatch()
{
- AsyncAppender* pThis = (AsyncAppender*) data;
bool isActive = true;
try
@@ -402,54 +377,52 @@
//
Pool p;
LoggingEventList events;
- {
- synchronized sync(pThis->bufferMutex);
- size_t bufferSize = pThis->buffer.size();
- isActive = !pThis->closed;
+ {
+ std::unique_lock lock(bufferMutex);
+ size_t bufferSize = buffer.size();
+ isActive = !closed;
while ((bufferSize == 0) && isActive)
{
- pThis->bufferNotEmpty.await(pThis->bufferMutex);
- bufferSize = pThis->buffer.size();
- isActive = !pThis->closed;
+ bufferNotEmpty.wait(lock);
+ bufferSize = buffer.size();
+ isActive = !closed;
}
- for (LoggingEventList::iterator eventIter = pThis->buffer.begin();
- eventIter != pThis->buffer.end();
+ for (LoggingEventList::iterator eventIter = buffer.begin();
+ eventIter != buffer.end();
eventIter++)
{
events.push_back(*eventIter);
}
- for (DiscardMap::iterator discardIter = pThis->discardMap->begin();
- discardIter != pThis->discardMap->end();
+ for (DiscardMap::iterator discardIter = discardMap->begin();
+ discardIter != discardMap->end();
discardIter++)
{
events.push_back(discardIter->second.createEvent(p));
}
- pThis->buffer.clear();
- pThis->discardMap->clear();
- pThis->bufferNotFull.signalAll();
+ buffer.clear();
+ discardMap->clear();
+ bufferNotFull.notify_all();
}
for (LoggingEventList::iterator iter = events.begin();
iter != events.end();
iter++)
{
- synchronized sync(pThis->appenders->getMutex());
- pThis->appenders->appendLoopOnAppenders(*iter, p);
+ std::unique_lock lock(appenders->getMutex());
+ appenders->appendLoopOnAppenders(*iter, p);
}
}
}
catch (InterruptedException&)
{
- Thread::currentThreadInterrupt();
+ //Thread::currentThreadInterrupt();
}
catch (...)
{
- }
+ }
- return 0;
}
-#endif
diff --git a/src/main/cpp/bytearrayinputstream.cpp b/src/main/cpp/bytearrayinputstream.cpp
index 566cffa..f710a2a 100644
--- a/src/main/cpp/bytearrayinputstream.cpp
+++ b/src/main/cpp/bytearrayinputstream.cpp
@@ -18,9 +18,9 @@
#include <log4cxx/helpers/bytearrayinputstream.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/bytebuffer.h>
-#include <apr_file_io.h>
#include <log4cxx/helpers/transcoder.h>
#include <algorithm>
+#include <cstring>
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -54,7 +54,7 @@
else
{
size_t bytesCopied = min(dst.remaining(), buf.size() - pos);
- memcpy(dst.current(), &buf[pos], bytesCopied);
+ std::memcpy(dst.current(), &buf[pos], bytesCopied);
pos += bytesCopied;
dst.position(dst.position() + bytesCopied);
return (int)bytesCopied;
diff --git a/src/main/cpp/bytebuffer.cpp b/src/main/cpp/bytebuffer.cpp
index fce185f..c82e3fc 100644
--- a/src/main/cpp/bytebuffer.cpp
+++ b/src/main/cpp/bytebuffer.cpp
@@ -17,7 +17,6 @@
#include <log4cxx/logstring.h>
#include <log4cxx/helpers/bytebuffer.h>
#include <log4cxx/helpers/exception.h>
-#include <apr_pools.h>
#include <log4cxx/helpers/pool.h>
using namespace log4cxx;
diff --git a/src/main/cpp/charsetdecoder.cpp b/src/main/cpp/charsetdecoder.cpp
index 395ee75..74ee0db 100644
--- a/src/main/cpp/charsetdecoder.cpp
+++ b/src/main/cpp/charsetdecoder.cpp
@@ -18,8 +18,6 @@
#include <log4cxx/helpers/charsetdecoder.h>
#include <log4cxx/helpers/bytebuffer.h>
#include <log4cxx/helpers/exception.h>
-#include <log4cxx/helpers/mutex.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/helpers/pool.h>
#include <apr_xlate.h>
#if !defined(LOG4CXX)
@@ -30,6 +28,7 @@
#include <apr_portable.h>
#include <log4cxx/helpers/stringhelper.h>
#include <log4cxx/helpers/transcoder.h>
+#include <mutex>
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -55,7 +54,7 @@
* Creates a new instance.
* @param frompage name of source encoding.
*/
- APRCharsetDecoder(const LogString& frompage) : pool(), mutex(pool)
+ APRCharsetDecoder(const LogString& frompage) : pool()
{
#if LOG4CXX_LOGCHAR_IS_WCHAR
const char* topage = "WCHAR_T";
@@ -97,7 +96,7 @@
{
size_t outbytes_left = initial_outbytes_left;
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
stat = apr_xlate_conv_buffer((apr_xlate_t*) convset,
NULL, NULL, (char*) buf, &outbytes_left);
}
@@ -112,7 +111,7 @@
size_t pos = in.position();
apr_size_t outbytes_left = initial_outbytes_left;
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
stat = apr_xlate_conv_buffer((apr_xlate_t*) convset,
in.data() + pos,
&inbytes_left,
@@ -131,7 +130,7 @@
APRCharsetDecoder(const APRCharsetDecoder&);
APRCharsetDecoder& operator=(const APRCharsetDecoder&);
log4cxx::helpers::Pool pool;
- Mutex mutex;
+ std::mutex mutex;
apr_xlate_t* convset;
};
@@ -425,7 +424,7 @@
class LocaleCharsetDecoder : public CharsetDecoder
{
public:
- LocaleCharsetDecoder() : pool(), mutex(pool), decoder(), encoding()
+ LocaleCharsetDecoder() : pool(), decoder(), encoding()
{
}
virtual ~LocaleCharsetDecoder()
@@ -450,8 +449,8 @@
{
Pool subpool;
const char* enc = apr_os_locale_encoding(subpool.getAPRPool());
- {
- synchronized sync(mutex);
+ {
+ std::unique_lock lock(mutex);
if (enc == 0)
{
@@ -484,7 +483,7 @@
}
private:
Pool pool;
- Mutex mutex;
+ std::mutex mutex;
CharsetDecoderPtr decoder;
std::string encoding;
};
diff --git a/src/main/cpp/charsetencoder.cpp b/src/main/cpp/charsetencoder.cpp
index 1d4fd75..78b2817 100644
--- a/src/main/cpp/charsetencoder.cpp
+++ b/src/main/cpp/charsetencoder.cpp
@@ -28,8 +28,7 @@
#include <log4cxx/private/log4cxx_private.h>
#include <apr_portable.h>
-#include <log4cxx/helpers/mutex.h>
-#include <log4cxx/helpers/synchronized.h>
+#include <mutex>
#ifdef LOG4CXX_HAS_WCSTOMBS
#include <stdlib.h>
@@ -53,7 +52,7 @@
class APRCharsetEncoder : public CharsetEncoder
{
public:
- APRCharsetEncoder(const LogString& topage) : pool(), mutex(pool)
+ APRCharsetEncoder(const LogString& topage) : pool()
{
#if LOG4CXX_LOGCHAR_IS_WCHAR
const char* frompage = "WCHAR_T";
@@ -91,7 +90,7 @@
if (iter == in.end())
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
stat = apr_xlate_conv_buffer(convset, NULL, NULL,
out.data() + position, &outbytes_left);
}
@@ -102,7 +101,7 @@
(in.size() - inOffset) * sizeof(LogString::value_type);
apr_size_t initial_inbytes_left = inbytes_left;
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
stat = apr_xlate_conv_buffer(convset,
(const char*) (in.data() + inOffset),
&inbytes_left,
@@ -120,7 +119,7 @@
APRCharsetEncoder(const APRCharsetEncoder&);
APRCharsetEncoder& operator=(const APRCharsetEncoder&);
Pool pool;
- Mutex mutex;
+ std::mutex mutex;
apr_xlate_t* convset;
};
#endif
@@ -452,7 +451,7 @@
class LocaleCharsetEncoder : public CharsetEncoder
{
public:
- LocaleCharsetEncoder() : pool(), mutex(pool), encoder(), encoding()
+ LocaleCharsetEncoder() : pool(), encoder(), encoding()
{
}
virtual ~LocaleCharsetEncoder()
@@ -481,7 +480,7 @@
Pool subpool;
const char* enc = apr_os_locale_encoding(subpool.getAPRPool());
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
if (enc == 0)
{
@@ -517,7 +516,7 @@
LocaleCharsetEncoder(const LocaleCharsetEncoder&);
LocaleCharsetEncoder& operator=(const LocaleCharsetEncoder&);
Pool pool;
- Mutex mutex;
+ std::mutex mutex;
CharsetEncoderPtr encoder;
std::string encoding;
};
diff --git a/src/main/cpp/condition.cpp b/src/main/cpp/condition.cpp
deleted file mode 100644
index 9970f27..0000000
--- a/src/main/cpp/condition.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <log4cxx/logstring.h>
-#include <log4cxx/helpers/condition.h>
-#include <log4cxx/helpers/exception.h>
-
-#include <apr_thread_cond.h>
-#include <log4cxx/helpers/synchronized.h>
-#include <log4cxx/helpers/pool.h>
-#include <log4cxx/helpers/thread.h>
-
-using namespace log4cxx::helpers;
-using namespace log4cxx;
-
-
-Condition::Condition(Pool& p)
-{
-#if APR_HAS_THREADS
- apr_status_t stat = apr_thread_cond_create(&condition, p.getAPRPool());
-
- if (stat != APR_SUCCESS)
- {
- throw RuntimeException(stat);
- }
-
-#endif
-}
-
-Condition::~Condition()
-{
-#if APR_HAS_THREADS
- apr_thread_cond_destroy(condition);
-#endif
-}
-
-log4cxx_status_t Condition::signalAll()
-{
-#if APR_HAS_THREADS
- return apr_thread_cond_broadcast(condition);
-#else
- return APR_SUCCESS;
-#endif
-}
-
-void Condition::await(Mutex& mutex)
-{
-#if APR_HAS_THREADS
-
- if (Thread::interrupted())
- {
- throw InterruptedException();
- }
-
- apr_status_t stat = apr_thread_cond_wait(
- condition,
- mutex.getAPRMutex());
-
- if (stat != APR_SUCCESS)
- {
- throw InterruptedException(stat);
- }
-
-#endif
-}
-
diff --git a/src/main/cpp/domconfigurator.cpp b/src/main/cpp/domconfigurator.cpp
index c5770bf..f340d60 100644
--- a/src/main/cpp/domconfigurator.cpp
+++ b/src/main/cpp/domconfigurator.cpp
@@ -32,7 +32,6 @@
#include <log4cxx/spi/loggerfactory.h>
#include <log4cxx/defaultloggerfactory.h>
#include <log4cxx/helpers/filewatchdog.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/spi/loggerrepository.h>
#include <log4cxx/spi/loggingevent.h>
#include <log4cxx/helpers/pool.h>
@@ -64,20 +63,20 @@
{
class XMLWatchdog : public FileWatchdog
{
- public:
- XMLWatchdog(const File& filename) : FileWatchdog(filename)
- {
- }
+public:
+ XMLWatchdog(const File& filename) : FileWatchdog(filename)
+ {
+ }
- /**
- Call DOMConfigurator#doConfigure with the
- <code>filename</code> to reconfigure log4cxx.
- */
- void doOnChange()
- {
- DOMConfigurator().doConfigure(file,
- LogManager::getLoggerRepository());
- }
+ /**
+ Call DOMConfigurator#doConfigure with the
+ <code>filename</code> to reconfigure log4cxx.
+ */
+ void doOnChange()
+ {
+ DOMConfigurator().doConfigure(file,
+ LogManager::getLoggerRepository());
+ }
};
}
}
@@ -116,579 +115,574 @@
#define INTERNAL_DEBUG_ATTR "debug"
DOMConfigurator::DOMConfigurator()
- : props(), repository()
+ : props(), repository()
{
}
void DOMConfigurator::addRef() const
{
- ObjectImpl::addRef();
+ ObjectImpl::addRef();
}
void DOMConfigurator::releaseRef() const
{
- ObjectImpl::releaseRef();
+ ObjectImpl::releaseRef();
}
/**
Used internally to parse appenders by IDREF name.
*/
AppenderPtr DOMConfigurator::findAppenderByName(log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* element,
- apr_xml_doc* doc,
- const LogString& appenderName,
- AppenderMap& appenders)
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* element,
+ apr_xml_doc* doc,
+ const LogString& appenderName,
+ AppenderMap& appenders)
{
- AppenderPtr appender;
- std::string tagName(element->name);
+ AppenderPtr appender;
+ std::string tagName(element->name);
- if (tagName == APPENDER_TAG)
- {
- if (appenderName == getAttribute(utf8Decoder, element, NAME_ATTR))
- {
- appender = parseAppender(p, utf8Decoder, element, doc, appenders);
- }
- }
+ if (tagName == APPENDER_TAG)
+ {
+ if (appenderName == getAttribute(utf8Decoder, element, NAME_ATTR))
+ {
+ appender = parseAppender(p, utf8Decoder, element, doc, appenders);
+ }
+ }
- if (element->first_child && !appender)
- {
- appender = findAppenderByName(p, utf8Decoder, element->first_child, doc, appenderName, appenders);
- }
+ if (element->first_child && !appender)
+ {
+ appender = findAppenderByName(p, utf8Decoder, element->first_child, doc, appenderName, appenders);
+ }
- if (element->next && !appender)
- {
- appender = findAppenderByName(p, utf8Decoder, element->next, doc, appenderName, appenders);
- }
+ if (element->next && !appender)
+ {
+ appender = findAppenderByName(p, utf8Decoder, element->next, doc, appenderName, appenders);
+ }
- return appender;
+ return appender;
}
/**
Used internally to parse appenders by IDREF element.
*/
AppenderPtr DOMConfigurator::findAppenderByReference(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* appenderRef,
- apr_xml_doc* doc,
- AppenderMap& appenders)
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* appenderRef,
+ apr_xml_doc* doc,
+ AppenderMap& appenders)
{
- LogString appenderName(subst(getAttribute(utf8Decoder, appenderRef, REF_ATTR)));
- AppenderMap::const_iterator match = appenders.find(appenderName);
- AppenderPtr appender;
+ LogString appenderName(subst(getAttribute(utf8Decoder, appenderRef, REF_ATTR)));
+ AppenderMap::const_iterator match = appenders.find(appenderName);
+ AppenderPtr appender;
- if (match != appenders.end())
- {
- appender = match->second;
- }
- else if (doc)
- {
- appender = findAppenderByName(p, utf8Decoder, doc->root, doc, appenderName, appenders);
+ if (match != appenders.end())
+ {
+ appender = match->second;
+ }
+ else if (doc)
+ {
+ appender = findAppenderByName(p, utf8Decoder, doc->root, doc, appenderName, appenders);
- if (appender)
- {
- appenders.insert(AppenderMap::value_type(appenderName, appender));
- }
- }
+ if (appender)
+ {
+ appenders.insert(AppenderMap::value_type(appenderName, appender));
+ }
+ }
- if (!appender)
- {
- LogLog::error(LOG4CXX_STR("No appender named [") +
- appenderName + LOG4CXX_STR("] could be found."));
- }
+ if (!appender)
+ {
+ LogLog::error(LOG4CXX_STR("No appender named [") +
+ appenderName + LOG4CXX_STR("] could be found."));
+ }
- return appender;
+ return appender;
}
/**
Used internally to parse an appender element.
*/
AppenderPtr DOMConfigurator::parseAppender(Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* appenderElement,
- apr_xml_doc* doc,
- AppenderMap& appenders)
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* appenderElement,
+ apr_xml_doc* doc,
+ AppenderMap& appenders)
{
- LogString className(subst(getAttribute(utf8Decoder, appenderElement, CLASS_ATTR)));
- LogLog::debug(LOG4CXX_STR("Class name: [") + className + LOG4CXX_STR("]"));
+ LogString className(subst(getAttribute(utf8Decoder, appenderElement, CLASS_ATTR)));
+ LogLog::debug(LOG4CXX_STR("Class name: [") + className + LOG4CXX_STR("]"));
- try
- {
- ObjectPtr instance = Loader::loadClass(className).newInstance();
- AppenderPtr appender = instance;
- PropertySetter propSetter(appender);
+ try
+ {
+ ObjectPtr instance = Loader::loadClass(className).newInstance();
+ AppenderPtr appender = instance;
+ PropertySetter propSetter(appender);
- appender->setName(subst(getAttribute(utf8Decoder, appenderElement, NAME_ATTR)));
+ appender->setName(subst(getAttribute(utf8Decoder, appenderElement, NAME_ATTR)));
- for (apr_xml_elem* currentElement = appenderElement->first_child;
- currentElement;
- currentElement = currentElement->next)
- {
+ for (apr_xml_elem* currentElement = appenderElement->first_child;
+ currentElement;
+ currentElement = currentElement->next)
+ {
- std::string tagName(currentElement->name);
+ std::string tagName(currentElement->name);
- // Parse appender parameters
- if (tagName == PARAM_TAG)
- {
- setParameter(p, utf8Decoder, currentElement, propSetter);
- }
- // Set appender layout
- else if (tagName == LAYOUT_TAG)
- {
- appender->setLayout(parseLayout(p, utf8Decoder, currentElement));
- }
- // Add filters
- else if (tagName == FILTER_TAG)
- {
- std::vector<log4cxx::spi::FilterPtr> filters;
- parseFilters(p, utf8Decoder, currentElement, filters);
+ // Parse appender parameters
+ if (tagName == PARAM_TAG)
+ {
+ setParameter(p, utf8Decoder, currentElement, propSetter);
+ }
+ // Set appender layout
+ else if (tagName == LAYOUT_TAG)
+ {
+ appender->setLayout(parseLayout(p, utf8Decoder, currentElement));
+ }
+ // Add filters
+ else if (tagName == FILTER_TAG)
+ {
+ std::vector<log4cxx::spi::FilterPtr> filters;
+ parseFilters(p, utf8Decoder, currentElement, filters);
- for (std::vector<log4cxx::spi::FilterPtr>::iterator iter = filters.begin();
- iter != filters.end();
- iter++)
- {
- appender->addFilter(*iter);
- }
- }
- else if (tagName == ERROR_HANDLER_TAG)
- {
- parseErrorHandler(p, utf8Decoder, currentElement, appender, doc, appenders);
- }
- else if (tagName == ROLLING_POLICY_TAG)
- {
- RollingPolicyPtr rollPolicy(parseRollingPolicy(p, utf8Decoder, currentElement));
- RollingFileAppenderPtr rfa(appender);
+ for (std::vector<log4cxx::spi::FilterPtr>::iterator iter = filters.begin();
+ iter != filters.end();
+ iter++)
+ {
+ appender->addFilter(*iter);
+ }
+ }
+ else if (tagName == ERROR_HANDLER_TAG)
+ {
+ parseErrorHandler(p, utf8Decoder, currentElement, appender, doc, appenders);
+ }
+ else if (tagName == ROLLING_POLICY_TAG)
+ {
+ RollingPolicyPtr rollPolicy(parseRollingPolicy(p, utf8Decoder, currentElement));
+ RollingFileAppenderPtr rfa(appender);
- if (rfa != NULL)
- {
- rfa->setRollingPolicy(rollPolicy);
- }
- }
- else if (tagName == TRIGGERING_POLICY_TAG)
- {
- ObjectPtr policy(parseTriggeringPolicy(p, utf8Decoder, currentElement));
- RollingFileAppenderPtr rfa(appender);
+ if (rfa != NULL)
+ {
+ rfa->setRollingPolicy(rollPolicy);
+ }
+ }
+ else if (tagName == TRIGGERING_POLICY_TAG)
+ {
+ ObjectPtr policy(parseTriggeringPolicy(p, utf8Decoder, currentElement));
+ RollingFileAppenderPtr rfa(appender);
- if (rfa != NULL)
- {
- rfa->setTriggeringPolicy(policy);
- }
- else
- {
- log4cxx::net::SMTPAppenderPtr smtpa(appender);
+ if (rfa != NULL)
+ {
+ rfa->setTriggeringPolicy(policy);
+ }
+ else
+ {
+ log4cxx::net::SMTPAppenderPtr smtpa(appender);
- if (smtpa != NULL)
- {
- log4cxx::spi::TriggeringEventEvaluatorPtr evaluator(policy);
- smtpa->setEvaluator(evaluator);
- }
- }
- }
- else if (tagName == APPENDER_REF_TAG)
- {
- LogString refName = subst(getAttribute(utf8Decoder, currentElement, REF_ATTR));
+ if (smtpa != NULL)
+ {
+ log4cxx::spi::TriggeringEventEvaluatorPtr evaluator(policy);
+ smtpa->setEvaluator(evaluator);
+ }
+ }
+ }
+ else if (tagName == APPENDER_REF_TAG)
+ {
+ LogString refName = subst(getAttribute(utf8Decoder, currentElement, REF_ATTR));
- if (appender->instanceof(AppenderAttachable::getStaticClass()))
- {
- AppenderAttachablePtr aa(appender);
- LogLog::debug(LOG4CXX_STR("Attaching appender named [") +
- refName + LOG4CXX_STR("] to appender named [") +
- appender->getName() + LOG4CXX_STR("]."));
- aa->addAppender(findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders));
- }
- else
- {
- LogLog::error(LOG4CXX_STR("Requesting attachment of appender named [") +
- refName + LOG4CXX_STR("] to appender named [") + appender->getName() +
- LOG4CXX_STR("] which does not implement AppenderAttachable."));
- }
- }
- }
+ if (appender->instanceof(AppenderAttachable::getStaticClass()))
+ {
+ AppenderAttachablePtr aa(appender);
+ LogLog::debug(LOG4CXX_STR("Attaching appender named [") +
+ refName + LOG4CXX_STR("] to appender named [") +
+ appender->getName() + LOG4CXX_STR("]."));
+ aa->addAppender(findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders));
+ }
+ else
+ {
+ LogLog::error(LOG4CXX_STR("Requesting attachment of appender named [") +
+ refName + LOG4CXX_STR("] to appender named [") + appender->getName() +
+ LOG4CXX_STR("] which does not implement AppenderAttachable."));
+ }
+ }
+ }
- propSetter.activate(p);
- return appender;
- }
- /* Yes, it's ugly. But all of these exceptions point to the same
- problem: we can't create an Appender */
- catch (Exception& oops)
- {
- LogLog::error(LOG4CXX_STR("Could not create an Appender. Reported error follows."),
- oops);
- return 0;
- }
+ propSetter.activate(p);
+ return appender;
+ }
+ /* Yes, it's ugly. But all of these exceptions point to the same
+ problem: we can't create an Appender */
+ catch (Exception& oops)
+ {
+ LogLog::error(LOG4CXX_STR("Could not create an Appender. Reported error follows."),
+ oops);
+ return 0;
+ }
}
/**
Used internally to parse an {@link ErrorHandler} element.
*/
void DOMConfigurator::parseErrorHandler(Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* element,
- AppenderPtr& appender,
- apr_xml_doc* doc,
- AppenderMap& appenders)
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* element,
+ AppenderPtr& appender,
+ apr_xml_doc* doc,
+ AppenderMap& appenders)
{
- ErrorHandlerPtr eh = OptionConverter::instantiateByClassName(
- subst(getAttribute(utf8Decoder, element, CLASS_ATTR)),
- ErrorHandler::getStaticClass(),
- 0);
+ ErrorHandlerPtr eh = OptionConverter::instantiateByClassName(
+ subst(getAttribute(utf8Decoder, element, CLASS_ATTR)),
+ ErrorHandler::getStaticClass(),
+ 0);
- if (eh != 0)
- {
- eh->setAppender(appender);
+ if (eh != 0)
+ {
+ eh->setAppender(appender);
- PropertySetter propSetter(eh);
+ PropertySetter propSetter(eh);
- for (apr_xml_elem* currentElement = element->first_child;
- currentElement;
- currentElement = currentElement->next)
- {
- std::string tagName(currentElement->name);
+ for (apr_xml_elem* currentElement = element->first_child;
+ currentElement;
+ currentElement = currentElement->next)
+ {
+ std::string tagName(currentElement->name);
- if (tagName == PARAM_TAG)
- {
- setParameter(p, utf8Decoder, currentElement, propSetter);
- }
- else if (tagName == APPENDER_REF_TAG)
- {
- eh->setBackupAppender(findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders));
- }
- else if (tagName == LOGGER_REF)
- {
- LogString loggerName(getAttribute(utf8Decoder, currentElement, REF_ATTR));
- LoggerPtr logger = repository->getLogger(loggerName, loggerFactory);
- eh->setLogger(logger);
- }
- else if (tagName == ROOT_REF)
- {
- LoggerPtr root = repository->getRootLogger();
- eh->setLogger(root);
- }
- }
+ if (tagName == PARAM_TAG)
+ {
+ setParameter(p, utf8Decoder, currentElement, propSetter);
+ }
+ else if (tagName == APPENDER_REF_TAG)
+ {
+ eh->setBackupAppender(findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders));
+ }
+ else if (tagName == LOGGER_REF)
+ {
+ LogString loggerName(getAttribute(utf8Decoder, currentElement, REF_ATTR));
+ LoggerPtr logger = repository->getLogger(loggerName, loggerFactory);
+ eh->setLogger(logger);
+ }
+ else if (tagName == ROOT_REF)
+ {
+ LoggerPtr root = repository->getRootLogger();
+ eh->setLogger(root);
+ }
+ }
- propSetter.activate(p);
- ObjectPtrT<AppenderSkeleton> appSkeleton(appender);
+ propSetter.activate(p);
+ ObjectPtrT<AppenderSkeleton> appSkeleton(appender);
- if (appSkeleton != 0)
- {
- appSkeleton->setErrorHandler(eh);
- }
- }
+ if (appSkeleton != 0)
+ {
+ appSkeleton->setErrorHandler(eh);
+ }
+ }
}
/**
Used internally to parse a filter element.
*/
void DOMConfigurator::parseFilters(Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* element,
- std::vector<log4cxx::spi::FilterPtr>& filters)
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* element,
+ std::vector<log4cxx::spi::FilterPtr>& filters)
{
- LogString clazz = subst(getAttribute(utf8Decoder, element, CLASS_ATTR));
- FilterPtr filter = OptionConverter::instantiateByClassName(clazz,
- Filter::getStaticClass(), 0);
+ LogString clazz = subst(getAttribute(utf8Decoder, element, CLASS_ATTR));
+ FilterPtr filter = OptionConverter::instantiateByClassName(clazz,
+ Filter::getStaticClass(), 0);
- if (filter != 0)
- {
- PropertySetter propSetter(filter);
+ if (filter != 0)
+ {
+ PropertySetter propSetter(filter);
- for (apr_xml_elem* currentElement = element->first_child;
- currentElement;
- currentElement = currentElement->next)
- {
- std::string tagName(currentElement->name);
+ for (apr_xml_elem* currentElement = element->first_child;
+ currentElement;
+ currentElement = currentElement->next)
+ {
+ std::string tagName(currentElement->name);
- if (tagName == PARAM_TAG)
- {
- setParameter(p, utf8Decoder, currentElement, propSetter);
- }
- }
+ if (tagName == PARAM_TAG)
+ {
+ setParameter(p, utf8Decoder, currentElement, propSetter);
+ }
+ }
- propSetter.activate(p);
- filters.push_back(filter);
- }
+ propSetter.activate(p);
+ filters.push_back(filter);
+ }
}
/**
Used internally to parse an category or logger element.
*/
void DOMConfigurator::parseLogger(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* loggerElement,
- apr_xml_doc* doc,
- AppenderMap& appenders)
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* loggerElement,
+ apr_xml_doc* doc,
+ AppenderMap& appenders)
{
- // Create a new Logger object from the <category> element.
- LogString loggerName = subst(getAttribute(utf8Decoder, loggerElement, NAME_ATTR));
+ // Create a new Logger object from the <category> element.
+ LogString loggerName = subst(getAttribute(utf8Decoder, loggerElement, NAME_ATTR));
- LogLog::debug(LOG4CXX_STR("Retreiving an instance of Logger."));
- LoggerPtr logger = repository->getLogger(loggerName, loggerFactory);
+ LogLog::debug(LOG4CXX_STR("Retreiving an instance of Logger."));
+ LoggerPtr logger = repository->getLogger(loggerName, loggerFactory);
- // Setting up a logger needs to be an atomic operation, in order
- // to protect potential log operations while logger
- // configuration is in progress.
- LOCK_W sync(logger->getMutex());
- bool additivity = OptionConverter::toBoolean(
- subst(getAttribute(utf8Decoder, loggerElement, ADDITIVITY_ATTR)),
- true);
+ // Setting up a logger needs to be an atomic operation, in order
+ // to protect potential log operations while logger
+ // configuration is in progress.
+ bool additivity = OptionConverter::toBoolean(
+ subst(getAttribute(utf8Decoder, loggerElement, ADDITIVITY_ATTR)),
+ true);
- LogLog::debug(LOG4CXX_STR("Setting [") + logger->getName() + LOG4CXX_STR("] additivity to [") +
- (additivity ? LogString(LOG4CXX_STR("true")) : LogString(LOG4CXX_STR("false"))) + LOG4CXX_STR("]."));
- logger->setAdditivity(additivity);
- parseChildrenOfLoggerElement(p, utf8Decoder, loggerElement, logger, false, doc, appenders);
+ LogLog::debug(LOG4CXX_STR("Setting [") + logger->getName() + LOG4CXX_STR("] additivity to [") +
+ (additivity ? LogString(LOG4CXX_STR("true")) : LogString(LOG4CXX_STR("false"))) + LOG4CXX_STR("]."));
+ parseChildrenOfLoggerElement(p, utf8Decoder, loggerElement, logger, false, doc, appenders, additivity);
}
/**
Used internally to parse the logger factory element.
*/
void DOMConfigurator::parseLoggerFactory(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* factoryElement)
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* factoryElement)
{
- LogString className(subst(getAttribute(utf8Decoder, factoryElement, CLASS_ATTR)));
+ LogString className(subst(getAttribute(utf8Decoder, factoryElement, CLASS_ATTR)));
- if (className.empty())
- {
- LogLog::error(LOG4CXX_STR("Logger Factory tag class attribute not found."));
- LogLog::debug(LOG4CXX_STR("No Logger Factory configured."));
- }
- else
- {
- LogLog::debug(LOG4CXX_STR("Desired logger factory: [") + className + LOG4CXX_STR("]"));
- loggerFactory = OptionConverter::instantiateByClassName(
- className,
- LoggerFactory::getStaticClass(),
- 0);
- PropertySetter propSetter(loggerFactory);
+ if (className.empty())
+ {
+ LogLog::error(LOG4CXX_STR("Logger Factory tag class attribute not found."));
+ LogLog::debug(LOG4CXX_STR("No Logger Factory configured."));
+ }
+ else
+ {
+ LogLog::debug(LOG4CXX_STR("Desired logger factory: [") + className + LOG4CXX_STR("]"));
+ loggerFactory = OptionConverter::instantiateByClassName(
+ className,
+ LoggerFactory::getStaticClass(),
+ 0);
+ PropertySetter propSetter(loggerFactory);
- for (apr_xml_elem* currentElement = factoryElement->first_child;
- currentElement;
- currentElement = currentElement->next)
- {
- std::string tagName(currentElement->name);
+ for (apr_xml_elem* currentElement = factoryElement->first_child;
+ currentElement;
+ currentElement = currentElement->next)
+ {
+ std::string tagName(currentElement->name);
- if (tagName == PARAM_TAG)
- {
- setParameter(p, utf8Decoder, currentElement, propSetter);
- }
- }
- }
+ if (tagName == PARAM_TAG)
+ {
+ setParameter(p, utf8Decoder, currentElement, propSetter);
+ }
+ }
+ }
}
/**
Used internally to parse the root logger element.
*/
void DOMConfigurator::parseRoot(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* rootElement,
- apr_xml_doc* doc,
- AppenderMap& appenders)
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* rootElement,
+ apr_xml_doc* doc,
+ AppenderMap& appenders)
{
- LoggerPtr root = repository->getRootLogger();
- // logger configuration needs to be atomic
- LOCK_W sync(root->getMutex());
- parseChildrenOfLoggerElement(p, utf8Decoder, rootElement, root, true, doc, appenders);
+ LoggerPtr root = repository->getRootLogger();
+ parseChildrenOfLoggerElement(p, utf8Decoder, rootElement, root, true, doc, appenders, true);
}
/**
Used internally to parse the children of a logger element.
*/
void DOMConfigurator::parseChildrenOfLoggerElement(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* loggerElement, LoggerPtr logger, bool isRoot,
- apr_xml_doc* doc,
- AppenderMap& appenders)
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* loggerElement, LoggerPtr logger, bool isRoot,
+ apr_xml_doc* doc,
+ AppenderMap& appenders,
+ bool additivity)
{
+ PropertySetter propSetter(logger);
+ std::vector<AppenderPtr> newappenders;
- PropertySetter propSetter(logger);
+ for (apr_xml_elem* currentElement = loggerElement->first_child;
+ currentElement;
+ currentElement = currentElement->next)
+ {
+ std::string tagName(currentElement->name);
- // Remove all existing appenders from logger. They will be
- // reconstructed if need be.
- logger->removeAllAppenders();
+ if (tagName == APPENDER_REF_TAG)
+ {
+ AppenderPtr appender = findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders);
+ LogString refName = subst(getAttribute(utf8Decoder, currentElement, REF_ATTR));
+ if (appender != 0)
+ {
+ LogLog::debug(LOG4CXX_STR("Adding appender named [") + refName +
+ LOG4CXX_STR("] to logger [") + logger->getName() + LOG4CXX_STR("]."));
+ }
+ else
+ {
+ LogLog::debug(LOG4CXX_STR("Appender named [") + refName +
+ LOG4CXX_STR("] not found."));
+ }
- for (apr_xml_elem* currentElement = loggerElement->first_child;
- currentElement;
- currentElement = currentElement->next)
- {
- std::string tagName(currentElement->name);
+ newappenders.push_back(appender);
- if (tagName == APPENDER_REF_TAG)
- {
- AppenderPtr appender = findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders);
- LogString refName = subst(getAttribute(utf8Decoder, currentElement, REF_ATTR));
+ }
+ else if (tagName == LEVEL_TAG)
+ {
+ parseLevel(p, utf8Decoder, currentElement, logger, isRoot);
+ }
+ else if (tagName == PRIORITY_TAG)
+ {
+ parseLevel(p, utf8Decoder, currentElement, logger, isRoot);
+ }
+ else if (tagName == PARAM_TAG)
+ {
+ setParameter(p, utf8Decoder, currentElement, propSetter);
+ }
+ }
- if (appender != 0)
- {
- LogLog::debug(LOG4CXX_STR("Adding appender named [") + refName +
- LOG4CXX_STR("] to logger [") + logger->getName() + LOG4CXX_STR("]."));
- }
- else
- {
- LogLog::debug(LOG4CXX_STR("Appender named [") + refName +
- LOG4CXX_STR("] not found."));
- }
+ // Handle the reconfiguring of the logger in an atomic manner.
+ logger->reconfigure( newappenders, additivity );
- logger->addAppender(appender);
-
- }
- else if (tagName == LEVEL_TAG)
- {
- parseLevel(p, utf8Decoder, currentElement, logger, isRoot);
- }
- else if (tagName == PRIORITY_TAG)
- {
- parseLevel(p, utf8Decoder, currentElement, logger, isRoot);
- }
- else if (tagName == PARAM_TAG)
- {
- setParameter(p, utf8Decoder, currentElement, propSetter);
- }
- }
-
- propSetter.activate(p);
+ propSetter.activate(p);
}
/**
Used internally to parse a layout element.
*/
LayoutPtr DOMConfigurator::parseLayout (
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* layout_element)
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* layout_element)
{
- LogString className(subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR)));
- LogLog::debug(LOG4CXX_STR("Parsing layout of class: \"") + className + LOG4CXX_STR("\""));
+ LogString className(subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR)));
+ LogLog::debug(LOG4CXX_STR("Parsing layout of class: \"") + className + LOG4CXX_STR("\""));
- try
- {
- ObjectPtr instance = Loader::loadClass(className).newInstance();
- LayoutPtr layout = instance;
- PropertySetter propSetter(layout);
+ try
+ {
+ ObjectPtr instance = Loader::loadClass(className).newInstance();
+ LayoutPtr layout = instance;
+ PropertySetter propSetter(layout);
- for (apr_xml_elem* currentElement = layout_element->first_child;
- currentElement;
- currentElement = currentElement->next)
- {
- std::string tagName(currentElement->name);
+ for (apr_xml_elem* currentElement = layout_element->first_child;
+ currentElement;
+ currentElement = currentElement->next)
+ {
+ std::string tagName(currentElement->name);
- if (tagName == PARAM_TAG)
- {
- setParameter(p, utf8Decoder, currentElement, propSetter);
- }
- }
+ if (tagName == PARAM_TAG)
+ {
+ setParameter(p, utf8Decoder, currentElement, propSetter);
+ }
+ }
- propSetter.activate(p);
- return layout;
- }
- catch (Exception& oops)
- {
- LogLog::error(LOG4CXX_STR("Could not create the Layout. Reported error follows."),
- oops);
- return 0;
- }
+ propSetter.activate(p);
+ return layout;
+ }
+ catch (Exception& oops)
+ {
+ LogLog::error(LOG4CXX_STR("Could not create the Layout. Reported error follows."),
+ oops);
+ return 0;
+ }
}
/**
Used internally to parse a triggering policy
*/
ObjectPtr DOMConfigurator::parseTriggeringPolicy (
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* layout_element)
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* layout_element)
{
- LogString className = subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR));
- LogLog::debug(LOG4CXX_STR("Parsing triggering policy of class: \"") + className + LOG4CXX_STR("\""));
+ LogString className = subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR));
+ LogLog::debug(LOG4CXX_STR("Parsing triggering policy of class: \"") + className + LOG4CXX_STR("\""));
- try
- {
- ObjectPtr instance = Loader::loadClass(className).newInstance();
- PropertySetter propSetter(instance);
+ try
+ {
+ ObjectPtr instance = Loader::loadClass(className).newInstance();
+ PropertySetter propSetter(instance);
- for (apr_xml_elem* currentElement = layout_element->first_child;
- currentElement;
- currentElement = currentElement->next)
- {
- std::string tagName(currentElement->name);
+ for (apr_xml_elem* currentElement = layout_element->first_child;
+ currentElement;
+ currentElement = currentElement->next)
+ {
+ std::string tagName(currentElement->name);
- if (tagName == PARAM_TAG)
- {
- setParameter(p, utf8Decoder, currentElement, propSetter);
- }
- else if (tagName == FILTER_TAG)
- {
- std::vector<log4cxx::spi::FilterPtr> filters;
- parseFilters(p, utf8Decoder, currentElement, filters);
- FilterBasedTriggeringPolicyPtr fbtp(instance);
+ if (tagName == PARAM_TAG)
+ {
+ setParameter(p, utf8Decoder, currentElement, propSetter);
+ }
+ else if (tagName == FILTER_TAG)
+ {
+ std::vector<log4cxx::spi::FilterPtr> filters;
+ parseFilters(p, utf8Decoder, currentElement, filters);
+ FilterBasedTriggeringPolicyPtr fbtp(instance);
- if (fbtp != NULL)
- {
- for (std::vector<log4cxx::spi::FilterPtr>::iterator iter = filters.begin();
- iter != filters.end();
- iter++)
- {
- fbtp->addFilter(*iter);
- }
- }
- }
- }
+ if (fbtp != NULL)
+ {
+ for (std::vector<log4cxx::spi::FilterPtr>::iterator iter = filters.begin();
+ iter != filters.end();
+ iter++)
+ {
+ fbtp->addFilter(*iter);
+ }
+ }
+ }
+ }
- propSetter.activate(p);
- return instance;
- }
- catch (Exception& oops)
- {
- LogLog::error(LOG4CXX_STR("Could not create the TriggeringPolicy. Reported error follows."),
- oops);
- return 0;
- }
+ propSetter.activate(p);
+ return instance;
+ }
+ catch (Exception& oops)
+ {
+ LogLog::error(LOG4CXX_STR("Could not create the TriggeringPolicy. Reported error follows."),
+ oops);
+ return 0;
+ }
}
/**
Used internally to parse a triggering policy
*/
RollingPolicyPtr DOMConfigurator::parseRollingPolicy (
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* layout_element)
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* layout_element)
{
- LogString className = subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR));
- LogLog::debug(LOG4CXX_STR("Parsing rolling policy of class: \"") + className + LOG4CXX_STR("\""));
+ LogString className = subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR));
+ LogLog::debug(LOG4CXX_STR("Parsing rolling policy of class: \"") + className + LOG4CXX_STR("\""));
- try
- {
- ObjectPtr instance = Loader::loadClass(className).newInstance();
- RollingPolicyPtr layout = instance;
- PropertySetter propSetter(layout);
+ try
+ {
+ ObjectPtr instance = Loader::loadClass(className).newInstance();
+ RollingPolicyPtr layout = instance;
+ PropertySetter propSetter(layout);
- for (apr_xml_elem* currentElement = layout_element->first_child;
- currentElement;
- currentElement = currentElement->next)
- {
- std::string tagName(currentElement->name);
+ for (apr_xml_elem* currentElement = layout_element->first_child;
+ currentElement;
+ currentElement = currentElement->next)
+ {
+ std::string tagName(currentElement->name);
- if (tagName == PARAM_TAG)
- {
- setParameter(p, utf8Decoder, currentElement, propSetter);
- }
- }
+ if (tagName == PARAM_TAG)
+ {
+ setParameter(p, utf8Decoder, currentElement, propSetter);
+ }
+ }
- propSetter.activate(p);
- return layout;
- }
- catch (Exception& oops)
- {
- LogLog::error(LOG4CXX_STR("Could not create the RollingPolicy. Reported error follows."),
- oops);
- return 0;
- }
+ propSetter.activate(p);
+ return layout;
+ }
+ catch (Exception& oops)
+ {
+ LogLog::error(LOG4CXX_STR("Could not create the RollingPolicy. Reported error follows."),
+ oops);
+ return 0;
+ }
}
@@ -697,238 +691,238 @@
Used internally to parse a level element.
*/
void DOMConfigurator::parseLevel(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* element, LoggerPtr logger, bool isRoot)
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* element, LoggerPtr logger, bool isRoot)
{
- LogString loggerName = logger->getName();
+ LogString loggerName = logger->getName();
- if (isRoot)
- {
- loggerName = LOG4CXX_STR("root");
- }
+ if (isRoot)
+ {
+ loggerName = LOG4CXX_STR("root");
+ }
- LogString levelStr(subst(getAttribute(utf8Decoder, element, VALUE_ATTR)));
- LogLog::debug(LOG4CXX_STR("Level value for ") + loggerName + LOG4CXX_STR(" is [") + levelStr + LOG4CXX_STR("]."));
+ LogString levelStr(subst(getAttribute(utf8Decoder, element, VALUE_ATTR)));
+ LogLog::debug(LOG4CXX_STR("Level value for ") + loggerName + LOG4CXX_STR(" is [") + levelStr + LOG4CXX_STR("]."));
- if (StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("INHERITED"), LOG4CXX_STR("inherited"))
- || StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("NULL"), LOG4CXX_STR("null")))
- {
- if (isRoot)
- {
- LogLog::error(LOG4CXX_STR("Root level cannot be inherited. Ignoring directive."));
- }
- else
- {
- logger->setLevel(0);
- }
- }
- else
- {
- LogString className(subst(getAttribute(utf8Decoder, element, CLASS_ATTR)));
+ if (StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("INHERITED"), LOG4CXX_STR("inherited"))
+ || StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("NULL"), LOG4CXX_STR("null")))
+ {
+ if (isRoot)
+ {
+ LogLog::error(LOG4CXX_STR("Root level cannot be inherited. Ignoring directive."));
+ }
+ else
+ {
+ logger->setLevel(0);
+ }
+ }
+ else
+ {
+ LogString className(subst(getAttribute(utf8Decoder, element, CLASS_ATTR)));
- if (className.empty())
- {
- logger->setLevel(OptionConverter::toLevel(levelStr, Level::getDebug()));
- }
- else
- {
- LogLog::debug(LOG4CXX_STR("Desired Level sub-class: [") + className + LOG4CXX_STR("]"));
+ if (className.empty())
+ {
+ logger->setLevel(OptionConverter::toLevel(levelStr, Level::getDebug()));
+ }
+ else
+ {
+ LogLog::debug(LOG4CXX_STR("Desired Level sub-class: [") + className + LOG4CXX_STR("]"));
- try
- {
- Level::LevelClass& levelClass =
- (Level::LevelClass&)Loader::loadClass(className);
- LevelPtr level = levelClass.toLevel(levelStr);
- logger->setLevel(level);
- }
- catch (Exception& oops)
- {
- LogLog::error(
- LOG4CXX_STR("Could not create level [") + levelStr +
- LOG4CXX_STR("]. Reported error follows."),
- oops);
+ try
+ {
+ Level::LevelClass& levelClass =
+ (Level::LevelClass&)Loader::loadClass(className);
+ LevelPtr level = levelClass.toLevel(levelStr);
+ logger->setLevel(level);
+ }
+ catch (Exception& oops)
+ {
+ LogLog::error(
+ LOG4CXX_STR("Could not create level [") + levelStr +
+ LOG4CXX_STR("]. Reported error follows."),
+ oops);
- return;
- }
- catch (...)
- {
- LogLog::error(
- LOG4CXX_STR("Could not create level [") + levelStr);
+ return;
+ }
+ catch (...)
+ {
+ LogLog::error(
+ LOG4CXX_STR("Could not create level [") + levelStr);
- return;
- }
- }
- }
+ return;
+ }
+ }
+ }
- LogLog::debug(loggerName + LOG4CXX_STR(" level set to ") +
- logger->getEffectiveLevel()->toString());
+ LogLog::debug(loggerName + LOG4CXX_STR(" level set to ") +
+ logger->getEffectiveLevel()->toString());
}
void DOMConfigurator::setParameter(log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* elem,
- PropertySetter& propSetter)
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* elem,
+ PropertySetter& propSetter)
{
- LogString name(subst(getAttribute(utf8Decoder, elem, NAME_ATTR)));
- LogString value(subst(getAttribute(utf8Decoder, elem, VALUE_ATTR)));
- value = subst(value);
- propSetter.setProperty(name, value, p);
+ LogString name(subst(getAttribute(utf8Decoder, elem, NAME_ATTR)));
+ LogString value(subst(getAttribute(utf8Decoder, elem, VALUE_ATTR)));
+ value = subst(value);
+ propSetter.setProperty(name, value, p);
}
void DOMConfigurator::doConfigure(const File& filename, spi::LoggerRepositoryPtr& repository1)
{
- repository1->setConfigured(true);
- this->repository = repository1;
- LogString msg(LOG4CXX_STR("DOMConfigurator configuring file "));
- msg.append(filename.getPath());
- msg.append(LOG4CXX_STR("..."));
- LogLog::debug(msg);
+ repository1->setConfigured(true);
+ this->repository = repository1;
+ LogString msg(LOG4CXX_STR("DOMConfigurator configuring file "));
+ msg.append(filename.getPath());
+ msg.append(LOG4CXX_STR("..."));
+ LogLog::debug(msg);
- loggerFactory = new DefaultLoggerFactory();
+ loggerFactory = new DefaultLoggerFactory();
- Pool p;
- apr_file_t* fd;
+ Pool p;
+ apr_file_t* fd;
- log4cxx_status_t rv = filename.open(&fd, APR_READ, APR_OS_DEFAULT, p);
+ log4cxx_status_t rv = filename.open(&fd, APR_READ, APR_OS_DEFAULT, p);
- if (rv != APR_SUCCESS)
- {
- LogString msg2(LOG4CXX_STR("Could not open file ["));
- msg2.append(filename.getPath());
- msg2.append(LOG4CXX_STR("]."));
- LogLog::error(msg2);
- }
- else
- {
- apr_xml_parser* parser = NULL;
- apr_xml_doc* doc = NULL;
- rv = apr_xml_parse_file(p.getAPRPool(), &parser, &doc, fd, 2000);
+ if (rv != APR_SUCCESS)
+ {
+ LogString msg2(LOG4CXX_STR("Could not open file ["));
+ msg2.append(filename.getPath());
+ msg2.append(LOG4CXX_STR("]."));
+ LogLog::error(msg2);
+ }
+ else
+ {
+ apr_xml_parser* parser = NULL;
+ apr_xml_doc* doc = NULL;
+ rv = apr_xml_parse_file(p.getAPRPool(), &parser, &doc, fd, 2000);
- if (rv != APR_SUCCESS)
- {
- char errbuf[2000];
- char errbufXML[2000];
- LogString msg2(LOG4CXX_STR("Error parsing file ["));
- msg2.append(filename.getPath());
- msg2.append(LOG4CXX_STR("], "));
- apr_strerror(rv, errbuf, sizeof(errbuf));
- LOG4CXX_DECODE_CHAR(lerrbuf, std::string(errbuf));
- msg2.append(lerrbuf);
+ if (rv != APR_SUCCESS)
+ {
+ char errbuf[2000];
+ char errbufXML[2000];
+ LogString msg2(LOG4CXX_STR("Error parsing file ["));
+ msg2.append(filename.getPath());
+ msg2.append(LOG4CXX_STR("], "));
+ apr_strerror(rv, errbuf, sizeof(errbuf));
+ LOG4CXX_DECODE_CHAR(lerrbuf, std::string(errbuf));
+ msg2.append(lerrbuf);
- if (parser)
- {
- apr_xml_parser_geterror(parser, errbufXML, sizeof(errbufXML));
- LOG4CXX_DECODE_CHAR(lerrbufXML, std::string(errbufXML));
- msg2.append(lerrbufXML);
- }
+ if (parser)
+ {
+ apr_xml_parser_geterror(parser, errbufXML, sizeof(errbufXML));
+ LOG4CXX_DECODE_CHAR(lerrbufXML, std::string(errbufXML));
+ msg2.append(lerrbufXML);
+ }
- LogLog::error(msg2);
- }
- else
- {
- AppenderMap appenders;
- CharsetDecoderPtr utf8Decoder(CharsetDecoder::getUTF8Decoder());
- parse(p, utf8Decoder, doc->root, doc, appenders);
- }
- }
+ LogLog::error(msg2);
+ }
+ else
+ {
+ AppenderMap appenders;
+ CharsetDecoderPtr utf8Decoder(CharsetDecoder::getUTF8Decoder());
+ parse(p, utf8Decoder, doc->root, doc, appenders);
+ }
+ }
}
void DOMConfigurator::configure(const std::string& filename)
{
- File file(filename);
- DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+ File file(filename);
+ DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
}
#if LOG4CXX_WCHAR_T_API
void DOMConfigurator::configure(const std::wstring& filename)
{
- File file(filename);
- DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+ File file(filename);
+ DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
}
#endif
#if LOG4CXX_UNICHAR_API
void DOMConfigurator::configure(const std::basic_string<UniChar>& filename)
{
- File file(filename);
- DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+ File file(filename);
+ DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
}
#endif
#if LOG4CXX_CFSTRING_API
void DOMConfigurator::configure(const CFStringRef& filename)
{
- File file(filename);
- DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+ File file(filename);
+ DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
}
#endif
void DOMConfigurator::configureAndWatch(const std::string& filename)
{
- configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
+ configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
}
#if LOG4CXX_WCHAR_T_API
void DOMConfigurator::configureAndWatch(const std::wstring& filename)
{
- configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
+ configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
}
#endif
#if LOG4CXX_UNICHAR_API
void DOMConfigurator::configureAndWatch(const std::basic_string<UniChar>& filename)
{
- configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
+ configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
}
#endif
#if LOG4CXX_CFSTRING_API
void DOMConfigurator::configureAndWatch(const CFStringRef& filename)
{
- configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
+ configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY);
}
#endif
void DOMConfigurator::configureAndWatch(const std::string& filename, long delay)
{
- File file(filename);
+ File file(filename);
#if APR_HAS_THREADS
- if ( xdog )
- {
- APRInitializer::unregisterCleanup(xdog);
- delete xdog;
- }
+ if ( xdog )
+ {
+ APRInitializer::unregisterCleanup(xdog);
+ delete xdog;
+ }
- xdog = new XMLWatchdog(file);
- APRInitializer::registerCleanup(xdog);
- xdog->setDelay(delay);
- xdog->start();
+ xdog = new XMLWatchdog(file);
+ APRInitializer::registerCleanup(xdog);
+ xdog->setDelay(delay);
+ xdog->start();
#else
- DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+ DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
#endif
}
#if LOG4CXX_WCHAR_T_API
void DOMConfigurator::configureAndWatch(const std::wstring& filename, long delay)
{
- File file(filename);
+ File file(filename);
#if APR_HAS_THREADS
- if ( xdog )
- {
- APRInitializer::unregisterCleanup(xdog);
- delete xdog;
- }
+ if ( xdog )
+ {
+ APRInitializer::unregisterCleanup(xdog);
+ delete xdog;
+ }
- xdog = new XMLWatchdog(file);
- APRInitializer::registerCleanup(xdog);
- xdog->setDelay(delay);
- xdog->start();
+ xdog = new XMLWatchdog(file);
+ APRInitializer::registerCleanup(xdog);
+ xdog->setDelay(delay);
+ xdog->start();
#else
- DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+ DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
#endif
}
#endif
@@ -936,21 +930,21 @@
#if LOG4CXX_UNICHAR_API
void DOMConfigurator::configureAndWatch(const std::basic_string<UniChar>& filename, long delay)
{
- File file(filename);
+ File file(filename);
#if APR_HAS_THREADS
- if ( xdog )
- {
- APRInitializer::unregisterCleanup(xdog);
- delete xdog;
- }
+ if ( xdog )
+ {
+ APRInitializer::unregisterCleanup(xdog);
+ delete xdog;
+ }
- xdog = new XMLWatchdog(file);
- APRInitializer::registerCleanup(xdog);
- xdog->setDelay(delay);
- xdog->start();
+ xdog = new XMLWatchdog(file);
+ APRInitializer::registerCleanup(xdog);
+ xdog->setDelay(delay);
+ xdog->start();
#else
- DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+ DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
#endif
}
#endif
@@ -958,154 +952,154 @@
#if LOG4CXX_CFSTRING_API
void DOMConfigurator::configureAndWatch(const CFStringRef& filename, long delay)
{
- File file(filename);
+ File file(filename);
#if APR_HAS_THREADS
- if ( xdog )
- {
- APRInitializer::unregisterCleanup(xdog);
- delete xdog;
- }
+ if ( xdog )
+ {
+ APRInitializer::unregisterCleanup(xdog);
+ delete xdog;
+ }
- xdog = new XMLWatchdog(file);
- APRInitializer::registerCleanup(xdog);
- xdog->setDelay(delay);
- xdog->start();
+ xdog = new XMLWatchdog(file);
+ APRInitializer::registerCleanup(xdog);
+ xdog->setDelay(delay);
+ xdog->start();
#else
- DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
+ DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
#endif
}
#endif
void DOMConfigurator::parse(
- Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* element,
- apr_xml_doc* doc,
- AppenderMap& appenders)
+ Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* element,
+ apr_xml_doc* doc,
+ AppenderMap& appenders)
{
- std::string rootElementName(element->name);
+ std::string rootElementName(element->name);
- if (rootElementName != CONFIGURATION_TAG)
- {
- if (rootElementName == OLD_CONFIGURATION_TAG)
- {
- //LogLog::warn(LOG4CXX_STR("The <")+String(OLD_CONFIGURATION_TAG)+
- // LOG4CXX_STR("> element has been deprecated."));
- //LogLog::warn(LOG4CXX_STR("Use the <")+String(CONFIGURATION_TAG)+
- // LOG4CXX_STR("> element instead."));
- }
- else
- {
- LogLog::error(LOG4CXX_STR("DOM element is - not a <configuration> element."));
- return;
- }
- }
+ if (rootElementName != CONFIGURATION_TAG)
+ {
+ if (rootElementName == OLD_CONFIGURATION_TAG)
+ {
+ //LogLog::warn(LOG4CXX_STR("The <")+String(OLD_CONFIGURATION_TAG)+
+ // LOG4CXX_STR("> element has been deprecated."));
+ //LogLog::warn(LOG4CXX_STR("Use the <")+String(CONFIGURATION_TAG)+
+ // LOG4CXX_STR("> element instead."));
+ }
+ else
+ {
+ LogLog::error(LOG4CXX_STR("DOM element is - not a <configuration> element."));
+ return;
+ }
+ }
- LogString debugAttrib = subst(getAttribute(utf8Decoder, element, INTERNAL_DEBUG_ATTR));
+ LogString debugAttrib = subst(getAttribute(utf8Decoder, element, INTERNAL_DEBUG_ATTR));
- static const LogString NuLL(LOG4CXX_STR("NULL"));
- LogLog::debug(LOG4CXX_STR("debug attribute= \"") + debugAttrib + LOG4CXX_STR("\"."));
+ static const LogString NuLL(LOG4CXX_STR("NULL"));
+ LogLog::debug(LOG4CXX_STR("debug attribute= \"") + debugAttrib + LOG4CXX_STR("\"."));
- // if the log4j.dtd is not specified in the XML file, then the
- // "debug" attribute is returned as the empty string.
- if (!debugAttrib.empty() && debugAttrib != NuLL)
- {
- LogLog::setInternalDebugging(OptionConverter::toBoolean(debugAttrib, true));
- }
- else
- {
- LogLog::debug(LOG4CXX_STR("Ignoring internalDebug attribute."));
- }
+ // if the log4j.dtd is not specified in the XML file, then the
+ // "debug" attribute is returned as the empty string.
+ if (!debugAttrib.empty() && debugAttrib != NuLL)
+ {
+ LogLog::setInternalDebugging(OptionConverter::toBoolean(debugAttrib, true));
+ }
+ else
+ {
+ LogLog::debug(LOG4CXX_STR("Ignoring internalDebug attribute."));
+ }
- LogString confDebug = subst(getAttribute(utf8Decoder, element, CONFIG_DEBUG_ATTR));
+ LogString confDebug = subst(getAttribute(utf8Decoder, element, CONFIG_DEBUG_ATTR));
- if (!confDebug.empty() && confDebug != NuLL)
- {
- LogLog::warn(LOG4CXX_STR("The \"configDebug\" attribute is deprecated."));
- LogLog::warn(LOG4CXX_STR("Use the \"internalDebug\" attribute instead."));
- LogLog::setInternalDebugging(OptionConverter::toBoolean(confDebug, true));
- }
+ if (!confDebug.empty() && confDebug != NuLL)
+ {
+ LogLog::warn(LOG4CXX_STR("The \"configDebug\" attribute is deprecated."));
+ LogLog::warn(LOG4CXX_STR("Use the \"internalDebug\" attribute instead."));
+ LogLog::setInternalDebugging(OptionConverter::toBoolean(confDebug, true));
+ }
- LogString thresholdStr = subst(getAttribute(utf8Decoder, element, THRESHOLD_ATTR));
- LogLog::debug(LOG4CXX_STR("Threshold =\"") + thresholdStr + LOG4CXX_STR("\"."));
+ LogString thresholdStr = subst(getAttribute(utf8Decoder, element, THRESHOLD_ATTR));
+ LogLog::debug(LOG4CXX_STR("Threshold =\"") + thresholdStr + LOG4CXX_STR("\"."));
- if (!thresholdStr.empty() && thresholdStr != NuLL)
- {
- repository->setThreshold(thresholdStr);
- }
+ if (!thresholdStr.empty() && thresholdStr != NuLL)
+ {
+ repository->setThreshold(thresholdStr);
+ }
- LogString strstrValue = subst(getAttribute(utf8Decoder, element, STRINGSTREAM_ATTR));
- LogLog::debug(LOG4CXX_STR("Stringstream =\"") + strstrValue + LOG4CXX_STR("\"."));
+ LogString strstrValue = subst(getAttribute(utf8Decoder, element, STRINGSTREAM_ATTR));
+ LogLog::debug(LOG4CXX_STR("Stringstream =\"") + strstrValue + LOG4CXX_STR("\"."));
- if (!strstrValue.empty() && strstrValue != NuLL)
- {
- MessageBufferUseStaticStream();
- }
+ if (!strstrValue.empty() && strstrValue != NuLL)
+ {
+ MessageBufferUseStaticStream();
+ }
- apr_xml_elem* currentElement;
+ apr_xml_elem* currentElement;
- for (currentElement = element->first_child;
- currentElement;
- currentElement = currentElement->next)
- {
- std::string tagName(currentElement->name);
+ for (currentElement = element->first_child;
+ currentElement;
+ currentElement = currentElement->next)
+ {
+ std::string tagName(currentElement->name);
- if (tagName == CATEGORY_FACTORY_TAG)
- {
- parseLoggerFactory(p, utf8Decoder, currentElement);
- }
- }
+ if (tagName == CATEGORY_FACTORY_TAG)
+ {
+ parseLoggerFactory(p, utf8Decoder, currentElement);
+ }
+ }
- for (currentElement = element->first_child;
- currentElement;
- currentElement = currentElement->next)
- {
- std::string tagName(currentElement->name);
+ for (currentElement = element->first_child;
+ currentElement;
+ currentElement = currentElement->next)
+ {
+ std::string tagName(currentElement->name);
- if (tagName == CATEGORY || tagName == LOGGER)
- {
- parseLogger(p, utf8Decoder, currentElement, doc, appenders);
- }
- else if (tagName == ROOT_TAG)
- {
- parseRoot(p, utf8Decoder, currentElement, doc, appenders);
- }
- }
+ if (tagName == CATEGORY || tagName == LOGGER)
+ {
+ parseLogger(p, utf8Decoder, currentElement, doc, appenders);
+ }
+ else if (tagName == ROOT_TAG)
+ {
+ parseRoot(p, utf8Decoder, currentElement, doc, appenders);
+ }
+ }
}
LogString DOMConfigurator::subst(const LogString& value)
{
- try
- {
- return OptionConverter::substVars(value, props);
- }
- catch (IllegalArgumentException& e)
- {
- LogLog::warn(LOG4CXX_STR("Could not perform variable substitution."), e);
- return value;
- }
+ try
+ {
+ return OptionConverter::substVars(value, props);
+ }
+ catch (IllegalArgumentException& e)
+ {
+ LogLog::warn(LOG4CXX_STR("Could not perform variable substitution."), e);
+ return value;
+ }
}
LogString DOMConfigurator::getAttribute(
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* element,
- const std::string& attrName)
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* element,
+ const std::string& attrName)
{
- LogString attrValue;
+ LogString attrValue;
- for (apr_xml_attr* attr = element->attr;
- attr;
- attr = attr->next)
- {
- if (attrName == attr->name)
- {
- ByteBuffer buf((char*) attr->value, strlen(attr->value));
- utf8Decoder->decode(buf, attrValue);
- }
- }
+ for (apr_xml_attr* attr = element->attr;
+ attr;
+ attr = attr->next)
+ {
+ if (attrName == attr->name)
+ {
+ ByteBuffer buf((char*) attr->value, strlen(attr->value));
+ utf8Decoder->decode(buf, attrValue);
+ }
+ }
- return attrValue;
+ return attrValue;
}
diff --git a/src/main/cpp/exception.cpp b/src/main/cpp/exception.cpp
index 0023a9a..759d074 100644
--- a/src/main/cpp/exception.cpp
+++ b/src/main/cpp/exception.cpp
@@ -246,30 +246,6 @@
}
-MutexException::MutexException(log4cxx_status_t stat)
- : Exception(formatMessage(stat))
-{
-}
-
-MutexException::MutexException(const MutexException& src)
- : Exception(src)
-{
-}
-
-MutexException& MutexException::operator=(const MutexException& src)
-{
- Exception::operator=(src);
- return *this;
-}
-
-LogString MutexException::formatMessage(log4cxx_status_t stat)
-{
- LogString s(LOG4CXX_STR("Mutex exception: stat = "));
- Pool p;
- StringHelper::toString(stat, p, s);
- return s;
-}
-
InterruptedException::InterruptedException() : Exception(LOG4CXX_STR("Thread was interrupted"))
{
}
diff --git a/src/main/cpp/fileappender.cpp b/src/main/cpp/fileappender.cpp
index 8d678d4..2d1549e 100644
--- a/src/main/cpp/fileappender.cpp
+++ b/src/main/cpp/fileappender.cpp
@@ -20,13 +20,11 @@
#include <log4cxx/helpers/stringhelper.h>
#include <log4cxx/helpers/loglog.h>
#include <log4cxx/helpers/optionconverter.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/helpers/pool.h>
#include <log4cxx/helpers/fileoutputstream.h>
#include <log4cxx/helpers/outputstreamwriter.h>
#include <log4cxx/helpers/bufferedwriter.h>
#include <log4cxx/helpers/bytebuffer.h>
-#include <log4cxx/helpers/synchronized.h>
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -37,155 +35,157 @@
FileAppender::FileAppender()
{
- LOCK_W sync(mutex);
- fileAppend = true;
- bufferedIO = false;
- bufferSize = 8 * 1024;
+ std::unique_lock lock(mutex);
+ fileAppend = true;
+ bufferedIO = false;
+ bufferSize = 8 * 1024;
}
FileAppender::FileAppender(const LayoutPtr& layout1, const LogString& fileName1,
- bool append1, bool bufferedIO1, int bufferSize1)
- : WriterAppender(layout1)
+ bool append1, bool bufferedIO1, int bufferSize1)
+ : WriterAppender(layout1)
{
- {
- LOCK_W sync(mutex);
- fileAppend = append1;
- fileName = fileName1;
- bufferedIO = bufferedIO1;
- bufferSize = bufferSize1;
- }
- Pool p;
- activateOptions(p);
+ {
+ std::unique_lock lock(mutex);
+ fileAppend = append1;
+ fileName = fileName1;
+ bufferedIO = bufferedIO1;
+ bufferSize = bufferSize1;
+ }
+ Pool p;
+ activateOptions(p);
}
FileAppender::FileAppender(const LayoutPtr& layout1, const LogString& fileName1,
- bool append1)
- : WriterAppender(layout1)
+ bool append1)
+ : WriterAppender(layout1)
{
- {
- LOCK_W sync(mutex);
- fileAppend = append1;
- fileName = fileName1;
- bufferedIO = false;
- bufferSize = 8 * 1024;
- }
- Pool p;
- activateOptions(p);
+ {
+ std::unique_lock lock(mutex);
+ fileAppend = append1;
+ fileName = fileName1;
+ bufferedIO = false;
+ bufferSize = 8 * 1024;
+ }
+ Pool p;
+ activateOptions(p);
}
FileAppender::FileAppender(const LayoutPtr& layout1, const LogString& fileName1)
- : WriterAppender(layout1)
+ : WriterAppender(layout1)
{
- {
- LOCK_W sync(mutex);
- fileAppend = true;
- fileName = fileName1;
- bufferedIO = false;
- bufferSize = 8 * 1024;
- }
- Pool p;
- activateOptions(p);
+ {
+ std::unique_lock lock(mutex);
+ fileAppend = true;
+ fileName = fileName1;
+ bufferedIO = false;
+ bufferSize = 8 * 1024;
+ }
+ Pool p;
+ activateOptions(p);
}
FileAppender::~FileAppender()
{
- finalize();
+ finalize();
}
void FileAppender::setAppend(bool fileAppend1)
{
- LOCK_W sync(mutex);
- this->fileAppend = fileAppend1;
+ std::unique_lock lock(mutex);
+ this->fileAppend = fileAppend1;
}
void FileAppender::setFile(const LogString& file)
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
fileName = file;
}
-
-
void FileAppender::setBufferedIO(bool bufferedIO1)
{
- LOCK_W sync(mutex);
- this->bufferedIO = bufferedIO1;
+ std::unique_lock lock(mutex);
+ this->bufferedIO = bufferedIO1;
- if (bufferedIO1)
- {
- setImmediateFlush(false);
- }
+ if (bufferedIO1)
+ {
+ setImmediateFlush(false);
+ }
}
void FileAppender::setOption(const LogString& option,
- const LogString& value)
+ const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("FILE"), LOG4CXX_STR("file"))
- || StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("FILENAME"), LOG4CXX_STR("filename")))
- {
- LOCK_W sync(mutex);
- fileName = stripDuplicateBackslashes(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("APPEND"), LOG4CXX_STR("append")))
- {
- LOCK_W sync(mutex);
- fileAppend = OptionConverter::toBoolean(value, true);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFEREDIO"), LOG4CXX_STR("bufferedio")))
- {
- LOCK_W sync(mutex);
- bufferedIO = OptionConverter::toBoolean(value, true);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("IMMEDIATEFLUSH"), LOG4CXX_STR("immediateflush")))
- {
- LOCK_W sync(mutex);
- bufferedIO = !OptionConverter::toBoolean(value, false);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFERSIZE"), LOG4CXX_STR("buffersize")))
- {
- LOCK_W sync(mutex);
- bufferSize = OptionConverter::toFileSize(value, 8 * 1024);
- }
- else
- {
- WriterAppender::setOption(option, value);
- }
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("FILE"), LOG4CXX_STR("file"))
+ || StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("FILENAME"), LOG4CXX_STR("filename")))
+ {
+ std::unique_lock lock(mutex);
+ fileName = stripDuplicateBackslashes(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("APPEND"), LOG4CXX_STR("append")))
+ {
+ std::unique_lock lock(mutex);
+ fileAppend = OptionConverter::toBoolean(value, true);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFEREDIO"), LOG4CXX_STR("bufferedio")))
+ {
+ std::unique_lock lock(mutex);
+ bufferedIO = OptionConverter::toBoolean(value, true);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("IMMEDIATEFLUSH"), LOG4CXX_STR("immediateflush")))
+ {
+ std::unique_lock lock(mutex);
+ bufferedIO = !OptionConverter::toBoolean(value, false);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFERSIZE"), LOG4CXX_STR("buffersize")))
+ {
+ std::unique_lock lock(mutex);
+ bufferSize = OptionConverter::toFileSize(value, 8 * 1024);
+ }
+ else
+ {
+ WriterAppender::setOption(option, value);
+ }
}
void FileAppender::activateOptions(Pool& p)
{
- LOCK_W sync(mutex);
- int errors = 0;
+ std::unique_lock lock(mutex);
+ activateOptionsInternal(p);
+}
- if (!fileName.empty())
- {
- try
- {
- setFile(fileName, fileAppend, bufferedIO, bufferSize, p);
- }
- catch (IOException& e)
- {
- errors++;
- LogString msg(LOG4CXX_STR("setFile("));
- msg.append(fileName);
- msg.append(1, (logchar) 0x2C /* ',' */);
- StringHelper::toString(fileAppend, msg);
- msg.append(LOG4CXX_STR(") call failed."));
- errorHandler->error(msg, e, ErrorCode::FILE_OPEN_FAILURE);
- }
- }
- else
- {
- errors++;
- LogLog::error(LogString(LOG4CXX_STR("File option not set for appender ["))
- + name + LOG4CXX_STR("]."));
- LogLog::warn(LOG4CXX_STR("Are you using FileAppender instead of ConsoleAppender?"));
- }
+void FileAppender::activateOptionsInternal(Pool& p){
+ int errors = 0;
- if (errors == 0)
- {
- WriterAppender::activateOptions(p);
- }
+ if (!fileName.empty())
+ {
+ try
+ {
+ setFileInternal(fileName, fileAppend, bufferedIO, bufferSize, p);
+ }
+ catch (IOException& e)
+ {
+ errors++;
+ LogString msg(LOG4CXX_STR("setFile("));
+ msg.append(fileName);
+ msg.append(1, (logchar) 0x2C /* ',' */);
+ StringHelper::toString(fileAppend, msg);
+ msg.append(LOG4CXX_STR(") call failed."));
+ errorHandler->error(msg, e, ErrorCode::FILE_OPEN_FAILURE);
+ }
+ }
+ else
+ {
+ errors++;
+ LogLog::error(LogString(LOG4CXX_STR("File option not set for appender ["))
+ + name + LOG4CXX_STR("]."));
+ LogLog::warn(LOG4CXX_STR("Are you using FileAppender instead of ConsoleAppender?"));
+ }
+
+ if (errors == 0)
+ {
+ WriterAppender::activateOptions(p);
+ }
}
@@ -202,45 +202,45 @@
*/
LogString FileAppender::stripDuplicateBackslashes(const LogString& src)
{
- logchar backslash = 0x5C; // '\\'
- LogString::size_type i = src.find_last_of(backslash);
+ logchar backslash = 0x5C; // '\\'
+ LogString::size_type i = src.find_last_of(backslash);
- if (i != LogString::npos)
- {
- LogString tmp(src);
+ if (i != LogString::npos)
+ {
+ LogString tmp(src);
- for (;
- i != LogString::npos && i > 0;
- i = tmp.find_last_of(backslash, i - 1))
- {
- //
- // if the preceding character is a slash then
- // remove the preceding character
- // and continue processing
- if (tmp[i - 1] == backslash)
- {
- tmp.erase(i, 1);
- i--;
+ for (;
+ i != LogString::npos && i > 0;
+ i = tmp.find_last_of(backslash, i - 1))
+ {
+ //
+ // if the preceding character is a slash then
+ // remove the preceding character
+ // and continue processing
+ if (tmp[i - 1] == backslash)
+ {
+ tmp.erase(i, 1);
+ i--;
- if (i == 0)
- {
- break;
- }
- }
- else
- {
- //
- // if there an odd number of slashes
- // the string wasn't trying to work around
- // OptionConverter::convertSpecialChars
- return src;
- }
- }
+ if (i == 0)
+ {
+ break;
+ }
+ }
+ else
+ {
+ //
+ // if there an odd number of slashes
+ // the string wasn't trying to work around
+ // OptionConverter::convertSpecialChars
+ return src;
+ }
+ }
- return tmp;
- }
+ return tmp;
+ }
- return src;
+ return src;
}
/**
@@ -263,98 +263,96 @@
@throws IOException
*/
-void FileAppender::setFile(
- const LogString& filename,
- bool append1,
- bool bufferedIO1,
- size_t bufferSize1,
- Pool& p)
+void FileAppender::setFileInternal(
+ const LogString& filename,
+ bool append1,
+ bool bufferedIO1,
+ size_t bufferSize1,
+ Pool& p)
{
- LOCK_W sync(mutex);
+ // It does not make sense to have immediate flush and bufferedIO.
+ if (bufferedIO1)
+ {
+ setImmediateFlush(false);
+ }
- // It does not make sense to have immediate flush and bufferedIO.
- if (bufferedIO1)
- {
- setImmediateFlush(false);
+ closeWriter();
+
+ bool writeBOM = false;
+
+ if (StringHelper::equalsIgnoreCase(getEncoding(),
+ LOG4CXX_STR("utf-16"), LOG4CXX_STR("UTF-16")))
+ {
+ //
+ // don't want to write a byte order mark if the file exists
+ //
+ if (append1)
+ {
+ File outFile;
+ outFile.setPath(filename);
+ writeBOM = !outFile.exists(p);
+ }
+ else
+ {
+ writeBOM = true;
+ }
+ }
+
+ OutputStreamPtr outStream;
+
+ try
+ {
+ outStream = new FileOutputStream(filename, append1);
+ }
+ catch (IOException&)
+ {
+ LogString parentName = File().setPath(filename).getParent(p);
+
+ if (!parentName.empty())
+ {
+ File parentDir;
+ parentDir.setPath(parentName);
+
+ if (!parentDir.exists(p) && parentDir.mkdirs(p))
+ {
+ outStream = new FileOutputStream(filename, append1);
+ }
+ else
+ {
+ throw;
+ }
+ }
+ else
+ {
+ throw;
+ }
+ }
+
+
+ //
+ // if a new file and UTF-16, then write a BOM
+ //
+ if (writeBOM)
+ {
+ char bom[] = { (char) 0xFE, (char) 0xFF };
+ ByteBuffer buf(bom, 2);
+ outStream->write(buf, p);
+ }
+
+ WriterPtr newWriter(createWriter(outStream));
+
+ if (bufferedIO1)
+ {
+ newWriter = new BufferedWriter(newWriter, bufferSize1);
}
- closeWriter();
+ setWriterInternal(newWriter);
- bool writeBOM = false;
-
- if (StringHelper::equalsIgnoreCase(getEncoding(),
- LOG4CXX_STR("utf-16"), LOG4CXX_STR("UTF-16")))
- {
- //
- // don't want to write a byte order mark if the file exists
- //
- if (append1)
- {
- File outFile;
- outFile.setPath(filename);
- writeBOM = !outFile.exists(p);
- }
- else
- {
- writeBOM = true;
- }
- }
-
- OutputStreamPtr outStream;
-
- try
- {
- outStream = new FileOutputStream(filename, append1);
- }
- catch (IOException&)
- {
- LogString parentName = File().setPath(filename).getParent(p);
-
- if (!parentName.empty())
- {
- File parentDir;
- parentDir.setPath(parentName);
-
- if (!parentDir.exists(p) && parentDir.mkdirs(p))
- {
- outStream = new FileOutputStream(filename, append1);
- }
- else
- {
- throw;
- }
- }
- else
- {
- throw;
- }
- }
-
-
- //
- // if a new file and UTF-16, then write a BOM
- //
- if (writeBOM)
- {
- char bom[] = { (char) 0xFE, (char) 0xFF };
- ByteBuffer buf(bom, 2);
- outStream->write(buf, p);
- }
-
- WriterPtr newWriter(createWriter(outStream));
-
- if (bufferedIO1)
- {
- newWriter = new BufferedWriter(newWriter, bufferSize1);
- }
-
- setWriter(newWriter);
-
- this->fileAppend = append1;
- this->bufferedIO = bufferedIO1;
- this->fileName = filename;
- this->bufferSize = (int)bufferSize1;
- writeHeader(p);
+ this->fileAppend = append1;
+ this->bufferedIO = bufferedIO1;
+ this->fileName = filename;
+ this->bufferSize = (int)bufferSize1;
+ writeHeader(p);
}
diff --git a/src/main/cpp/filewatchdog.cpp b/src/main/cpp/filewatchdog.cpp
index b2771ff..65c5321 100644
--- a/src/main/cpp/filewatchdog.cpp
+++ b/src/main/cpp/filewatchdog.cpp
@@ -23,14 +23,13 @@
#include <apr_atomic.h>
#include <log4cxx/helpers/transcoder.h>
#include <log4cxx/helpers/exception.h>
+#include <functional>
using namespace log4cxx;
using namespace log4cxx::helpers;
long FileWatchdog::DEFAULT_DELAY = 60000;
-#if APR_HAS_THREADS
-
FileWatchdog::FileWatchdog(const File& file1)
: file(file1), delay(DEFAULT_DELAY), lastModif(0),
warnedAlready(false), interrupted(0), thread()
@@ -39,16 +38,13 @@
FileWatchdog::~FileWatchdog()
{
- apr_atomic_set32(&interrupted, 0xFFFF);
+ interrupted = 0xFFFF;
- try
- {
- thread.interrupt();
- thread.join();
- }
- catch (Exception&)
- {
- }
+ {
+ std::unique_lock lock(interrupt_mutex);
+ interrupt.notify_all();
+ }
+ thread.join();
}
void FileWatchdog::checkAndConfigure()
@@ -78,33 +74,27 @@
}
}
-void* APR_THREAD_FUNC FileWatchdog::run(apr_thread_t* /* thread */, void* data)
+void FileWatchdog::run()
{
- FileWatchdog* pThis = (FileWatchdog*) data;
- unsigned int interrupted = apr_atomic_read32(&pThis->interrupted);
+ while (interrupted != 0xFFFF)
+ {
+ std::unique_lock lock( interrupt_mutex );
+ interrupt.wait_for( lock, std::chrono::milliseconds( delay ),
+ std::bind(&FileWatchdog::is_interrupted, this) );
- while (!interrupted)
- {
- try
- {
- Thread::sleep(pThis->delay);
- pThis->checkAndConfigure();
- }
- catch (InterruptedException&)
- {
- interrupted = apr_atomic_read32(&pThis->interrupted);
- }
- }
+ checkAndConfigure();
+ }
- return NULL;
}
void FileWatchdog::start()
{
checkAndConfigure();
- thread.run(run, this);
+ thread = std::thread( &FileWatchdog::run, this );
}
-#endif
+bool FileWatchdog::is_interrupted(){
+ return interrupted == 0xFFFF;
+}
diff --git a/src/main/cpp/hierarchy.cpp b/src/main/cpp/hierarchy.cpp
index ee6d417..bab5908 100644
--- a/src/main/cpp/hierarchy.cpp
+++ b/src/main/cpp/hierarchy.cpp
@@ -29,7 +29,6 @@
#include <algorithm>
#include <log4cxx/helpers/loglog.h>
#include <log4cxx/appender.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/logstring.h>
#include <log4cxx/helpers/stringhelper.h>
#if !defined(LOG4CXX)
@@ -38,8 +37,8 @@
#include <log4cxx/helpers/aprinitializer.h>
#include <log4cxx/defaultconfigurator.h>
#include <log4cxx/spi/rootlogger.h>
-#include <apr_atomic.h>
#include "assert.h"
+#include <mutex>
using namespace log4cxx;
@@ -49,12 +48,11 @@
IMPLEMENT_LOG4CXX_OBJECT(Hierarchy)
Hierarchy::Hierarchy() :
- pool(),
- mutex(pool),
+ pool(),
loggers(new LoggerMap()),
provisionNodes(new ProvisionNodeMap())
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
root = new RootLogger(pool, Level::getDebug());
root->setHierarchy(this);
defaultFactory = new DefaultLoggerFactory();
@@ -87,7 +85,7 @@
void Hierarchy::addHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener)
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
if (std::find(listeners.begin(), listeners.end(), listener) != listeners.end())
{
@@ -101,7 +99,7 @@
void Hierarchy::clear()
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
loggers->clear();
}
@@ -109,7 +107,7 @@
{
bool emitWarning = false;
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
emitWarning = !emittedNoAppenderWarning;
emittedNoAppenderWarning = true;
}
@@ -126,7 +124,7 @@
LoggerPtr Hierarchy::exists(const LogString& name)
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
LoggerPtr logger;
LoggerMap::iterator it = loggers->find(name);
@@ -144,14 +142,8 @@
{
if (l != 0)
{
- synchronized sync(mutex);
- thresholdInt = l->toInt();
- threshold = l;
-
- if (thresholdInt != Level::ALL_INT)
- {
- setConfigured(true);
- }
+ std::unique_lock lock(mutex);
+ setThresholdInternal(l);
}
}
@@ -170,12 +162,22 @@
}
}
+void Hierarchy::setThresholdInternal(const LevelPtr &l){
+ thresholdInt = l->toInt();
+ threshold = l;
+
+ if (thresholdInt != Level::ALL_INT)
+ {
+ configured = true;
+ }
+}
+
void Hierarchy::fireAddAppenderEvent(const LoggerPtr& logger, const AppenderPtr& appender)
{
setConfigured(true);
HierarchyEventListenerList clonedList;
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
clonedList = listeners;
}
@@ -194,7 +196,7 @@
{
HierarchyEventListenerList clonedList;
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
clonedList = listeners;
}
HierarchyEventListenerList::iterator it, itEnd = clonedList.end();
@@ -220,7 +222,7 @@
LoggerPtr Hierarchy::getLogger(const LogString& name,
const spi::LoggerFactoryPtr& factory)
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
LoggerMap::iterator it = loggers->find(name);
@@ -250,7 +252,7 @@
LoggerList Hierarchy::getCurrentLoggers() const
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
LoggerList v;
LoggerMap::const_iterator it, itEnd = loggers->end();
@@ -271,15 +273,15 @@
bool Hierarchy::isDisabled(int level) const
{
- if (!configured)
- {
- synchronized sync(mutex);
-
- if (!configured)
- {
- DefaultConfigurator::configure(
- const_cast<Hierarchy*>(this));
- }
+ bool currentlyConfigured;
+ {
+ std::unique_lock lock(mutex);
+ currentlyConfigured = configured;
+ }
+ if (!currentlyConfigured)
+ {
+ DefaultConfigurator::configure(
+ const_cast<Hierarchy*>(this));
}
return thresholdInt > level;
@@ -288,62 +290,61 @@
void Hierarchy::resetConfiguration()
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
getRootLogger()->setLevel(Level::getDebug());
root->setResourceBundle(0);
- setThreshold(Level::getAll());
+ setThresholdInternal(Level::getAll());
- shutdown(); // nested locks are OK
+ shutdownInternal();
- LoggerList loggers1 = getCurrentLoggers();
- LoggerList::iterator it, itEnd = loggers1.end();
+ LoggerMap::const_iterator it, itEnd = loggers->end();
- for (it = loggers1.begin(); it != itEnd; it++)
- {
- LoggerPtr& logger = *it;
- logger->setLevel(0);
- logger->setAdditivity(true);
- logger->setResourceBundle(0);
- }
+ for (it = loggers->begin(); it != itEnd; it++)
+ {
+ it->second->setLevel(0);
+ it->second->setAdditivity(true);
+ it->second->setResourceBundle(0);
+ }
//rendererMap.clear();
}
void Hierarchy::shutdown()
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
- setConfigured(false);
-
- LoggerPtr root1 = getRootLogger();
-
- // begin by closing nested appenders
- root1->closeNestedAppenders();
-
- LoggerList loggers1 = getCurrentLoggers();
- LoggerList::iterator it, itEnd = loggers1.end();
-
- for (it = loggers1.begin(); it != itEnd; it++)
- {
- LoggerPtr& logger = *it;
- logger->closeNestedAppenders();
- }
-
- // then, remove all appenders
- root1->removeAllAppenders();
-
- for (it = loggers1.begin(); it != itEnd; it++)
- {
- LoggerPtr& logger = *it;
- logger->removeAllAppenders();
- }
+ shutdownInternal();
}
+void Hierarchy::shutdownInternal(){
+ configured = false;
+
+ LoggerPtr root1 = getRootLogger();
+
+ // begin by closing nested appenders
+ root1->closeNestedAppenders();
+
+ LoggerMap::iterator it, itEnd = loggers->end();
+
+ for (it = loggers->begin(); it != itEnd; it++)
+ {
+ LoggerPtr& logger = it->second;
+ logger->closeNestedAppenders();
+ }
+
+ // then, remove all appenders
+ root1->removeAllAppenders();
+
+ for (it = loggers->begin(); it != itEnd; it++)
+ {
+ LoggerPtr& logger = it->second;
+ logger->removeAllAppenders();
+ }
+}
void Hierarchy::updateParents(LoggerPtr logger)
{
- synchronized sync(mutex);
const LogString name(logger->getName());
size_t length = name.size();
bool parentFound = false;
@@ -409,7 +410,7 @@
void Hierarchy::setConfigured(bool newValue)
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
configured = newValue;
}
diff --git a/src/main/cpp/jsonlayout.cpp b/src/main/cpp/jsonlayout.cpp
index a2e72c3..d475777 100644
--- a/src/main/cpp/jsonlayout.cpp
+++ b/src/main/cpp/jsonlayout.cpp
@@ -24,8 +24,6 @@
#include <log4cxx/helpers/stringhelper.h>
#include <log4cxx/helpers/transcoder.h>
-#include <apr_time.h>
-#include <apr_strings.h>
#include <string.h>
using namespace log4cxx;
diff --git a/src/main/cpp/locationinfo.cpp b/src/main/cpp/locationinfo.cpp
index 0ff6246..6106687 100644
--- a/src/main/cpp/locationinfo.cpp
+++ b/src/main/cpp/locationinfo.cpp
@@ -18,8 +18,6 @@
#include <log4cxx/spi/location/locationinfo.h>
#include <log4cxx/helpers/objectoutputstream.h>
#include <log4cxx/helpers/pool.h>
-#include "apr_pools.h"
-#include "apr_strings.h"
using namespace ::log4cxx::spi;
using namespace log4cxx::helpers;
diff --git a/src/main/cpp/logger.cpp b/src/main/cpp/logger.cpp
index 5738740..db2b8d9 100644
--- a/src/main/cpp/logger.cpp
+++ b/src/main/cpp/logger.cpp
@@ -25,12 +25,11 @@
#include <log4cxx/helpers/loglog.h>
#include <log4cxx/spi/loggerrepository.h>
#include <log4cxx/helpers/stringhelper.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/helpers/transcoder.h>
#include <log4cxx/helpers/appenderattachableimpl.h>
#include <log4cxx/helpers/exception.h>
#if !defined(LOG4CXX)
- #define LOG4CXX 1
+#define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
#include <log4cxx/helpers/aprinitializer.h>
@@ -42,11 +41,11 @@
IMPLEMENT_LOG4CXX_OBJECT(Logger)
Logger::Logger(Pool& p, const LogString& name1)
- : pool(&p), name(), level(), parent(), resourceBundle(),
- repository(), aai(), SHARED_MUTEX_INIT(mutex, p)
+ : pool(&p), name(), level(), parent(), resourceBundle(),
+ repository(), aai()
{
- name = name1;
- additive = true;
+ name = name1;
+ additive = true;
}
Logger::~Logger()
@@ -55,291 +54,315 @@
void Logger::addRef() const
{
- ObjectImpl::addRef();
+ ObjectImpl::addRef();
}
void Logger::releaseRef() const
{
- ObjectImpl::releaseRef();
+ ObjectImpl::releaseRef();
}
void Logger::addAppender(const AppenderPtr& newAppender)
{
- log4cxx::spi::LoggerRepository* rep = 0;
- {
- LOCK_W sync(mutex);
+ log4cxx::spi::LoggerRepository* rep = 0;
+ {
+ std::shared_lock lock(mutex);
- if (aai == 0)
- {
- aai = new AppenderAttachableImpl(*pool);
- }
+ if (aai == 0)
+ {
+ aai = new AppenderAttachableImpl(*pool);
+ }
- aai->addAppender(newAppender);
- rep = repository;
- }
+ aai->addAppender(newAppender);
+ rep = repository;
+ }
- if (rep != 0)
- {
- rep->fireAddAppenderEvent(this, newAppender);
- }
+ if (rep != 0)
+ {
+ rep->fireAddAppenderEvent(this, newAppender);
+ }
}
+void Logger::reconfigure( const std::vector<AppenderPtr>& appenders, bool additive1 ) {
+ std::unique_lock lock(mutex);
+
+ additive = additive1;
+
+ if (aai != 0)
+ {
+ aai->removeAllAppenders();
+ aai = 0;
+ }
+
+ aai = new AppenderAttachableImpl(*pool);
+
+ for( std::vector<AppenderPtr>::const_iterator it = appenders.cbegin();
+ it != appenders.cend();
+ it++ ) {
+ aai->addAppender( *it );
+
+ if (repository != 0)
+ {
+ repository->fireAddAppenderEvent(this, *it);
+ }
+ }
+}
void Logger::callAppenders(const spi::LoggingEventPtr& event, Pool& p) const
{
- int writes = 0;
+ int writes = 0;
- for (LoggerPtr logger(const_cast<Logger*>(this));
- logger != 0;
- logger = logger->parent)
- {
- // Protected against simultaneous call to addAppender, removeAppender,...
- LOCK_R sync(logger->mutex);
+ for (LoggerPtr logger(const_cast<Logger*>(this));
+ logger != 0;
+ logger = logger->parent)
+ {
+ // Protected against simultaneous call to addAppender, removeAppender,...
+ std::unique_lock lock(logger->mutex);
- if (logger->aai != 0)
- {
- writes += logger->aai->appendLoopOnAppenders(event, p);
- }
+ if (logger->aai != 0)
+ {
+ writes += logger->aai->appendLoopOnAppenders(event, p);
+ }
- if (!logger->additive)
- {
- break;
- }
- }
+ if (!logger->additive)
+ {
+ break;
+ }
+ }
- if (writes == 0 && repository != 0)
- {
- repository->emitNoAppenderWarning(const_cast<Logger*>(this));
- }
+ if (writes == 0 && repository != 0)
+ {
+ repository->emitNoAppenderWarning(const_cast<Logger*>(this));
+ }
}
void Logger::closeNestedAppenders()
{
- AppenderList appenders = getAllAppenders();
+ AppenderList appenders = getAllAppenders();
- for (AppenderList::iterator it = appenders.begin(); it != appenders.end(); ++it)
- {
- (*it)->close();
- }
+ for (AppenderList::iterator it = appenders.begin(); it != appenders.end(); ++it)
+ {
+ (*it)->close();
+ }
}
void Logger::forcedLog(const LevelPtr& level1, const std::string& message,
- const LocationInfo& location) const
+ const LocationInfo& location) const
{
- Pool p;
- LOG4CXX_DECODE_CHAR(msg, message);
- LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
- callAppenders(event, p);
+ Pool p;
+ LOG4CXX_DECODE_CHAR(msg, message);
+ LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
+ callAppenders(event, p);
}
void Logger::forcedLog(const LevelPtr& level1, const std::string& message) const
{
- Pool p;
- LOG4CXX_DECODE_CHAR(msg, message);
- LoggingEventPtr event(new LoggingEvent(name, level1, msg,
- LocationInfo::getLocationUnavailable()));
- callAppenders(event, p);
+ Pool p;
+ LOG4CXX_DECODE_CHAR(msg, message);
+ LoggingEventPtr event(new LoggingEvent(name, level1, msg,
+ LocationInfo::getLocationUnavailable()));
+ callAppenders(event, p);
}
void Logger::forcedLogLS(const LevelPtr& level1, const LogString& message,
- const LocationInfo& location) const
+ const LocationInfo& location) const
{
- Pool p;
- LoggingEventPtr event(new LoggingEvent(name, level1, message, location));
- callAppenders(event, p);
+ Pool p;
+ LoggingEventPtr event(new LoggingEvent(name, level1, message, location));
+ callAppenders(event, p);
}
bool Logger::getAdditivity() const
{
- return additive;
+ return additive;
}
AppenderList Logger::getAllAppenders() const
{
- LOCK_W sync(mutex);
+ std::shared_lock lock(mutex);
- if (aai == 0)
- {
- return AppenderList();
- }
- else
- {
- return aai->getAllAppenders();
- }
+ if (aai == 0)
+ {
+ return AppenderList();
+ }
+ else
+ {
+ return aai->getAllAppenders();
+ }
}
AppenderPtr Logger::getAppender(const LogString& name1) const
{
- LOCK_W sync(mutex);
+ std::shared_lock lock(mutex);
- if (aai == 0 || name1.empty())
- {
- return 0;
- }
+ if (aai == 0 || name1.empty())
+ {
+ return 0;
+ }
- return aai->getAppender(name1);
+ return aai->getAppender(name1);
}
const LevelPtr& Logger::getEffectiveLevel() const
{
- for (const Logger* l = this; l != 0; l = l->parent)
- {
- if (l->level != 0)
- {
- return l->level;
- }
- }
+ for (const Logger* l = this; l != 0; l = l->parent)
+ {
+ if (l->level != 0)
+ {
+ return l->level;
+ }
+ }
- throw NullPointerException(LOG4CXX_STR("No level specified for logger or ancestors."));
+ throw NullPointerException(LOG4CXX_STR("No level specified for logger or ancestors."));
#if LOG4CXX_RETURN_AFTER_THROW
- return this->level;
+ return this->level;
#endif
}
LoggerRepositoryPtr Logger::getLoggerRepository() const
{
- return repository;
+ return repository;
}
ResourceBundlePtr Logger::getResourceBundle() const
{
- for (LoggerPtr l(const_cast<Logger*>(this)); l != 0; l = l->parent)
- {
- if (l->resourceBundle != 0)
- {
- return l->resourceBundle;
- }
- }
+ for (LoggerPtr l(const_cast<Logger*>(this)); l != 0; l = l->parent)
+ {
+ if (l->resourceBundle != 0)
+ {
+ return l->resourceBundle;
+ }
+ }
- // It might be the case that there is no resource bundle
- return 0;
+ // It might be the case that there is no resource bundle
+ return 0;
}
LogString Logger::getResourceBundleString(const LogString& key) const
{
- ResourceBundlePtr rb = getResourceBundle();
+ ResourceBundlePtr rb = getResourceBundle();
- // This is one of the rare cases where we can use logging in order
- // to report errors from within log4j.
- if (rb == 0)
- {
- return LogString();
- }
- else
- {
- try
- {
- return rb->getString(key);
- }
- catch (MissingResourceException&)
- {
- logLS(Level::getError(), LOG4CXX_STR("No resource is associated with key \"") +
- key + LOG4CXX_STR("\"."), LocationInfo::getLocationUnavailable());
+ // This is one of the rare cases where we can use logging in order
+ // to report errors from within log4j.
+ if (rb == 0)
+ {
+ return LogString();
+ }
+ else
+ {
+ try
+ {
+ return rb->getString(key);
+ }
+ catch (MissingResourceException&)
+ {
+ logLS(Level::getError(), LOG4CXX_STR("No resource is associated with key \"") +
+ key + LOG4CXX_STR("\"."), LocationInfo::getLocationUnavailable());
- return LogString();
- }
- }
+ return LogString();
+ }
+ }
}
LoggerPtr Logger::getParent() const
{
- return parent;
+ return parent;
}
LevelPtr Logger::getLevel() const
{
- return level;
+ return level;
}
bool Logger::isAttached(const AppenderPtr& appender) const
{
- LOCK_R sync(mutex);
+ std::shared_lock lock(mutex);
- if (appender == 0 || aai == 0)
- {
- return false;
- }
- else
- {
- return aai->isAttached(appender);
- }
+ if (appender == 0 || aai == 0)
+ {
+ return false;
+ }
+ else
+ {
+ return aai->isAttached(appender);
+ }
}
bool Logger::isTraceEnabled() const
{
- if (repository == 0 || repository->isDisabled(Level::TRACE_INT))
- {
- return false;
- }
+ if (repository == 0 || repository->isDisabled(Level::TRACE_INT))
+ {
+ return false;
+ }
- return getEffectiveLevel()->toInt() <= Level::TRACE_INT;
+ return getEffectiveLevel()->toInt() <= Level::TRACE_INT;
}
bool Logger::isDebugEnabled() const
{
- if (repository == 0 || repository->isDisabled(Level::DEBUG_INT))
- {
- return false;
- }
+ if (repository == 0 || repository->isDisabled(Level::DEBUG_INT))
+ {
+ return false;
+ }
- return getEffectiveLevel()->toInt() <= Level::DEBUG_INT;
+ return getEffectiveLevel()->toInt() <= Level::DEBUG_INT;
}
bool Logger::isEnabledFor(const LevelPtr& level1) const
{
- if (repository == 0 || repository->isDisabled(level1->toInt()))
- {
- return false;
- }
+ if (repository == 0 || repository->isDisabled(level1->toInt()))
+ {
+ return false;
+ }
- return level1->isGreaterOrEqual(getEffectiveLevel());
+ return level1->isGreaterOrEqual(getEffectiveLevel());
}
bool Logger::isInfoEnabled() const
{
- if (repository == 0 || repository->isDisabled(Level::INFO_INT))
- {
- return false;
- }
+ if (repository == 0 || repository->isDisabled(Level::INFO_INT))
+ {
+ return false;
+ }
- return getEffectiveLevel()->toInt() <= Level::INFO_INT;
+ return getEffectiveLevel()->toInt() <= Level::INFO_INT;
}
bool Logger::isErrorEnabled() const
{
- if (repository == 0 || repository->isDisabled(Level::ERROR_INT))
- {
- return false;
- }
+ if (repository == 0 || repository->isDisabled(Level::ERROR_INT))
+ {
+ return false;
+ }
- return getEffectiveLevel()->toInt() <= Level::ERROR_INT;
+ return getEffectiveLevel()->toInt() <= Level::ERROR_INT;
}
bool Logger::isWarnEnabled() const
{
- if (repository == 0 || repository->isDisabled(Level::WARN_INT))
- {
- return false;
- }
+ if (repository == 0 || repository->isDisabled(Level::WARN_INT))
+ {
+ return false;
+ }
- return getEffectiveLevel()->toInt() <= Level::WARN_INT;
+ return getEffectiveLevel()->toInt() <= Level::WARN_INT;
}
bool Logger::isFatalEnabled() const
{
- if (repository == 0 || repository->isDisabled(Level::FATAL_INT))
- {
- return false;
- }
+ if (repository == 0 || repository->isDisabled(Level::FATAL_INT))
+ {
+ return false;
+ }
- return getEffectiveLevel()->toInt() <= Level::FATAL_INT;
+ return getEffectiveLevel()->toInt() <= Level::FATAL_INT;
}
/*void Logger::l7dlog(const LevelPtr& level, const String& key,
@@ -368,294 +391,294 @@
void Logger::l7dlog(const LevelPtr& level1, const LogString& key,
- const LocationInfo& location, const std::vector<LogString>& params) const
+ const LocationInfo& location, const std::vector<LogString>& params) const
{
- if (repository == 0 || repository->isDisabled(level1->toInt()))
- {
- return;
- }
+ if (repository == 0 || repository->isDisabled(level1->toInt()))
+ {
+ return;
+ }
- if (level1->isGreaterOrEqual(getEffectiveLevel()))
- {
- LogString pattern = getResourceBundleString(key);
- LogString msg;
+ if (level1->isGreaterOrEqual(getEffectiveLevel()))
+ {
+ LogString pattern = getResourceBundleString(key);
+ LogString msg;
- if (pattern.empty())
- {
- msg = key;
- }
- else
- {
- msg = StringHelper::format(pattern, params);
- }
+ if (pattern.empty())
+ {
+ msg = key;
+ }
+ else
+ {
+ msg = StringHelper::format(pattern, params);
+ }
- forcedLogLS(level1, msg, location);
- }
+ forcedLogLS(level1, msg, location);
+ }
}
void Logger::l7dlog(const LevelPtr& level1, const std::string& key,
- const LocationInfo& location) const
+ const LocationInfo& location) const
{
- LOG4CXX_DECODE_CHAR(lkey, key);
+ LOG4CXX_DECODE_CHAR(lkey, key);
- std::vector<LogString> values(0);
- l7dlog(level1, lkey, location, values);
+ std::vector<LogString> values(0);
+ l7dlog(level1, lkey, location, values);
}
void Logger::l7dlog(const LevelPtr& level1, const std::string& key,
- const LocationInfo& location, const std::string& val1) const
+ const LocationInfo& location, const std::string& val1) const
{
- LOG4CXX_DECODE_CHAR(lkey, key);
- LOG4CXX_DECODE_CHAR(lval1, val1);
+ LOG4CXX_DECODE_CHAR(lkey, key);
+ LOG4CXX_DECODE_CHAR(lval1, val1);
- std::vector<LogString> values(1);
- values[0] = lval1;
- l7dlog(level1, lkey, location, values);
+ std::vector<LogString> values(1);
+ values[0] = lval1;
+ l7dlog(level1, lkey, location, values);
}
void Logger::l7dlog(const LevelPtr& level1, const std::string& key,
- const LocationInfo& location,
- const std::string& val1, const std::string& val2) const
+ const LocationInfo& location,
+ const std::string& val1, const std::string& val2) const
{
- LOG4CXX_DECODE_CHAR(lkey, key);
- LOG4CXX_DECODE_CHAR(lval1, val1);
- LOG4CXX_DECODE_CHAR(lval2, val2);
+ LOG4CXX_DECODE_CHAR(lkey, key);
+ LOG4CXX_DECODE_CHAR(lval1, val1);
+ LOG4CXX_DECODE_CHAR(lval2, val2);
- std::vector<LogString> values(2);
- values[0] = lval1;
- values[1] = lval2;
- l7dlog(level1, lkey, location, values);
+ std::vector<LogString> values(2);
+ values[0] = lval1;
+ values[1] = lval2;
+ l7dlog(level1, lkey, location, values);
}
void Logger::l7dlog(const LevelPtr& level1, const std::string& key,
- const LocationInfo& location,
- const std::string& val1, const std::string& val2, const std::string& val3) const
+ const LocationInfo& location,
+ const std::string& val1, const std::string& val2, const std::string& val3) const
{
- LOG4CXX_DECODE_CHAR(lkey, key);
- LOG4CXX_DECODE_CHAR(lval1, val1);
- LOG4CXX_DECODE_CHAR(lval2, val2);
- LOG4CXX_DECODE_CHAR(lval3, val3);
+ LOG4CXX_DECODE_CHAR(lkey, key);
+ LOG4CXX_DECODE_CHAR(lval1, val1);
+ LOG4CXX_DECODE_CHAR(lval2, val2);
+ LOG4CXX_DECODE_CHAR(lval3, val3);
- std::vector<LogString> values(3);
- values[0] = lval1;
- values[1] = lval2;
- values[2] = lval3;
- l7dlog(level1, lkey, location, values);
+ std::vector<LogString> values(3);
+ values[0] = lval1;
+ values[1] = lval2;
+ values[2] = lval3;
+ l7dlog(level1, lkey, location, values);
}
void Logger::removeAllAppenders()
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
- if (aai != 0)
- {
- aai->removeAllAppenders();
- aai = 0;
- }
+ if (aai != 0)
+ {
+ aai->removeAllAppenders();
+ aai = 0;
+ }
}
void Logger::removeAppender(const AppenderPtr& appender)
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
- if (appender == 0 || aai == 0)
- {
- return;
- }
+ if (appender == 0 || aai == 0)
+ {
+ return;
+ }
- aai->removeAppender(appender);
+ aai->removeAppender(appender);
}
void Logger::removeAppender(const LogString& name1)
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
- if (name1.empty() || aai == 0)
- {
- return;
- }
+ if (name1.empty() || aai == 0)
+ {
+ return;
+ }
- aai->removeAppender(name1);
+ aai->removeAppender(name1);
}
void Logger::setAdditivity(bool additive1)
{
- LOCK_W sync(mutex);
- this->additive = additive1;
+ std::shared_lock lock(mutex);
+ this->additive = additive1;
}
void Logger::setHierarchy(spi::LoggerRepository* repository1)
{
- this->repository = repository1;
+ this->repository = repository1;
}
void Logger::setLevel(const LevelPtr& level1)
{
- this->level = level1;
+ this->level = level1;
}
LoggerPtr Logger::getLogger(const std::string& name)
{
- return LogManager::getLogger(name);
+ return LogManager::getLogger(name);
}
LoggerPtr Logger::getLogger(const char* const name)
{
- return LogManager::getLogger(name);
+ return LogManager::getLogger(name);
}
LoggerPtr Logger::getRootLogger()
{
- return LogManager::getRootLogger();
+ return LogManager::getRootLogger();
}
LoggerPtr Logger::getLoggerLS(const LogString& name,
- const spi::LoggerFactoryPtr& factory)
+ const spi::LoggerFactoryPtr& factory)
{
- return LogManager::getLoggerLS(name, factory);
+ return LogManager::getLoggerLS(name, factory);
}
void Logger::getName(std::string& rv) const
{
- Transcoder::encode(name, rv);
+ Transcoder::encode(name, rv);
}
void Logger::trace(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isTraceEnabled())
- {
- forcedLog(log4cxx::Level::getTrace(), msg, location);
- }
+ if (isTraceEnabled())
+ {
+ forcedLog(log4cxx::Level::getTrace(), msg, location);
+ }
}
void Logger::trace(const std::string& msg) const
{
- if (isTraceEnabled())
- {
- forcedLog(log4cxx::Level::getTrace(), msg);
- }
+ if (isTraceEnabled())
+ {
+ forcedLog(log4cxx::Level::getTrace(), msg);
+ }
}
void Logger::debug(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isDebugEnabled())
- {
- forcedLog(log4cxx::Level::getDebug(), msg, location);
- }
+ if (isDebugEnabled())
+ {
+ forcedLog(log4cxx::Level::getDebug(), msg, location);
+ }
}
void Logger::debug(const std::string& msg) const
{
- if (isDebugEnabled())
- {
- forcedLog(log4cxx::Level::getDebug(), msg);
- }
+ if (isDebugEnabled())
+ {
+ forcedLog(log4cxx::Level::getDebug(), msg);
+ }
}
void Logger::error(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isErrorEnabled())
- {
- forcedLog(log4cxx::Level::getError(), msg, location);
- }
+ if (isErrorEnabled())
+ {
+ forcedLog(log4cxx::Level::getError(), msg, location);
+ }
}
void Logger::error(const std::string& msg) const
{
- if (isErrorEnabled())
- {
- forcedLog(log4cxx::Level::getError(), msg);
- }
+ if (isErrorEnabled())
+ {
+ forcedLog(log4cxx::Level::getError(), msg);
+ }
}
void Logger::fatal(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isFatalEnabled())
- {
- forcedLog(log4cxx::Level::getFatal(), msg, location);
- }
+ if (isFatalEnabled())
+ {
+ forcedLog(log4cxx::Level::getFatal(), msg, location);
+ }
}
void Logger::fatal(const std::string& msg) const
{
- if (isFatalEnabled())
- {
- forcedLog(log4cxx::Level::getFatal(), msg);
- }
+ if (isFatalEnabled())
+ {
+ forcedLog(log4cxx::Level::getFatal(), msg);
+ }
}
void Logger::info(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isInfoEnabled())
- {
- forcedLog(log4cxx::Level::getInfo(), msg, location);
- }
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg, location);
+ }
}
void Logger::info(const std::string& msg) const
{
- if (isInfoEnabled())
- {
- forcedLog(log4cxx::Level::getInfo(), msg);
- }
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg);
+ }
}
void Logger::log(const LevelPtr& level1, const std::string& message,
- const log4cxx::spi::LocationInfo& location) const
+ const log4cxx::spi::LocationInfo& location) const
{
- if (isEnabledFor(level1))
- {
- forcedLog(level1, message, location);
- }
+ if (isEnabledFor(level1))
+ {
+ forcedLog(level1, message, location);
+ }
}
void Logger::log(const LevelPtr& level1, const std::string& message) const
{
- if (isEnabledFor(level1))
- {
- forcedLog(level1, message);
- }
+ if (isEnabledFor(level1))
+ {
+ forcedLog(level1, message);
+ }
}
void Logger::logLS(const LevelPtr& level1, const LogString& message,
- const log4cxx::spi::LocationInfo& location) const
+ const log4cxx::spi::LocationInfo& location) const
{
- if (isEnabledFor(level1))
- {
- forcedLogLS(level1, message, location);
- }
+ if (isEnabledFor(level1))
+ {
+ forcedLogLS(level1, message, location);
+ }
}
void Logger::warn(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isWarnEnabled())
- {
- forcedLog(log4cxx::Level::getWarn(), msg, location);
- }
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg, location);
+ }
}
void Logger::warn(const std::string& msg) const
{
- if (isWarnEnabled())
- {
- forcedLog(log4cxx::Level::getWarn(), msg);
- }
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg);
+ }
}
LoggerPtr Logger::getLoggerLS(const LogString& name)
{
- return LogManager::getLoggerLS(name);
+ return LogManager::getLoggerLS(name);
}
@@ -663,150 +686,150 @@
#if LOG4CXX_WCHAR_T_API
void Logger::forcedLog(const LevelPtr& level1, const std::wstring& message,
- const LocationInfo& location) const
+ const LocationInfo& location) const
{
- Pool p;
- LOG4CXX_DECODE_WCHAR(msg, message);
- LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
- callAppenders(event, p);
+ Pool p;
+ LOG4CXX_DECODE_WCHAR(msg, message);
+ LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
+ callAppenders(event, p);
}
void Logger::forcedLog(const LevelPtr& level1, const std::wstring& message) const
{
- Pool p;
- LOG4CXX_DECODE_WCHAR(msg, message);
- LoggingEventPtr event(new LoggingEvent(name, level1, msg,
- LocationInfo::getLocationUnavailable()));
- callAppenders(event, p);
+ Pool p;
+ LOG4CXX_DECODE_WCHAR(msg, message);
+ LoggingEventPtr event(new LoggingEvent(name, level1, msg,
+ LocationInfo::getLocationUnavailable()));
+ callAppenders(event, p);
}
void Logger::getName(std::wstring& rv) const
{
- Transcoder::encode(name, rv);
+ Transcoder::encode(name, rv);
}
LoggerPtr Logger::getLogger(const std::wstring& name)
{
- return LogManager::getLogger(name);
+ return LogManager::getLogger(name);
}
LoggerPtr Logger::getLogger(const wchar_t* const name)
{
- return LogManager::getLogger(name);
+ return LogManager::getLogger(name);
}
void Logger::trace(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isTraceEnabled())
- {
- forcedLog(log4cxx::Level::getTrace(), msg, location);
- }
+ if (isTraceEnabled())
+ {
+ forcedLog(log4cxx::Level::getTrace(), msg, location);
+ }
}
void Logger::trace(const std::wstring& msg) const
{
- if (isTraceEnabled())
- {
- forcedLog(log4cxx::Level::getTrace(), msg);
- }
+ if (isTraceEnabled())
+ {
+ forcedLog(log4cxx::Level::getTrace(), msg);
+ }
}
void Logger::debug(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isDebugEnabled())
- {
- forcedLog(log4cxx::Level::getDebug(), msg, location);
- }
+ if (isDebugEnabled())
+ {
+ forcedLog(log4cxx::Level::getDebug(), msg, location);
+ }
}
void Logger::debug(const std::wstring& msg) const
{
- if (isDebugEnabled())
- {
- forcedLog(log4cxx::Level::getDebug(), msg);
- }
+ if (isDebugEnabled())
+ {
+ forcedLog(log4cxx::Level::getDebug(), msg);
+ }
}
void Logger::error(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isErrorEnabled())
- {
- forcedLog(log4cxx::Level::getError(), msg, location);
- }
+ if (isErrorEnabled())
+ {
+ forcedLog(log4cxx::Level::getError(), msg, location);
+ }
}
void Logger::error(const std::wstring& msg) const
{
- if (isErrorEnabled())
- {
- forcedLog(log4cxx::Level::getError(), msg);
- }
+ if (isErrorEnabled())
+ {
+ forcedLog(log4cxx::Level::getError(), msg);
+ }
}
void Logger::fatal(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isFatalEnabled())
- {
- forcedLog(log4cxx::Level::getFatal(), msg, location);
- }
+ if (isFatalEnabled())
+ {
+ forcedLog(log4cxx::Level::getFatal(), msg, location);
+ }
}
void Logger::fatal(const std::wstring& msg) const
{
- if (isFatalEnabled())
- {
- forcedLog(log4cxx::Level::getFatal(), msg);
- }
+ if (isFatalEnabled())
+ {
+ forcedLog(log4cxx::Level::getFatal(), msg);
+ }
}
void Logger::info(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isInfoEnabled())
- {
- forcedLog(log4cxx::Level::getInfo(), msg, location);
- }
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg, location);
+ }
}
void Logger::info(const std::wstring& msg) const
{
- if (isInfoEnabled())
- {
- forcedLog(log4cxx::Level::getInfo(), msg);
- }
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg);
+ }
}
void Logger::log(const LevelPtr& level1, const std::wstring& message,
- const log4cxx::spi::LocationInfo& location) const
+ const log4cxx::spi::LocationInfo& location) const
{
- if (isEnabledFor(level1))
- {
- forcedLog(level1, message, location);
- }
+ if (isEnabledFor(level1))
+ {
+ forcedLog(level1, message, location);
+ }
}
void Logger::log(const LevelPtr& level1, const std::wstring& message) const
{
- if (isEnabledFor(level1))
- {
- forcedLog(level1, message);
- }
+ if (isEnabledFor(level1))
+ {
+ forcedLog(level1, message);
+ }
}
void Logger::warn(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isWarnEnabled())
- {
- forcedLog(log4cxx::Level::getWarn(), msg, location);
- }
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg, location);
+ }
}
void Logger::warn(const std::wstring& msg) const
{
- if (isWarnEnabled())
- {
- forcedLog(log4cxx::Level::getWarn(), msg);
- }
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg);
+ }
}
#endif
@@ -814,147 +837,147 @@
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
void Logger::forcedLog(const LevelPtr& level1, const std::basic_string<UniChar>& message,
- const LocationInfo& location) const
+ const LocationInfo& location) const
{
- Pool p;
- LOG4CXX_DECODE_UNICHAR(msg, message);
- LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
- callAppenders(event, p);
+ Pool p;
+ LOG4CXX_DECODE_UNICHAR(msg, message);
+ LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
+ callAppenders(event, p);
}
void Logger::forcedLog(const LevelPtr& level1, const std::basic_string<UniChar>& message) const
{
- Pool p;
- LOG4CXX_DECODE_UNICHAR(msg, message);
- LoggingEventPtr event(new LoggingEvent(name, level1, msg,
- LocationInfo::getLocationUnavailable()));
- callAppenders(event, p);
+ Pool p;
+ LOG4CXX_DECODE_UNICHAR(msg, message);
+ LoggingEventPtr event(new LoggingEvent(name, level1, msg,
+ LocationInfo::getLocationUnavailable()));
+ callAppenders(event, p);
}
#endif
#if LOG4CXX_UNICHAR_API
void Logger::getName(std::basic_string<UniChar>& rv) const
{
- Transcoder::encode(name, rv);
+ Transcoder::encode(name, rv);
}
LoggerPtr Logger::getLogger(const std::basic_string<UniChar>& name)
{
- return LogManager::getLogger(name);
+ return LogManager::getLogger(name);
}
void Logger::trace(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isTraceEnabled())
- {
- forcedLog(log4cxx::Level::getTrace(), msg, location);
- }
+ if (isTraceEnabled())
+ {
+ forcedLog(log4cxx::Level::getTrace(), msg, location);
+ }
}
void Logger::trace(const std::basic_string<UniChar>& msg) const
{
- if (isTraceEnabled())
- {
- forcedLog(log4cxx::Level::getTrace(), msg);
- }
+ if (isTraceEnabled())
+ {
+ forcedLog(log4cxx::Level::getTrace(), msg);
+ }
}
void Logger::debug(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isDebugEnabled())
- {
- forcedLog(log4cxx::Level::getDebug(), msg, location);
- }
+ if (isDebugEnabled())
+ {
+ forcedLog(log4cxx::Level::getDebug(), msg, location);
+ }
}
void Logger::debug(const std::basic_string<UniChar>& msg) const
{
- if (isDebugEnabled())
- {
- forcedLog(log4cxx::Level::getDebug(), msg);
- }
+ if (isDebugEnabled())
+ {
+ forcedLog(log4cxx::Level::getDebug(), msg);
+ }
}
void Logger::error(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isErrorEnabled())
- {
- forcedLog(log4cxx::Level::getError(), msg, location);
- }
+ if (isErrorEnabled())
+ {
+ forcedLog(log4cxx::Level::getError(), msg, location);
+ }
}
void Logger::error(const std::basic_string<UniChar>& msg) const
{
- if (isErrorEnabled())
- {
- forcedLog(log4cxx::Level::getError(), msg);
- }
+ if (isErrorEnabled())
+ {
+ forcedLog(log4cxx::Level::getError(), msg);
+ }
}
void Logger::fatal(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isFatalEnabled())
- {
- forcedLog(log4cxx::Level::getFatal(), msg, location);
- }
+ if (isFatalEnabled())
+ {
+ forcedLog(log4cxx::Level::getFatal(), msg, location);
+ }
}
void Logger::fatal(const std::basic_string<UniChar>& msg) const
{
- if (isFatalEnabled())
- {
- forcedLog(log4cxx::Level::getFatal(), msg);
- }
+ if (isFatalEnabled())
+ {
+ forcedLog(log4cxx::Level::getFatal(), msg);
+ }
}
void Logger::info(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isInfoEnabled())
- {
- forcedLog(log4cxx::Level::getInfo(), msg, location);
- }
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg, location);
+ }
}
void Logger::info(const std::basic_string<UniChar>& msg) const
{
- if (isInfoEnabled())
- {
- forcedLog(log4cxx::Level::getInfo(), msg);
- }
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg);
+ }
}
void Logger::log(const LevelPtr& level1, const std::basic_string<UniChar>& message,
- const log4cxx::spi::LocationInfo& location) const
+ const log4cxx::spi::LocationInfo& location) const
{
- if (isEnabledFor(level1))
- {
- forcedLog(level1, message, location);
- }
+ if (isEnabledFor(level1))
+ {
+ forcedLog(level1, message, location);
+ }
}
void Logger::log(const LevelPtr& level1, const std::basic_string<UniChar>& message) const
{
- if (isEnabledFor(level1))
- {
- forcedLog(level1, message);
- }
+ if (isEnabledFor(level1))
+ {
+ forcedLog(level1, message);
+ }
}
void Logger::warn(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isWarnEnabled())
- {
- forcedLog(log4cxx::Level::getWarn(), msg, location);
- }
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg, location);
+ }
}
void Logger::warn(const std::basic_string<UniChar>& msg) const
{
- if (isWarnEnabled())
- {
- forcedLog(log4cxx::Level::getWarn(), msg);
- }
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg);
+ }
}
#endif
@@ -962,145 +985,145 @@
#if LOG4CXX_CFSTRING_API
void Logger::forcedLog(const LevelPtr& level1, const CFStringRef& message,
- const LocationInfo& location) const
+ const LocationInfo& location) const
{
- Pool p;
- LOG4CXX_DECODE_CFSTRING(msg, message);
- LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
- callAppenders(event, p);
+ Pool p;
+ LOG4CXX_DECODE_CFSTRING(msg, message);
+ LoggingEventPtr event(new LoggingEvent(name, level1, msg, location));
+ callAppenders(event, p);
}
void Logger::forcedLog(const LevelPtr& level1, const CFStringRef& message) const
{
- Pool p;
- LOG4CXX_DECODE_CFSTRING(msg, message);
- LoggingEventPtr event(new LoggingEvent(name, level1, msg,
- LocationInfo::getLocationUnavailable()));
- callAppenders(event, p);
+ Pool p;
+ LOG4CXX_DECODE_CFSTRING(msg, message);
+ LoggingEventPtr event(new LoggingEvent(name, level1, msg,
+ LocationInfo::getLocationUnavailable()));
+ callAppenders(event, p);
}
void Logger::getName(CFStringRef& rv) const
{
- rv = Transcoder::encode(name);
+ rv = Transcoder::encode(name);
}
LoggerPtr Logger::getLogger(const CFStringRef& name)
{
- return LogManager::getLogger(name);
+ return LogManager::getLogger(name);
}
void Logger::trace(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isTraceEnabled())
- {
- forcedLog(log4cxx::Level::getTrace(), msg, location);
- }
+ if (isTraceEnabled())
+ {
+ forcedLog(log4cxx::Level::getTrace(), msg, location);
+ }
}
void Logger::trace(const CFStringRef& msg) const
{
- if (isTraceEnabled())
- {
- forcedLog(log4cxx::Level::getTrace(), msg);
- }
+ if (isTraceEnabled())
+ {
+ forcedLog(log4cxx::Level::getTrace(), msg);
+ }
}
void Logger::debug(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isDebugEnabled())
- {
- forcedLog(log4cxx::Level::getDebug(), msg, location);
- }
+ if (isDebugEnabled())
+ {
+ forcedLog(log4cxx::Level::getDebug(), msg, location);
+ }
}
void Logger::debug(const CFStringRef& msg) const
{
- if (isDebugEnabled())
- {
- forcedLog(log4cxx::Level::getDebug(), msg);
- }
+ if (isDebugEnabled())
+ {
+ forcedLog(log4cxx::Level::getDebug(), msg);
+ }
}
void Logger::error(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isErrorEnabled())
- {
- forcedLog(log4cxx::Level::getError(), msg, location);
- }
+ if (isErrorEnabled())
+ {
+ forcedLog(log4cxx::Level::getError(), msg, location);
+ }
}
void Logger::error(const CFStringRef& msg) const
{
- if (isErrorEnabled())
- {
- forcedLog(log4cxx::Level::getError(), msg);
- }
+ if (isErrorEnabled())
+ {
+ forcedLog(log4cxx::Level::getError(), msg);
+ }
}
void Logger::fatal(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isFatalEnabled())
- {
- forcedLog(log4cxx::Level::getFatal(), msg, location);
- }
+ if (isFatalEnabled())
+ {
+ forcedLog(log4cxx::Level::getFatal(), msg, location);
+ }
}
void Logger::fatal(const CFStringRef& msg) const
{
- if (isFatalEnabled())
- {
- forcedLog(log4cxx::Level::getFatal(), msg);
- }
+ if (isFatalEnabled())
+ {
+ forcedLog(log4cxx::Level::getFatal(), msg);
+ }
}
void Logger::info(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isInfoEnabled())
- {
- forcedLog(log4cxx::Level::getInfo(), msg, location);
- }
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg, location);
+ }
}
void Logger::info(const CFStringRef& msg) const
{
- if (isInfoEnabled())
- {
- forcedLog(log4cxx::Level::getInfo(), msg);
- }
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg);
+ }
}
void Logger::log(const LevelPtr& level1, const CFStringRef& message,
- const log4cxx::spi::LocationInfo& location) const
+ const log4cxx::spi::LocationInfo& location) const
{
- if (isEnabledFor(level1))
- {
- forcedLog(level1, message, location);
- }
+ if (isEnabledFor(level1))
+ {
+ forcedLog(level1, message, location);
+ }
}
void Logger::log(const LevelPtr& level1, const CFStringRef& message) const
{
- if (isEnabledFor(level1))
- {
- forcedLog(level1, message);
- }
+ if (isEnabledFor(level1))
+ {
+ forcedLog(level1, message);
+ }
}
void Logger::warn(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
{
- if (isWarnEnabled())
- {
- forcedLog(log4cxx::Level::getWarn(), msg, location);
- }
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg, location);
+ }
}
void Logger::warn(const CFStringRef& msg) const
{
- if (isWarnEnabled())
- {
- forcedLog(log4cxx::Level::getWarn(), msg);
- }
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg);
+ }
}
#endif
diff --git a/src/main/cpp/loglog.cpp b/src/main/cpp/loglog.cpp
index 7b1e867..fa2ab71 100644
--- a/src/main/cpp/loglog.cpp
+++ b/src/main/cpp/loglog.cpp
@@ -23,19 +23,16 @@
#define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/helpers/aprinitializer.h>
#include <log4cxx/helpers/systemerrwriter.h>
using namespace log4cxx;
using namespace log4cxx::helpers;
-LogLog::LogLog() : mutex(APRInitializer::getRootPool())
+LogLog::LogLog()
{
- synchronized sync(mutex);
-
- debugEnabled = false;
- quietMode = false;
+ debugEnabled = false;
+ quietMode = false;
}
LogLog& LogLog::getInstance()
@@ -47,7 +44,7 @@
void LogLog::setInternalDebugging(bool debugEnabled1)
{
- synchronized sync(getInstance().mutex);
+ std::unique_lock lock(getInstance().mutex);
getInstance().debugEnabled = debugEnabled1;
}
@@ -59,7 +56,7 @@
return;
}
- synchronized sync(getInstance().mutex);
+ std::unique_lock lock(getInstance().mutex);
emit(msg);
}
@@ -71,47 +68,47 @@
return;
}
- synchronized sync(getInstance().mutex);
+ std::unique_lock lock(getInstance().mutex);
- debug(msg);
+ emit(msg);
emit(e);
}
void LogLog::error(const LogString& msg)
{
- synchronized sync(getInstance().mutex);
+ std::unique_lock lock(getInstance().mutex);
emit(msg);
}
void LogLog::error(const LogString& msg, const std::exception& e)
{
- synchronized sync(getInstance().mutex);
+ std::unique_lock lock(getInstance().mutex);
- error(msg);
+ emit(msg);
emit(e);
}
void LogLog::setQuietMode(bool quietMode1)
{
- synchronized sync(getInstance().mutex);
+ std::unique_lock lock(getInstance().mutex);
getInstance().quietMode = quietMode1;
}
void LogLog::warn(const LogString& msg)
{
- synchronized sync(getInstance().mutex);
+ std::unique_lock lock(getInstance().mutex);
emit(msg);
}
void LogLog::warn(const LogString& msg, const std::exception& e)
{
- synchronized sync(getInstance().mutex);
+ std::unique_lock lock(getInstance().mutex);
- warn(msg);
+ emit(msg);
emit(e);
}
diff --git a/src/main/cpp/logmanager.cpp b/src/main/cpp/logmanager.cpp
index 41c1155..fc39333 100644
--- a/src/main/cpp/logmanager.cpp
+++ b/src/main/cpp/logmanager.cpp
@@ -32,8 +32,6 @@
#include <log4cxx/helpers/optionconverter.h>
#include <log4cxx/helpers/loglog.h>
-#include <apr_general.h>
-
#include <log4cxx/spi/loggingevent.h>
#include <log4cxx/file.h>
#include <log4cxx/helpers/transcoder.h>
diff --git a/src/main/cpp/mutex.cpp b/src/main/cpp/mutex.cpp
deleted file mode 100644
index 25344a7..0000000
--- a/src/main/cpp/mutex.cpp
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <log4cxx/logstring.h>
-#include <log4cxx/helpers/exception.h>
-#include <log4cxx/helpers/mutex.h>
-#include <log4cxx/helpers/pool.h>
-#include <apr_thread_mutex.h>
-#include <apr_thread_rwlock.h>
-#include <assert.h>
-#if !defined(LOG4CXX)
- #define LOG4CXX 1
-#endif
-#include <log4cxx/helpers/aprinitializer.h>
-
-#if defined(NON_BLOCKING)
-
- #if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
- #include <windows.h>
- #else
- // POSIX
- #include <semaphore.h>
- #endif
-
-#endif // NON_BLOCKING
-
-using namespace log4cxx::helpers;
-using namespace log4cxx;
-
-
-Mutex::Mutex(Pool& p)
-{
-#if APR_HAS_THREADS
- apr_status_t stat = apr_thread_mutex_create(&mutex,
- APR_THREAD_MUTEX_NESTED, p.getAPRPool());
-
- if (stat != APR_SUCCESS)
- {
- throw MutexException(stat);
- }
-
-#endif
-}
-
-Mutex::Mutex(apr_pool_t* p)
-{
-#if APR_HAS_THREADS
- apr_status_t stat = apr_thread_mutex_create(&mutex,
- APR_THREAD_MUTEX_NESTED, p);
-
- if (stat != APR_SUCCESS)
- {
- throw MutexException(stat);
- }
-
-#endif
-}
-
-
-Mutex::~Mutex()
-{
-#if APR_HAS_THREADS
-
- // LOGCXX-322
- if (APRInitializer::isDestructed)
- {
- return;
- }
-
- apr_thread_mutex_destroy(mutex);
-#endif
-}
-
-apr_thread_mutex_t* Mutex::getAPRMutex() const
-{
- return mutex;
-}
-
-#if defined(RW_MUTEX)
-
-RWMutex::RWMutex(Pool& p)
- : id((apr_os_thread_t) -1)
- , count(0)
-{
-#if APR_HAS_THREADS
- apr_status_t stat = apr_thread_rwlock_create(&mutex,
- p.getAPRPool());
-
- if (stat != APR_SUCCESS)
- {
- throw MutexException(stat);
- }
-
-#endif
-}
-
-RWMutex::RWMutex(apr_pool_t* p)
- : id((apr_os_thread_t) -1)
- , count(0)
-{
-#if APR_HAS_THREADS
- apr_status_t stat = apr_thread_rwlock_create(&mutex, p);
-
- if (stat != APR_SUCCESS)
- {
- throw MutexException(stat);
- }
-
-#endif
-}
-
-
-RWMutex::~RWMutex()
-{
-#if APR_HAS_THREADS
- apr_thread_rwlock_destroy(mutex);
-#endif
-}
-
-void RWMutex::rdLock() const
-{
-#if APR_HAS_THREADS
- apr_status_t stat = apr_thread_rwlock_rdlock(mutex);
-#endif
-}
-
-void RWMutex::rdUnlock() const
-{
-#if APR_HAS_THREADS
- apr_status_t stat = apr_thread_rwlock_unlock(mutex);
-#endif
-}
-
-void RWMutex::wrLock() const
-{
-#if APR_HAS_THREADS
- apr_os_thread_t self = apr_os_thread_current();
-
- if (id == self)
- {
- ++count;
- }
- else
- {
- apr_status_t stat = apr_thread_rwlock_wrlock(mutex);
- id = self;
- count = 1;
- }
-
-#endif
-}
-
-void RWMutex::wrUnlock() const
-{
-#if APR_HAS_THREADS
-
- if (--count == 0)
- {
- id = (apr_os_thread_t) -1; // id_ = "not a thread"
- apr_status_t stat = apr_thread_rwlock_unlock(mutex);
- }
- else
- {
- }
-
-#endif
-}
-
-#endif // RW_MUTEX
-
-#if defined(NON_BLOCKING)
-
-#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
-
-namespace log4cxx
-{
-namespace helpers
-{
-struct SemaphoreImpl
-{
- HANDLE semaphore;
-};
-}
-}
-
-static const LONG cMax = 10000; // arbitrary high value
-
-Semaphore::Semaphore(log4cxx::helpers::Pool& p)
- : impl(nullptr)
-{
-#if APR_HAS_THREADS
- impl = (SemaphoreImpl*)p.palloc(sizeof(SemaphoreImpl));
-
- if (nullptr == impl)
- {
- throw MutexException(APR_ENOMEM);
- }
-
- impl->semaphore = CreateSemaphore(
- NULL, // default security attributes
- 0, // initial count
- cMax, // maximum count
- NULL); // unnamed semaphore
-
- if (impl->semaphore == NULL)
- {
- throw MutexException(APR_ENOSHMAVAIL);
- }
-
-#endif
-}
-
-Semaphore::~Semaphore()
-{
-#if APR_HAS_THREADS
-
- if (impl && impl->semaphore)
- {
- CloseHandle(impl->semaphore);
- }
-
-#endif
-}
-
-void Semaphore::await() const
-{
-#if APR_HAS_THREADS
- DWORD dwWaitResult = WaitForSingleObject(impl->semaphore, INFINITE);
-
- if (stat != 0)
- {
- throw MutexException(1);
- }
-
-#endif
-}
-
-void Semaphore::signalAll() const
-{
-#if APR_HAS_THREADS
- BOOL stat = ReleaseSemaphore(impl->semaphore, 1, NULL);
-
- if (!stat)
- {
- throw MutexException(stat);
- }
-
-#endif
-}
-
-#else
-// POSIX
-
-namespace log4cxx
-{
-namespace helpers
-{
-struct SemaphoreImpl
-{
- sem_t semaphore;
-};
-}
-}
-
-Semaphore::Semaphore(log4cxx::helpers::Pool& p)
- : impl(nullptr)
-{
-#if APR_HAS_THREADS
- impl = (SemaphoreImpl*)p.palloc(sizeof(SemaphoreImpl));
-
- if (nullptr == impl)
- {
- throw MutexException(APR_ENOMEM);
- }
-
- int stat = sem_init(&impl->semaphore, 0, 0);
-
- if (stat != 0)
- {
- throw MutexException(APR_ENOSHMAVAIL);
- }
-
-#endif
-}
-
-Semaphore::~Semaphore()
-{
-#if APR_HAS_THREADS
-
- if (impl)
- {
- int stat = sem_destroy(&impl->semaphore);
- }
-
-#endif
-}
-
-void Semaphore::await() const
-{
-#if APR_HAS_THREADS
- int stat = sem_wait(&impl->semaphore);
-
- if (stat != 0)
- {
- throw MutexException(stat);
- }
-
-#endif
-}
-
-void Semaphore::signalAll() const
-{
-#if APR_HAS_THREADS
- int stat = sem_post(&impl->semaphore);
-
- if (stat != 0)
- {
- throw MutexException(stat);
- }
-
-#endif
-}
-
-#endif // POSIX
-
-#endif // NON_BLOCKING
diff --git a/src/main/cpp/objectoutputstream.cpp b/src/main/cpp/objectoutputstream.cpp
index 017ad12..6beb1a2 100644
--- a/src/main/cpp/objectoutputstream.cpp
+++ b/src/main/cpp/objectoutputstream.cpp
@@ -23,7 +23,6 @@
#include <log4cxx/helpers/bytebuffer.h>
#include <log4cxx/helpers/outputstream.h>
#include <log4cxx/helpers/charsetencoder.h>
-#include "apr_pools.h"
using namespace log4cxx;
using namespace log4cxx::helpers;
diff --git a/src/main/cpp/propertyconfigurator.cpp b/src/main/cpp/propertyconfigurator.cpp
index 905f968..b24c3ac 100644
--- a/src/main/cpp/propertyconfigurator.cpp
+++ b/src/main/cpp/propertyconfigurator.cpp
@@ -32,10 +32,6 @@
#include <log4cxx/config/propertysetter.h>
#include <log4cxx/spi/loggerrepository.h>
#include <log4cxx/helpers/stringtokenizer.h>
-#include <log4cxx/helpers/synchronized.h>
-#include <apr_file_io.h>
-#include <apr_file_info.h>
-#include <apr_pools.h>
#include <log4cxx/helpers/transcoder.h>
#include <log4cxx/helpers/fileinputstream.h>
@@ -55,21 +51,21 @@
{
class PropertyWatchdog : public FileWatchdog
{
- public:
- PropertyWatchdog(const File& filename) : FileWatchdog(filename)
- {
- }
+public:
+ PropertyWatchdog(const File& filename) : FileWatchdog(filename)
+ {
+ }
- /**
- Call PropertyConfigurator#doConfigure(const String& configFileName,
- const spi::LoggerRepositoryPtr& hierarchy) with the
- <code>filename</code> to reconfigure log4cxx.
- */
- void doOnChange()
- {
- PropertyConfigurator().doConfigure(file,
- LogManager::getLoggerRepository());
- }
+ /**
+ Call PropertyConfigurator#doConfigure(const String& configFileName,
+ const spi::LoggerRepositoryPtr& hierarchy) with the
+ <code>filename</code> to reconfigure log4cxx.
+ */
+ void doOnChange()
+ {
+ PropertyConfigurator().doConfigure(file,
+ LogManager::getLoggerRepository());
+ }
};
}
@@ -80,406 +76,408 @@
IMPLEMENT_LOG4CXX_OBJECT(PropertyConfigurator)
PropertyConfigurator::PropertyConfigurator()
- : registry(new std::map<LogString, AppenderPtr>()), loggerFactory(new DefaultLoggerFactory())
+ : registry(new std::map<LogString, AppenderPtr>()), loggerFactory(new DefaultLoggerFactory())
{
}
PropertyConfigurator::~PropertyConfigurator()
{
- delete registry;
+ delete registry;
}
void PropertyConfigurator::addRef() const
{
- ObjectImpl::addRef();
+ ObjectImpl::addRef();
}
void PropertyConfigurator::releaseRef() const
{
- ObjectImpl::releaseRef();
+ ObjectImpl::releaseRef();
}
void PropertyConfigurator::doConfigure(const File& configFileName,
- spi::LoggerRepositoryPtr& hierarchy)
+ spi::LoggerRepositoryPtr& hierarchy)
{
- hierarchy->setConfigured(true);
+ hierarchy->setConfigured(true);
- Properties props;
+ Properties props;
- try
- {
- InputStreamPtr inputStream = new FileInputStream(configFileName);
- props.load(inputStream);
- }
- catch (const IOException&)
- {
- LogLog::error(((LogString) LOG4CXX_STR("Could not read configuration file ["))
- + configFileName.getPath() + LOG4CXX_STR("]."));
- return;
- }
+ try
+ {
+ InputStreamPtr inputStream = new FileInputStream(configFileName);
+ props.load(inputStream);
+ }
+ catch (const IOException&)
+ {
+ LogLog::error(((LogString) LOG4CXX_STR("Could not read configuration file ["))
+ + configFileName.getPath() + LOG4CXX_STR("]."));
+ return;
+ }
- try
- {
- doConfigure(props, hierarchy);
- }
- catch (const std::exception& ex)
- {
- LogLog::error(((LogString) LOG4CXX_STR("Could not parse configuration file ["))
- + configFileName.getPath() + LOG4CXX_STR("]."), ex);
- }
+ try
+ {
+ doConfigure(props, hierarchy);
+ }
+ catch (const std::exception& ex)
+ {
+ LogLog::error(((LogString) LOG4CXX_STR("Could not parse configuration file ["))
+ + configFileName.getPath() + LOG4CXX_STR("]."), ex);
+ }
}
void PropertyConfigurator::configure(const File& configFilename)
{
- PropertyConfigurator().doConfigure(configFilename, LogManager::getLoggerRepository());
+ PropertyConfigurator().doConfigure(configFilename, LogManager::getLoggerRepository());
}
void PropertyConfigurator::configure(helpers::Properties& properties)
{
- PropertyConfigurator().doConfigure(properties, LogManager::getLoggerRepository());
+ PropertyConfigurator().doConfigure(properties, LogManager::getLoggerRepository());
}
#if APR_HAS_THREADS
void PropertyConfigurator::configureAndWatch(const File& configFilename)
{
- configureAndWatch(configFilename, FileWatchdog::DEFAULT_DELAY);
+ configureAndWatch(configFilename, FileWatchdog::DEFAULT_DELAY);
}
void PropertyConfigurator::configureAndWatch(
- const File& configFilename, long delay)
+ const File& configFilename, long delay)
{
- if (pdog)
- {
- APRInitializer::unregisterCleanup(pdog);
- delete pdog;
- }
+ if (pdog)
+ {
+ APRInitializer::unregisterCleanup(pdog);
+ delete pdog;
+ }
- pdog = new PropertyWatchdog(configFilename);
- APRInitializer::registerCleanup(pdog);
- pdog->setDelay(delay);
- pdog->start();
+ pdog = new PropertyWatchdog(configFilename);
+ APRInitializer::registerCleanup(pdog);
+ pdog->setDelay(delay);
+ pdog->start();
}
#endif
void PropertyConfigurator::doConfigure(helpers::Properties& properties,
- spi::LoggerRepositoryPtr& hierarchy)
+ spi::LoggerRepositoryPtr& hierarchy)
{
- hierarchy->setConfigured(true);
+ hierarchy->setConfigured(true);
- static const LogString DEBUG_KEY(LOG4CXX_STR("log4j.debug"));
- LogString value(properties.getProperty(DEBUG_KEY));
+ static const LogString DEBUG_KEY(LOG4CXX_STR("log4j.debug"));
+ LogString value(properties.getProperty(DEBUG_KEY));
- if (!value.empty())
- {
- LogLog::setInternalDebugging(OptionConverter::toBoolean(value, true));
- }
+ if (!value.empty())
+ {
+ LogLog::setInternalDebugging(OptionConverter::toBoolean(value, true));
+ }
- static const LogString THRESHOLD_PREFIX(LOG4CXX_STR("log4j.threshold"));
- LogString thresholdStr =
- OptionConverter::findAndSubst(THRESHOLD_PREFIX, properties);
+ static const LogString THRESHOLD_PREFIX(LOG4CXX_STR("log4j.threshold"));
+ LogString thresholdStr =
+ OptionConverter::findAndSubst(THRESHOLD_PREFIX, properties);
- if (!thresholdStr.empty())
- {
- hierarchy->setThreshold(OptionConverter::toLevel(thresholdStr, Level::getAll()));
- LogLog::debug(((LogString) LOG4CXX_STR("Hierarchy threshold set to ["))
- + hierarchy->getThreshold()->toString()
- + LOG4CXX_STR("]."));
- }
+ if (!thresholdStr.empty())
+ {
+ hierarchy->setThreshold(OptionConverter::toLevel(thresholdStr, Level::getAll()));
+ LogLog::debug(((LogString) LOG4CXX_STR("Hierarchy threshold set to ["))
+ + hierarchy->getThreshold()->toString()
+ + LOG4CXX_STR("]."));
+ }
- static const LogString STRINGSTREAM_KEY(LOG4CXX_STR("log4j.stringstream"));
- LogString strstrValue(properties.getProperty(STRINGSTREAM_KEY));
+ static const LogString STRINGSTREAM_KEY(LOG4CXX_STR("log4j.stringstream"));
+ LogString strstrValue(properties.getProperty(STRINGSTREAM_KEY));
- if (strstrValue == LOG4CXX_STR("static"))
- {
- MessageBufferUseStaticStream();
- }
+ if (strstrValue == LOG4CXX_STR("static"))
+ {
+ MessageBufferUseStaticStream();
+ }
- configureRootLogger(properties, hierarchy);
- configureLoggerFactory(properties);
- parseCatsAndRenderers(properties, hierarchy);
+ configureRootLogger(properties, hierarchy);
+ configureLoggerFactory(properties);
+ parseCatsAndRenderers(properties, hierarchy);
- LogLog::debug(LOG4CXX_STR("Finished configuring."));
+ LogLog::debug(LOG4CXX_STR("Finished configuring."));
- // We don't want to hold references to appenders preventing their
- // destruction.
- registry->clear();
+ // We don't want to hold references to appenders preventing their
+ // destruction.
+ registry->clear();
}
void PropertyConfigurator::configureLoggerFactory(helpers::Properties& props)
{
- static const LogString LOGGER_FACTORY_KEY(LOG4CXX_STR("log4j.loggerFactory"));
+ static const LogString LOGGER_FACTORY_KEY(LOG4CXX_STR("log4j.loggerFactory"));
- LogString factoryClassName =
- OptionConverter::findAndSubst(LOGGER_FACTORY_KEY, props);
+ LogString factoryClassName =
+ OptionConverter::findAndSubst(LOGGER_FACTORY_KEY, props);
- if (!factoryClassName.empty())
- {
- LogString msg(LOG4CXX_STR("Setting logger factory to ["));
- msg += factoryClassName;
- msg += LOG4CXX_STR("].");
- LogLog::debug(msg);
- loggerFactory =
- OptionConverter::instantiateByClassName(
- factoryClassName, LoggerFactory::getStaticClass(), loggerFactory);
- static const LogString FACTORY_PREFIX(LOG4CXX_STR("log4j.factory."));
- Pool p;
- PropertySetter::setProperties(loggerFactory, props, FACTORY_PREFIX, p);
- }
+ if (!factoryClassName.empty())
+ {
+ LogString msg(LOG4CXX_STR("Setting logger factory to ["));
+ msg += factoryClassName;
+ msg += LOG4CXX_STR("].");
+ LogLog::debug(msg);
+ loggerFactory =
+ OptionConverter::instantiateByClassName(
+ factoryClassName, LoggerFactory::getStaticClass(), loggerFactory);
+ static const LogString FACTORY_PREFIX(LOG4CXX_STR("log4j.factory."));
+ Pool p;
+ PropertySetter::setProperties(loggerFactory, props, FACTORY_PREFIX, p);
+ }
}
void PropertyConfigurator::configureRootLogger(helpers::Properties& props,
- spi::LoggerRepositoryPtr& hierarchy)
+ spi::LoggerRepositoryPtr& hierarchy)
{
- static const LogString ROOT_CATEGORY_PREFIX(LOG4CXX_STR("log4j.rootCategory"));
- static const LogString ROOT_LOGGER_PREFIX(LOG4CXX_STR("log4j.rootLogger"));
+ static const LogString ROOT_CATEGORY_PREFIX(LOG4CXX_STR("log4j.rootCategory"));
+ static const LogString ROOT_LOGGER_PREFIX(LOG4CXX_STR("log4j.rootLogger"));
- LogString effectiveFrefix(ROOT_LOGGER_PREFIX);
- LogString value = OptionConverter::findAndSubst(ROOT_LOGGER_PREFIX, props);
+ LogString effectiveFrefix(ROOT_LOGGER_PREFIX);
+ LogString value = OptionConverter::findAndSubst(ROOT_LOGGER_PREFIX, props);
- if (value.empty())
- {
- value = OptionConverter::findAndSubst(ROOT_CATEGORY_PREFIX, props);
- effectiveFrefix = ROOT_CATEGORY_PREFIX;
- }
+ if (value.empty())
+ {
+ value = OptionConverter::findAndSubst(ROOT_CATEGORY_PREFIX, props);
+ effectiveFrefix = ROOT_CATEGORY_PREFIX;
+ }
- if (value.empty())
- {
- LogLog::debug(LOG4CXX_STR("Could not find root logger information. Is this OK?"));
- }
- else
- {
- LoggerPtr root = hierarchy->getRootLogger();
+ if (value.empty())
+ {
+ LogLog::debug(LOG4CXX_STR("Could not find root logger information. Is this OK?"));
+ }
+ else
+ {
+ LoggerPtr root = hierarchy->getRootLogger();
- LOCK_W sync(root->getMutex());
- static const LogString INTERNAL_ROOT_NAME(LOG4CXX_STR("root"));
- parseLogger(props, root, effectiveFrefix, INTERNAL_ROOT_NAME, value);
- }
+ static const LogString INTERNAL_ROOT_NAME(LOG4CXX_STR("root"));
+ parseLogger(props, root, effectiveFrefix, INTERNAL_ROOT_NAME, value, true);
+ }
}
void PropertyConfigurator::parseCatsAndRenderers(helpers::Properties& props,
- spi::LoggerRepositoryPtr& hierarchy)
+ spi::LoggerRepositoryPtr& hierarchy)
{
- static const LogString CATEGORY_PREFIX(LOG4CXX_STR("log4j.category."));
- static const LogString LOGGER_PREFIX(LOG4CXX_STR("log4j.logger."));
+ static const LogString CATEGORY_PREFIX(LOG4CXX_STR("log4j.category."));
+ static const LogString LOGGER_PREFIX(LOG4CXX_STR("log4j.logger."));
- std::vector<LogString> names = props.propertyNames();
+ std::vector<LogString> names = props.propertyNames();
- std::vector<LogString>::iterator it = names.begin();
- std::vector<LogString>::iterator itEnd = names.end();
+ std::vector<LogString>::iterator it = names.begin();
+ std::vector<LogString>::iterator itEnd = names.end();
- while (it != itEnd)
- {
- LogString key = *it++;
+ while (it != itEnd)
+ {
+ LogString key = *it++;
- if (key.find(CATEGORY_PREFIX) == 0 || key.find(LOGGER_PREFIX) == 0)
- {
- LogString loggerName;
+ if (key.find(CATEGORY_PREFIX) == 0 || key.find(LOGGER_PREFIX) == 0)
+ {
+ LogString loggerName;
- if (key.find(CATEGORY_PREFIX) == 0)
- {
- loggerName = key.substr(CATEGORY_PREFIX.length());
- }
- else if (key.find(LOGGER_PREFIX) == 0)
- {
- loggerName = key.substr(LOGGER_PREFIX.length());
- }
+ if (key.find(CATEGORY_PREFIX) == 0)
+ {
+ loggerName = key.substr(CATEGORY_PREFIX.length());
+ }
+ else if (key.find(LOGGER_PREFIX) == 0)
+ {
+ loggerName = key.substr(LOGGER_PREFIX.length());
+ }
- LogString value = OptionConverter::findAndSubst(key, props);
- LoggerPtr logger = hierarchy->getLogger(loggerName, loggerFactory);
+ LogString value = OptionConverter::findAndSubst(key, props);
+ LoggerPtr logger = hierarchy->getLogger(loggerName, loggerFactory);
- LOCK_W sync(logger->getMutex());
- parseLogger(props, logger, key, loggerName, value);
- parseAdditivityForLogger(props, logger, loggerName);
- }
- }
+ bool additivity = parseAdditivityForLogger(props, logger, loggerName);
+ parseLogger(props, logger, key, loggerName, value, additivity);
+
+ }
+ }
}
-void PropertyConfigurator::parseAdditivityForLogger(helpers::Properties& props,
- LoggerPtr& cat, const LogString& loggerName)
+bool PropertyConfigurator::parseAdditivityForLogger(helpers::Properties& props,
+ LoggerPtr& cat, const LogString& loggerName)
{
- static const LogString ADDITIVITY_PREFIX(LOG4CXX_STR("log4j.additivity."));
+ static const LogString ADDITIVITY_PREFIX(LOG4CXX_STR("log4j.additivity."));
- LogString value(OptionConverter::findAndSubst(ADDITIVITY_PREFIX + loggerName, props));
- LogLog::debug((LogString) LOG4CXX_STR("Handling ") + ADDITIVITY_PREFIX
- + loggerName + LOG4CXX_STR("=[") + value + LOG4CXX_STR("]"));
+ LogString value(OptionConverter::findAndSubst(ADDITIVITY_PREFIX + loggerName, props));
+ LogLog::debug((LogString) LOG4CXX_STR("Handling ") + ADDITIVITY_PREFIX
+ + loggerName + LOG4CXX_STR("=[") + value + LOG4CXX_STR("]"));
- // touch additivity only if necessary
- if (!value.empty())
- {
- bool additivity = OptionConverter::toBoolean(value, true);
- LogLog::debug(((LogString) LOG4CXX_STR("Setting additivity for \""))
- + loggerName
- + ((additivity) ? LOG4CXX_STR("\" to true") :
- LOG4CXX_STR("\" to false")));
- cat->setAdditivity(additivity);
- }
+ // touch additivity only if necessary
+ if (!value.empty())
+ {
+ bool additivity = OptionConverter::toBoolean(value, true);
+ LogLog::debug(((LogString) LOG4CXX_STR("Setting additivity for \""))
+ + loggerName
+ + ((additivity) ? LOG4CXX_STR("\" to true") :
+ LOG4CXX_STR("\" to false")));
+
+ return additivity;
+ }
+
+ return true;
}
/**
This method must work for the root logger as well.
*/
void PropertyConfigurator::parseLogger(
- helpers::Properties& props, LoggerPtr& logger, const LogString& /* optionKey */,
- const LogString& loggerName, const LogString& value)
+ helpers::Properties& props, LoggerPtr& logger, const LogString& /* optionKey */,
+ const LogString& loggerName, const LogString& value, bool additivity)
{
- LogLog::debug(((LogString) LOG4CXX_STR("Parsing for ["))
- + loggerName
- + LOG4CXX_STR("] with value=[")
- + value + LOG4CXX_STR("]."));
+ LogLog::debug(((LogString) LOG4CXX_STR("Parsing for ["))
+ + loggerName
+ + LOG4CXX_STR("] with value=[")
+ + value + LOG4CXX_STR("]."));
- // We must skip over ',' but not white space
- StringTokenizer st(value, LOG4CXX_STR(","));
+ // We must skip over ',' but not white space
+ StringTokenizer st(value, LOG4CXX_STR(","));
- // If value is not in the form ", appender.." or "", then we should set
- // the level of the logger.
- if (!(value.find(LOG4CXX_STR(",")) == 0 || value.empty()))
- {
- // just to be on the safe side...
- if (!st.hasMoreTokens())
- {
- return;
- }
+ // If value is not in the form ", appender.." or "", then we should set
+ // the level of the logger.
+ if (!(value.find(LOG4CXX_STR(",")) == 0 || value.empty()))
+ {
+ // just to be on the safe side...
+ if (!st.hasMoreTokens())
+ {
+ return;
+ }
- LogString levelStr = st.nextToken();
- LogLog::debug((LogString) LOG4CXX_STR("Level token is [")
- + levelStr + LOG4CXX_STR("]."));
+ LogString levelStr = st.nextToken();
+ LogLog::debug((LogString) LOG4CXX_STR("Level token is [")
+ + levelStr + LOG4CXX_STR("]."));
- // If the level value is inherited, set logger level value to
- // null. We also check that the user has not specified inherited for the
- // root logger.
- if (StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("INHERITED"), LOG4CXX_STR("inherited"))
- || StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("NULL"), LOG4CXX_STR("null")))
- {
- static const LogString INTERNAL_ROOT_NAME(LOG4CXX_STR("root"));
+ // If the level value is inherited, set logger level value to
+ // null. We also check that the user has not specified inherited for the
+ // root logger.
+ if (StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("INHERITED"), LOG4CXX_STR("inherited"))
+ || StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("NULL"), LOG4CXX_STR("null")))
+ {
+ static const LogString INTERNAL_ROOT_NAME(LOG4CXX_STR("root"));
- if (loggerName == INTERNAL_ROOT_NAME)
- {
- LogLog::warn(LOG4CXX_STR("The root logger cannot be set to null."));
- }
- else
- {
- logger->setLevel(0);
- LogLog::debug((LogString) LOG4CXX_STR("Logger ")
- + loggerName + LOG4CXX_STR(" set to null"));
- }
- }
- else
- {
- logger->setLevel(OptionConverter::toLevel(levelStr, Level::getDebug()));
+ if (loggerName == INTERNAL_ROOT_NAME)
+ {
+ LogLog::warn(LOG4CXX_STR("The root logger cannot be set to null."));
+ }
+ else
+ {
+ logger->setLevel(0);
+ LogLog::debug((LogString) LOG4CXX_STR("Logger ")
+ + loggerName + LOG4CXX_STR(" set to null"));
+ }
+ }
+ else
+ {
+ logger->setLevel(OptionConverter::toLevel(levelStr, Level::getDebug()));
- LogLog::debug((LogString) LOG4CXX_STR("Logger ")
- + loggerName + LOG4CXX_STR(" set to ")
- + logger->getLevel()->toString());
- }
+ LogLog::debug((LogString) LOG4CXX_STR("Logger ")
+ + loggerName + LOG4CXX_STR(" set to ")
+ + logger->getLevel()->toString());
+ }
- }
+ }
- // Begin by removing all existing appenders.
- logger->removeAllAppenders();
+ AppenderPtr appender;
+ LogString appenderName;
+ std::vector<AppenderPtr> newappenders;
- AppenderPtr appender;
- LogString appenderName;
+ while (st.hasMoreTokens())
+ {
+ appenderName = StringHelper::trim(st.nextToken());
- while (st.hasMoreTokens())
- {
- appenderName = StringHelper::trim(st.nextToken());
+ if (appenderName.empty() || appenderName == LOG4CXX_STR(","))
+ {
+ continue;
+ }
- if (appenderName.empty() || appenderName == LOG4CXX_STR(","))
- {
- continue;
- }
+ LogLog::debug(LOG4CXX_STR("Parsing appender named ")
+ + appenderName + LOG4CXX_STR("\"."));
+ appender = parseAppender(props, appenderName);
- LogLog::debug(LOG4CXX_STR("Parsing appender named ")
- + appenderName + LOG4CXX_STR("\"."));
- appender = parseAppender(props, appenderName);
+ if (appender != 0)
+ {
+ newappenders.push_back(appender);
+ }
+ }
- if (appender != 0)
- {
- logger->addAppender(appender);
- }
- }
+ logger->reconfigure( newappenders, additivity );
}
AppenderPtr PropertyConfigurator::parseAppender(
- helpers::Properties& props, const LogString& appenderName)
+ helpers::Properties& props, const LogString& appenderName)
{
- AppenderPtr appender = registryGet(appenderName);
+ AppenderPtr appender = registryGet(appenderName);
- if (appender != 0)
- {
- LogLog::debug((LogString) LOG4CXX_STR("Appender \"")
- + appenderName + LOG4CXX_STR("\" was already parsed."));
+ if (appender != 0)
+ {
+ LogLog::debug((LogString) LOG4CXX_STR("Appender \"")
+ + appenderName + LOG4CXX_STR("\" was already parsed."));
- return appender;
- }
+ return appender;
+ }
- static const LogString APPENDER_PREFIX(LOG4CXX_STR("log4j.appender."));
+ static const LogString APPENDER_PREFIX(LOG4CXX_STR("log4j.appender."));
- // Appender was not previously initialized.
- LogString prefix = APPENDER_PREFIX + appenderName;
- LogString layoutPrefix = prefix + LOG4CXX_STR(".layout");
+ // Appender was not previously initialized.
+ LogString prefix = APPENDER_PREFIX + appenderName;
+ LogString layoutPrefix = prefix + LOG4CXX_STR(".layout");
- appender =
- OptionConverter::instantiateByKey(
- props, prefix, Appender::getStaticClass(), 0);
+ appender =
+ OptionConverter::instantiateByKey(
+ props, prefix, Appender::getStaticClass(), 0);
- if (appender == 0)
- {
- LogLog::error((LogString) LOG4CXX_STR("Could not instantiate appender named \"")
- + appenderName + LOG4CXX_STR("\"."));
- return 0;
- }
+ if (appender == 0)
+ {
+ LogLog::error((LogString) LOG4CXX_STR("Could not instantiate appender named \"")
+ + appenderName + LOG4CXX_STR("\"."));
+ return 0;
+ }
- appender->setName(appenderName);
+ appender->setName(appenderName);
- if (appender->instanceof(OptionHandler::getStaticClass()))
- {
- Pool p;
+ if (appender->instanceof(OptionHandler::getStaticClass()))
+ {
+ Pool p;
- if (appender->requiresLayout())
- {
- LayoutPtr layout =
- OptionConverter::instantiateByKey(
- props, layoutPrefix, Layout::getStaticClass(), 0);
+ if (appender->requiresLayout())
+ {
+ LayoutPtr layout =
+ OptionConverter::instantiateByKey(
+ props, layoutPrefix, Layout::getStaticClass(), 0);
- if (layout != 0)
- {
- appender->setLayout(layout);
- LogLog::debug((LogString) LOG4CXX_STR("Parsing layout options for \"")
- + appenderName + LOG4CXX_STR("\"."));
+ if (layout != 0)
+ {
+ appender->setLayout(layout);
+ LogLog::debug((LogString) LOG4CXX_STR("Parsing layout options for \"")
+ + appenderName + LOG4CXX_STR("\"."));
- //configureOptionHandler(layout, layoutPrefix + ".", props);
- PropertySetter::setProperties(layout, props, layoutPrefix + LOG4CXX_STR("."), p);
- LogLog::debug((LogString) LOG4CXX_STR("End of parsing for \"")
- + appenderName + LOG4CXX_STR("\"."));
- }
- }
+ //configureOptionHandler(layout, layoutPrefix + ".", props);
+ PropertySetter::setProperties(layout, props, layoutPrefix + LOG4CXX_STR("."), p);
+ LogLog::debug((LogString) LOG4CXX_STR("End of parsing for \"")
+ + appenderName + LOG4CXX_STR("\"."));
+ }
+ }
- //configureOptionHandler((OptionHandler) appender, prefix + _T("."), props);
- PropertySetter::setProperties(appender, props, prefix + LOG4CXX_STR("."), p);
- LogLog::debug((LogString) LOG4CXX_STR("Parsed \"")
- + appenderName + LOG4CXX_STR("\" options."));
- }
+ //configureOptionHandler((OptionHandler) appender, prefix + _T("."), props);
+ PropertySetter::setProperties(appender, props, prefix + LOG4CXX_STR("."), p);
+ LogLog::debug((LogString) LOG4CXX_STR("Parsed \"")
+ + appenderName + LOG4CXX_STR("\" options."));
+ }
- registryPut(appender);
+ registryPut(appender);
- return appender;
+ return appender;
}
void PropertyConfigurator::registryPut(const AppenderPtr& appender)
{
- (*registry)[appender->getName()] = appender;
+ (*registry)[appender->getName()] = appender;
}
AppenderPtr PropertyConfigurator::registryGet(const LogString& name)
{
- return (*registry)[name];
+ return (*registry)[name];
}
diff --git a/src/main/cpp/rollingfileappender.cpp b/src/main/cpp/rollingfileappender.cpp
index dfabb3b..b79834d 100644
--- a/src/main/cpp/rollingfileappender.cpp
+++ b/src/main/cpp/rollingfileappender.cpp
@@ -34,7 +34,6 @@
#include <log4cxx/rolling/rollingfileappender.h>
#include <log4cxx/helpers/loglog.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/rolling/rolloverdescription.h>
#include <log4cxx/helpers/fileoutputstream.h>
#include <log4cxx/helpers/bytebuffer.h>
@@ -93,7 +92,7 @@
}
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
triggeringPolicy->activateOptions(p);
rollingPolicy->activateOptions(p);
@@ -111,8 +110,8 @@
syncAction->execute(p);
}
- setFile(rollover1->getActiveFileName());
- setAppend(rollover1->getAppend());
+ fileName = rollover1->getActiveFileName();
+ fileAppend = rollover1->getAppend();
//
// async action not yet implemented
@@ -137,7 +136,7 @@
fileLength = 0;
}
- FileAppender::activateOptions(p);
+ FileAppender::activateOptionsInternal(p);
}
catch (std::exception&)
{
@@ -182,6 +181,12 @@
*/
bool RollingFileAppenderSkeleton::rollover(Pool& p)
{
+ std::unique_lock lock(mutex);
+ return rolloverInternal(p);
+}
+
+bool RollingFileAppenderSkeleton::rolloverInternal(Pool& p)
+{
//
// can't roll without a policy
//
@@ -189,7 +194,6 @@
{
{
- LOCK_W sync(mutex);
#ifdef LOG4CXX_MULTI_PROCESS
std::string fileName(getFile());
@@ -328,13 +332,13 @@
asyncAction->execute(p);
}
- setFile(
+ setFileInternal(
rollover1->getActiveFileName(), rollover1->getAppend(),
bufferedIO, bufferSize, p);
}
else
{
- setFile(
+ setFileInternal(
rollover1->getActiveFileName(), true, bufferedIO, bufferSize, p);
}
}
@@ -344,8 +348,8 @@
rollover1->getActiveFileName(), rollover1->getAppend()));
WriterPtr newWriter(createWriter(os));
closeWriter();
- setFile(rollover1->getActiveFileName());
- setWriter(newWriter);
+ fileName = rollover1->getActiveFileName();
+ setWriterInternal(newWriter);
bool success = true;
@@ -450,7 +454,7 @@
try
{
_event = &(const_cast<LoggingEventPtr&>(event));
- rollover(p);
+ rolloverInternal(p);
}
catch (std::exception&)
{
diff --git a/src/main/cpp/serversocket.cpp b/src/main/cpp/serversocket.cpp
index 5af4955..2e1a6b2 100644
--- a/src/main/cpp/serversocket.cpp
+++ b/src/main/cpp/serversocket.cpp
@@ -16,7 +16,6 @@
*/
#include <log4cxx/helpers/serversocket.h>
-#include <log4cxx/helpers/synchronized.h>
#include "apr_network_io.h"
#include "apr_pools.h"
#include "apr_poll.h"
@@ -25,7 +24,7 @@
/** Creates a server socket on a specified port.
*/
-ServerSocket::ServerSocket(int port) : pool(), mutex(pool), socket(0), timeout(0)
+ServerSocket::ServerSocket(int port) : pool(), socket(0), timeout(0)
{
apr_status_t status =
apr_socket_create(&socket, APR_INET, SOCK_STREAM,
@@ -78,7 +77,7 @@
void ServerSocket::close()
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
if (socket != 0)
{
@@ -98,7 +97,7 @@
*/
SocketPtr ServerSocket::accept()
{
- synchronized sync(mutex);
+ std::unique_lock lock(mutex);
if (socket == 0)
{
diff --git a/src/main/cpp/smtpappender.cpp b/src/main/cpp/smtpappender.cpp
index 3be6600..015fc15 100644
--- a/src/main/cpp/smtpappender.cpp
+++ b/src/main/cpp/smtpappender.cpp
@@ -22,7 +22,6 @@
#include <log4cxx/helpers/stringhelper.h>
#include <log4cxx/helpers/stringtokenizer.h>
#include <log4cxx/helpers/transcoder.h>
-#include <log4cxx/helpers/synchronized.h>
#if !defined(LOG4CXX)
#define LOG4CXX 1
#endif
diff --git a/src/main/cpp/socketappender.cpp b/src/main/cpp/socketappender.cpp
index 5b3e158..99e91d9 100644
--- a/src/main/cpp/socketappender.cpp
+++ b/src/main/cpp/socketappender.cpp
@@ -23,7 +23,6 @@
#include <log4cxx/helpers/optionconverter.h>
#include <log4cxx/helpers/stringhelper.h>
#include <log4cxx/spi/loggingevent.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/helpers/objectoutputstream.h>
#include <apr_time.h>
#include <apr_atomic.h>
@@ -79,7 +78,7 @@
void SocketAppender::setSocket(log4cxx::helpers::SocketPtr& socket, Pool& p)
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
oos = new ObjectOutputStream(new SocketOutputStream(socket), p);
}
diff --git a/src/main/cpp/socketappenderskeleton.cpp b/src/main/cpp/socketappenderskeleton.cpp
index af08126..9bf8943 100644
--- a/src/main/cpp/socketappenderskeleton.cpp
+++ b/src/main/cpp/socketappenderskeleton.cpp
@@ -24,9 +24,9 @@
#include <log4cxx/helpers/optionconverter.h>
#include <log4cxx/helpers/stringhelper.h>
#include <log4cxx/spi/loggingevent.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/helpers/transcoder.h>
#include <log4cxx/helpers/bytearrayoutputstream.h>
+#include <functional>
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -38,7 +38,7 @@
port(defaultPort),
reconnectionDelay(reconnectionDelay1),
locationInfo(false),
- thread()
+ thread()
{
}
@@ -66,16 +66,7 @@
SocketAppenderSkeleton::~SocketAppenderSkeleton()
{
- finalize();
-
- try
- {
- thread.join();
- }
- catch (ThreadException& ex)
- {
- LogLog::error(LOG4CXX_STR("Error closing socket appender connection thread"), ex);
- }
+ finalize();
}
void SocketAppenderSkeleton::activateOptions(Pool& p)
@@ -86,7 +77,7 @@
void SocketAppenderSkeleton::close()
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
if (closed)
{
@@ -95,7 +86,15 @@
closed = true;
cleanUp(pool);
- thread.interrupt();
+
+ {
+ std::unique_lock lock2(interrupt_mutex);
+ interrupt.notify_all();
+ }
+
+ if( thread.joinable() ){
+ thread.join();
+ }
}
void SocketAppenderSkeleton::connect(Pool& p)
@@ -156,56 +155,52 @@
void SocketAppenderSkeleton::fireConnector()
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
- if ( !thread.isAlive() )
+ if ( !thread.joinable() )
{
LogLog::debug(LOG4CXX_STR("Connector thread not alive: starting monitor."));
- try
- {
- thread.run(monitor, this);
- }
- catch ( ThreadException& te )
- {
- LogLog::error(LOG4CXX_STR("Monitor not started: "), te);
- }
+ thread = std::thread( &SocketAppenderSkeleton::monitor, this );
}
}
-void* LOG4CXX_THREAD_FUNC SocketAppenderSkeleton::monitor(apr_thread_t* /* thread */, void* data)
+void SocketAppenderSkeleton::monitor()
{
- SocketAppenderSkeleton* socketAppender = (SocketAppenderSkeleton*) data;
SocketPtr socket;
- bool isClosed = socketAppender->closed;
+ bool isClosed = closed;
while (!isClosed)
{
try
- {
- Thread::sleep(socketAppender->reconnectionDelay);
+ {
+ std::this_thread::sleep_for( std::chrono::milliseconds( reconnectionDelay ) );
- if (!socketAppender->closed)
+ std::unique_lock lock( interrupt_mutex );
+ interrupt.wait_for( lock, std::chrono::milliseconds( reconnectionDelay ),
+ std::bind(&SocketAppenderSkeleton::is_closed, this) );
+
+ if (!closed)
{
LogLog::debug(LogString(LOG4CXX_STR("Attempting connection to "))
- + socketAppender->address->getHostName());
- socket = new Socket(socketAppender->address, socketAppender->port);
+ + address->getHostName());
+ socket = new Socket(address, port);
Pool p;
- socketAppender->setSocket(socket, p);
+ setSocket(socket, p);
LogLog::debug(LOG4CXX_STR("Connection established. Exiting connector thread."));
}
- return NULL;
+ return;
}
catch (InterruptedException&)
{
LogLog::debug(LOG4CXX_STR("Connector interrupted. Leaving loop."));
- return NULL;
+ return;
}
catch (ConnectException&)
{
LogLog::debug(LOG4CXX_STR("Remote host ")
- + socketAppender->address->getHostName()
+ + address->getHostName()
+ LOG4CXX_STR(" refused connection."));
}
catch (IOException& e)
@@ -214,14 +209,17 @@
log4cxx::helpers::Transcoder::decode(e.what(), exmsg);
LogLog::debug(((LogString) LOG4CXX_STR("Could not connect to "))
- + socketAppender->address->getHostName()
+ + address->getHostName()
+ LOG4CXX_STR(". Exception is ")
+ exmsg);
}
- isClosed = socketAppender->closed;
+ isClosed = closed;
}
- LogLog::debug(LOG4CXX_STR("Exiting Connector.run() method."));
- return NULL;
+ LogLog::debug(LOG4CXX_STR("Exiting Connector.run() method."));
+}
+
+bool SocketAppenderSkeleton::is_closed(){
+ return closed;
}
diff --git a/src/main/cpp/sockethubappender.cpp b/src/main/cpp/sockethubappender.cpp
index 79646f7..0c74c5b 100644
--- a/src/main/cpp/sockethubappender.cpp
+++ b/src/main/cpp/sockethubappender.cpp
@@ -25,7 +25,6 @@
#include <log4cxx/helpers/stringhelper.h>
#include <log4cxx/helpers/serversocket.h>
#include <log4cxx/spi/loggingevent.h>
-#include <log4cxx/helpers/synchronized.h>
#include <apr_atomic.h>
#include <apr_thread_proc.h>
#include <log4cxx/helpers/objectoutputstream.h>
@@ -37,8 +36,6 @@
using namespace log4cxx::net;
using namespace log4cxx::spi;
-#if APR_HAS_THREADS
-
IMPLEMENT_LOG4CXX_OBJECT(SocketHubAppender)
int SocketHubAppender::DEFAULT_PORT = 4560;
@@ -85,7 +82,7 @@
void SocketHubAppender::close()
{
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
if (closed)
{
@@ -99,9 +96,11 @@
//
// wait until the server thread completes
//
- thread.join();
+ if( thread.joinable() ){
+ thread.join();
+ }
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
// close all of the connections
LogLog::debug(LOG4CXX_STR("closing client connections"));
@@ -175,28 +174,26 @@
void SocketHubAppender::startServer()
{
- thread.run(monitor, this);
+ thread = std::thread( &SocketHubAppender::monitor, this );
}
-void* APR_THREAD_FUNC SocketHubAppender::monitor(apr_thread_t* /* thread */, void* data)
+void SocketHubAppender::monitor()
{
- SocketHubAppender* pThis = (SocketHubAppender*) data;
-
ServerSocket* serverSocket = 0;
try
{
- serverSocket = new ServerSocket(pThis->port);
+ serverSocket = new ServerSocket(port);
serverSocket->setSoTimeout(1000);
}
catch (SocketException& e)
{
LogLog::error(LOG4CXX_STR("exception setting timeout, shutting down server socket."), e);
delete serverSocket;
- return NULL;
+ return;
}
- bool stopRunning = pThis->closed;
+ bool stopRunning = closed;
while (!stopRunning)
{
@@ -233,11 +230,11 @@
+ LOG4CXX_STR(")"));
// add it to the oosList.
- LOCK_W sync(pThis->mutex);
+ std::unique_lock lock(mutex);
OutputStreamPtr os(new SocketOutputStream(socket));
Pool p;
ObjectOutputStreamPtr oos(new ObjectOutputStream(os, p));
- pThis->streams.push_back(oos);
+ streams.push_back(oos);
}
catch (IOException& e)
{
@@ -245,11 +242,8 @@
}
}
- stopRunning = (stopRunning || pThis->closed);
+ stopRunning = (stopRunning ||closed);
}
- delete serverSocket;
- return NULL;
+ delete serverSocket;
}
-
-#endif
diff --git a/src/main/cpp/synchronized.cpp b/src/main/cpp/synchronized.cpp
deleted file mode 100644
index 03a130a..0000000
--- a/src/main/cpp/synchronized.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <log4cxx/logstring.h>
-#include <log4cxx/helpers/synchronized.h>
-#include <log4cxx/helpers/mutex.h>
-#include <log4cxx/helpers/exception.h>
-
-#include <apr_thread_mutex.h>
-
-using namespace log4cxx::helpers;
-using namespace log4cxx;
-
-synchronized::synchronized(const Mutex& mutex1)
- : mutex(mutex1.getAPRMutex())
-{
-#if APR_HAS_THREADS
- apr_status_t stat = apr_thread_mutex_lock(
- (apr_thread_mutex_t*) this->mutex);
-
- if (stat != APR_SUCCESS)
- {
- throw MutexException(stat);
- }
-
-#endif
-}
-
-synchronized::synchronized(apr_thread_mutex_t* mutex1)
- : mutex(mutex1)
-{
-#if APR_HAS_THREADS
- apr_status_t stat = apr_thread_mutex_lock(
- (apr_thread_mutex_t*) this->mutex);
-
- if (stat != APR_SUCCESS)
- {
- throw MutexException(stat);
- }
-
-#endif
-}
-
-synchronized::~synchronized()
-{
-#if APR_HAS_THREADS
- apr_status_t stat = apr_thread_mutex_unlock(
- (apr_thread_mutex_t*) mutex);
-
- if (stat != APR_SUCCESS)
- {
- throw MutexException(stat);
- }
-
-#endif
-}
-
-#if defined(RW_MUTEX)
-
-synchronized_read::synchronized_read(const RWMutex& mutex1)
- : mutex(mutex1)
-{
- mutex.rdLock();
-}
-
-synchronized_read::~synchronized_read()
-{
- mutex.rdUnlock();
-}
-
-synchronized_write::synchronized_write(const RWMutex& mutex1)
- : mutex(mutex1)
-{
- mutex.wrLock();
-}
-
-synchronized_write::~synchronized_write()
-{
- mutex.wrUnlock();
-}
-
-#endif // RW_MUTEX
diff --git a/src/main/cpp/telnetappender.cpp b/src/main/cpp/telnetappender.cpp
index 79b6edc..e7e9132 100644
--- a/src/main/cpp/telnetappender.cpp
+++ b/src/main/cpp/telnetappender.cpp
@@ -19,7 +19,6 @@
#include <log4cxx/helpers/loglog.h>
#include <log4cxx/helpers/optionconverter.h>
#include <log4cxx/helpers/stringhelper.h>
-#include <log4cxx/helpers/synchronized.h>
#include <apr_thread_proc.h>
#include <apr_atomic.h>
#include <apr_strings.h>
@@ -30,8 +29,6 @@
using namespace log4cxx::helpers;
using namespace log4cxx::net;
-#if APR_HAS_THREADS
-
IMPLEMENT_LOG4CXX_OBJECT(TelnetAppender)
/** The default telnet server port */
@@ -46,7 +43,6 @@
encoder(CharsetEncoder::getUTF8Encoder()),
serverSocket(NULL), sh()
{
- LOCK_W sync(mutex);
activeConnections = 0;
}
@@ -64,7 +60,7 @@
serverSocket->setSoTimeout(1000);
}
- sh.run(acceptConnections, this);
+ sh = std::thread( &TelnetAppender::acceptConnections, this );
}
void TelnetAppender::setOption(const LogString& option,
@@ -86,13 +82,13 @@
LogString TelnetAppender::getEncoding() const
{
- LOCK_W sync(mutex);
+ std::shared_lock lock(mutex);
return encoding;
}
void TelnetAppender::setEncoding(const LogString& value)
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
encoder = CharsetEncoder::getEncoder(value);
encoding = value;
}
@@ -100,7 +96,7 @@
void TelnetAppender::close()
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
if (closed)
{
@@ -133,13 +129,9 @@
}
}
- try
- {
+ if( sh.joinable() ){
sh.join();
}
- catch (Exception&)
- {
- }
activeConnections = 0;
}
@@ -200,7 +192,7 @@
LogString::const_iterator msgIter(msg.begin());
ByteBuffer buf(bytes, bytesSize);
- LOCK_W sync(this->mutex);
+ std::shared_lock lock(mutex);
while (msgIter != msg.end())
{
@@ -223,33 +215,32 @@
}
}
-void* APR_THREAD_FUNC TelnetAppender::acceptConnections(apr_thread_t* /* thread */, void* data)
+void TelnetAppender::acceptConnections()
{
- TelnetAppender* pThis = (TelnetAppender*) data;
// main loop; is left when This->closed is != 0 after an accept()
while (true)
{
try
{
- SocketPtr newClient = pThis->serverSocket->accept();
- bool done = pThis->closed;
+ SocketPtr newClient = serverSocket->accept();
+ bool done = closed;
if (done)
{
Pool p;
- pThis->writeStatus(newClient, LOG4CXX_STR("Log closed.\r\n"), p);
+ writeStatus(newClient, LOG4CXX_STR("Log closed.\r\n"), p);
newClient->close();
break;
}
- size_t count = pThis->activeConnections;
+ size_t count = activeConnections;
- if (count >= pThis->connections.size())
+ if (count >= connections.size())
{
Pool p;
- pThis->writeStatus(newClient, LOG4CXX_STR("Too many connections.\r\n"), p);
+ writeStatus(newClient, LOG4CXX_STR("Too many connections.\r\n"), p);
newClient->close();
}
else
@@ -257,16 +248,16 @@
//
// find unoccupied connection
//
- LOCK_W sync(pThis->mutex);
+ std::unique_lock lock(mutex);
- for (ConnectionList::iterator iter = pThis->connections.begin();
- iter != pThis->connections.end();
+ for (ConnectionList::iterator iter = connections.begin();
+ iter != connections.end();
iter++)
{
if (*iter == NULL)
{
*iter = newClient;
- pThis->activeConnections++;
+ activeConnections++;
break;
}
@@ -276,19 +267,19 @@
LogString oss(LOG4CXX_STR("TelnetAppender v1.0 ("));
StringHelper::toString((int) count + 1, p, oss);
oss += LOG4CXX_STR(" active connections)\r\n\r\n");
- pThis->writeStatus(newClient, oss, p);
+ writeStatus(newClient, oss, p);
}
}
catch (InterruptedIOException&)
{
- if (pThis->closed)
+ if (closed)
{
break;
}
}
catch (Exception& e)
{
- if (!pThis->closed)
+ if (!closed)
{
LogLog::error(LOG4CXX_STR("Encountered error while in SocketHandler loop."), e);
}
@@ -299,7 +290,4 @@
}
}
- return NULL;
}
-
-#endif
diff --git a/src/main/cpp/threadcxx.cpp b/src/main/cpp/threadcxx.cpp
deleted file mode 100644
index 8d17776..0000000
--- a/src/main/cpp/threadcxx.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <log4cxx/logstring.h>
-#include <log4cxx/helpers/thread.h>
-#include <log4cxx/helpers/exception.h>
-#include <apr_thread_proc.h>
-#include <apr_atomic.h>
-#include <log4cxx/helpers/pool.h>
-#include <log4cxx/helpers/threadlocal.h>
-#include <log4cxx/helpers/synchronized.h>
-#include <apr_thread_cond.h>
-
-using namespace log4cxx::helpers;
-using namespace log4cxx;
-
-#if APR_HAS_THREADS
-namespace
-{
-/**
- * This class is used to encapsulate the parameters to
- * Thread::run when they are passed to Thread::launcher.
- *
- */
-class LaunchPackage
-{
- public:
- /**
- * Placement new to create LaunchPackage in specified pool.
- * LaunchPackage needs to be dynamically allocated since
- * since a stack allocated instance may go out of scope
- * before thread is launched.
- */
- static void* operator new (size_t sz, Pool& p)
- {
- return p.palloc(sz);
- }
- /**
- * operator delete would be called if exception during construction.
- */
- static void operator delete (void*, Pool& p)
- {
- }
- /**
- * Create new instance.
- */
- LaunchPackage(Thread* t, Runnable r, void* d) : thread(t), runnable(r), data(d)
- {
- }
- /**
- * Gets thread parameter.
- * @return thread.
- */
- Thread* getThread() const
- {
- return thread;
- }
-
- /**
- * Gets runnable parameter.
- * @return runnable.
- */
- Runnable getRunnable() const
- {
- return runnable;
- }
- /**
- * gets data parameter.
- * @return thread.
- */
- void* getData() const
- {
- return data;
- }
- private:
- LaunchPackage(const LaunchPackage&);
- LaunchPackage& operator=(const LaunchPackage&);
- Thread* thread;
- Runnable runnable;
- void* data;
-};
-
-/**
- * This object atomically sets the specified memory location
- * to non-zero on construction and to zero on destruction.
- * Used to maintain Thread.alive.
- */
-class LaunchStatus
-{
- public:
- /*
- * Construct new instance.
- * @param p address of memory to set to non-zero on construction, zero on destruction.
- */
- LaunchStatus(volatile unsigned int* p) : alive(p)
- {
- apr_atomic_set32(alive, 0xFFFFFFFF);
- }
- /**
- * Destructor.
- */
- ~LaunchStatus()
- {
- apr_atomic_set32(alive, 0);
- }
-
- private:
- LaunchStatus(const LaunchStatus&);
- LaunchStatus& operator=(const LaunchStatus&);
- volatile unsigned int* alive;
-};
-
-/**
- * Get a key to the thread local storage used to hold the reference to
- * the corresponding Thread object.
- */
-ThreadLocal& getThreadLocal()
-{
- static ThreadLocal tls;
- return tls;
-}
-
-}
-
-void* LOG4CXX_THREAD_FUNC ThreadLaunch::launcher(apr_thread_t* thread, void* data)
-{
- LaunchPackage* package = (LaunchPackage*) data;
- ThreadLocal& tls = getThreadLocal();
- tls.set(package->getThread());
- {
- (package->getRunnable())(thread, package->getData());
- package->getThread()->ending();
- }
- apr_thread_exit(thread, 0); // this function never returns !
- return 0;
-}
-#endif
-
-Thread::Thread() : thread(NULL), alive(0), interruptedStatus(0),
- interruptedMutex(NULL), interruptedCondition(NULL)
-{
-}
-
-Thread::~Thread()
-{
- join();
-}
-
-
-
-void Thread::run(Runnable start, void* data)
-{
-#if APR_HAS_THREADS
-
- // Try to join first if previous instance did exit
- if ( isActive() && !isAlive() )
- {
- join();
- }
-
- // now we're ready to create the thread again
- //
- // if attempting a second run method on the same Thread object
- // throw an exception
- //
- if (thread != NULL)
- {
- throw IllegalStateException();
- }
-
- apr_threadattr_t* attrs;
- apr_status_t stat = apr_threadattr_create(&attrs, p.getAPRPool());
-
- if (stat != APR_SUCCESS)
- {
- throw ThreadException(stat);
- }
-
- stat = apr_thread_cond_create(&interruptedCondition, p.getAPRPool());
-
- if (stat != APR_SUCCESS)
- {
- throw ThreadException(stat);
- }
-
- stat = apr_thread_mutex_create(&interruptedMutex, APR_THREAD_MUTEX_NESTED,
- p.getAPRPool());
-
- if (stat != APR_SUCCESS)
- {
- throw ThreadException(stat);
- }
-
- // create LaunchPackage on the thread's memory pool
- LaunchPackage* package = new (p) LaunchPackage(this, start, data);
- stat = apr_thread_create(&thread, attrs,
- ThreadLaunch::launcher, package, p.getAPRPool());
-
- if (stat != APR_SUCCESS)
- {
- throw ThreadException(stat);
- }
-
- // we need to set alive here already, since we use isAlive() to check
- // if run() has been called in a thread-safe way.
- apr_atomic_set32(&alive, 0xFFFFFFFF);
-#else
- throw ThreadException(LOG4CXX_STR("APR_HAS_THREADS is not true"));
-#endif
-}
-
-void Thread::join()
-{
-#if APR_HAS_THREADS
-
- if (thread != NULL)
- {
- apr_status_t startStat;
- apr_status_t stat = apr_thread_join(&startStat, thread);
- thread = NULL;
-
- if (stat != APR_SUCCESS)
- {
- throw ThreadException(stat);
- }
- }
-
-#endif
-}
-
-void Thread::currentThreadInterrupt()
-{
-#if APR_HAS_THREADS
- void* tls = getThreadLocal().get();
-
- if (tls != 0)
- {
- ((Thread*) tls)->interrupt();
- }
-
-#endif
-}
-
-void Thread::interrupt()
-{
- apr_atomic_set32(&interruptedStatus, 0xFFFFFFFF);
-#if APR_HAS_THREADS
-
- if (interruptedMutex != NULL)
- {
- synchronized sync(interruptedMutex);
- apr_status_t stat = apr_thread_cond_signal(interruptedCondition);
-
- if (stat != APR_SUCCESS)
- {
- throw ThreadException(stat);
- }
- }
-
-#endif
-}
-
-bool Thread::interrupted()
-{
-#if APR_HAS_THREADS
- void* tls = getThreadLocal().get();
-
- if (tls != 0)
- {
- return apr_atomic_xchg32(&(((Thread*) tls)->interruptedStatus), 0) != 0;
- }
-
-#endif
- return false;
-}
-
-bool Thread::isCurrentThread() const
-{
-#if APR_HAS_THREADS
- const void* tls = getThreadLocal().get();
- return (tls == this);
-#else
- return true;
-#endif
-}
-
-bool Thread::isAlive()
-{
- return apr_atomic_read32(&alive) != 0;
-}
-
-void Thread::ending()
-{
- apr_atomic_set32(&alive, 0);
-}
-
-
-void Thread::sleep(int duration)
-{
-#if APR_HAS_THREADS
-
- if (interrupted())
- {
- throw InterruptedException();
- }
-
- if (duration > 0)
- {
- Thread* pThis = (Thread*) getThreadLocal().get();
-
- if (pThis == NULL)
- {
- apr_sleep(duration * 1000);
- }
- else
- {
- synchronized sync(pThis->interruptedMutex);
- apr_status_t stat = apr_thread_cond_timedwait(pThis->interruptedCondition,
- pThis->interruptedMutex, duration * 1000);
-
- if (stat != APR_SUCCESS && !APR_STATUS_IS_TIMEUP(stat))
- {
- throw ThreadException(stat);
- }
-
- if (interrupted())
- {
- throw InterruptedException();
- }
- }
- }
-
-#else
-
- if (duration > 0)
- {
- apr_sleep(duration * 1000);
- }
-
-#endif
-}
diff --git a/src/main/cpp/transcoder.cpp b/src/main/cpp/transcoder.cpp
index 76e9361..177f3bb 100644
--- a/src/main/cpp/transcoder.cpp
+++ b/src/main/cpp/transcoder.cpp
@@ -24,8 +24,7 @@
#include <log4cxx/helpers/charsetdecoder.h>
#include <log4cxx/helpers/charsetencoder.h>
#include <vector>
-#include <apr.h>
-#include <apr_strings.h>
+#include <cstring>
#if !defined(LOG4CXX)
#define LOG4CXX 1
#endif
@@ -536,7 +535,7 @@
#endif
wchar_t* dst = (wchar_t*) p.palloc((tmp.length() + 1) * sizeof(wchar_t));
dst[tmp.length()] = 0;
- memcpy(dst, tmp.data(), tmp.length() * sizeof(wchar_t));
+ std::memcpy(dst, tmp.data(), tmp.length() * sizeof(wchar_t));
return dst;
}
diff --git a/src/main/cpp/writerappender.cpp b/src/main/cpp/writerappender.cpp
index 6b8ee2b..bbd8baf 100644
--- a/src/main/cpp/writerappender.cpp
+++ b/src/main/cpp/writerappender.cpp
@@ -17,7 +17,6 @@
#include <log4cxx/writerappender.h>
#include <log4cxx/helpers/loglog.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/layout.h>
#include <log4cxx/helpers/stringhelper.h>
@@ -29,57 +28,54 @@
WriterAppender::WriterAppender()
{
- LOCK_W sync(mutex);
- immediateFlush = true;
+ immediateFlush = true;
}
WriterAppender::WriterAppender(const LayoutPtr& layout1,
- log4cxx::helpers::WriterPtr& writer1)
- : AppenderSkeleton(layout1), writer(writer1)
+ log4cxx::helpers::WriterPtr& writer1)
+ : AppenderSkeleton(layout1), writer(writer1)
{
- Pool p;
- LOCK_W sync(mutex);
- immediateFlush = true;
- activateOptions(p);
+ Pool p;
+ immediateFlush = true;
+ activateOptions(p);
}
WriterAppender::WriterAppender(const LayoutPtr& layout1)
- : AppenderSkeleton(layout1)
+ : AppenderSkeleton(layout1)
{
- LOCK_W sync(mutex);
- immediateFlush = true;
+ immediateFlush = true;
}
WriterAppender::~WriterAppender()
{
- finalize();
+ finalize();
}
void WriterAppender::activateOptions(Pool& p)
{
- int errors = 0;
+ int errors = 0;
- if (layout == 0)
- {
- errorHandler->error(
- ((LogString) LOG4CXX_STR("No layout set for the appender named ["))
- + name + LOG4CXX_STR("]."));
- errors++;
- }
+ if (layout == 0)
+ {
+ errorHandler->error(
+ ((LogString) LOG4CXX_STR("No layout set for the appender named ["))
+ + name + LOG4CXX_STR("]."));
+ errors++;
+ }
- if (writer == 0)
- {
- errorHandler->error(
- ((LogString) LOG4CXX_STR("No writer set for the appender named ["))
- + name + LOG4CXX_STR("]."));
- errors++;
- }
+ if (writer == 0)
+ {
+ errorHandler->error(
+ ((LogString) LOG4CXX_STR("No writer set for the appender named ["))
+ + name + LOG4CXX_STR("]."));
+ errors++;
+ }
- if (errors == 0)
- {
- AppenderSkeleton::activateOptions(p);
- }
+ if (errors == 0)
+ {
+ AppenderSkeleton::activateOptions(p);
+ }
}
@@ -87,12 +83,12 @@
void WriterAppender::append(const spi::LoggingEventPtr& event, Pool& pool1)
{
- if (!checkEntryConditions())
- {
- return;
- }
+ if (!checkEntryConditions())
+ {
+ return;
+ }
- subAppend(event, pool1);
+ subAppend(event, pool1);
}
/**
@@ -103,42 +99,42 @@
value <code>false</code> is returned. */
bool WriterAppender::checkEntryConditions() const
{
- static bool warnedClosed = false;
- static bool warnedNoWriter = false;
+ static bool warnedClosed = false;
+ static bool warnedNoWriter = false;
- if (closed)
- {
- if (!warnedClosed)
- {
- LogLog::warn(LOG4CXX_STR("Not allowed to write to a closed appender."));
- warnedClosed = true;
- }
+ if (closed)
+ {
+ if (!warnedClosed)
+ {
+ LogLog::warn(LOG4CXX_STR("Not allowed to write to a closed appender."));
+ warnedClosed = true;
+ }
- return false;
- }
+ return false;
+ }
- if (writer == 0)
- {
- if (warnedNoWriter)
- {
- errorHandler->error(
- LogString(LOG4CXX_STR("No output stream or file set for the appender named [")) +
- name + LOG4CXX_STR("]."));
- warnedNoWriter = true;
- }
+ if (writer == 0)
+ {
+ if (warnedNoWriter)
+ {
+ errorHandler->error(
+ LogString(LOG4CXX_STR("No output stream or file set for the appender named [")) +
+ name + LOG4CXX_STR("]."));
+ warnedNoWriter = true;
+ }
- return false;
- }
+ return false;
+ }
- if (layout == 0)
- {
- errorHandler->error(
- LogString(LOG4CXX_STR("No layout set for the appender named [")) +
- name + LOG4CXX_STR("]."));
- return false;
- }
+ if (layout == 0)
+ {
+ errorHandler->error(
+ LogString(LOG4CXX_STR("No layout set for the appender named [")) +
+ name + LOG4CXX_STR("]."));
+ return false;
+ }
- return true;
+ return true;
}
@@ -154,15 +150,15 @@
*/
void WriterAppender::close()
{
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
- if (closed)
- {
- return;
- }
+ if (closed)
+ {
+ return;
+ }
- closed = true;
- closeWriter();
+ closed = true;
+ closeWriter();
}
/**
@@ -170,24 +166,24 @@
* */
void WriterAppender::closeWriter()
{
- if (writer != NULL)
- {
- try
- {
- // before closing we have to output out layout's footer
- //
- // 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(pool);
- writer->close(pool);
- writer = 0;
- }
- catch (IOException& e)
- {
- LogLog::error(LogString(LOG4CXX_STR("Could not close writer for WriterAppender named ")) + name, e);
- }
- }
+ if (writer != NULL)
+ {
+ try
+ {
+ // before closing we have to output out layout's footer
+ //
+ // 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(pool);
+ writer->close(pool);
+ writer = 0;
+ }
+ catch (IOException& e)
+ {
+ LogLog::error(LogString(LOG4CXX_STR("Could not close writer for WriterAppender named ")) + name, e);
+ }
+ }
}
@@ -200,117 +196,115 @@
WriterPtr WriterAppender::createWriter(OutputStreamPtr& os)
{
- LogString enc(getEncoding());
+ LogString enc(getEncoding());
- CharsetEncoderPtr encoder;
+ CharsetEncoderPtr encoder;
- if (enc.empty())
- {
- encoder = CharsetEncoder::getDefaultEncoder();
- }
- else
- {
- if (StringHelper::equalsIgnoreCase(enc,
- LOG4CXX_STR("utf-16"), LOG4CXX_STR("UTF-16")))
- {
- encoder = CharsetEncoder::getEncoder(LOG4CXX_STR("UTF-16BE"));
- }
- else
- {
- encoder = CharsetEncoder::getEncoder(enc);
- }
+ if (enc.empty())
+ {
+ encoder = CharsetEncoder::getDefaultEncoder();
+ }
+ else
+ {
+ if (StringHelper::equalsIgnoreCase(enc,
+ LOG4CXX_STR("utf-16"), LOG4CXX_STR("UTF-16")))
+ {
+ encoder = CharsetEncoder::getEncoder(LOG4CXX_STR("UTF-16BE"));
+ }
+ else
+ {
+ encoder = CharsetEncoder::getEncoder(enc);
+ }
- if (encoder == NULL)
- {
- encoder = CharsetEncoder::getDefaultEncoder();
- LogLog::warn(LOG4CXX_STR("Error initializing output writer."));
- LogLog::warn(LOG4CXX_STR("Unsupported encoding?"));
- }
- }
+ if (encoder == NULL)
+ {
+ encoder = CharsetEncoder::getDefaultEncoder();
+ LogLog::warn(LOG4CXX_STR("Error initializing output writer."));
+ LogLog::warn(LOG4CXX_STR("Unsupported encoding?"));
+ }
+ }
- return new OutputStreamWriter(os, encoder);
+ return new OutputStreamWriter(os, encoder);
}
LogString WriterAppender::getEncoding() const
{
- return encoding;
+ return encoding;
}
void WriterAppender::setEncoding(const LogString& enc)
{
- encoding = enc;
+ encoding = enc;
}
void WriterAppender::subAppend(const spi::LoggingEventPtr& event, Pool& p)
{
- LogString msg;
- layout->format(msg, event, p);
- {
- LOCK_W sync(mutex);
+ LogString msg;
+ layout->format(msg, event, p);
+ if (writer != NULL)
+ {
+ writer->write(msg, p);
- if (writer != NULL)
- {
- writer->write(msg, p);
-
- if (immediateFlush)
- {
- writer->flush(p);
- }
- }
- }
+ if (immediateFlush)
+ {
+ writer->flush(p);
+ }
+ }
}
void WriterAppender::writeFooter(Pool& p)
{
- if (layout != NULL)
- {
- LogString foot;
- layout->appendFooter(foot, p);
- LOCK_W sync(mutex);
- writer->write(foot, p);
- }
+ if (layout != NULL)
+ {
+ LogString foot;
+ layout->appendFooter(foot, p);
+ writer->write(foot, p);
+ }
}
void WriterAppender::writeHeader(Pool& p)
{
- if (layout != NULL)
- {
- LogString header;
- layout->appendHeader(header, p);
- LOCK_W sync(mutex);
- writer->write(header, p);
- }
+ if (layout != NULL)
+ {
+ LogString header;
+ layout->appendHeader(header, p);
+ writer->write(header, p);
+ }
}
void WriterAppender::setWriter(const WriterPtr& newWriter)
{
- LOCK_W sync(mutex);
- writer = newWriter;
+ std::unique_lock lock(mutex);
+ setWriterInternal(newWriter);
}
+void WriterAppender::setWriterInternal(const WriterPtr& newWriter)
+{
+ writer = newWriter;
+}
bool WriterAppender::requiresLayout() const
{
- return true;
+ return true;
}
void WriterAppender::setOption(const LogString& option, const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("ENCODING"), LOG4CXX_STR("encoding")))
- {
- setEncoding(value);
- }
- else
- {
- AppenderSkeleton::setOption(option, value);
- }
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("ENCODING"), LOG4CXX_STR("encoding")))
+ {
+ setEncoding(value);
+ }
+ else
+ {
+ AppenderSkeleton::setOption(option, value);
+ }
}
void WriterAppender::setImmediateFlush(bool value)
{
- LOCK_W sync(mutex);
- immediateFlush = value;
+ std::unique_lock lock(mutex);
+ immediateFlush = value;
}
diff --git a/src/main/cpp/xmlsocketappender.cpp b/src/main/cpp/xmlsocketappender.cpp
index 98356db..456b93e 100644
--- a/src/main/cpp/xmlsocketappender.cpp
+++ b/src/main/cpp/xmlsocketappender.cpp
@@ -24,8 +24,6 @@
#include <log4cxx/xml/xmllayout.h>
#include <log4cxx/level.h>
#include <log4cxx/helpers/transform.h>
-#include <apr_time.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/helpers/transcoder.h>
#include <log4cxx/helpers/socketoutputstream.h>
@@ -86,7 +84,7 @@
{
OutputStreamPtr os(new SocketOutputStream(socket));
CharsetEncoderPtr charset(CharsetEncoder::getUTF8Encoder());
- LOCK_W sync(mutex);
+ std::unique_lock lock(mutex);
writer = new OutputStreamWriter(os, charset);
}
diff --git a/src/main/include/log4cxx/appender.h b/src/main/include/log4cxx/appender.h
index 0f58dfc..fb3f4f5 100644
--- a/src/main/include/log4cxx/appender.h
+++ b/src/main/include/log4cxx/appender.h
@@ -61,6 +61,8 @@
virtual ~Appender() {}
+ void asdf();
+
/**
Add a filter to the end of the filter list.
*/
diff --git a/src/main/include/log4cxx/appenderskeleton.h b/src/main/include/log4cxx/appenderskeleton.h
index 3face72..4f529df 100644
--- a/src/main/include/log4cxx/appenderskeleton.h
+++ b/src/main/include/log4cxx/appenderskeleton.h
@@ -29,10 +29,9 @@
#include <log4cxx/spi/errorhandler.h>
#include <log4cxx/spi/filter.h>
#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/mutex.h>
#include <log4cxx/helpers/pool.h>
#include <log4cxx/level.h>
-
+#include <shared_mutex>
namespace log4cxx
{
@@ -76,7 +75,7 @@
bool closed;
log4cxx::helpers::Pool pool;
- mutable SHARED_MUTEX mutex;
+ mutable std::shared_mutex mutex;
/**
Subclasses of <code>AppenderSkeleton</code> should implement this
diff --git a/src/main/include/log4cxx/asyncappender.h b/src/main/include/log4cxx/asyncappender.h
index fcd4cdf..e7e0105 100644
--- a/src/main/include/log4cxx/asyncappender.h
+++ b/src/main/include/log4cxx/asyncappender.h
@@ -28,9 +28,10 @@
#include <log4cxx/helpers/appenderattachableimpl.h>
#include <deque>
#include <log4cxx/spi/loggingevent.h>
-#include <log4cxx/helpers/thread.h>
-#include <log4cxx/helpers/mutex.h>
-#include <log4cxx/helpers/condition.h>
+
+#include <mutex>
+#include <condition_variable>
+#include <thread>
#if defined(NON_BLOCKING)
#include <boost/lockfree/queue.hpp>
@@ -211,14 +212,14 @@
/**
* Mutex used to guard access to buffer and discardMap.
*/
- SHARED_MUTEX bufferMutex;
+ std::mutex bufferMutex;
#if defined(NON_BLOCKING)
::log4cxx::helpers::Semaphore bufferNotFull;
::log4cxx::helpers::Semaphore bufferNotEmpty;
#else
- ::log4cxx::helpers::Condition bufferNotFull;
- ::log4cxx::helpers::Condition bufferNotEmpty;
+ std::condition_variable bufferNotFull;
+ std::condition_variable bufferNotEmpty;
#endif
class DiscardSummary
{
@@ -283,7 +284,7 @@
/**
* Dispatcher.
*/
- helpers::Thread dispatcher;
+ std::thread dispatcher;
/**
* Should location info be included in dispatched messages.
@@ -298,7 +299,7 @@
/**
* Dispatch routine.
*/
- static void* LOG4CXX_THREAD_FUNC dispatch(apr_thread_t* thread, void* data);
+ void dispatch();
}; // class AsyncAppender
LOG4CXX_PTR_DEF(AsyncAppender);
diff --git a/src/main/include/log4cxx/fileappender.h b/src/main/include/log4cxx/fileappender.h
index 1b737c1..39fbe82 100644
--- a/src/main/include/log4cxx/fileappender.h
+++ b/src/main/include/log4cxx/fileappender.h
@@ -128,28 +128,6 @@
virtual void setFile(const LogString& file);
/**
- Sets and <i>opens</i> the file where the log output will
- go. The specified file must be writable.
-
- <p>If there was already an opened file, then the previous file
- is closed first.
-
- <p><b>Do not use this method directly. To configure a FileAppender
- or one of its subclasses, set its properties one by one and then
- call activateOptions.</b>
-
- @param file The path to the log file.
- @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.
- */
- virtual void setFile(const LogString& file, bool append,
- bool bufferedIO, size_t bufferSize,
- log4cxx::helpers::Pool& p);
-
- /**
Returns the value of the <b>Append</b> option.
*/
inline bool getAppend() const
@@ -232,6 +210,33 @@
*/
static LogString stripDuplicateBackslashes(const LogString& name);
+protected:
+ void activateOptionsInternal(log4cxx::helpers::Pool& p);
+
+ /**
+ Sets and <i>opens</i> the file where the log output will
+ go. The specified file must be writable.
+
+ <p>If there was already an opened file, then the previous file
+ is closed first.
+
+ <p><b>Do not use this method directly. To configure a FileAppender
+ or one of its subclasses, set its properties one by one and then
+ call activateOptions.</b>
+
+ The mutex must be locked before calling this function.
+
+ @param file The path to the log file.
+ @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.
+ */
+ void setFileInternal(const LogString& file, bool append,
+ bool bufferedIO, size_t bufferSize,
+ log4cxx::helpers::Pool& p);
+
private:
FileAppender(const FileAppender&);
FileAppender& operator=(const FileAppender&);
diff --git a/src/main/include/log4cxx/helpers/appenderattachableimpl.h b/src/main/include/log4cxx/helpers/appenderattachableimpl.h
index 4c3caeb..0842a19 100644
--- a/src/main/include/log4cxx/helpers/appenderattachableimpl.h
+++ b/src/main/include/log4cxx/helpers/appenderattachableimpl.h
@@ -26,8 +26,8 @@
#include <log4cxx/spi/appenderattachable.h>
#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/mutex.h>
#include <log4cxx/helpers/pool.h>
+#include <mutex>
namespace log4cxx
{
@@ -108,13 +108,13 @@
*/
virtual void removeAppender(const LogString& name);
- inline const log4cxx::helpers::Mutex& getMutex() const
+ inline std::mutex& getMutex() const
{
return mutex;
}
private:
- log4cxx::helpers::Mutex mutex;
+ mutable std::mutex mutex;
AppenderAttachableImpl(const AppenderAttachableImpl&);
AppenderAttachableImpl& operator=(const AppenderAttachableImpl&);
};
diff --git a/src/main/include/log4cxx/helpers/aprinitializer.h b/src/main/include/log4cxx/helpers/aprinitializer.h
index b2f1f05..9881001 100644
--- a/src/main/include/log4cxx/helpers/aprinitializer.h
+++ b/src/main/include/log4cxx/helpers/aprinitializer.h
@@ -23,6 +23,7 @@
#endif
#include <list>
+#include <mutex>
extern "C" {
typedef struct apr_thread_mutex_t apr_thread_mutex_t;
@@ -58,7 +59,7 @@
APRInitializer(const APRInitializer&);
APRInitializer& operator=(const APRInitializer&);
apr_pool_t* p;
- apr_thread_mutex_t* mutex;
+ std::mutex mutex;
std::list<FileWatchdog*> watchdogs;
apr_time_t startTime;
apr_threadkey_t* tlsKey;
diff --git a/src/main/include/log4cxx/helpers/condition.h b/src/main/include/log4cxx/helpers/condition.h
deleted file mode 100644
index 9ceb790..0000000
--- a/src/main/include/log4cxx/helpers/condition.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LOG4CXX_HELPERS_CONDITION_H
-#define _LOG4CXX_HELPERS_CONDITION_H
-
-#include <log4cxx/log4cxx.h>
-#include <log4cxx/helpers/mutex.h>
-
-extern "C" {
- struct apr_thread_cond_t;
-}
-
-namespace log4cxx
-{
-namespace helpers
-{
-class Pool;
-
-/**
- * This class provides a means for one thread to suspend exception until
- * notified by another thread to resume. This class should have
- * similar semantics to java.util.concurrent.locks.Condition.
- */
-class LOG4CXX_EXPORT Condition
-{
- public:
- /**
- * Create new instance.
- * @param p pool on which condition will be created. Needs to be
- * longer-lived than created instance.
- */
- Condition(log4cxx::helpers::Pool& p);
- /**
- * Destructor.
- */
- ~Condition();
- /**
- * Signal all waiting threads.
- */
- log4cxx_status_t signalAll();
- /**
- * Await signaling of condition.
- * @param lock lock associated with condition, calling thread must
- * own lock. Lock will be released while waiting and reacquired
- * before returning from wait.
- * @throws InterruptedException if thread is interrupted.
- */
- void await(Mutex& lock);
-
- private:
- apr_thread_cond_t* condition;
- Condition(const Condition&);
- Condition& operator=(const Condition&);
-};
-} // namespace helpers
-} // namespace log4cxx
-
-#endif //_LOG4CXX_HELPERS_CONDITION_H
diff --git a/src/main/include/log4cxx/helpers/exception.h b/src/main/include/log4cxx/helpers/exception.h
index 2749544..0349927 100644
--- a/src/main/include/log4cxx/helpers/exception.h
+++ b/src/main/include/log4cxx/helpers/exception.h
@@ -119,16 +119,6 @@
};
-class LOG4CXX_EXPORT MutexException : public Exception
-{
- public:
- MutexException(log4cxx_status_t stat);
- MutexException(const MutexException& src);
- MutexException& operator=(const MutexException&);
- private:
- static LogString formatMessage(log4cxx_status_t stat);
-};
-
class LOG4CXX_EXPORT InterruptedException : public Exception
{
public:
diff --git a/src/main/include/log4cxx/helpers/filewatchdog.h b/src/main/include/log4cxx/helpers/filewatchdog.h
index bc07d03..b491463 100644
--- a/src/main/include/log4cxx/helpers/filewatchdog.h
+++ b/src/main/include/log4cxx/helpers/filewatchdog.h
@@ -21,8 +21,10 @@
#include <log4cxx/logstring.h>
#include <time.h>
#include <log4cxx/helpers/pool.h>
-#include <log4cxx/helpers/thread.h>
#include <log4cxx/file.h>
+#include <thread>
+#include <condition_variable>
+#include <atomic>
namespace log4cxx
{
@@ -54,7 +56,7 @@
long delay;
log4cxx_time_t lastModif;
bool warnedAlready;
- volatile unsigned int interrupted;
+ std::atomic<int> interrupted;
protected:
FileWatchdog(const File& filename);
@@ -73,9 +75,12 @@
void start();
private:
- static void* LOG4CXX_THREAD_FUNC run(apr_thread_t* thread, void* data);
+ void run();
+ bool is_interrupted();
Pool pool;
- Thread thread;
+ std::thread thread;
+ std::condition_variable interrupt;
+ std::mutex interrupt_mutex;
FileWatchdog(const FileWatchdog&);
FileWatchdog& operator=(const FileWatchdog&);
diff --git a/src/main/include/log4cxx/helpers/loglog.h b/src/main/include/log4cxx/helpers/loglog.h
index 0f0b8b5..a4c9241 100644
--- a/src/main/include/log4cxx/helpers/loglog.h
+++ b/src/main/include/log4cxx/helpers/loglog.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_HELPERS_LOG_LOG_H
#include <log4cxx/logstring.h>
-#include <log4cxx/helpers/mutex.h>
#include <exception>
+#include <mutex>
namespace log4cxx
{
@@ -48,7 +48,7 @@
In quietMode not even errors generate any output.
*/
bool quietMode;
- Mutex mutex;
+ std::mutex mutex;
LogLog();
LogLog(const LogLog&);
LogLog& operator=(const LogLog&);
diff --git a/src/main/include/log4cxx/helpers/mutex.h b/src/main/include/log4cxx/helpers/mutex.h
deleted file mode 100644
index 67c73ad..0000000
--- a/src/main/include/log4cxx/helpers/mutex.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LOG4CXX_HELPERS_MUTEX_H
-#define _LOG4CXX_HELPERS_MUTEX_H
-
-#include <log4cxx/log4cxx.h>
-
-#if defined(RW_MUTEX)
- #include <apr_portable.h>
- #include <atomic>
-#endif
-
-extern "C" {
- struct apr_thread_mutex_t;
- struct apr_pool_t;
- struct apr_thread_rwlock_t;
-}
-
-
-namespace log4cxx
-{
-namespace helpers
-{
-class Pool;
-
-class LOG4CXX_EXPORT Mutex
-{
- public:
- Mutex(log4cxx::helpers::Pool& p);
- Mutex(apr_pool_t* p);
- ~Mutex();
- apr_thread_mutex_t* getAPRMutex() const;
-
- private:
- Mutex(const Mutex&);
- Mutex& operator=(const Mutex&);
- apr_thread_mutex_t* mutex;
-};
-} // namespace helpers
-} // namespace log4cxx
-
-
-#if defined(RW_MUTEX)
-
-namespace log4cxx
-{
-namespace helpers
-{
-class Pool;
-
-class LOG4CXX_EXPORT RWMutex
-{
- public:
- RWMutex(log4cxx::helpers::Pool& p);
- RWMutex(apr_pool_t* p);
- ~RWMutex();
-
- void rdLock() const;
- void rdUnlock() const;
-
- void wrLock() const;
- void wrUnlock() const;
-
- private:
- mutable std::atomic<apr_os_thread_t> id;
- mutable unsigned count;
- RWMutex(const RWMutex&);
- RWMutex& operator=(const RWMutex&);
- apr_thread_rwlock_t* mutex;
-};
-} // namespace helpers
-} // namespace log4cxx
-
-#define SHARED_MUTEX log4cxx::helpers::RWMutex
-
-#else // no RW_MUTEX
-
-#define SHARED_MUTEX log4cxx::helpers::Mutex
-
-#endif // RW_MUTEX
-
-#define SHARED_MUTEX_INIT(mutex, p) mutex(p)
-
-#if defined(NON_BLOCKING)
-
-namespace log4cxx
-{
-namespace helpers
-{
-struct SemaphoreImpl;
-
-class LOG4CXX_EXPORT Semaphore
-{
- public:
- Semaphore(log4cxx::helpers::Pool& p);
- ~Semaphore();
-
- void await() const;
- void signalAll() const;
-
- private:
- Semaphore(const Semaphore&);
- Semaphore& operator=(const Semaphore&);
-
- SemaphoreImpl* impl;
-};
-} // namespace helpers
-} // namespace log4cxx
-
-#endif // NON_BLOCKING
-
-#endif //_LOG4CXX_HELPERS_MUTEX_H
diff --git a/src/main/include/log4cxx/helpers/serversocket.h b/src/main/include/log4cxx/helpers/serversocket.h
index 322dcd0..7da75b9 100644
--- a/src/main/include/log4cxx/helpers/serversocket.h
+++ b/src/main/include/log4cxx/helpers/serversocket.h
@@ -19,7 +19,7 @@
#define _LOG4CXX_HELPERS_SERVER_SOCKET_H
#include <log4cxx/helpers/socket.h>
-#include <log4cxx/helpers/mutex.h>
+#include <mutex>
namespace log4cxx
{
@@ -53,7 +53,7 @@
private:
Pool pool;
- Mutex mutex;
+ std::mutex mutex;
apr_socket_t* socket;
int timeout;
diff --git a/src/main/include/log4cxx/helpers/synchronized.h b/src/main/include/log4cxx/helpers/synchronized.h
deleted file mode 100644
index ad0bf2f..0000000
--- a/src/main/include/log4cxx/helpers/synchronized.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LOG4CXX_HELPERS_SYNCHRONIZED_H
-#define _LOG4CXX_HELPERS_SYNCHRONIZED_H
-#include <log4cxx/log4cxx.h>
-
-extern "C" {
- typedef struct apr_thread_mutex_t apr_thread_mutex_t;
-}
-
-namespace log4cxx
-{
-namespace helpers
-{
-class Mutex;
-
-/** utility class for objects multi-thread synchronization.*/
-class LOG4CXX_EXPORT synchronized
-{
- public:
- synchronized(const Mutex& mutex);
- synchronized(apr_thread_mutex_t* mutex);
- ~synchronized();
-
-
- private:
- void* mutex;
- // prevent use of copy and assignment
- synchronized(const synchronized&);
- synchronized& operator=(const synchronized&);
-};
-}
-}
-
-#if defined(RW_MUTEX)
-
-namespace log4cxx
-{
-namespace helpers
-{
-class RWMutex;
-
-// utility class for objects multi-thread synchronization.
-class LOG4CXX_EXPORT synchronized_read
-{
- public:
- synchronized_read(const RWMutex& mutex);
- ~synchronized_read();
-
-
- private:
- const RWMutex& mutex;
- // prevent use of copy and assignment
- synchronized_read(const synchronized_read&);
- synchronized_read& operator=(const synchronized_read&);
-};
-}
-}
-
-namespace log4cxx
-{
-namespace helpers
-{
-class RWMutex;
-
-// utility class for objects multi-thread synchronization.
-class LOG4CXX_EXPORT synchronized_write
-{
- public:
- synchronized_write(const RWMutex& mutex);
- ~synchronized_write();
-
-
- private:
- const RWMutex& mutex;
- // prevent use of copy and assignment
- synchronized_write(const synchronized_write&);
- synchronized_write& operator=(const synchronized_write&);
-};
-}
-}
-
-#define LOCK_R synchronized_read
-#define LOCK_W synchronized_write
-
-#else
-
-#define LOCK_R synchronized
-#define LOCK_W synchronized
-
-#endif // RW_MUTEX
-
-#endif //_LOG4CXX_HELPERS_SYNCHRONIZED_H
diff --git a/src/main/include/log4cxx/helpers/thread.h b/src/main/include/log4cxx/helpers/thread.h
deleted file mode 100644
index c131c03..0000000
--- a/src/main/include/log4cxx/helpers/thread.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _LOG4CXX_HELPERS_THREAD_H
-#define _LOG4CXX_HELPERS_THREAD_H
-
-#include <log4cxx/log4cxx.h>
-#include <log4cxx/helpers/pool.h>
-
-#if !defined(LOG4CXX_THREAD_FUNC)
- #if defined(_WIN32)
- #if defined(__MINGW32__)
- #define LOG4CXX_THREAD_FUNC
- #else
- #define LOG4CXX_THREAD_FUNC __stdcall
- #endif
- #else
- #define LOG4CXX_THREAD_FUNC
- #endif
-#endif
-
-extern "C" {
- typedef struct apr_thread_t apr_thread_t;
- typedef struct apr_thread_cond_t apr_thread_cond_t;
- typedef struct apr_thread_mutex_t apr_thread_mutex_t;
-}
-
-
-namespace log4cxx
-{
-namespace helpers
-{
-class Pool;
-class ThreadLocal;
-
-typedef void* (LOG4CXX_THREAD_FUNC* Runnable)(apr_thread_t* thread, void* data);
-namespace ThreadLaunch
-{
-extern "C" void* LOG4CXX_THREAD_FUNC launcher(apr_thread_t* thread, void* data);
-}
-
-/**
- * This class implements an approximation of java.util.Thread.
- */
-class LOG4CXX_EXPORT Thread
-{
- public:
- /**
- * Create new instance.
- */
- Thread();
- /**
- * Destructor.
- */
- ~Thread();
-
- /**
- * Runs the specified method on a newly created thread.
- */
- void run(Runnable start, void* data);
- void join();
-
- inline bool isActive()
- {
- return thread != 0;
- }
-
- /**
- * Causes the currently executing thread to sleep for the
- * specified number of milliseconds.
- * @param millis milliseconds.
- * @throws Interrupted Exception if the thread is interrupted.
- */
- static void sleep(int millis);
- /**
- * Sets interrupted status for current thread to true.
- */
- static void currentThreadInterrupt();
- /**
- * Sets interrupted status to true.
- */
- void interrupt();
- /**
- * Tests if the current thread has been interrupted and
- * sets the interrupted status to false.
- */
- static bool interrupted();
-
- bool isAlive();
- bool isCurrentThread() const;
- void ending();
-
-
- private:
- Pool p;
- apr_thread_t* thread;
- volatile unsigned int alive;
- volatile unsigned int interruptedStatus;
- apr_thread_mutex_t* interruptedMutex;
- apr_thread_cond_t* interruptedCondition;
- Thread(const Thread&);
- Thread& operator=(const Thread&);
- friend void* LOG4CXX_THREAD_FUNC ThreadLaunch::launcher(apr_thread_t* thread, void* data);
-};
-} // namespace helpers
-} // namespace log4cxx
-
-#endif //_LOG4CXX_HELPERS_THREAD_H
diff --git a/src/main/include/log4cxx/hierarchy.h b/src/main/include/log4cxx/hierarchy.h
index a8448c3..a00f50e 100644
--- a/src/main/include/log4cxx/hierarchy.h
+++ b/src/main/include/log4cxx/hierarchy.h
@@ -31,6 +31,7 @@
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/spi/hierarchyeventlistener.h>
#include <log4cxx/helpers/pool.h>
+#include <mutex>
namespace log4cxx
{
@@ -58,7 +59,7 @@
{
private:
log4cxx::helpers::Pool pool;
- log4cxx::helpers::Mutex mutex;
+ mutable std::mutex mutex;
bool configured;
spi::LoggerFactoryPtr defaultFactory;
@@ -232,6 +233,16 @@
private:
/**
+ * Set the threshold. The mutex must already be locked.
+ */
+ void setThresholdInternal(const LevelPtr& l);
+
+ /**
+ * Internal shutdown. The mutex must already be locked.
+ */
+ void shutdownInternal();
+
+ /**
This method loops through all the *potential* parents of
'cat'. There 3 possible cases:
diff --git a/src/main/include/log4cxx/logger.h b/src/main/include/log4cxx/logger.h
index 07a9047..6c5150e 100644
--- a/src/main/include/log4cxx/logger.h
+++ b/src/main/include/log4cxx/logger.h
@@ -19,22 +19,21 @@
#define _LOG4CXX_LOGGER_H
#if defined(_MSC_VER) && (_MSC_VER < 1900)
- #pragma warning ( push )
- #pragma warning ( disable: 4127 )
+#pragma warning ( push )
+#pragma warning ( disable: 4127 )
#endif
#if defined(_MSC_VER)
- #pragma warning ( push )
- #pragma warning ( disable: 4231 4251 4275 4786 )
+#pragma warning ( push )
+#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/helpers/appenderattachableimpl.h>
#include <log4cxx/level.h>
#include <log4cxx/helpers/pool.h>
-#include <log4cxx/helpers/mutex.h>
#include <log4cxx/spi/location/locationinfo.h>
#include <log4cxx/helpers/resourcebundle.h>
#include <log4cxx/helpers/messagebuffer.h>
-
+#include <shared_mutex>
namespace log4cxx
{
@@ -63,1673 +62,1676 @@
operations, except configuration, are done through this class.
*/
class LOG4CXX_EXPORT Logger :
- public virtual log4cxx::spi::AppenderAttachable,
- public virtual helpers::ObjectImpl
+ public virtual log4cxx::spi::AppenderAttachable,
+ public virtual helpers::ObjectImpl
{
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(Logger)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(Logger)
- LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
- END_LOG4CXX_CAST_MAP()
+public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(Logger)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(Logger)
+ LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
+ END_LOG4CXX_CAST_MAP()
- private:
- /**
- * Reference to memory pool.
- */
- helpers::Pool* pool;
+private:
+ /**
+ * Reference to memory pool.
+ */
+ helpers::Pool* pool;
- protected:
- /**
- The name of this logger.
- */
- LogString name;
+protected:
+ /**
+ The name of this logger.
+ */
+ LogString name;
- /**
- The assigned level of this logger. The
- <code>level</code> variable need not be assigned a value in
- which case it is inherited form the hierarchy. */
- LevelPtr level;
+ /**
+ The assigned level of this logger. The
+ <code>level</code> variable need not be assigned a value in
+ which case it is inherited form the hierarchy. */
+ LevelPtr level;
- /**
- The parent of this logger. All loggers have at least one
- ancestor which is the root logger. */
- LoggerPtr parent;
+ /**
+ The parent of this logger. All loggers have at least one
+ ancestor which is the root logger. */
+ LoggerPtr parent;
- /** The resourceBundle for localized messages.
+ /** The resourceBundle for localized messages.
- @see setResourceBundle, getResourceBundle
- */
- helpers::ResourceBundlePtr resourceBundle;
+ @see setResourceBundle, getResourceBundle
+ */
+ helpers::ResourceBundlePtr resourceBundle;
- // Loggers need to know what Hierarchy they are in
- log4cxx::spi::LoggerRepository* repository;
+ // Loggers need to know what Hierarchy they are in
+ log4cxx::spi::LoggerRepository* repository;
- helpers::AppenderAttachableImplPtr aai;
+ helpers::AppenderAttachableImplPtr aai;
- /** Additivity is set to true by default, that is children inherit
- the appenders of their ancestors by default. If this variable is
- set to <code>false</code> then the appenders found in the
- ancestors of this logger are not used. However, the children
- of this logger will inherit its appenders, unless the children
- have their additivity flag set to <code>false</code> too. See
- the user manual for more details. */
- bool additive;
+ /** Additivity is set to true by default, that is children inherit
+ the appenders of their ancestors by default. If this variable is
+ set to <code>false</code> then the appenders found in the
+ ancestors of this logger are not used. However, the children
+ of this logger will inherit its appenders, unless the children
+ have their additivity flag set to <code>false</code> too. See
+ the user manual for more details. */
+ bool additive;
- protected:
- friend class DefaultLoggerFactory;
+protected:
+ friend class DefaultLoggerFactory;
- /**
- This constructor created a new <code>logger</code> instance and
- sets its name.
+ /**
+ This constructor created a new <code>logger</code> instance and
+ sets its name.
- <p>It is intended to be used by sub-classes only. You should not
- create categories directly.
+ <p>It is intended to be used by sub-classes only. You should not
+ create categories directly.
- @param pool lifetime of pool must be longer than logger.
- @param name The name of the logger.
- */
- Logger(log4cxx::helpers::Pool& pool, const LogString& name);
+ @param pool lifetime of pool must be longer than logger.
+ @param name The name of the logger.
+ */
+ Logger(log4cxx::helpers::Pool& pool, const LogString& name);
- public:
- ~Logger();
+public:
+ ~Logger();
- void addRef() const;
- void releaseRef() const;
+ void addRef() const;
+ void releaseRef() const;
- /**
- Add <code>newAppender</code> to the list of appenders of this
- Logger instance.
+ /**
+ Add <code>newAppender</code> to the list of appenders of this
+ Logger instance.
- <p>If <code>newAppender</code> is already in the list of
- appenders, then it won't be added again.
- */
- virtual void addAppender(const AppenderPtr& newAppender);
+ <p>If <code>newAppender</code> is already in the list of
+ appenders, then it won't be added again.
+ */
+ virtual void addAppender(const AppenderPtr& newAppender);
- /**
- Call the appenders in the hierrachy starting at
- <code>this</code>. If no appenders could be found, emit a
- warning.
+ /**
+ Call the appenders in the hierrachy starting at
+ <code>this</code>. If no appenders could be found, emit a
+ warning.
- <p>This method calls all the appenders inherited from the
- hierarchy circumventing any evaluation of whether to log or not
- to log the particular log request.
+ <p>This method calls all the appenders inherited from the
+ hierarchy circumventing any evaluation of whether to log or not
+ to log the particular log request.
- @param event the event to log.
- @param p memory pool for any allocations needed to process request.
- */
- void callAppenders(const log4cxx::spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) const;
+ @param event the event to log.
+ @param p memory pool for any allocations needed to process request.
+ */
+ void callAppenders(const log4cxx::spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) const;
- /**
- Close all attached appenders implementing the AppenderAttachable
- interface.
- */
- void closeNestedAppenders();
+ /**
+ Close all attached appenders implementing the AppenderAttachable
+ interface.
+ */
+ void closeNestedAppenders();
- /**
- Log a message string with the DEBUG level.
+ /**
+ Log a message string with the DEBUG level.
- <p>This method first checks if this logger is <code>DEBUG</code>
- enabled by comparing the level of this logger with the
- DEBUG level. If this logger is
- <code>DEBUG</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>DEBUG</code>
+ enabled by comparing the level of this logger with the
+ DEBUG level. If this logger is
+ <code>DEBUG</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void debug(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the DEBUG level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void debug(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the DEBUG level.
- <p>This method first checks if this logger is <code>DEBUG</code>
- enabled by comparing the level of this logger with the
- DEBUG level. If this logger is
- <code>DEBUG</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>DEBUG</code>
+ enabled by comparing the level of this logger with the
+ DEBUG level. If this logger is
+ <code>DEBUG</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void debug(const std::string& msg) const;
+ @param msg the message string to log.
+ */
+ void debug(const std::string& msg) const;
#if LOG4CXX_WCHAR_T_API
- /**
- Log a message string with the DEBUG level.
+ /**
+ Log a message string with the DEBUG level.
- <p>This method first checks if this logger is <code>DEBUG</code>
- enabled by comparing the level of this logger with the
- DEBUG level. If this logger is
- <code>DEBUG</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>DEBUG</code>
+ enabled by comparing the level of this logger with the
+ DEBUG level. If this logger is
+ <code>DEBUG</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void debug(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the DEBUG level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void debug(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the DEBUG level.
- <p>This method first checks if this logger is <code>DEBUG</code>
- enabled by comparing the level of this logger with the
- DEBUG level. If this logger is
- <code>DEBUG</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>DEBUG</code>
+ enabled by comparing the level of this logger with the
+ DEBUG level. If this logger is
+ <code>DEBUG</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void debug(const std::wstring& msg) const;
+ @param msg the message string to log.
+ */
+ void debug(const std::wstring& msg) const;
#endif
#if LOG4CXX_UNICHAR_API
- /**
- Log a message string with the DEBUG level.
+ /**
+ Log a message string with the DEBUG level.
- <p>This method first checks if this logger is <code>DEBUG</code>
- enabled by comparing the level of this logger with the
- DEBUG level. If this logger is
- <code>DEBUG</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>DEBUG</code>
+ enabled by comparing the level of this logger with the
+ DEBUG level. If this logger is
+ <code>DEBUG</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void debug(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the DEBUG level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void debug(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the DEBUG level.
- <p>This method first checks if this logger is <code>DEBUG</code>
- enabled by comparing the level of this logger with the
- DEBUG level. If this logger is
- <code>DEBUG</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>DEBUG</code>
+ enabled by comparing the level of this logger with the
+ DEBUG level. If this logger is
+ <code>DEBUG</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void debug(const std::basic_string<UniChar>& msg) const;
+ @param msg the message string to log.
+ */
+ void debug(const std::basic_string<UniChar>& msg) const;
#endif
#if LOG4CXX_CFSTRING_API
- /**
- Log a message string with the DEBUG level.
+ /**
+ Log a message string with the DEBUG level.
- <p>This method first checks if this logger is <code>DEBUG</code>
- enabled by comparing the level of this logger with the
- DEBUG level. If this logger is
- <code>DEBUG</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>DEBUG</code>
+ enabled by comparing the level of this logger with the
+ DEBUG level. If this logger is
+ <code>DEBUG</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void debug(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the DEBUG level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void debug(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the DEBUG level.
- <p>This method first checks if this logger is <code>DEBUG</code>
- enabled by comparing the level of this logger with the
- DEBUG level. If this logger is
- <code>DEBUG</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>DEBUG</code>
+ enabled by comparing the level of this logger with the
+ DEBUG level. If this logger is
+ <code>DEBUG</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void debug(const CFStringRef& msg) const;
+ @param msg the message string to log.
+ */
+ void debug(const CFStringRef& msg) const;
#endif
- /**
- Log a message string with the ERROR level.
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void error(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the ERROR level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void error(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void error(const std::string& msg) const;
+ @param msg the message string to log.
+ */
+ void error(const std::string& msg) const;
#if LOG4CXX_WCHAR_T_API
- /**
- Log a message string with the ERROR level.
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void error(const std::wstring& msg) const;
- /**
- Log a message string with the ERROR level.
+ @param msg the message string to log.
+ */
+ void error(const std::wstring& msg) const;
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void error(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void error(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
#endif
#if LOG4CXX_UNICHAR_API
- /**
- Log a message string with the ERROR level.
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void error(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the ERROR level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void error(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void error(const std::basic_string<UniChar>& msg) const;
+ @param msg the message string to log.
+ */
+ void error(const std::basic_string<UniChar>& msg) const;
#endif
#if LOG4CXX_CFSTRING_API
- /**
- Log a message string with the ERROR level.
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void error(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the ERROR level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void error(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void error(const CFStringRef& msg) const;
+ @param msg the message string to log.
+ */
+ void error(const CFStringRef& msg) const;
#endif
- /**
- Log a message string with the FATAL level.
+ /**
+ Log a message string with the FATAL level.
- <p>This method first checks if this logger is <code>FATAL</code>
- enabled by comparing the level of this logger with the
- FATAL level. If this logger is
- <code>FATAL</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>FATAL</code>
+ enabled by comparing the level of this logger with the
+ FATAL level. If this logger is
+ <code>FATAL</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void fatal(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the ERROR level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void fatal(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void fatal(const std::string& msg) const;
+ @param msg the message string to log.
+ */
+ void fatal(const std::string& msg) const;
#if LOG4CXX_WCHAR_T_API
- /**
- Log a message string with the ERROR level.
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void fatal(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the ERROR level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void fatal(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void fatal(const std::wstring& msg) const;
+ @param msg the message string to log.
+ */
+ void fatal(const std::wstring& msg) const;
#endif
#if LOG4CXX_UNICHAR_API
- /**
- Log a message string with the ERROR level.
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void fatal(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the ERROR level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void fatal(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void fatal(const std::basic_string<UniChar>& msg) const;
+ @param msg the message string to log.
+ */
+ void fatal(const std::basic_string<UniChar>& msg) const;
#endif
#if LOG4CXX_CFSTRING_API
- /**
- Log a message string with the ERROR level.
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void fatal(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the ERROR level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void fatal(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the ERROR level.
- <p>This method first checks if this logger is <code>ERROR</code>
- enabled by comparing the level of this logger with the
- ERROR level. If this logger is
- <code>ERROR</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>ERROR</code>
+ enabled by comparing the level of this logger with the
+ ERROR level. If this logger is
+ <code>ERROR</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void fatal(const CFStringRef& msg) const;
+ @param msg the message string to log.
+ */
+ void fatal(const CFStringRef& msg) const;
#endif
- /**
- This method creates a new logging event and logs the event
- without further checks.
- @param level the level to log.
- @param message message.
- @param location location of source of logging request.
- */
- void forcedLog(const LevelPtr& level, const std::string& message,
- const log4cxx::spi::LocationInfo& location) const;
- /**
- This method creates a new logging event and logs the event
- without further checks.
- @param level the level to log.
- @param message message.
- */
- void forcedLog(const LevelPtr& level, const std::string& message) const;
+ /**
+ This method creates a new logging event and logs the event
+ without further checks.
+ @param level the level to log.
+ @param message message.
+ @param location location of source of logging request.
+ */
+ void forcedLog(const LevelPtr& level, const std::string& message,
+ const log4cxx::spi::LocationInfo& location) const;
+ /**
+ This method creates a new logging event and logs the event
+ without further checks.
+ @param level the level to log.
+ @param message message.
+ */
+ void forcedLog(const LevelPtr& level, const std::string& message) const;
#if LOG4CXX_WCHAR_T_API
- /**
- This method creates a new logging event and logs the event
- without further checks.
- @param level the level to log.
- @param message message.
- @param location location of source of logging request.
- */
- void forcedLog(const LevelPtr& level, const std::wstring& message,
- const log4cxx::spi::LocationInfo& location) const;
- /**
- This method creates a new logging event and logs the event
- without further checks.
- @param level the level to log.
- @param message message.
- */
- void forcedLog(const LevelPtr& level, const std::wstring& message) const;
+ /**
+ This method creates a new logging event and logs the event
+ without further checks.
+ @param level the level to log.
+ @param message message.
+ @param location location of source of logging request.
+ */
+ void forcedLog(const LevelPtr& level, const std::wstring& message,
+ const log4cxx::spi::LocationInfo& location) const;
+ /**
+ This method creates a new logging event and logs the event
+ without further checks.
+ @param level the level to log.
+ @param message message.
+ */
+ void forcedLog(const LevelPtr& level, const std::wstring& message) const;
#endif
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
- /**
- This method creates a new logging event and logs the event
- without further checks.
- @param level the level to log.
- @param message message.
- @param location location of source of logging request.
- */
- void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message,
- const log4cxx::spi::LocationInfo& location) const;
- /**
- This method creates a new logging event and logs the event
- without further checks.
- @param level the level to log.
- @param message message.
- */
- void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
+ /**
+ This method creates a new logging event and logs the event
+ without further checks.
+ @param level the level to log.
+ @param message message.
+ @param location location of source of logging request.
+ */
+ void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message,
+ const log4cxx::spi::LocationInfo& location) const;
+ /**
+ This method creates a new logging event and logs the event
+ without further checks.
+ @param level the level to log.
+ @param message message.
+ */
+ void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
#endif
#if LOG4CXX_CFSTRING_API
- /**
- This method creates a new logging event and logs the event
- without further checks.
- @param level the level to log.
- @param message message.
- @param location location of source of logging request.
- */
- void forcedLog(const LevelPtr& level, const CFStringRef& message,
- const log4cxx::spi::LocationInfo& location) const;
- /**
- This method creates a new logging event and logs the event
- without further checks.
- @param level the level to log.
- @param message message.
- */
- void forcedLog(const LevelPtr& level, const CFStringRef& message) const;
+ /**
+ This method creates a new logging event and logs the event
+ without further checks.
+ @param level the level to log.
+ @param message message.
+ @param location location of source of logging request.
+ */
+ void forcedLog(const LevelPtr& level, const CFStringRef& message,
+ const log4cxx::spi::LocationInfo& location) const;
+ /**
+ This method creates a new logging event and logs the event
+ without further checks.
+ @param level the level to log.
+ @param message message.
+ */
+ void forcedLog(const LevelPtr& level, const CFStringRef& message) const;
#endif
- /**
- This method creates a new logging event and logs the event
- without further checks.
- @param level the level to log.
- @param message the message string to log.
- @param location location of the logging statement.
- */
- void forcedLogLS(const LevelPtr& level, const LogString& message,
- const log4cxx::spi::LocationInfo& location) const;
+ /**
+ This method creates a new logging event and logs the event
+ without further checks.
+ @param level the level to log.
+ @param message the message string to log.
+ @param location location of the logging statement.
+ */
+ void forcedLogLS(const LevelPtr& level, const LogString& message,
+ const log4cxx::spi::LocationInfo& location) const;
- /**
- Get the additivity flag for this Logger instance.
- */
- bool getAdditivity() const;
+ /**
+ Get the additivity flag for this Logger instance.
+ */
+ bool getAdditivity() const;
- /**
- Get the appenders contained in this logger as an AppenderList.
- If no appenders can be found, then an empty AppenderList
- is returned.
- @return AppenderList An collection of the appenders in this logger.*/
- AppenderList getAllAppenders() const;
+ /**
+ Get the appenders contained in this logger as an AppenderList.
+ If no appenders can be found, then an empty AppenderList
+ is returned.
+ @return AppenderList An collection of the appenders in this logger.*/
+ AppenderList getAllAppenders() const;
- /**
- Look for the appender named as <code>name</code>.
- <p>Return the appender with that name if in the list. Return
- <code>NULL</code> otherwise. */
- AppenderPtr getAppender(const LogString& name) const;
+ /**
+ Look for the appender named as <code>name</code>.
+ <p>Return the appender with that name if in the list. Return
+ <code>NULL</code> otherwise. */
+ AppenderPtr getAppender(const LogString& name) const;
- /**
- Starting from this logger, search the logger hierarchy for a
- non-null level and return it.
+ /**
+ Starting from this logger, search the logger hierarchy for a
+ non-null level and return it.
- <p>The Logger class is designed so that this method executes as
- quickly as possible.
+ <p>The Logger class is designed so that this method executes as
+ quickly as possible.
- @throws RuntimeException if all levels are null in the hierarchy
- */
- virtual const LevelPtr& getEffectiveLevel() const;
+ @throws RuntimeException if all levels are null in the hierarchy
+ */
+ virtual const LevelPtr& getEffectiveLevel() const;
- /**
- Return the the LoggerRepository where this
- <code>Logger</code> is attached.
- */
- log4cxx::spi::LoggerRepositoryPtr getLoggerRepository() const;
+ /**
+ Return the the LoggerRepository where this
+ <code>Logger</code> is attached.
+ */
+ log4cxx::spi::LoggerRepositoryPtr getLoggerRepository() const;
- /**
- * Get the logger name.
- * @return logger name as LogString.
- */
- const LogString& getName() const
- {
- return name;
- }
- /**
- * Get logger name in current encoding.
- * @param name buffer to which name is appended.
- */
- void getName(std::string& name) const;
+ /**
+ * Get the logger name.
+ * @return logger name as LogString.
+ */
+ const LogString& getName() const
+ {
+ return name;
+ }
+ /**
+ * Get logger name in current encoding.
+ * @param name buffer to which name is appended.
+ */
+ void getName(std::string& name) const;
#if LOG4CXX_WCHAR_T_API
- /**
- * Get logger name.
- * @param name buffer to which name is appended.
- */
- void getName(std::wstring& name) const;
+ /**
+ * Get logger name.
+ * @param name buffer to which name is appended.
+ */
+ void getName(std::wstring& name) const;
#endif
#if LOG4CXX_UNICHAR_API
- /**
- * Get logger name.
- * @param name buffer to which name is appended.
- */
- void getName(std::basic_string<UniChar>& name) const;
+ /**
+ * Get logger name.
+ * @param name buffer to which name is appended.
+ */
+ void getName(std::basic_string<UniChar>& name) const;
#endif
#if LOG4CXX_CFSTRING_API
- /**
- * Get logger name.
- * @param name buffer to which name is appended.
- */
- void getName(CFStringRef& name) const;
+ /**
+ * Get logger name.
+ * @param name buffer to which name is appended.
+ */
+ void getName(CFStringRef& name) const;
#endif
- /**
- Returns the parent of this logger. Note that the parent of a
- given logger may change during the lifetime of the logger.
+ /**
+ Returns the parent of this logger. Note that the parent of a
+ given logger may change during the lifetime of the logger.
- <p>The root logger will return <code>0</code>.
- */
- LoggerPtr getParent() const;
+ <p>The root logger will return <code>0</code>.
+ */
+ LoggerPtr getParent() const;
- /**
- Returns the assigned Level, if any, for this Logger.
+ /**
+ Returns the assigned Level, if any, for this Logger.
- @return Level - the assigned Level, can be null.
- */
- LevelPtr getLevel() const;
+ @return Level - the assigned Level, can be null.
+ */
+ LevelPtr getLevel() const;
- /**
- * Retrieve a logger by name in current encoding.
- * @param name logger name.
- */
- static LoggerPtr getLogger(const std::string& name);
- /**
- * Retrieve a logger by name in current encoding.
- * @param name logger name.
- */
- static LoggerPtr getLogger(const char* const name);
+ /**
+ * Retrieve a logger by name in current encoding.
+ * @param name logger name.
+ */
+ static LoggerPtr getLogger(const std::string& name);
+ /**
+ * Retrieve a logger by name in current encoding.
+ * @param name logger name.
+ */
+ static LoggerPtr getLogger(const char* const name);
#if LOG4CXX_WCHAR_T_API
- /**
- * Retrieve a logger by name.
- * @param name logger name.
- */
- static LoggerPtr getLogger(const std::wstring& name);
- /**
- * Retrieve a logger by name.
- * @param name logger name.
- */
- static LoggerPtr getLogger(const wchar_t* const name);
+ /**
+ * Retrieve a logger by name.
+ * @param name logger name.
+ */
+ static LoggerPtr getLogger(const std::wstring& name);
+ /**
+ * Retrieve a logger by name.
+ * @param name logger name.
+ */
+ static LoggerPtr getLogger(const wchar_t* const name);
#endif
#if LOG4CXX_UNICHAR_API
- /**
- * Retrieve a logger by name.
- * @param name logger name.
- */
- static LoggerPtr getLogger(const std::basic_string<UniChar>& name);
+ /**
+ * Retrieve a logger by name.
+ * @param name logger name.
+ */
+ static LoggerPtr getLogger(const std::basic_string<UniChar>& name);
#endif
#if LOG4CXX_CFSTRING_API
- /**
- * Retrieve a logger by name.
- * @param name logger name.
- */
- static LoggerPtr getLogger(const CFStringRef& name);
+ /**
+ * Retrieve a logger by name.
+ * @param name logger name.
+ */
+ static LoggerPtr getLogger(const CFStringRef& name);
#endif
- /**
- * Retrieve a logger by name in Unicode.
- * @param name logger name.
- */
- static LoggerPtr getLoggerLS(const LogString& name);
+ /**
+ * Retrieve a logger by name in Unicode.
+ * @param name logger name.
+ */
+ static LoggerPtr getLoggerLS(const LogString& name);
- /**
- Retrieve the root logger.
- */
- static LoggerPtr getRootLogger();
+ /**
+ Retrieve the root logger.
+ */
+ static LoggerPtr getRootLogger();
- /**
- Like #getLogger except that the type of logger
- instantiated depends on the type returned by the
- LoggerFactory#makeNewLoggerInstance method of the
- <code>factory</code> parameter.
+ /**
+ Like #getLogger except that the type of logger
+ instantiated depends on the type returned by the
+ LoggerFactory#makeNewLoggerInstance method of the
+ <code>factory</code> parameter.
- <p>This method is intended to be used by sub-classes.
+ <p>This method is intended to be used by sub-classes.
- @param name The name of the logger to retrieve.
+ @param name The name of the logger to retrieve.
- @param factory A LoggerFactory implementation that will
- actually create a new Instance.
- */
- static LoggerPtr getLoggerLS(const LogString& name,
- const log4cxx::spi::LoggerFactoryPtr& factory);
- /**
- Like #getLogger except that the type of logger
- instantiated depends on the type returned by the
- LoggerFactory#makeNewLoggerInstance method of the
- <code>factory</code> parameter.
+ @param factory A LoggerFactory implementation that will
+ actually create a new Instance.
+ */
+ static LoggerPtr getLoggerLS(const LogString& name,
+ const log4cxx::spi::LoggerFactoryPtr& factory);
+ /**
+ Like #getLogger except that the type of logger
+ instantiated depends on the type returned by the
+ LoggerFactory#makeNewLoggerInstance method of the
+ <code>factory</code> parameter.
- <p>This method is intended to be used by sub-classes.
+ <p>This method is intended to be used by sub-classes.
- @param name The name of the logger to retrieve.
+ @param name The name of the logger to retrieve.
- @param factory A LoggerFactory implementation that will
- actually create a new Instance.
- */
- static LoggerPtr getLogger(const std::string& name,
- const log4cxx::spi::LoggerFactoryPtr& factory);
+ @param factory A LoggerFactory implementation that will
+ actually create a new Instance.
+ */
+ static LoggerPtr getLogger(const std::string& name,
+ const log4cxx::spi::LoggerFactoryPtr& factory);
#if LOG4CXX_WCHAR_T_API
- /**
- Like #getLogger except that the type of logger
- instantiated depends on the type returned by the
- LoggerFactory#makeNewLoggerInstance method of the
- <code>factory</code> parameter.
+ /**
+ Like #getLogger except that the type of logger
+ instantiated depends on the type returned by the
+ LoggerFactory#makeNewLoggerInstance method of the
+ <code>factory</code> parameter.
- <p>This method is intended to be used by sub-classes.
+ <p>This method is intended to be used by sub-classes.
- @param name The name of the logger to retrieve.
+ @param name The name of the logger to retrieve.
- @param factory A LoggerFactory implementation that will
- actually create a new Instance.
- */
- static LoggerPtr getLogger(const std::wstring& name,
- const log4cxx::spi::LoggerFactoryPtr& factory);
+ @param factory A LoggerFactory implementation that will
+ actually create a new Instance.
+ */
+ static LoggerPtr getLogger(const std::wstring& name,
+ const log4cxx::spi::LoggerFactoryPtr& factory);
#endif
#if LOG4CXX_UNICHAR_API
- /**
- Like #getLogger except that the type of logger
- instantiated depends on the type returned by the
- LoggerFactory#makeNewLoggerInstance method of the
- <code>factory</code> parameter.
+ /**
+ Like #getLogger except that the type of logger
+ instantiated depends on the type returned by the
+ LoggerFactory#makeNewLoggerInstance method of the
+ <code>factory</code> parameter.
- <p>This method is intended to be used by sub-classes.
+ <p>This method is intended to be used by sub-classes.
- @param name The name of the logger to retrieve.
+ @param name The name of the logger to retrieve.
- @param factory A LoggerFactory implementation that will
- actually create a new Instance.
- */
- static LoggerPtr getLogger(const std::basic_string<UniChar>& name,
- const log4cxx::spi::LoggerFactoryPtr& factory);
+ @param factory A LoggerFactory implementation that will
+ actually create a new Instance.
+ */
+ static LoggerPtr getLogger(const std::basic_string<UniChar>& name,
+ const log4cxx::spi::LoggerFactoryPtr& factory);
#endif
#if LOG4CXX_CFSTRING_API
- /**
- Like #getLogger except that the type of logger
- instantiated depends on the type returned by the
- LoggerFactory#makeNewLoggerInstance method of the
- <code>factory</code> parameter.
+ /**
+ Like #getLogger except that the type of logger
+ instantiated depends on the type returned by the
+ LoggerFactory#makeNewLoggerInstance method of the
+ <code>factory</code> parameter.
- <p>This method is intended to be used by sub-classes.
+ <p>This method is intended to be used by sub-classes.
- @param name The name of the logger to retrieve.
+ @param name The name of the logger to retrieve.
- @param factory A LoggerFactory implementation that will
- actually create a new Instance.
- */
- static LoggerPtr getLogger(const CFStringRef& name,
- const log4cxx::spi::LoggerFactoryPtr& factory);
+ @param factory A LoggerFactory implementation that will
+ actually create a new Instance.
+ */
+ static LoggerPtr getLogger(const CFStringRef& name,
+ const log4cxx::spi::LoggerFactoryPtr& factory);
#endif
- /**
- Return the <em>inherited</em> ResourceBundle for this logger.
+ /**
+ Return the <em>inherited</em> ResourceBundle for this logger.
- This method walks the hierarchy to find the appropriate resource bundle.
- It will return the resource bundle attached to the closest ancestor of
- this logger, much like the way priorities are searched. In case there
- is no bundle in the hierarchy then <code>NULL</code> is returned.
- */
- helpers::ResourceBundlePtr getResourceBundle() const;
+ This method walks the hierarchy to find the appropriate resource bundle.
+ It will return the resource bundle attached to the closest ancestor of
+ this logger, much like the way priorities are searched. In case there
+ is no bundle in the hierarchy then <code>NULL</code> is returned.
+ */
+ helpers::ResourceBundlePtr getResourceBundle() const;
- protected:
- /**
- Returns the string resource coresponding to <code>key</code> in this
- logger's inherited resource bundle.
+protected:
+ /**
+ Returns the string resource coresponding to <code>key</code> in this
+ logger's inherited resource bundle.
- If the resource cannot be found, then an {@link #error error} message
- will be logged complaining about the missing resource.
+ If the resource cannot be found, then an {@link #error error} message
+ will be logged complaining about the missing resource.
- @see #getResourceBundle.
- */
- LogString getResourceBundleString(const LogString& key) const;
+ @see #getResourceBundle.
+ */
+ LogString getResourceBundleString(const LogString& key) const;
- public:
- /**
- Log a message string with the INFO level.
+public:
+ /**
+ Log a message string with the INFO level.
- <p>This method first checks if this logger is <code>INFO</code>
- enabled by comparing the level of this logger with the
- INFO level. If this logger is
- <code>INFO</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>INFO</code>
+ enabled by comparing the level of this logger with the
+ INFO level. If this logger is
+ <code>INFO</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void info(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
- void info(const std::string& msg) const;
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void info(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
+ void info(const std::string& msg) const;
#if LOG4CXX_WCHAR_T_API
- /**
- Log a message string with the INFO level.
+ /**
+ Log a message string with the INFO level.
- <p>This method first checks if this logger is <code>INFO</code>
- enabled by comparing the level of this logger with the
- INFO level. If this logger is
- <code>INFO</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>INFO</code>
+ enabled by comparing the level of this logger with the
+ INFO level. If this logger is
+ <code>INFO</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void info(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the INFO level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void info(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the INFO level.
- <p>This method first checks if this logger is <code>INFO</code>
- enabled by comparing the level of this logger with the
- INFO level. If this logger is
- <code>INFO</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>INFO</code>
+ enabled by comparing the level of this logger with the
+ INFO level. If this logger is
+ <code>INFO</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void info(const std::wstring& msg) const;
+ @param msg the message string to log.
+ */
+ void info(const std::wstring& msg) const;
#endif
#if LOG4CXX_UNICHAR_API
- /**
- Log a message string with the INFO level.
+ /**
+ Log a message string with the INFO level.
- <p>This method first checks if this logger is <code>INFO</code>
- enabled by comparing the level of this logger with the
- INFO level. If this logger is
- <code>INFO</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>INFO</code>
+ enabled by comparing the level of this logger with the
+ INFO level. If this logger is
+ <code>INFO</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void info(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the INFO level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void info(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the INFO level.
- <p>This method first checks if this logger is <code>INFO</code>
- enabled by comparing the level of this logger with the
- INFO level. If this logger is
- <code>INFO</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>INFO</code>
+ enabled by comparing the level of this logger with the
+ INFO level. If this logger is
+ <code>INFO</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void info(const std::basic_string<UniChar>& msg) const;
+ @param msg the message string to log.
+ */
+ void info(const std::basic_string<UniChar>& msg) const;
#endif
#if LOG4CXX_CFSTRING_API
- /**
- Log a message string with the INFO level.
+ /**
+ Log a message string with the INFO level.
- <p>This method first checks if this logger is <code>INFO</code>
- enabled by comparing the level of this logger with the
- INFO level. If this logger is
- <code>INFO</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>INFO</code>
+ enabled by comparing the level of this logger with the
+ INFO level. If this logger is
+ <code>INFO</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void info(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the INFO level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void info(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the INFO level.
- <p>This method first checks if this logger is <code>INFO</code>
- enabled by comparing the level of this logger with the
- INFO level. If this logger is
- <code>INFO</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>INFO</code>
+ enabled by comparing the level of this logger with the
+ INFO level. If this logger is
+ <code>INFO</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void info(const CFStringRef& msg) const;
+ @param msg the message string to log.
+ */
+ void info(const CFStringRef& msg) const;
#endif
- /**
- Is the appender passed as parameter attached to this logger?
- */
- bool isAttached(const AppenderPtr& appender) const;
+ /**
+ Is the appender passed as parameter attached to this logger?
+ */
+ bool isAttached(const AppenderPtr& appender) const;
- /**
- * Check whether this logger is enabled for the <code>DEBUG</code>
- * Level.
- *
- * <p> This function is intended to lessen the computational cost of
- * disabled log debug statements.
- *
- * <p> For some <code>logger</code> Logger object, when you write,
- * <pre>
- * logger->debug("debug message");
- * </pre>
- *
- * <p>You incur the cost constructing the message, concatenation in
- * this case, regardless of whether the message is logged or not.
- *
- * <p>If you are worried about speed, then you should write
- * <pre>
- * if(logger->isDebugEnabled()) {
- * logger->debug("debug message");
- * }
- * </pre>
- *
- * <p>This way you will not incur the cost of parameter
- * construction if debugging is disabled for <code>logger</code>. On
- * the other hand, if the <code>logger</code> is debug enabled, you
- * will incur the cost of evaluating whether the logger is debug
- * enabled twice. Once in <code>isDebugEnabled</code> and once in
- * the <code>debug</code>. This is an insignificant overhead
- * since evaluating a logger takes about 1%% of the time it
- * takes to actually log.
- *
- * @return bool - <code>true</code> if this logger is debug
- * enabled, <code>false</code> otherwise.
- * */
- bool isDebugEnabled() const;
+ /**
+ * Check whether this logger is enabled for the <code>DEBUG</code>
+ * Level.
+ *
+ * <p> This function is intended to lessen the computational cost of
+ * disabled log debug statements.
+ *
+ * <p> For some <code>logger</code> Logger object, when you write,
+ * <pre>
+ * logger->debug("debug message");
+ * </pre>
+ *
+ * <p>You incur the cost constructing the message, concatenation in
+ * this case, regardless of whether the message is logged or not.
+ *
+ * <p>If you are worried about speed, then you should write
+ * <pre>
+ * if(logger->isDebugEnabled()) {
+ * logger->debug("debug message");
+ * }
+ * </pre>
+ *
+ * <p>This way you will not incur the cost of parameter
+ * construction if debugging is disabled for <code>logger</code>. On
+ * the other hand, if the <code>logger</code> is debug enabled, you
+ * will incur the cost of evaluating whether the logger is debug
+ * enabled twice. Once in <code>isDebugEnabled</code> and once in
+ * the <code>debug</code>. This is an insignificant overhead
+ * since evaluating a logger takes about 1%% of the time it
+ * takes to actually log.
+ *
+ * @return bool - <code>true</code> if this logger is debug
+ * enabled, <code>false</code> otherwise.
+ * */
+ bool isDebugEnabled() const;
- /**
- Check whether this logger is enabled for a given
- Level passed as parameter.
+ /**
+ Check whether this logger is enabled for a given
+ Level passed as parameter.
- See also #isDebugEnabled.
+ See also #isDebugEnabled.
- @return bool True if this logger is enabled for <code>level</code>.
- */
- bool isEnabledFor(const LevelPtr& level) const;
+ @return bool True if this logger is enabled for <code>level</code>.
+ */
+ bool isEnabledFor(const LevelPtr& level) const;
- /**
- Check whether this logger is enabled for the info Level.
- See also #isDebugEnabled.
+ /**
+ Check whether this logger is enabled for the info Level.
+ See also #isDebugEnabled.
- @return bool - <code>true</code> if this logger is enabled
- for level info, <code>false</code> otherwise.
- */
- bool isInfoEnabled() const;
+ @return bool - <code>true</code> if this logger is enabled
+ for level info, <code>false</code> otherwise.
+ */
+ bool isInfoEnabled() const;
- /**
- Check whether this logger is enabled for the warn Level.
- See also #isDebugEnabled.
+ /**
+ Check whether this logger is enabled for the warn Level.
+ See also #isDebugEnabled.
- @return bool - <code>true</code> if this logger is enabled
- for level warn, <code>false</code> otherwise.
- */
- bool isWarnEnabled() const;
+ @return bool - <code>true</code> if this logger is enabled
+ for level warn, <code>false</code> otherwise.
+ */
+ bool isWarnEnabled() const;
- /**
- Check whether this logger is enabled for the error Level.
- See also #isDebugEnabled.
+ /**
+ Check whether this logger is enabled for the error Level.
+ See also #isDebugEnabled.
- @return bool - <code>true</code> if this logger is enabled
- for level error, <code>false</code> otherwise.
- */
- bool isErrorEnabled() const;
+ @return bool - <code>true</code> if this logger is enabled
+ for level error, <code>false</code> otherwise.
+ */
+ bool isErrorEnabled() const;
- /**
- Check whether this logger is enabled for the fatal Level.
- See also #isDebugEnabled.
+ /**
+ Check whether this logger is enabled for the fatal Level.
+ See also #isDebugEnabled.
- @return bool - <code>true</code> if this logger is enabled
- for level fatal, <code>false</code> otherwise.
- */
- bool isFatalEnabled() const;
+ @return bool - <code>true</code> if this logger is enabled
+ for level fatal, <code>false</code> otherwise.
+ */
+ bool isFatalEnabled() const;
- /**
- Check whether this logger is enabled for the trace level.
- See also #isDebugEnabled.
+ /**
+ Check whether this logger is enabled for the trace level.
+ See also #isDebugEnabled.
- @return bool - <code>true</code> if this logger is enabled
- for level trace, <code>false</code> otherwise.
- */
- bool isTraceEnabled() const;
+ @return bool - <code>true</code> if this logger is enabled
+ for level trace, <code>false</code> otherwise.
+ */
+ bool isTraceEnabled() const;
- /**
- Log a localized and parameterized message.
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param values The values for the placeholders <code>{0}</code>,
- <code>{1}</code> etc. within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param values The values for the placeholders <code>{0}</code>,
+ <code>{1}</code> etc. within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const LogString& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const std::vector<LogString>& values) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const LogString& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const std::vector<LogString>& values) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const std::string& key,
- const log4cxx::spi::LocationInfo& locationInfo) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const std::string& key,
+ const log4cxx::spi::LocationInfo& locationInfo) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param val1 The first value for the placeholders within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param val1 The first value for the placeholders within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const std::string& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const std::string& val1) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const std::string& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const std::string& val1) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param val1 The first value for the placeholders within the pattern.
- @param val2 The second value for the placeholders within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param val1 The first value for the placeholders within the pattern.
+ @param val2 The second value for the placeholders within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const std::string& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const std::string& val1, const std::string& val2) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const std::string& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const std::string& val1, const std::string& val2) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param val1 The value for the first placeholder within the pattern.
- @param val2 The value for the second placeholder within the pattern.
- @param val3 The value for the third placeholder within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param val1 The value for the first placeholder within the pattern.
+ @param val2 The value for the second placeholder within the pattern.
+ @param val3 The value for the third placeholder within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const std::string& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const std::string& val1, const std::string& val2, const std::string& val3) const;
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const std::string& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const std::string& val1, const std::string& val2, const std::string& val3) const;
#if LOG4CXX_WCHAR_T_API
- /**
- Log a localized and parameterized message.
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const std::wstring& key,
- const log4cxx::spi::LocationInfo& locationInfo) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const std::wstring& key,
+ const log4cxx::spi::LocationInfo& locationInfo) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param val1 The value for the first placeholder within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param val1 The value for the first placeholder within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const std::wstring& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const std::wstring& val1) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const std::wstring& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const std::wstring& val1) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param val1 The value for the first placeholder within the pattern.
- @param val2 The value for the second placeholder within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param val1 The value for the first placeholder within the pattern.
+ @param val2 The value for the second placeholder within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const std::wstring& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const std::wstring& val1, const std::wstring& val2) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const std::wstring& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const std::wstring& val1, const std::wstring& val2) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param val1 The value for the first placeholder within the pattern.
- @param val2 The value for the second placeholder within the pattern.
- @param val3 The value for the third placeholder within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param val1 The value for the first placeholder within the pattern.
+ @param val2 The value for the second placeholder within the pattern.
+ @param val3 The value for the third placeholder within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const std::wstring& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const std::wstring& val1, const std::wstring& val2, const std::wstring& val3) const;
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const std::wstring& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const std::wstring& val1, const std::wstring& val2, const std::wstring& val3) const;
#endif
#if LOG4CXX_UNICHAR_API
- /**
- Log a localized and parameterized message.
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
- const log4cxx::spi::LocationInfo& locationInfo) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
+ const log4cxx::spi::LocationInfo& locationInfo) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param val1 The value for the first placeholder within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param val1 The value for the first placeholder within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const std::basic_string<UniChar>& val1) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const std::basic_string<UniChar>& val1) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param val1 The value for the first placeholder within the pattern.
- @param val2 The value for the second placeholder within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param val1 The value for the first placeholder within the pattern.
+ @param val2 The value for the second placeholder within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param val1 The value for the first placeholder within the pattern.
- @param val2 The value for the second placeholder within the pattern.
- @param val3 The value for the third placeholder within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param val1 The value for the first placeholder within the pattern.
+ @param val2 The value for the second placeholder within the pattern.
+ @param val3 The value for the third placeholder within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2,
- const std::basic_string<UniChar>& val3) const;
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const std::basic_string<UniChar>& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const std::basic_string<UniChar>& val1, const std::basic_string<UniChar>& val2,
+ const std::basic_string<UniChar>& val3) const;
#endif
#if LOG4CXX_CFSTRING_API
- /**
- Log a localized and parameterized message.
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const CFStringRef& key,
- const log4cxx::spi::LocationInfo& locationInfo) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const CFStringRef& key,
+ const log4cxx::spi::LocationInfo& locationInfo) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param val1 The value for the first placeholder within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param val1 The value for the first placeholder within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const CFStringRef& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const CFStringRef& val1) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const CFStringRef& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const CFStringRef& val1) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param val1 The value for the first placeholder within the pattern.
- @param val2 The value for the second placeholder within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param val1 The value for the first placeholder within the pattern.
+ @param val2 The value for the second placeholder within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const CFStringRef& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const CFStringRef& val1, const CFStringRef& val2) const;
- /**
- Log a localized and parameterized message.
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const CFStringRef& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const CFStringRef& val1, const CFStringRef& val2) const;
+ /**
+ Log a localized and parameterized message.
- First, the user supplied
- <code>key</code> is searched in the resource bundle. Next, the resulting
- pattern is formatted using helpers::StringHelper::format method with the user
- supplied string array <code>params</code>.
+ First, the user supplied
+ <code>key</code> is searched in the resource bundle. Next, the resulting
+ pattern is formatted using helpers::StringHelper::format method with the user
+ supplied string array <code>params</code>.
- @param level The level of the logging request.
- @param key The key to be searched in the ResourceBundle.
- @param locationInfo The location info of the logging request.
- @param val1 The value for the first placeholder within the pattern.
- @param val2 The value for the second placeholder within the pattern.
- @param val3 The value for the third placeholder within the pattern.
+ @param level The level of the logging request.
+ @param key The key to be searched in the ResourceBundle.
+ @param locationInfo The location info of the logging request.
+ @param val1 The value for the first placeholder within the pattern.
+ @param val2 The value for the second placeholder within the pattern.
+ @param val3 The value for the third placeholder within the pattern.
- @see #setResourceBundle
- */
- void l7dlog(const LevelPtr& level, const CFStringRef& key,
- const log4cxx::spi::LocationInfo& locationInfo,
- const CFStringRef& val1, const CFStringRef& val2,
- const CFStringRef& val3) const;
+ @see #setResourceBundle
+ */
+ void l7dlog(const LevelPtr& level, const CFStringRef& key,
+ const log4cxx::spi::LocationInfo& locationInfo,
+ const CFStringRef& val1, const CFStringRef& val2,
+ const CFStringRef& val3) const;
#endif
- /**
- This is the most generic printing method. It is intended to be
- invoked by <b>wrapper</b> classes.
+ /**
+ This is the most generic printing method. It is intended to be
+ invoked by <b>wrapper</b> classes.
- @param level The level of the logging request.
- @param message The message of the logging request.
- @param location The source file of the logging request, may be null. */
- void log(const LevelPtr& level, const std::string& message,
- const log4cxx::spi::LocationInfo& location) const;
- /**
- This is the most generic printing method. It is intended to be
- invoked by <b>wrapper</b> classes.
+ @param level The level of the logging request.
+ @param message The message of the logging request.
+ @param location The source file of the logging request, may be null. */
+ void log(const LevelPtr& level, const std::string& message,
+ const log4cxx::spi::LocationInfo& location) const;
+ /**
+ This is the most generic printing method. It is intended to be
+ invoked by <b>wrapper</b> classes.
- @param level The level of the logging request.
- @param message The message of the logging request.
- */
- void log(const LevelPtr& level, const std::string& message) const;
+ @param level The level of the logging request.
+ @param message The message of the logging request.
+ */
+ void log(const LevelPtr& level, const std::string& message) const;
#if LOG4CXX_WCHAR_T_API
- /**
- This is the most generic printing method. It is intended to be
- invoked by <b>wrapper</b> classes.
+ /**
+ This is the most generic printing method. It is intended to be
+ invoked by <b>wrapper</b> classes.
- @param level The level of the logging request.
- @param message The message of the logging request.
- @param location The source file of the logging request, may be null. */
- void log(const LevelPtr& level, const std::wstring& message,
- const log4cxx::spi::LocationInfo& location) const;
- /**
- This is the most generic printing method. It is intended to be
- invoked by <b>wrapper</b> classes.
+ @param level The level of the logging request.
+ @param message The message of the logging request.
+ @param location The source file of the logging request, may be null. */
+ void log(const LevelPtr& level, const std::wstring& message,
+ const log4cxx::spi::LocationInfo& location) const;
+ /**
+ This is the most generic printing method. It is intended to be
+ invoked by <b>wrapper</b> classes.
- @param level The level of the logging request.
- @param message The message of the logging request.
- */
- void log(const LevelPtr& level, const std::wstring& message) const;
+ @param level The level of the logging request.
+ @param message The message of the logging request.
+ */
+ void log(const LevelPtr& level, const std::wstring& message) const;
#endif
#if LOG4CXX_UNICHAR_API
- /**
- This is the most generic printing method. It is intended to be
- invoked by <b>wrapper</b> classes.
+ /**
+ This is the most generic printing method. It is intended to be
+ invoked by <b>wrapper</b> classes.
- @param level The level of the logging request.
- @param message The message of the logging request.
- @param location The source file of the logging request, may be null. */
- void log(const LevelPtr& level, const std::basic_string<UniChar>& message,
- const log4cxx::spi::LocationInfo& location) const;
- /**
- This is the most generic printing method. It is intended to be
- invoked by <b>wrapper</b> classes.
+ @param level The level of the logging request.
+ @param message The message of the logging request.
+ @param location The source file of the logging request, may be null. */
+ void log(const LevelPtr& level, const std::basic_string<UniChar>& message,
+ const log4cxx::spi::LocationInfo& location) const;
+ /**
+ This is the most generic printing method. It is intended to be
+ invoked by <b>wrapper</b> classes.
- @param level The level of the logging request.
- @param message The message of the logging request.
- */
- void log(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
+ @param level The level of the logging request.
+ @param message The message of the logging request.
+ */
+ void log(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
#endif
#if LOG4CXX_CFSTRING_API
- /**
- This is the most generic printing method. It is intended to be
- invoked by <b>wrapper</b> classes.
+ /**
+ This is the most generic printing method. It is intended to be
+ invoked by <b>wrapper</b> classes.
- @param level The level of the logging request.
- @param message The message of the logging request.
- @param location The source file of the logging request, may be null. */
- void log(const LevelPtr& level, const CFStringRef& message,
- const log4cxx::spi::LocationInfo& location) const;
- /**
- This is the most generic printing method. It is intended to be
- invoked by <b>wrapper</b> classes.
+ @param level The level of the logging request.
+ @param message The message of the logging request.
+ @param location The source file of the logging request, may be null. */
+ void log(const LevelPtr& level, const CFStringRef& message,
+ const log4cxx::spi::LocationInfo& location) const;
+ /**
+ This is the most generic printing method. It is intended to be
+ invoked by <b>wrapper</b> classes.
- @param level The level of the logging request.
- @param message The message of the logging request.
- */
- void log(const LevelPtr& level, const CFStringRef& message) const;
+ @param level The level of the logging request.
+ @param message The message of the logging request.
+ */
+ void log(const LevelPtr& level, const CFStringRef& message) const;
#endif
- /**
- This is the most generic printing method. It is intended to be
- invoked by <b>wrapper</b> classes.
+ /**
+ This is the most generic printing method. It is intended to be
+ invoked by <b>wrapper</b> classes.
- @param level The level of the logging request.
- @param message The message of the logging request.
- @param location The source file of the logging request, may be null. */
- void logLS(const LevelPtr& level, const LogString& message,
- const log4cxx::spi::LocationInfo& location) const;
+ @param level The level of the logging request.
+ @param message The message of the logging request.
+ @param location The source file of the logging request, may be null. */
+ void logLS(const LevelPtr& level, const LogString& message,
+ const log4cxx::spi::LocationInfo& location) const;
- /**
- Remove all previously added appenders from this logger
- instance.
- <p>This is useful when re-reading configuration information.
- */
- void removeAllAppenders();
+ /**
+ Remove all previously added appenders from this logger
+ instance.
+ <p>This is useful when re-reading configuration information.
+ */
+ void removeAllAppenders();
- /**
- Remove the appender passed as parameter form the list of appenders.
- */
- void removeAppender(const AppenderPtr& appender);
+ /**
+ Remove the appender passed as parameter form the list of appenders.
+ */
+ void removeAppender(const AppenderPtr& appender);
- /**
- Remove the appender with the name passed as parameter form the
- list of appenders.
- */
- void removeAppender(const LogString& name);
+ /**
+ Remove the appender with the name passed as parameter form the
+ list of appenders.
+ */
+ void removeAppender(const LogString& name);
- /**
- Set the additivity flag for this Logger instance.
- */
- void setAdditivity(bool additive);
+ /**
+ Set the additivity flag for this Logger instance.
+ */
+ void setAdditivity(bool additive);
- protected:
- friend class Hierarchy;
- /**
- Only the Hierarchy class can set the hierarchy of a logger.*/
- void setHierarchy(spi::LoggerRepository* repository);
+protected:
+ friend class Hierarchy;
+ /**
+ Only the Hierarchy class can set the hierarchy of a logger.*/
+ void setHierarchy(spi::LoggerRepository* repository);
- public:
- /**
- Set the level of this Logger.
+public:
+ /**
+ Set the level of this Logger.
- <p>As in <pre> logger->setLevel(Level::getDebug()); </pre>
+ <p>As in <pre> logger->setLevel(Level::getDebug()); </pre>
- <p>Null values are admitted. */
- virtual void setLevel(const LevelPtr& level);
+ <p>Null values are admitted. */
+ virtual void setLevel(const LevelPtr& level);
- /**
- Set the resource bundle to be used with localized logging methods.
- */
- inline void setResourceBundle(const helpers::ResourceBundlePtr& bundle)
- {
- resourceBundle = bundle;
- }
+ /**
+ Set the resource bundle to be used with localized logging methods.
+ */
+ inline void setResourceBundle(const helpers::ResourceBundlePtr& bundle)
+ {
+ resourceBundle = bundle;
+ }
#if LOG4CXX_WCHAR_T_API
- /**
- Log a message string with the WARN level.
+ /**
+ Log a message string with the WARN level.
- <p>This method first checks if this logger is <code>WARN</code>
- enabled by comparing the level of this logger with the
- WARN level. If this logger is
- <code>WARN</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>WARN</code>
+ enabled by comparing the level of this logger with the
+ WARN level. If this logger is
+ <code>WARN</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void warn(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the WARN level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void warn(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the WARN level.
- <p>This method first checks if this logger is <code>WARN</code>
- enabled by comparing the level of this logger with the
- WARN level. If this logger is
- <code>WARN</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>WARN</code>
+ enabled by comparing the level of this logger with the
+ WARN level. If this logger is
+ <code>WARN</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void warn(const std::wstring& msg) const;
+ @param msg the message string to log.
+ */
+ void warn(const std::wstring& msg) const;
#endif
#if LOG4CXX_UNICHAR_API
- /**
- Log a message string with the WARN level.
+ /**
+ Log a message string with the WARN level.
- <p>This method first checks if this logger is <code>WARN</code>
- enabled by comparing the level of this logger with the
- WARN level. If this logger is
- <code>WARN</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>WARN</code>
+ enabled by comparing the level of this logger with the
+ WARN level. If this logger is
+ <code>WARN</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void warn(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the WARN level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void warn(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the WARN level.
- <p>This method first checks if this logger is <code>WARN</code>
- enabled by comparing the level of this logger with the
- WARN level. If this logger is
- <code>WARN</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>WARN</code>
+ enabled by comparing the level of this logger with the
+ WARN level. If this logger is
+ <code>WARN</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void warn(const std::basic_string<UniChar>& msg) const;
+ @param msg the message string to log.
+ */
+ void warn(const std::basic_string<UniChar>& msg) const;
#endif
#if LOG4CXX_CFSTRING_API
- /**
- Log a message string with the WARN level.
+ /**
+ Log a message string with the WARN level.
- <p>This method first checks if this logger is <code>WARN</code>
- enabled by comparing the level of this logger with the
- WARN level. If this logger is
- <code>WARN</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>WARN</code>
+ enabled by comparing the level of this logger with the
+ WARN level. If this logger is
+ <code>WARN</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void warn(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the WARN level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void warn(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the WARN level.
- <p>This method first checks if this logger is <code>WARN</code>
- enabled by comparing the level of this logger with the
- WARN level. If this logger is
- <code>WARN</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>WARN</code>
+ enabled by comparing the level of this logger with the
+ WARN level. If this logger is
+ <code>WARN</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void warn(const CFStringRef& msg) const;
+ @param msg the message string to log.
+ */
+ void warn(const CFStringRef& msg) const;
#endif
- /**
- Log a message string with the WARN level.
+ /**
+ Log a message string with the WARN level.
- <p>This method first checks if this logger is <code>WARN</code>
- enabled by comparing the level of this logger with the
- WARN level. If this logger is
- <code>WARN</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>WARN</code>
+ enabled by comparing the level of this logger with the
+ WARN level. If this logger is
+ <code>WARN</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void warn(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the WARN level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void warn(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the WARN level.
- <p>This method first checks if this logger is <code>WARN</code>
- enabled by comparing the level of this logger with the
- WARN level. If this logger is
- <code>WARN</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>WARN</code>
+ enabled by comparing the level of this logger with the
+ WARN level. If this logger is
+ <code>WARN</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void warn(const std::string& msg) const;
+ @param msg the message string to log.
+ */
+ void warn(const std::string& msg) const;
#if LOG4CXX_WCHAR_T_API
- /**
- Log a message string with the TRACE level.
+ /**
+ Log a message string with the TRACE level.
- <p>This method first checks if this logger is <code>TRACE</code>
- enabled by comparing the level of this logger with the
- TRACE level. If this logger is
- <code>TRACE</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>TRACE</code>
+ enabled by comparing the level of this logger with the
+ TRACE level. If this logger is
+ <code>TRACE</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void trace(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the TRACE level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void trace(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the TRACE level.
- <p>This method first checks if this logger is <code>TRACE</code>
- enabled by comparing the level of this logger with the
- TRACE level. If this logger is
- <code>TRACE</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>TRACE</code>
+ enabled by comparing the level of this logger with the
+ TRACE level. If this logger is
+ <code>TRACE</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void trace(const std::wstring& msg) const;
+ @param msg the message string to log.
+ */
+ void trace(const std::wstring& msg) const;
#endif
#if LOG4CXX_UNICHAR_API
- /**
- Log a message string with the TRACE level.
+ /**
+ Log a message string with the TRACE level.
- <p>This method first checks if this logger is <code>TRACE</code>
- enabled by comparing the level of this logger with the
- TRACE level. If this logger is
- <code>TRACE</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>TRACE</code>
+ enabled by comparing the level of this logger with the
+ TRACE level. If this logger is
+ <code>TRACE</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void trace(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the TRACE level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void trace(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the TRACE level.
- <p>This method first checks if this logger is <code>TRACE</code>
- enabled by comparing the level of this logger with the
- TRACE level. If this logger is
- <code>TRACE</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>TRACE</code>
+ enabled by comparing the level of this logger with the
+ TRACE level. If this logger is
+ <code>TRACE</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void trace(const std::basic_string<UniChar>& msg) const;
+ @param msg the message string to log.
+ */
+ void trace(const std::basic_string<UniChar>& msg) const;
#endif
#if LOG4CXX_CFSTRING_API
- /**
- Log a message string with the TRACE level.
+ /**
+ Log a message string with the TRACE level.
- <p>This method first checks if this logger is <code>TRACE</code>
- enabled by comparing the level of this logger with the
- TRACE level. If this logger is
- <code>TRACE</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>TRACE</code>
+ enabled by comparing the level of this logger with the
+ TRACE level. If this logger is
+ <code>TRACE</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void trace(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the TRACE level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void trace(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the TRACE level.
- <p>This method first checks if this logger is <code>TRACE</code>
- enabled by comparing the level of this logger with the
- TRACE level. If this logger is
- <code>TRACE</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>TRACE</code>
+ enabled by comparing the level of this logger with the
+ TRACE level. If this logger is
+ <code>TRACE</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void trace(const CFStringRef& msg) const;
+ @param msg the message string to log.
+ */
+ void trace(const CFStringRef& msg) const;
#endif
- /**
- Log a message string with the TRACE level.
+ /**
+ Log a message string with the TRACE level.
- <p>This method first checks if this logger is <code>TRACE</code>
- enabled by comparing the level of this logger with the
- TRACE level. If this logger is
- <code>TRACE</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>TRACE</code>
+ enabled by comparing the level of this logger with the
+ TRACE level. If this logger is
+ <code>TRACE</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- @param location location of source of logging request.
- */
- void trace(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
- /**
- Log a message string with the TRACE level.
+ @param msg the message string to log.
+ @param location location of source of logging request.
+ */
+ void trace(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
+ /**
+ Log a message string with the TRACE level.
- <p>This method first checks if this logger is <code>TRACE</code>
- enabled by comparing the level of this logger with the
- TRACE level. If this logger is
- <code>TRACE</code> enabled, it proceeds to call all the
- registered appenders in this logger and also higher in the
- hierarchy depending on the value of the additivity flag.
+ <p>This method first checks if this logger is <code>TRACE</code>
+ enabled by comparing the level of this logger with the
+ TRACE level. If this logger is
+ <code>TRACE</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
- @param msg the message string to log.
- */
- void trace(const std::string& msg) const;
+ @param msg the message string to log.
+ */
+ void trace(const std::string& msg) const;
- inline SHARED_MUTEX& getMutex()
- {
- return mutex;
- }
+ /**
+ * Reconfigure this logger by configuring all of the appenders.
+ *
+ * @param appenders The appenders to set. Any currently existing appenders are removed.
+ * @param additivity The additivity of this logger
+ */
+ void reconfigure( const std::vector<AppenderPtr>& appenders, bool additivity );
- private:
- //
- // prevent copy and assignment
- Logger(const Logger&);
- Logger& operator=(const Logger&);
- mutable SHARED_MUTEX mutex;
- friend class log4cxx::helpers::synchronized;
+private:
+ //
+ // prevent copy and assignment
+ Logger(const Logger&);
+ Logger& operator=(const Logger&);
+ mutable std::shared_mutex mutex;
+ friend class log4cxx::helpers::synchronized;
};
LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
@@ -1740,23 +1742,23 @@
*/
#if !defined(LOG4CXX_UNLIKELY)
- #if __GNUC__ >= 3
- /**
- Provides optimization hint to the compiler
- to optimize for the expression being false.
- @param expr boolean expression.
- @returns value of expression.
- */
- #define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0)
- #else
- /**
- Provides optimization hint to the compiler
- to optimize for the expression being false.
- @param expr boolean expression.
- @returns value of expression.
- **/
- #define LOG4CXX_UNLIKELY(expr) expr
- #endif
+#if __GNUC__ >= 3
+/**
+Provides optimization hint to the compiler
+to optimize for the expression being false.
+@param expr boolean expression.
+@returns value of expression.
+*/
+#define LOG4CXX_UNLIKELY(expr) __builtin_expect(expr, 0)
+#else
+/**
+Provides optimization hint to the compiler
+to optimize for the expression being false.
+@param expr boolean expression.
+@returns value of expression.
+**/
+#define LOG4CXX_UNLIKELY(expr) expr
+#endif
#endif
@@ -1941,7 +1943,7 @@
/**@}*/
#if defined(_MSC_VER)
- #pragma warning ( pop )
+#pragma warning ( pop )
#endif
#include <log4cxx/spi/loggerrepository.h>
diff --git a/src/main/include/log4cxx/net/socketappenderskeleton.h b/src/main/include/log4cxx/net/socketappenderskeleton.h
index 184374f..c278c33 100644
--- a/src/main/include/log4cxx/net/socketappenderskeleton.h
+++ b/src/main/include/log4cxx/net/socketappenderskeleton.h
@@ -20,7 +20,8 @@
#include <log4cxx/appenderskeleton.h>
#include <log4cxx/helpers/socket.h>
-#include <log4cxx/helpers/thread.h>
+#include <thread>
+#include <atomic>
#include <log4cxx/helpers/objectoutputstream.h>
#if defined(_MSC_VER)
@@ -189,8 +190,11 @@
connection is droppped.
*/
- helpers::Thread thread;
- static void* LOG4CXX_THREAD_FUNC monitor(apr_thread_t* thread, void* data);
+ std::thread thread;
+ std::condition_variable interrupt;
+ std::mutex interrupt_mutex;
+ void monitor();
+ bool is_closed();
SocketAppenderSkeleton(const SocketAppenderSkeleton&);
SocketAppenderSkeleton& operator=(const SocketAppenderSkeleton&);
diff --git a/src/main/include/log4cxx/net/sockethubappender.h b/src/main/include/log4cxx/net/sockethubappender.h
index 69bc10c..b7bdc5b 100644
--- a/src/main/include/log4cxx/net/sockethubappender.h
+++ b/src/main/include/log4cxx/net/sockethubappender.h
@@ -26,7 +26,7 @@
#include <log4cxx/appenderskeleton.h>
#include <vector>
-#include <log4cxx/helpers/thread.h>
+#include <thread>
#include <log4cxx/helpers/objectoutputstream.h>
@@ -193,8 +193,8 @@
private:
void startServer();
- helpers::Thread thread;
- static void* LOG4CXX_THREAD_FUNC monitor(apr_thread_t* thread, void* data);
+ std::thread thread;
+ void monitor();
}; // class SocketHubAppender
LOG4CXX_PTR_DEF(SocketHubAppender);
diff --git a/src/main/include/log4cxx/net/telnetappender.h b/src/main/include/log4cxx/net/telnetappender.h
index 8f91ee9..9d0d66a 100644
--- a/src/main/include/log4cxx/net/telnetappender.h
+++ b/src/main/include/log4cxx/net/telnetappender.h
@@ -28,7 +28,7 @@
#include <log4cxx/appenderskeleton.h>
#include <log4cxx/helpers/socket.h>
#include <log4cxx/helpers/serversocket.h>
-#include <log4cxx/helpers/thread.h>
+#include <thread>
#include <vector>
#include <log4cxx/helpers/charsetencoder.h>
@@ -147,9 +147,9 @@
LogString encoding;
log4cxx::helpers::CharsetEncoderPtr encoder;
helpers::ServerSocket* serverSocket;
- helpers::Thread sh;
+ std::thread sh;
size_t activeConnections;
- static void* LOG4CXX_THREAD_FUNC acceptConnections(apr_thread_t* thread, void* data);
+ void acceptConnections();
}; // class TelnetAppender
LOG4CXX_PTR_DEF(TelnetAppender);
diff --git a/src/main/include/log4cxx/propertyconfigurator.h b/src/main/include/log4cxx/propertyconfigurator.h
index d4611fe..c2b6f7d 100644
--- a/src/main/include/log4cxx/propertyconfigurator.h
+++ b/src/main/include/log4cxx/propertyconfigurator.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_PROPERTY_CONFIGURATOR_H
#if defined(_MSC_VER)
- #pragma warning (push)
- #pragma warning ( disable: 4231 4251 4275 4786 )
+#pragma warning (push)
+#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -91,307 +91,307 @@
<code>/home/xyz</code>.
*/
class LOG4CXX_EXPORT PropertyConfigurator :
- virtual public spi::Configurator,
- virtual public helpers::ObjectImpl
+ virtual public spi::Configurator,
+ virtual public helpers::ObjectImpl
{
- protected:
+protected:
- /**
- Used internally to keep track of configured appenders.
- */
- std::map<LogString, AppenderPtr>* registry;
+ /**
+ Used internally to keep track of configured appenders.
+ */
+ std::map<LogString, AppenderPtr>* registry;
- /**
- Used to create new instances of logger
- */
- helpers::ObjectPtrT<spi::LoggerFactory> loggerFactory;
+ /**
+ Used to create new instances of logger
+ */
+ helpers::ObjectPtrT<spi::LoggerFactory> loggerFactory;
- public:
- DECLARE_LOG4CXX_OBJECT(PropertyConfigurator)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(spi::Configurator)
- END_LOG4CXX_CAST_MAP()
+public:
+ DECLARE_LOG4CXX_OBJECT(PropertyConfigurator)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(spi::Configurator)
+ END_LOG4CXX_CAST_MAP()
- PropertyConfigurator();
- virtual ~PropertyConfigurator();
- void addRef() const;
- void releaseRef() const;
+ PropertyConfigurator();
+ virtual ~PropertyConfigurator();
+ void addRef() const;
+ void releaseRef() const;
- /**
- Read configuration from a file. <b>The existing configuration is
- not cleared nor reset.</b> If you require a different behavior,
- then call {@link LogManager#resetConfiguration
- resetConfiguration} method before calling
- <code>doConfigure</code>.
+ /**
+ Read configuration from a file. <b>The existing configuration is
+ not cleared nor reset.</b> If you require a different behavior,
+ then call {@link LogManager#resetConfiguration
+ resetConfiguration} method before calling
+ <code>doConfigure</code>.
- <p>The configuration file consists of statements in the format
- <code>key=value</code>. The syntax of different configuration
- elements are discussed below.
+ <p>The configuration file consists of statements in the format
+ <code>key=value</code>. The syntax of different configuration
+ elements are discussed below.
- <h3>Repository-wide threshold</h3>
+ <h3>Repository-wide threshold</h3>
- <p>The repository-wide threshold filters logging requests by level
- regardless of logger. The syntax is:
+ <p>The repository-wide threshold filters logging requests by level
+ regardless of logger. The syntax is:
- <pre>
- log4j.threshold=[level]
- </pre>
+ <pre>
+ log4j.threshold=[level]
+ </pre>
- <p>The level value can consist of the string values OFF, FATAL,
- ERROR, WARN, INFO, DEBUG, ALL or a <em>custom level</em> value. A
- custom level value can be specified in the form
- level#classname. By default the repository-wide threshold is set
- to the lowest possible value, namely the level <code>ALL</code>.
- </p>
+ <p>The level value can consist of the string values OFF, FATAL,
+ ERROR, WARN, INFO, DEBUG, ALL or a <em>custom level</em> value. A
+ custom level value can be specified in the form
+ level#classname. By default the repository-wide threshold is set
+ to the lowest possible value, namely the level <code>ALL</code>.
+ </p>
- <h3>Appender configuration</h3>
+ <h3>Appender configuration</h3>
- <p>Appender configuration syntax is:
- <pre>
- # For appender named <i>appenderName</i>, set its class.
- # Note: The appender name can contain dots.
- log4j.appender.appenderName=fully.qualified.name.of.appender.class
+ <p>Appender configuration syntax is:
+ <pre>
+ # For appender named <i>appenderName</i>, set its class.
+ # Note: The appender name can contain dots.
+ log4j.appender.appenderName=fully.qualified.name.of.appender.class
- # Set appender specific options.
- log4j.appender.appenderName.option1=value1
- ...
- log4j.appender.appenderName.optionN=valueN
- </pre>
+ # Set appender specific options.
+ log4j.appender.appenderName.option1=value1
+ ...
+ log4j.appender.appenderName.optionN=valueN
+ </pre>
- For each named appender you can configure its {@link Layout Layout}. The
- syntax for configuring an appender's layout is:
- <pre>
- log4j.appender.appenderName.layout=fully.qualified.name.of.layout.class
- log4j.appender.appenderName.layout.option1=value1
- ....
- log4j.appender.appenderName.layout.optionN=valueN
- </pre>
+ For each named appender you can configure its {@link Layout Layout}. The
+ syntax for configuring an appender's layout is:
+ <pre>
+ log4j.appender.appenderName.layout=fully.qualified.name.of.layout.class
+ log4j.appender.appenderName.layout.option1=value1
+ ....
+ log4j.appender.appenderName.layout.optionN=valueN
+ </pre>
- <h3>Configuring loggers</h3>
+ <h3>Configuring loggers</h3>
- <p>The syntax for configuring the root logger is:
- <pre>
- log4j.rootLogger=[level], appenderName, appenderName, ...
- </pre>
+ <p>The syntax for configuring the root logger is:
+ <pre>
+ log4j.rootLogger=[level], appenderName, appenderName, ...
+ </pre>
- <p>This syntax means that an optional <em>level</em> can be
- supplied followed by appender names separated by commas.
+ <p>This syntax means that an optional <em>level</em> can be
+ supplied followed by appender names separated by commas.
- <p>The level value can consist of the string values OFF, FATAL,
- ERROR, WARN, INFO, DEBUG, ALL or a <em>custom level</em> value. A
- custom level value can be specified in the form
- <code>level#classname</code>.
+ <p>The level value can consist of the string values OFF, FATAL,
+ ERROR, WARN, INFO, DEBUG, ALL or a <em>custom level</em> value. A
+ custom level value can be specified in the form
+ <code>level#classname</code>.
- <p>If a level value is specified, then the root level is set
- to the corresponding level. If no level value is specified,
- then the root level remains untouched.
+ <p>If a level value is specified, then the root level is set
+ to the corresponding level. If no level value is specified,
+ then the root level remains untouched.
- <p>The root logger can be assigned multiple appenders.
+ <p>The root logger can be assigned multiple appenders.
- <p>Each <i>appenderName</i> (separated by commas) will be added to
- the root logger. The named appender is defined using the
- appender syntax defined above.
+ <p>Each <i>appenderName</i> (separated by commas) will be added to
+ the root logger. The named appender is defined using the
+ appender syntax defined above.
- <p>For non-root categories the syntax is almost the same:
- <pre>
- log4j.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName,
- ...
- </pre>
+ <p>For non-root categories the syntax is almost the same:
+ <pre>
+ log4j.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName,
+ ...
+ </pre>
- <p>The meaning of the optional level value is discussed above
- in relation to the root logger. In addition however, the value
- INHERITED can be specified meaning that the named logger should
- inherit its level from the logger hierarchy.
+ <p>The meaning of the optional level value is discussed above
+ in relation to the root logger. In addition however, the value
+ INHERITED can be specified meaning that the named logger should
+ inherit its level from the logger hierarchy.
- <p>If no level value is supplied, then the level of the
- named logger remains untouched.
+ <p>If no level value is supplied, then the level of the
+ named logger remains untouched.
- <p>By default categories inherit their level from the
- hierarchy. However, if you set the level of a logger and later
- decide that that logger should inherit its level, then you should
- specify INHERITED as the value for the level value. NULL is a
- synonym for INHERITED.
+ <p>By default categories inherit their level from the
+ hierarchy. However, if you set the level of a logger and later
+ decide that that logger should inherit its level, then you should
+ specify INHERITED as the value for the level value. NULL is a
+ synonym for INHERITED.
- <p>Similar to the root logger syntax, each <i>appenderName</i>
- (separated by commas) will be attached to the named logger.
+ <p>Similar to the root logger syntax, each <i>appenderName</i>
+ (separated by commas) will be attached to the named logger.
- <p>See the <a href="Introduction.html#additivity">appender
- additivity rule</a> in the user manual for the meaning of the
- <code>additivity</code> flag.
+ <p>See the <a href="Introduction.html#additivity">appender
+ additivity rule</a> in the user manual for the meaning of the
+ <code>additivity</code> flag.
- <h3>Logger Factories</h3>
+ <h3>Logger Factories</h3>
- The usage of custom logger factories is discouraged and no longer
- documented.
+ The usage of custom logger factories is discouraged and no longer
+ documented.
- <h3>Example</h3>
+ <h3>Example</h3>
- <p>An example configuration is given below. Other configuration
- file examples are given in the <code>examples</code> folder.
+ <p>An example configuration is given below. Other configuration
+ file examples are given in the <code>examples</code> folder.
- <pre>
+ <pre>
- # Set options for appender named "A1".
- # Appender "A1" will be a SyslogAppender
- log4j.appender.A1=SyslogAppender
+ # Set options for appender named "A1".
+ # Appender "A1" will be a SyslogAppender
+ log4j.appender.A1=SyslogAppender
- # The syslog daemon resides on www.abc.net
- log4j.appender.A1.SyslogHost=www.abc.net
+ # The syslog daemon resides on www.abc.net
+ log4j.appender.A1.SyslogHost=www.abc.net
- # A1's layout is a PatternLayout, using the conversion pattern
- # <b>%r %-5p %c{2} %M.%L %x - %m\n</b>. Thus, the log output will
- # include # the relative time since the start of the application in
- # milliseconds, followed by the level of the log request,
- # followed by the two rightmost components of the logger name,
- # followed by the callers method name, followed by the line number,
- # the nested disgnostic context and finally the message itself.
- # Refer to the documentation of PatternLayout for further information
- # on the syntax of the ConversionPattern key.
- log4j.appender.A1.layout=PatternLayout
- log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %c{2} %M.%L %x - %m\n
+ # A1's layout is a PatternLayout, using the conversion pattern
+ # <b>%r %-5p %c{2} %M.%L %x - %m\n</b>. Thus, the log output will
+ # include # the relative time since the start of the application in
+ # milliseconds, followed by the level of the log request,
+ # followed by the two rightmost components of the logger name,
+ # followed by the callers method name, followed by the line number,
+ # the nested disgnostic context and finally the message itself.
+ # Refer to the documentation of PatternLayout for further information
+ # on the syntax of the ConversionPattern key.
+ log4j.appender.A1.layout=PatternLayout
+ log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %c{2} %M.%L %x - %m\n
- # Set options for appender named "A2"
- # A2 should be a RollingFileAppender, with maximum file size of 10 MB
- # using at most one backup file. A2's layout is TTCC, using the
- # ISO8061 date format with context printing enabled.
- log4j.appender.A2=RollingFileAppender
- log4j.appender.A2.MaxFileSize=10MB
- log4j.appender.A2.MaxBackupIndex=1
- log4j.appender.A2.layout=TTCCLayout
- log4j.appender.A2.layout.ContextPrinting=enabled
- log4j.appender.A2.layout.DateFormat=ISO8601
+ # Set options for appender named "A2"
+ # A2 should be a RollingFileAppender, with maximum file size of 10 MB
+ # using at most one backup file. A2's layout is TTCC, using the
+ # ISO8061 date format with context printing enabled.
+ log4j.appender.A2=RollingFileAppender
+ log4j.appender.A2.MaxFileSize=10MB
+ log4j.appender.A2.MaxBackupIndex=1
+ log4j.appender.A2.layout=TTCCLayout
+ log4j.appender.A2.layout.ContextPrinting=enabled
+ log4j.appender.A2.layout.DateFormat=ISO8601
- # Root logger set to DEBUG using the A2 appender defined above.
- log4j.rootLogger=DEBUG, A2
+ # Root logger set to DEBUG using the A2 appender defined above.
+ log4j.rootLogger=DEBUG, A2
- # Logger definitions:
- # The SECURITY logger inherits is level from root. However, it's output
- # will go to A1 appender defined above. It's additivity is non-cumulative.
- log4j.logger.SECURITY=INHERIT, A1
- log4j.additivity.SECURITY=false
+ # Logger definitions:
+ # The SECURITY logger inherits is level from root. However, it's output
+ # will go to A1 appender defined above. It's additivity is non-cumulative.
+ log4j.logger.SECURITY=INHERIT, A1
+ log4j.additivity.SECURITY=false
- # Only warnings or above will be logged for the logger "SECURITY.access".
- # Output will go to A1.
- log4j.logger.SECURITY.access=WARN
+ # Only warnings or above will be logged for the logger "SECURITY.access".
+ # Output will go to A1.
+ log4j.logger.SECURITY.access=WARN
- # The logger "class.of.the.day" inherits its level from the
- # logger hierarchy. Output will go to the appender's of the root
- # logger, A2 in this case.
- log4j.logger.class.of.the.day=INHERIT
- </pre>
+ # The logger "class.of.the.day" inherits its level from the
+ # logger hierarchy. Output will go to the appender's of the root
+ # logger, A2 in this case.
+ log4j.logger.class.of.the.day=INHERIT
+ </pre>
- <p>Refer to the <b>setOption</b> method in each Appender and
- Layout for class specific options.
+ <p>Refer to the <b>setOption</b> method in each Appender and
+ Layout for class specific options.
- <p>Use the <code>#</code> or <code>!</code> characters at the
- beginning of a line for comments.
+ <p>Use the <code>#</code> or <code>!</code> characters at the
+ beginning of a line for comments.
- <p>
- @param configFileName The name of the configuration file where the
- configuration information is stored.
- @param hierarchy The hierarchy to operation upon.
- */
- void doConfigure(const File& configFileName,
- spi::LoggerRepositoryPtr& hierarchy);
+ <p>
+ @param configFileName The name of the configuration file where the
+ configuration information is stored.
+ @param hierarchy The hierarchy to operation upon.
+ */
+ void doConfigure(const File& configFileName,
+ spi::LoggerRepositoryPtr& hierarchy);
- /**
- Read configuration options from file <code>configFilename</code>.
- */
- static void configure(const File& configFilename);
+ /**
+ Read configuration options from file <code>configFilename</code>.
+ */
+ static void configure(const File& configFilename);
- /**
- Like {@link #configureAndWatch(const File& configFilename, long delay)}
- except that the
- default delay as defined by helpers::FileWatchdog#DEFAULT_DELAY
- is used.
- @param configFilename A file in key=value format.
- */
- static void configureAndWatch(const File& configFilename);
+ /**
+ Like {@link #configureAndWatch(const File& configFilename, long delay)}
+ except that the
+ default delay as defined by helpers::FileWatchdog#DEFAULT_DELAY
+ is used.
+ @param configFilename A file in key=value format.
+ */
+ static void configureAndWatch(const File& configFilename);
- /**
- Read the configuration file <code>configFilename</code> if it
- exists. Moreover, a thread will be created that will periodically
- check if <code>configFilename</code> has been created or
- modified. The period is determined by the <code>delay</code>
- argument. If a change or file creation is detected, then
- <code>configFilename</code> is read to configure log4j.
+ /**
+ Read the configuration file <code>configFilename</code> if it
+ exists. Moreover, a thread will be created that will periodically
+ check if <code>configFilename</code> has been created or
+ modified. The period is determined by the <code>delay</code>
+ argument. If a change or file creation is detected, then
+ <code>configFilename</code> is read to configure log4j.
- @param configFilename A file in key=value format.
- @param delay The delay in milliseconds to wait between each check.
- */
- static void configureAndWatch(const File& configFilename,
- long delay);
+ @param configFilename A file in key=value format.
+ @param delay The delay in milliseconds to wait between each check.
+ */
+ static void configureAndWatch(const File& configFilename,
+ long delay);
- /**
- Read configuration options from <code>properties</code>.
- See #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)
- for the expected format.
- */
- static void configure(helpers::Properties& properties);
+ /**
+ Read configuration options from <code>properties</code>.
+ See #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)
+ for the expected format.
+ */
+ static void configure(helpers::Properties& properties);
- /**
- Read configuration options from <code>properties</code>.
- See #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)
- for the expected format.
- */
- void doConfigure(helpers::Properties& properties,
- spi::LoggerRepositoryPtr& hierarchy);
+ /**
+ Read configuration options from <code>properties</code>.
+ See #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)
+ for the expected format.
+ */
+ void doConfigure(helpers::Properties& properties,
+ spi::LoggerRepositoryPtr& hierarchy);
- // --------------------------------------------------------------------------
- // Internal stuff
- // --------------------------------------------------------------------------
- protected:
- /**
- Check the provided <code>Properties</code> object for a
- #loggerFactory
- entry specified by LOGGER_FACTORY_KEY. If such an entry
- exists, an attempt is made to create an instance using the default
- constructor. This instance is used for subsequent Logger creations
- within this configurator.
- @see #parseCatsAndRenderers
- */
- void configureLoggerFactory(helpers::Properties& props);
+ // --------------------------------------------------------------------------
+ // Internal stuff
+ // --------------------------------------------------------------------------
+protected:
+ /**
+ Check the provided <code>Properties</code> object for a
+ #loggerFactory
+ entry specified by LOGGER_FACTORY_KEY. If such an entry
+ exists, an attempt is made to create an instance using the default
+ constructor. This instance is used for subsequent Logger creations
+ within this configurator.
+ @see #parseCatsAndRenderers
+ */
+ void configureLoggerFactory(helpers::Properties& props);
- void configureRootLogger(helpers::Properties& props,
- spi::LoggerRepositoryPtr& hierarchy);
+ void configureRootLogger(helpers::Properties& props,
+ spi::LoggerRepositoryPtr& hierarchy);
- /**
- Parse non-root elements, such non-root categories and renderers.
- */
- void parseCatsAndRenderers(helpers::Properties& props,
- spi::LoggerRepositoryPtr& hierarchy);
+ /**
+ Parse non-root elements, such non-root categories and renderers.
+ */
+ void parseCatsAndRenderers(helpers::Properties& props,
+ spi::LoggerRepositoryPtr& hierarchy);
- /**
- Parse the additivity option for a non-root logger.
- */
- void parseAdditivityForLogger(helpers::Properties& props,
- LoggerPtr& cat, const LogString& loggerName);
+ /**
+ Parse the additivity option for a non-root logger.
+ */
+ bool parseAdditivityForLogger(helpers::Properties& props,
+ LoggerPtr& cat, const LogString& loggerName);
- /**
- This method must work for the root logger as well.
- */
- void parseLogger(
- helpers::Properties& props, LoggerPtr& logger,
- const LogString& optionKey, const LogString& loggerName,
- const LogString& value);
+ /**
+ This method must work for the root logger as well.
+ */
+ void parseLogger(
+ helpers::Properties& props, LoggerPtr& logger,
+ const LogString& optionKey, const LogString& loggerName,
+ const LogString& value, bool additivity);
- AppenderPtr parseAppender(
- helpers::Properties& props, const LogString& appenderName);
+ AppenderPtr parseAppender(
+ helpers::Properties& props, const LogString& appenderName);
- void registryPut(const AppenderPtr& appender);
- AppenderPtr registryGet(const LogString& name);
+ void registryPut(const AppenderPtr& appender);
+ AppenderPtr registryGet(const LogString& name);
- private:
- PropertyConfigurator(const PropertyConfigurator&);
- PropertyConfigurator& operator=(const PropertyConfigurator&);
- static PropertyWatchdog* pdog;
+private:
+ PropertyConfigurator(const PropertyConfigurator&);
+ PropertyConfigurator& operator=(const PropertyConfigurator&);
+ static PropertyWatchdog* pdog;
}; // class PropertyConfigurator
} // namespace log4cxx
#if defined(_MSC_VER)
- #pragma warning (pop)
+#pragma warning (pop)
#endif
diff --git a/src/main/include/log4cxx/rolling/action.h b/src/main/include/log4cxx/rolling/action.h
index 7c4f4c7..830bdb2 100644
--- a/src/main/include/log4cxx/rolling/action.h
+++ b/src/main/include/log4cxx/rolling/action.h
@@ -20,8 +20,8 @@
#include <log4cxx/portability.h>
#include <log4cxx/helpers/objectimpl.h>
-#include <log4cxx/helpers/mutex.h>
#include <log4cxx/helpers/pool.h>
+#include <mutex>
namespace log4cxx
{
@@ -49,7 +49,7 @@
bool interrupted;
log4cxx::helpers::Pool pool;
- log4cxx::helpers::Mutex mutex;
+ std::mutex mutex;
protected:
diff --git a/src/main/include/log4cxx/rolling/rollingfileappenderskeleton.h b/src/main/include/log4cxx/rolling/rollingfileappenderskeleton.h
index e84f8ef..1663fdf 100644
--- a/src/main/include/log4cxx/rolling/rollingfileappenderskeleton.h
+++ b/src/main/include/log4cxx/rolling/rollingfileappenderskeleton.h
@@ -97,6 +97,8 @@
*/
virtual void subAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+ bool rolloverInternal(log4cxx::helpers::Pool& p);
+
protected:
RollingPolicyPtr getRollingPolicy() const;
diff --git a/src/main/include/log4cxx/writerappender.h b/src/main/include/log4cxx/writerappender.h
index 677c4de..d8c6980 100644
--- a/src/main/include/log4cxx/writerappender.h
+++ b/src/main/include/log4cxx/writerappender.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_WRITER_APPENDER_H
#if defined(_MSC_VER)
- #pragma warning ( push )
- #pragma warning ( disable: 4231 4251 4275 4786 )
+#pragma warning ( push )
+#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/appenderskeleton.h>
@@ -39,181 +39,186 @@
*/
class LOG4CXX_EXPORT WriterAppender : public AppenderSkeleton
{
- private:
- /**
- Immediate flush means that the underlying writer or output stream
- will be flushed at the end of each append operation. Immediate
- flush is slower but ensures that each append request is actually
- written. If <code>immediateFlush</code> is set to
- <code>false</code>, then there is a good chance that the last few
- logs events are not actually written to persistent media if and
- when the application crashes.
+private:
+ /**
+ Immediate flush means that the underlying writer or output stream
+ will be flushed at the end of each append operation. Immediate
+ flush is slower but ensures that each append request is actually
+ written. If <code>immediateFlush</code> is set to
+ <code>false</code>, then there is a good chance that the last few
+ logs events are not actually written to persistent media if and
+ when the application crashes.
- <p>The <code>immediateFlush</code> variable is set to
- <code>true</code> by default.
+ <p>The <code>immediateFlush</code> variable is set to
+ <code>true</code> by default.
- */
- bool immediateFlush;
+ */
+ bool immediateFlush;
- /**
- The encoding to use when opening an input stream.
- <p>The <code>encoding</code> variable is set to <code>""</code> by
- default which results in the utilization of the system's default
- encoding. */
- LogString encoding;
+ /**
+ The encoding to use when opening an input stream.
+ <p>The <code>encoding</code> variable is set to <code>""</code> by
+ default which results in the utilization of the system's default
+ encoding. */
+ LogString encoding;
- /**
- * This is the {@link Writer Writer} where we will write to.
- */
- log4cxx::helpers::WriterPtr writer;
+ /**
+ * This is the {@link Writer Writer} where we will write to.
+ */
+ log4cxx::helpers::WriterPtr writer;
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(WriterAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(WriterAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
+public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(WriterAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(WriterAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
- /**
- This default constructor does nothing.*/
- WriterAppender();
- protected:
- WriterAppender(const LayoutPtr& layout,
- log4cxx::helpers::WriterPtr& writer);
- WriterAppender(const LayoutPtr& layout);
+ /**
+ This default constructor does nothing.*/
+ WriterAppender();
+protected:
+ WriterAppender(const LayoutPtr& layout,
+ log4cxx::helpers::WriterPtr& writer);
+ WriterAppender(const LayoutPtr& layout);
- public:
- ~WriterAppender();
+public:
+ ~WriterAppender();
- /**
- Derived appenders should override this method if option structure
- requires it.
- */
- virtual void activateOptions(log4cxx::helpers::Pool& pool);
+ /**
+ Derived appenders should override this method if option structure
+ requires it.
+ */
+ virtual void activateOptions(log4cxx::helpers::Pool& pool);
- /**
- If the <b>ImmediateFlush</b> option is set to
- <code>true</code>, the appender will flush at the end of each
- write. This is the default behavior. If the option is set to
- <code>false</code>, then the underlying stream can defer writing
- to physical medium to a later time.
+ /**
+ If the <b>ImmediateFlush</b> option is set to
+ <code>true</code>, the appender will flush at the end of each
+ write. This is the default behavior. If the option is set to
+ <code>false</code>, then the underlying stream can defer writing
+ to physical medium to a later time.
- <p>Avoiding the flush operation at the end of each append results in
- a performance gain of 10 to 20 percent. However, there is safety
- tradeoff involved in skipping flushing. Indeed, when flushing is
- skipped, then it is likely that the last few log events will not
- be recorded on disk when the application exits. This is a high
- price to pay even for a 20% performance gain.
- */
- void setImmediateFlush(bool value);
- /**
- Returns value of the <b>ImmediateFlush</b> option.
- */
- bool getImmediateFlush() const
- {
- return immediateFlush;
- }
+ <p>Avoiding the flush operation at the end of each append results in
+ a performance gain of 10 to 20 percent. However, there is safety
+ tradeoff involved in skipping flushing. Indeed, when flushing is
+ skipped, then it is likely that the last few log events will not
+ be recorded on disk when the application exits. This is a high
+ price to pay even for a 20% performance gain.
+ */
+ void setImmediateFlush(bool value);
+ /**
+ Returns value of the <b>ImmediateFlush</b> option.
+ */
+ bool getImmediateFlush() const
+ {
+ return immediateFlush;
+ }
- /**
- This method is called by the AppenderSkeleton#doAppend
- method.
+ /**
+ This method is called by the AppenderSkeleton#doAppend
+ method.
- <p>If the output stream exists and is writable then write a log
- statement to the output stream. Otherwise, write a single warning
- message to <code>stderr</code>.
+ <p>If the output stream exists and is writable then write a log
+ statement to the output stream. Otherwise, write a single warning
+ message to <code>stderr</code>.
- <p>The format of the output will depend on this appender's
- layout.
+ <p>The format of the output will depend on this appender's
+ layout.
- */
- virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+ */
+ virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
- protected:
- /**
- This method determines if there is a sense in attempting to append.
+protected:
+ /**
+ This method determines if there is a sense in attempting to append.
- <p>It checks whether there is a set output target and also if
- there is a set layout. If these checks fail, then the boolean
- value <code>false</code> is returned. */
- virtual bool checkEntryConditions() const;
+ <p>It checks whether there is a set output target and also if
+ there is a set layout. If these checks fail, then the boolean
+ value <code>false</code> is returned. */
+ virtual bool checkEntryConditions() const;
- public:
- /**
- Close this appender instance. The underlying stream or writer is
- also closed.
+public:
+ /**
+ Close this appender instance. The underlying stream or writer is
+ also closed.
- <p>Closed appenders cannot be reused.
- */
- virtual void close();
+ <p>Closed appenders cannot be reused.
+ */
+ virtual void close();
- protected:
- /**
- * Close the underlying {@link log4cxx::helpers::Writer}.
- * */
- void closeWriter();
+protected:
+ /**
+ * Close the underlying {@link log4cxx::helpers::Writer}.
+ * */
+ void closeWriter();
- /**
- Returns an OutputStreamWriter when passed an OutputStream. The
- encoding used will depend on the value of the
- <code>encoding</code> property. If the encoding value is
- specified incorrectly the writer will be opened using the default
- system encoding (an error message will be printed to the loglog. */
- virtual log4cxx::helpers::WriterPtr createWriter(
- log4cxx::helpers::OutputStreamPtr& os);
+ /**
+ Returns an OutputStreamWriter when passed an OutputStream. The
+ encoding used will depend on the value of the
+ <code>encoding</code> property. If the encoding value is
+ specified incorrectly the writer will be opened using the default
+ system encoding (an error message will be printed to the loglog. */
+ virtual log4cxx::helpers::WriterPtr createWriter(
+ log4cxx::helpers::OutputStreamPtr& os);
- public:
- LogString getEncoding() const;
- void setEncoding(const LogString& value);
- void setOption(const LogString& option,
- const LogString& value);
+public:
+ LogString getEncoding() const;
+ void setEncoding(const LogString& value);
+ void setOption(const LogString& option,
+ const LogString& value);
- /**
- <p>Sets the Writer where the log output will go. The
- specified Writer must be opened by the user and be
- writable.
+ /**
+ <p>Sets the Writer where the log output will go. The
+ specified Writer must be opened by the user and be
+ writable.
- <p>The <code>java.io.Writer</code> will be closed when the
- appender instance is closed.
+ <p>The <code>java.io.Writer</code> will be closed when the
+ appender instance is closed.
- <p><b>WARNING:</b> Logging to an unopened Writer will fail.
- <p>
- @param writer An already opened Writer. */
- void setWriter(const log4cxx::helpers::WriterPtr& writer);
+ <p><b>WARNING:</b> Logging to an unopened Writer will fail.
+ <p>
+ @param writer An already opened Writer. */
+ void setWriter(const log4cxx::helpers::WriterPtr& writer);
#ifdef LOG4CXX_MULTI_PROCESS
- const log4cxx::helpers::WriterPtr getWriter()
- {
- return writer;
- };
+ const log4cxx::helpers::WriterPtr getWriter()
+ {
+ return writer;
+ };
#endif
- virtual bool requiresLayout() const;
+ virtual bool requiresLayout() const;
- protected:
- /**
- Actual writing occurs here.
- */
- virtual void subAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+protected:
+ /**
+ Actual writing occurs here.
+ */
+ virtual void subAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
- /**
- Write a footer as produced by the embedded layout's
- Layout#appendFooter method. */
- virtual void writeFooter(log4cxx::helpers::Pool& p);
+ /**
+ Write a footer as produced by the embedded layout's
+ Layout#appendFooter method. */
+ virtual void writeFooter(log4cxx::helpers::Pool& p);
- /**
- Write a header as produced by the embedded layout's
- Layout#appendHeader method. */
- virtual void writeHeader(log4cxx::helpers::Pool& p);
+ /**
+ Write a header as produced by the embedded layout's
+ Layout#appendHeader method. */
+ virtual void writeHeader(log4cxx::helpers::Pool& p);
- private:
- //
- // prevent copy and assignment
- WriterAppender(const WriterAppender&);
- WriterAppender& operator=(const WriterAppender&);
+ /**
+ * Set the writer. Mutex must already be held.
+ */
+ void setWriterInternal(const log4cxx::helpers::WriterPtr& writer);
+
+private:
+ //
+ // prevent copy and assignment
+ WriterAppender(const WriterAppender&);
+ WriterAppender& operator=(const WriterAppender&);
};
LOG4CXX_PTR_DEF(WriterAppender);
@@ -221,7 +226,7 @@
} //namespace log4cxx
#if defined(_MSC_VER)
- #pragma warning ( pop )
+#pragma warning ( pop )
#endif
#endif //_LOG4CXX_WRITER_APPENDER_H
diff --git a/src/main/include/log4cxx/xml/domconfigurator.h b/src/main/include/log4cxx/xml/domconfigurator.h
index e6ed348..8bbc7de 100644
--- a/src/main/include/log4cxx/xml/domconfigurator.h
+++ b/src/main/include/log4cxx/xml/domconfigurator.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_XML_DOM_CONFIGURATOR_H
#if defined(_MSC_VER)
- #pragma warning (push)
- #pragma warning ( disable: 4231 4251 4275 4786 )
+#pragma warning (push)
+#pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -40,8 +40,8 @@
#include <log4cxx/config/propertysetter.h>
extern "C" {
- struct apr_xml_doc;
- struct apr_xml_elem;
+ struct apr_xml_doc;
+ struct apr_xml_elem;
}
namespace log4cxx
@@ -67,251 +67,252 @@
<p>There are sample XML files included in the package.
*/
class LOG4CXX_EXPORT DOMConfigurator :
- virtual public spi::Configurator,
- virtual public helpers::ObjectImpl
+ virtual public spi::Configurator,
+ virtual public helpers::ObjectImpl
{
- protected:
- typedef std::map<LogString, AppenderPtr> AppenderMap;
- /**
- Used internally to parse appenders by IDREF name.
- */
- AppenderPtr findAppenderByName(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* elem,
- apr_xml_doc* doc,
- const LogString& appenderName,
- AppenderMap& appenders);
+protected:
+ typedef std::map<LogString, AppenderPtr> AppenderMap;
+ /**
+ Used internally to parse appenders by IDREF name.
+ */
+ AppenderPtr findAppenderByName(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* elem,
+ apr_xml_doc* doc,
+ const LogString& appenderName,
+ AppenderMap& appenders);
- /**
- Used internally to parse appenders by IDREF element.
- */
- AppenderPtr findAppenderByReference(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* appenderRef,
- apr_xml_doc* doc,
- AppenderMap& appenders);
+ /**
+ Used internally to parse appenders by IDREF element.
+ */
+ AppenderPtr findAppenderByReference(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* appenderRef,
+ apr_xml_doc* doc,
+ AppenderMap& appenders);
- /**
- Used internally to parse an appender element.
- */
- AppenderPtr parseAppender(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* appenderElement,
- apr_xml_doc* doc,
- AppenderMap& appenders);
+ /**
+ Used internally to parse an appender element.
+ */
+ AppenderPtr parseAppender(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* appenderElement,
+ apr_xml_doc* doc,
+ AppenderMap& appenders);
- /**
- Used internally to parse an {@link spi::ErrorHandler ErrorHandler } element.
- */
- void parseErrorHandler(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* element,
- AppenderPtr& appender,
- apr_xml_doc* doc,
- AppenderMap& appenders);
+ /**
+ Used internally to parse an {@link spi::ErrorHandler ErrorHandler } element.
+ */
+ void parseErrorHandler(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* element,
+ AppenderPtr& appender,
+ apr_xml_doc* doc,
+ AppenderMap& appenders);
- /**
- Used internally to parse a filter element.
- */
- void parseFilters(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* element,
- std::vector<log4cxx::spi::FilterPtr>& filters);
+ /**
+ Used internally to parse a filter element.
+ */
+ void parseFilters(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* element,
+ std::vector<log4cxx::spi::FilterPtr>& filters);
- /**
- Used internally to parse a logger element.
- */
- void parseLogger(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* loggerElement,
- apr_xml_doc* doc,
- AppenderMap& appenders);
+ /**
+ Used internally to parse a logger element.
+ */
+ void parseLogger(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* loggerElement,
+ apr_xml_doc* doc,
+ AppenderMap& appenders);
- /**
- Used internally to parse the logger factory element.
- */
- void parseLoggerFactory(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* factoryElement);
+ /**
+ Used internally to parse the logger factory element.
+ */
+ void parseLoggerFactory(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* factoryElement);
- /**
- Used internally to parse the logger factory element.
- */
- log4cxx::helpers::ObjectPtr parseTriggeringPolicy(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* factoryElement);
+ /**
+ Used internally to parse the logger factory element.
+ */
+ log4cxx::helpers::ObjectPtr parseTriggeringPolicy(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* factoryElement);
- /**
- Used internally to parse the logger factory element.
- */
- log4cxx::rolling::RollingPolicyPtr parseRollingPolicy(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* factoryElement);
+ /**
+ Used internally to parse the logger factory element.
+ */
+ log4cxx::rolling::RollingPolicyPtr parseRollingPolicy(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* factoryElement);
- /**
- Used internally to parse the root logger element.
- */
- void parseRoot(log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* rootElement, apr_xml_doc* doc, AppenderMap& appenders);
+ /**
+ Used internally to parse the root logger element.
+ */
+ void parseRoot(log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* rootElement, apr_xml_doc* doc, AppenderMap& appenders);
- /**
- Used internally to parse the children of a logger element.
- */
- void parseChildrenOfLoggerElement(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* catElement,
- LoggerPtr logger, bool isRoot,
- apr_xml_doc* doc,
- AppenderMap& appenders);
+ /**
+ Used internally to parse the children of a logger element.
+ */
+ void parseChildrenOfLoggerElement(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* catElement,
+ LoggerPtr logger, bool isRoot,
+ apr_xml_doc* doc,
+ AppenderMap& appenders,
+ bool additivity );
- /**
- Used internally to parse a layout element.
- */
- LayoutPtr parseLayout(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* layout_element);
+ /**
+ Used internally to parse a layout element.
+ */
+ LayoutPtr parseLayout(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* layout_element);
- /**
- Used internally to parse a level element.
- */
- void parseLevel(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* element,
- LoggerPtr logger, bool isRoot);
+ /**
+ Used internally to parse a level element.
+ */
+ void parseLevel(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* element,
+ LoggerPtr logger, bool isRoot);
- void setParameter(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* elem,
- log4cxx::config::PropertySetter& propSetter);
+ void setParameter(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* elem,
+ log4cxx::config::PropertySetter& propSetter);
- /**
- Used internally to configure the log4cxx framework from
- an in-memory representation of an XML document.
- */
- void parse(
- log4cxx::helpers::Pool& p,
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem* element,
- apr_xml_doc* doc,
- AppenderMap& appenders);
+ /**
+ Used internally to configure the log4cxx framework from
+ an in-memory representation of an XML document.
+ */
+ void parse(
+ log4cxx::helpers::Pool& p,
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem* element,
+ apr_xml_doc* doc,
+ AppenderMap& appenders);
- public:
- DOMConfigurator();
+public:
+ DOMConfigurator();
- DECLARE_LOG4CXX_OBJECT(DOMConfigurator)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(spi::Configurator)
- END_LOG4CXX_CAST_MAP()
+ DECLARE_LOG4CXX_OBJECT(DOMConfigurator)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(spi::Configurator)
+ END_LOG4CXX_CAST_MAP()
- DOMConfigurator(log4cxx::helpers::Pool& p);
+ DOMConfigurator(log4cxx::helpers::Pool& p);
- void addRef() const;
- void releaseRef() const;
+ void addRef() const;
+ void releaseRef() const;
- /**
- A static version of #doConfigure.
- */
- static void configure(const std::string& filename);
+ /**
+ A static version of #doConfigure.
+ */
+ static void configure(const std::string& filename);
#if LOG4CXX_WCHAR_T_API
- static void configure(const std::wstring& filename);
+ static void configure(const std::wstring& filename);
#endif
#if LOG4CXX_UNICHAR_API
- static void configure(const std::basic_string<UniChar>& filename);
+ static void configure(const std::basic_string<UniChar>& filename);
#endif
#if LOG4CXX_CFSTRING_API
- static void configure(const CFStringRef& filename);
+ static void configure(const CFStringRef& filename);
#endif
- /**
- Like #configureAndWatch(const std::string& configFilename, long delay)
- except that the default delay as defined by
- log4cxx::helpers::FileWatchdog#DEFAULT_DELAY is used.
- @param configFilename A log4j configuration file in XML format.
- */
- static void configureAndWatch(const std::string& configFilename);
+ /**
+ Like #configureAndWatch(const std::string& configFilename, long delay)
+ except that the default delay as defined by
+ log4cxx::helpers::FileWatchdog#DEFAULT_DELAY is used.
+ @param configFilename A log4j configuration file in XML format.
+ */
+ static void configureAndWatch(const std::string& configFilename);
#if LOG4CXX_WCHAR_T_API
- static void configureAndWatch(const std::wstring& configFilename);
+ static void configureAndWatch(const std::wstring& configFilename);
#endif
#if LOG4CXX_UNICHAR_API
- static void configureAndWatch(const std::basic_string<UniChar>& configFilename);
+ static void configureAndWatch(const std::basic_string<UniChar>& configFilename);
#endif
#if LOG4CXX_CFSTRING_API
- static void configureAndWatch(const CFStringRef& configFilename);
+ static void configureAndWatch(const CFStringRef& configFilename);
#endif
- /**
- Read the configuration file <code>configFilename</code> if it
- exists. Moreover, a thread will be created that will periodically
- check if <code>configFilename</code> has been created or
- modified. The period is determined by the <code>delay</code>
- argument. If a change or file creation is detected, then
- <code>configFilename</code> is read to configure log4cxx.
+ /**
+ Read the configuration file <code>configFilename</code> if it
+ exists. Moreover, a thread will be created that will periodically
+ check if <code>configFilename</code> has been created or
+ modified. The period is determined by the <code>delay</code>
+ argument. If a change or file creation is detected, then
+ <code>configFilename</code> is read to configure log4cxx.
- @param configFilename A log4j configuration file in XML format.
- @param delay The delay in milliseconds to wait between each check.
- */
- static void configureAndWatch(const std::string& configFilename,
- long delay);
+ @param configFilename A log4j configuration file in XML format.
+ @param delay The delay in milliseconds to wait between each check.
+ */
+ static void configureAndWatch(const std::string& configFilename,
+ long delay);
#if LOG4CXX_WCHAR_T_API
- static void configureAndWatch(const std::wstring& configFilename,
- long delay);
+ static void configureAndWatch(const std::wstring& configFilename,
+ long delay);
#endif
#if LOG4CXX_UNICHAR_API
- static void configureAndWatch(const std::basic_string<UniChar>& configFilename,
- long delay);
+ static void configureAndWatch(const std::basic_string<UniChar>& configFilename,
+ long delay);
#endif
#if LOG4CXX_CFSTRING_API
- static void configureAndWatch(const CFStringRef& configFilename,
- long delay);
+ static void configureAndWatch(const CFStringRef& configFilename,
+ long delay);
#endif
- /**
- Interpret the XML file pointed by <code>filename</code> and set up
- log4cxx accordingly.
- <p>The configuration is done relative to the hierarchy parameter.
- @param filename The file to parse.
- @param repository The hierarchy to operation upon.
- */
- void doConfigure(const File& filename,
- spi::LoggerRepositoryPtr& repository);
+ /**
+ Interpret the XML file pointed by <code>filename</code> and set up
+ log4cxx accordingly.
+ <p>The configuration is done relative to the hierarchy parameter.
+ @param filename The file to parse.
+ @param repository The hierarchy to operation upon.
+ */
+ void doConfigure(const File& filename,
+ spi::LoggerRepositoryPtr& repository);
- protected:
- static LogString getAttribute(
- log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
- apr_xml_elem*,
- const std::string& attrName);
+protected:
+ static LogString getAttribute(
+ log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
+ apr_xml_elem*,
+ const std::string& attrName);
- LogString subst(const LogString& value);
+ LogString subst(const LogString& value);
- protected:
- helpers::Properties props;
- spi::LoggerRepositoryPtr repository;
- spi::LoggerFactoryPtr loggerFactory;
+protected:
+ helpers::Properties props;
+ spi::LoggerRepositoryPtr repository;
+ spi::LoggerFactoryPtr loggerFactory;
- private:
- // prevent assignment or copy statements
- DOMConfigurator(const DOMConfigurator&);
- DOMConfigurator& operator=(const DOMConfigurator&);
- static XMLWatchdog* xdog;
+private:
+ // prevent assignment or copy statements
+ DOMConfigurator(const DOMConfigurator&);
+ DOMConfigurator& operator=(const DOMConfigurator&);
+ static XMLWatchdog* xdog;
};
LOG4CXX_PTR_DEF(DOMConfigurator);
} // namespace xml
} // namespace log4cxx
#if defined(_MSC_VER)
- #pragma warning (pop)
+#pragma warning (pop)
#endif
#endif // _LOG4CXX_XML_DOM_CONFIGURATOR_H
diff --git a/src/test/cpp/CMakeLists.txt b/src/test/cpp/CMakeLists.txt
index 386af20..bc38e91 100644
--- a/src/test/cpp/CMakeLists.txt
+++ b/src/test/cpp/CMakeLists.txt
@@ -1,5 +1,6 @@
# Components required by all tests
add_library(testingFramework STATIC abts.cpp appenderskeletontestcase.cpp logunit.cpp vectorappender.cpp writerappendertestcase.cpp )
+target_compile_features(testingFramework PUBLIC cxx_std_17)
target_compile_definitions(testingFramework PRIVATE ${LOG4CXX_COMPILE_DEFINITIONS} ${APR_COMPILE_DEFINITIONS} ${APR_UTIL_COMPILE_DEFINITIONS} )
target_include_directories(testingFramework PRIVATE ${CMAKE_CURRENT_LIST_DIR} $<TARGET_PROPERTY:log4cxx,INCLUDE_DIRECTORIES>)
add_subdirectory(util)
@@ -88,7 +89,9 @@
foreach(testName IN LISTS ALL_LOG4CXX_TESTS)
target_compile_definitions(${testName} PRIVATE ${LOG4CXX_COMPILE_DEFINITIONS} ${APR_COMPILE_DEFINITIONS} ${APR_UTIL_COMPILE_DEFINITIONS} )
target_include_directories(${testName} PRIVATE ${CMAKE_CURRENT_LIST_DIR} $<TARGET_PROPERTY:log4cxx,INCLUDE_DIRECTORIES>)
- target_link_libraries(${testName} PRIVATE testingFramework testingUtilities log4cxx ${APR_LIBRARIES} ${APR_SYSTEM_LIBS})
+ target_link_libraries(${testName} PRIVATE testingFramework testingUtilities log4cxx ${APR_LIBRARIES} ${APR_SYSTEM_LIBS} Threads::Threads)
+ target_compile_features(${testName} PUBLIC
+ cxx_std_17)
add_test(NAME ${testName}
COMMAND ${testName} -v
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../resources
diff --git a/src/test/cpp/asyncappendertestcase.cpp b/src/test/cpp/asyncappendertestcase.cpp
index 0e6795a..f1fb7b2 100644
--- a/src/test/cpp/asyncappendertestcase.cpp
+++ b/src/test/cpp/asyncappendertestcase.cpp
@@ -27,10 +27,10 @@
#include <apr_strings.h>
#include "testchar.h"
#include <log4cxx/helpers/stringhelper.h>
-#include <log4cxx/helpers/synchronized.h>
#include <log4cxx/spi/location/locationinfo.h>
#include <log4cxx/xml/domconfigurator.h>
#include <log4cxx/file.h>
+#include <mutex>
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -68,12 +68,12 @@
class BlockableVectorAppender : public VectorAppender
{
private:
- Mutex blocker;
+ std::mutex blocker;
public:
/**
* Create new instance.
*/
- BlockableVectorAppender() : blocker(pool)
+ BlockableVectorAppender()
{
}
@@ -82,7 +82,7 @@
*/
void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p)
{
- synchronized sync(blocker);
+ std::unique_lock lock( blocker );
VectorAppender::append(event, p);
//
@@ -98,7 +98,7 @@
}
}
- Mutex& getBlocker()
+ std::mutex& getBlocker()
{
return blocker;
}
@@ -117,17 +117,17 @@
//
// tests inherited from AppenderSkeletonTestCase
//
- LOGUNIT_TEST(testDefaultThreshold);
- LOGUNIT_TEST(testSetOptionThreshold);
+ LOGUNIT_TEST(testDefaultThreshold);
+ LOGUNIT_TEST(testSetOptionThreshold);
- LOGUNIT_TEST(closeTest);
- LOGUNIT_TEST(test2);
- LOGUNIT_TEST(test3);
+ LOGUNIT_TEST(closeTest);
+ LOGUNIT_TEST(test2);
+ LOGUNIT_TEST(test3);
//
// TODO: test fails on Linux.
//LOGUNIT_TEST(testBadAppender);
- LOGUNIT_TEST(testLocationInfoTrue);
- LOGUNIT_TEST(testConfiguration);
+ LOGUNIT_TEST(testLocationInfoTrue);
+ LOGUNIT_TEST(testConfiguration);
LOGUNIT_TEST_SUITE_END();
@@ -226,8 +226,8 @@
asyncAppender->activateOptions(p);
LoggerPtr root = Logger::getRootLogger();
root->addAppender(asyncAppender);
- LOG4CXX_INFO(root, "Message");
- Thread::sleep(10);
+ LOG4CXX_INFO(root, "Message");
+ std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
try
{
@@ -255,12 +255,12 @@
LoggerPtr rootLogger = Logger::getRootLogger();
rootLogger->addAppender(async);
{
- synchronized sync(blockableAppender->getBlocker());
+ std::unique_lock sync(blockableAppender->getBlocker());
for (int i = 0; i < 140; i++)
{
LOG4CXX_INFO(rootLogger, "Hello, World");
- Thread::sleep(1);
+ std::this_thread::sleep_for( std::chrono::milliseconds( 1 ) );
}
LOG4CXX_ERROR(rootLogger, "That's all folks.");
diff --git a/src/test/cpp/helpers/CMakeLists.txt b/src/test/cpp/helpers/CMakeLists.txt
index 78aa1b1..e8b8a5f 100644
--- a/src/test/cpp/helpers/CMakeLists.txt
+++ b/src/test/cpp/helpers/CMakeLists.txt
@@ -15,7 +15,6 @@
stringhelpertestcase
stringtokenizertestcase
syslogwritertest
- threadtestcase
timezonetestcase
transcodertestcase
)
@@ -23,6 +22,8 @@
add_executable(${fileName} "${fileName}.cpp")
target_compile_definitions(${fileName} PRIVATE ${APR_COMPILE_DEFINITIONS} ${APR_UTIL_COMPILE_DEFINITIONS} )
target_include_directories(${fileName} PRIVATE ${CMAKE_CURRENT_LIST_DIR} $<TARGET_PROPERTY:log4cxx,INCLUDE_DIRECTORIES> ${APR_INCLUDE_DIR})
+ target_compile_features(${fileName} PUBLIC
+ cxx_std_17)
endforeach()
target_sources(cacheddateformattestcase PRIVATE localechanger.cpp)
target_sources(datetimedateformattestcase PRIVATE localechanger.cpp)
diff --git a/src/test/cpp/helpers/charsetencodertestcase.cpp b/src/test/cpp/helpers/charsetencodertestcase.cpp
index 5677820..e12ecbf 100644
--- a/src/test/cpp/helpers/charsetencodertestcase.cpp
+++ b/src/test/cpp/helpers/charsetencodertestcase.cpp
@@ -19,13 +19,11 @@
#include "../logunit.h"
#include "../insertwide.h"
#include <log4cxx/helpers/bytebuffer.h>
-#include <log4cxx/helpers/thread.h>
-#include <log4cxx/helpers/mutex.h>
-#include <log4cxx/helpers/condition.h>
-#include <log4cxx/helpers/synchronized.h>
#include <apr.h>
#include <apr_atomic.h>
-
+#include <mutex>
+#include <condition_variable>
+#include <thread>
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -186,20 +184,20 @@
{
public:
ThreadPackage(CharsetEncoderPtr& enc, int repetitions) :
- p(), lock(p), condition(p), passCount(0), failCount(0), enc(enc), repetitions(repetitions)
+ p(), passCount(0), failCount(0), enc(enc), repetitions(repetitions)
{
}
void await()
{
- synchronized sync(lock);
- condition.await(lock);
+ std::unique_lock sync(lock);
+ condition.wait(sync);
}
void signalAll()
{
- synchronized sync(lock);
- condition.signalAll();
+ std::unique_lock sync(lock);
+ condition.notify_all();
}
void fail()
@@ -232,102 +230,99 @@
return enc;
}
+ void run()
+ {
+ #if LOG4CXX_LOGCHAR_IS_UTF8
+ const logchar greet[] = { 'H', 'e', 'l', 'l', 'o', ' ',
+ (char) 0xC2, (char) 0xA2, // cent sign
+ (char) 0xC2, (char) 0xA9, // copyright
+ (char) 0xc3, (char) 0xb4, // latin small letter o with circumflex
+ 0
+ };
+ #endif
+ #if LOG4CXX_LOGCHAR_IS_WCHAR || LOG4CXX_LOGCHAR_IS_UNICHAR
+ // arbitrary, hopefully meaningless, characters from
+ // Latin, Arabic, Armenian, Bengali, CJK and Cyrillic
+ const logchar greet[] = { L'H', L'e', L'l', L'l', L'o', L' ',
+ 0x00A2, 0x00A9, 0x00F4, 0
+ };
+ #endif
+
+ const char expected[] = { 'H', 'e', 'l', 'l', 'o', ' ',
+ (char) 0x00A2, (char) 0x00A9, (char) 0x00F4
+ };
+
+ LogString greeting(greet);
+
+ await();
+
+ for (int i = 0; i < getRepetitions(); i++)
+ {
+ bool pass = true;
+ char buf[BUFSIZE];
+ ByteBuffer out(buf, BUFSIZE);
+ LogString::const_iterator iter = greeting.begin();
+ log4cxx_status_t stat = getEncoder()->encode(greeting, iter, out);
+ pass = (false == CharsetEncoder::isError(stat));
+
+ if (pass)
+ {
+ stat = getEncoder()->encode(greeting, iter, out);
+ pass = (false == CharsetEncoder::isError(stat));
+
+ if (pass)
+ {
+ out.flip();
+ pass = (sizeof(expected) == out.limit());
+
+ for (size_t i = 0; i < out.limit() && pass; i++)
+ {
+ pass = (expected[i] == out.data()[i]);
+ }
+
+ pass = pass && (iter == greeting.end());
+ }
+ }
+
+ if (pass)
+ {
+ ThreadPackage::pass();
+ }
+ else
+ {
+ fail();
+ }
+ }
+ }
+
private:
ThreadPackage(const ThreadPackage&);
ThreadPackage& operator=(ThreadPackage&);
Pool p;
- Mutex lock;
- Condition condition;
+ std::mutex lock;
+ std::condition_variable condition;
volatile apr_uint32_t passCount;
volatile apr_uint32_t failCount;
CharsetEncoderPtr enc;
int repetitions;
};
- static void* LOG4CXX_THREAD_FUNC thread1Action(apr_thread_t* /* thread */, void* data)
- {
- ThreadPackage* package = (ThreadPackage*) data;
-#if LOG4CXX_LOGCHAR_IS_UTF8
- const logchar greet[] = { 'H', 'e', 'l', 'l', 'o', ' ',
- (char) 0xC2, (char) 0xA2, // cent sign
- (char) 0xC2, (char) 0xA9, // copyright
- (char) 0xc3, (char) 0xb4, // latin small letter o with circumflex
- 0
- };
-#endif
-#if LOG4CXX_LOGCHAR_IS_WCHAR || LOG4CXX_LOGCHAR_IS_UNICHAR
- // arbitrary, hopefully meaningless, characters from
- // Latin, Arabic, Armenian, Bengali, CJK and Cyrillic
- const logchar greet[] = { L'H', L'e', L'l', L'l', L'o', L' ',
- 0x00A2, 0x00A9, 0x00F4, 0
- };
-#endif
-
- const char expected[] = { 'H', 'e', 'l', 'l', 'o', ' ',
- (char) 0x00A2, (char) 0x00A9, (char) 0x00F4
- };
-
- LogString greeting(greet);
-
- package->await();
-
- for (int i = 0; i < package->getRepetitions(); i++)
- {
- bool pass = true;
- char buf[BUFSIZE];
- ByteBuffer out(buf, BUFSIZE);
- LogString::const_iterator iter = greeting.begin();
- log4cxx_status_t stat = package->getEncoder()->encode(greeting, iter, out);
- pass = (false == CharsetEncoder::isError(stat));
-
- if (pass)
- {
- stat = package->getEncoder()->encode(greeting, iter, out);
- pass = (false == CharsetEncoder::isError(stat));
-
- if (pass)
- {
- out.flip();
- pass = (sizeof(expected) == out.limit());
-
- for (size_t i = 0; i < out.limit() && pass; i++)
- {
- pass = (expected[i] == out.data()[i]);
- }
-
- pass = pass && (iter == greeting.end());
- }
- }
-
- if (pass)
- {
- package->pass();
- }
- else
- {
- package->fail();
- }
- }
-
- return 0;
- }
-
void thread1()
{
enum { THREAD_COUNT = 10, THREAD_REPS = 10000 };
- Thread threads[THREAD_COUNT];
+ std::thread threads[THREAD_COUNT];
CharsetEncoderPtr enc(CharsetEncoder::getEncoder(LOG4CXX_STR("ISO-8859-1")));
ThreadPackage* package = new ThreadPackage(enc, THREAD_REPS);
{
for (int i = 0; i < THREAD_COUNT; i++)
{
- threads[i].run(thread1Action, package);
+ threads[i] = std::thread(&ThreadPackage::run, package);
}
}
//
// give time for all threads to be launched so
- // we don't signal before everybody is waiting.
- Thread::sleep(100);
+ // we don't signal before everybody is waiting.
+ std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
package->signalAll();
for (int i = 0; i < THREAD_COUNT; i++)
diff --git a/src/test/cpp/helpers/threadtestcase.cpp b/src/test/cpp/helpers/threadtestcase.cpp
deleted file mode 100644
index 21fc671..0000000
--- a/src/test/cpp/helpers/threadtestcase.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <log4cxx/helpers/thread.h>
-#include "../insertwide.h"
-#include "../logunit.h"
-#include <apr_time.h>
-#include <log4cxx/helpers/exception.h>
-
-using namespace log4cxx;
-using namespace log4cxx::helpers;
-
-
-/**
- Unit test for Thread.
-
- */
-LOGUNIT_CLASS(ThreadTestCase)
-{
- LOGUNIT_TEST_SUITE(ThreadTestCase);
- LOGUNIT_TEST(testInterrupt);
- LOGUNIT_TEST_SUITE_END();
-
-public:
- /**
- * Start a thread that will wait for a minute, then interrupt it.
- */
- void testInterrupt()
- {
- Thread thread1;
- bool interrupted = false;
- thread1.run(sleep, &interrupted);
- apr_sleep(100000);
- apr_time_t start = apr_time_now();
- thread1.interrupt();
- thread1.join();
- LOGUNIT_ASSERT_EQUAL(true, interrupted);
- apr_time_t elapsed = apr_time_now() - start;
- LOGUNIT_ASSERT(elapsed < 1000000);
- }
-
-private:
- static void* LOG4CXX_THREAD_FUNC sleep(apr_thread_t* thread, void* data)
- {
- try
- {
- Thread::sleep(60000);
- }
- catch (InterruptedException& ex)
- {
- *(reinterpret_cast<bool*>(data)) = true;
- }
-
- return NULL;
- }
-
-};
-
-LOGUNIT_TEST_SUITE_REGISTRATION(ThreadTestCase);
-
diff --git a/src/test/cpp/net/sockethubappendertestcase.cpp b/src/test/cpp/net/sockethubappendertestcase.cpp
index 816193d..03afc4f 100644
--- a/src/test/cpp/net/sockethubappendertestcase.cpp
+++ b/src/test/cpp/net/sockethubappendertestcase.cpp
@@ -17,7 +17,6 @@
#include <log4cxx/net/sockethubappender.h>
#include "../appenderskeletontestcase.h"
-#include <log4cxx/helpers/thread.h>
#include <apr.h>
using namespace log4cxx;
@@ -61,8 +60,8 @@
{
SocketHubAppenderPtr hubAppender(new SocketHubAppender());
Pool p;
- hubAppender->activateOptions(p);
- Thread::sleep(1000);
+ hubAppender->activateOptions(p);
+ std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
hubAppender->close();
}
diff --git a/src/test/cpp/net/telnetappendertestcase.cpp b/src/test/cpp/net/telnetappendertestcase.cpp
index 8cde17f..dc82101 100644
--- a/src/test/cpp/net/telnetappendertestcase.cpp
+++ b/src/test/cpp/net/telnetappendertestcase.cpp
@@ -68,8 +68,8 @@
appender->setLayout(new TTCCLayout());
appender->setPort(TEST_PORT);
Pool p;
- appender->activateOptions(p);
- Thread::sleep(1000);
+ appender->activateOptions(p);
+ std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
appender->close();
}
diff --git a/src/test/cpp/util/CMakeLists.txt b/src/test/cpp/util/CMakeLists.txt
index c818ab8..e6da43e 100644
--- a/src/test/cpp/util/CMakeLists.txt
+++ b/src/test/cpp/util/CMakeLists.txt
@@ -20,3 +20,5 @@
)
target_compile_definitions(testingUtilities PRIVATE ${LOG4CXX_COMPILE_DEFINITIONS} ${APR_COMPILE_DEFINITIONS} ${APR_UTIL_COMPILE_DEFINITIONS} )
target_include_directories(testingUtilities PRIVATE ${CMAKE_CURRENT_LIST_DIR} $<TARGET_PROPERTY:log4cxx,INCLUDE_DIRECTORIES>)
+target_compile_features(testingUtilities PUBLIC
+ cxx_std_17)
diff --git a/src/test/cpp/vectorappender.cpp b/src/test/cpp/vectorappender.cpp
index fef8e7c..4698e3d 100644
--- a/src/test/cpp/vectorappender.cpp
+++ b/src/test/cpp/vectorappender.cpp
@@ -16,7 +16,7 @@
*/
#include "vectorappender.h"
-#include <log4cxx/helpers/thread.h>
+#include <thread>
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -25,13 +25,7 @@
void VectorAppender::append(const spi::LoggingEventPtr& event, Pool& /*p*/)
{
- try
- {
- Thread::sleep(100);
- }
- catch (Exception&)
- {
- }
+ std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
vector.push_back(event);
}
diff --git a/src/test/cpp/xml/domtestcase.cpp b/src/test/cpp/xml/domtestcase.cpp
index 251770a..9868093 100644
--- a/src/test/cpp/xml/domtestcase.cpp
+++ b/src/test/cpp/xml/domtestcase.cpp
@@ -30,6 +30,7 @@
#include <apr_pools.h>
#include <apr_file_io.h>
#include "../testchar.h"
+#include "log4cxx/helpers/loglog.h"
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -45,180 +46,181 @@
LOGUNIT_CLASS(DOMTestCase)
{
- LOGUNIT_TEST_SUITE(DOMTestCase);
- LOGUNIT_TEST(test1);
+ LOGUNIT_TEST_SUITE(DOMTestCase);
+ LOGUNIT_TEST(test1);
#if defined(_WIN32)
- LOGUNIT_TEST(test2);
+ LOGUNIT_TEST(test2);
#endif
- LOGUNIT_TEST(test3);
- LOGUNIT_TEST(test4);
- LOGUNIT_TEST_SUITE_END();
+ LOGUNIT_TEST(test3);
+ LOGUNIT_TEST(test4);
+ LOGUNIT_TEST_SUITE_END();
- LoggerPtr root;
- LoggerPtr logger;
+ LoggerPtr root;
+ LoggerPtr logger;
- static const File TEMP_A1;
- static const File TEMP_A2;
- static const File FILTERED_A1;
- static const File FILTERED_A2;
- static const File TEMP_A1_2;
- static const File TEMP_A2_2;
- static const File FILTERED_A1_2;
- static const File FILTERED_A2_2;
+ static const File TEMP_A1;
+ static const File TEMP_A2;
+ static const File FILTERED_A1;
+ static const File FILTERED_A2;
+ static const File TEMP_A1_2;
+ static const File TEMP_A2_2;
+ static const File FILTERED_A1_2;
+ static const File FILTERED_A2_2;
public:
- void setUp()
- {
- root = Logger::getRootLogger();
- logger = Logger::getLogger(LOG4CXX_TEST_STR("org.apache.log4j.xml.DOMTestCase"));
- }
+ void setUp()
+ {
+ root = Logger::getRootLogger();
+ logger = Logger::getLogger(LOG4CXX_TEST_STR("org.apache.log4j.xml.DOMTestCase"));
+ }
- void tearDown()
- {
- root->getLoggerRepository()->resetConfiguration();
- }
+ void tearDown()
+ {
+ root->getLoggerRepository()->resetConfiguration();
+ }
- void test1()
- {
- DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase1.xml"));
- common();
+ void test1()
+ {
+ LogLog::setInternalDebugging(true);
+ DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase1.xml"));
+ common();
- ControlFilter cf1;
- cf1 << TEST1_1A_PAT << TEST1_1B_PAT;
+ ControlFilter cf1;
+ cf1 << TEST1_1A_PAT << TEST1_1B_PAT;
- ControlFilter cf2;
- cf2 << TEST1_2_PAT;
+ ControlFilter cf2;
+ cf2 << TEST1_2_PAT;
- ThreadFilter threadFilter;
- ISO8601Filter iso8601Filter;
+ ThreadFilter threadFilter;
+ ISO8601Filter iso8601Filter;
- std::vector<Filter*> filters1;
- filters1.push_back(&cf1);
+ std::vector<Filter*> filters1;
+ filters1.push_back(&cf1);
- std::vector<Filter*> filters2;
- filters2.push_back(&cf2);
- filters2.push_back(&threadFilter);
- filters2.push_back(&iso8601Filter);
+ std::vector<Filter*> filters2;
+ filters2.push_back(&cf2);
+ filters2.push_back(&threadFilter);
+ filters2.push_back(&iso8601Filter);
- try
- {
- Transformer::transform(TEMP_A1, FILTERED_A1, filters1);
- Transformer::transform(TEMP_A2, FILTERED_A2, filters2);
- }
- catch (UnexpectedFormatException& e)
- {
- std::cout << "UnexpectedFormatException :" << e.what() << std::endl;
- throw;
- }
+ try
+ {
+ Transformer::transform(TEMP_A1, FILTERED_A1, filters1);
+ Transformer::transform(TEMP_A2, FILTERED_A2, filters2);
+ }
+ catch (UnexpectedFormatException& e)
+ {
+ std::cout << "UnexpectedFormatException :" << e.what() << std::endl;
+ throw;
+ }
- const File witness1(LOG4CXX_TEST_STR("witness/dom.A1.1"));
- const File witness2(LOG4CXX_TEST_STR("witness/dom.A2.1"));
- // TODO: A1 doesn't contain duplicate entries
- //
- // LOGUNIT_ASSERT(Compare::compare(FILTERED_A1, witness1));
- LOGUNIT_ASSERT(Compare::compare(FILTERED_A2, witness2));
- }
+ const File witness1(LOG4CXX_TEST_STR("witness/dom.A1.1"));
+ const File witness2(LOG4CXX_TEST_STR("witness/dom.A2.1"));
+ // TODO: A1 doesn't contain duplicate entries
+ //
+ // LOGUNIT_ASSERT(Compare::compare(FILTERED_A1, witness1));
+ LOGUNIT_ASSERT(Compare::compare(FILTERED_A2, witness2));
+ }
- //
- // Same test but backslashes instead of forward
- //
- void test2()
- {
- DOMConfigurator::configure(LOG4CXX_TEST_STR("input\\xml\\DOMTestCase2.xml"));
- common();
+ //
+ // Same test but backslashes instead of forward
+ //
+ void test2()
+ {
+ DOMConfigurator::configure(LOG4CXX_TEST_STR("input\\xml\\DOMTestCase2.xml"));
+ common();
- ThreadFilter threadFilter;
- ISO8601Filter iso8601Filter;
+ ThreadFilter threadFilter;
+ ISO8601Filter iso8601Filter;
- std::vector<Filter*> filters1;
+ std::vector<Filter*> filters1;
- std::vector<Filter*> filters2;
- filters2.push_back(&threadFilter);
- filters2.push_back(&iso8601Filter);
+ std::vector<Filter*> filters2;
+ filters2.push_back(&threadFilter);
+ filters2.push_back(&iso8601Filter);
- try
- {
- Transformer::transform(TEMP_A1_2, FILTERED_A1_2, filters1);
- Transformer::transform(TEMP_A2_2, FILTERED_A2_2, filters2);
- }
- catch (UnexpectedFormatException& e)
- {
- std::cout << "UnexpectedFormatException :" << e.what() << std::endl;
- throw;
- }
+ try
+ {
+ Transformer::transform(TEMP_A1_2, FILTERED_A1_2, filters1);
+ Transformer::transform(TEMP_A2_2, FILTERED_A2_2, filters2);
+ }
+ catch (UnexpectedFormatException& e)
+ {
+ std::cout << "UnexpectedFormatException :" << e.what() << std::endl;
+ throw;
+ }
- const File witness1(LOG4CXX_TEST_STR("witness/dom.A1.2"));
- const File witness2(LOG4CXX_TEST_STR("witness/dom.A2.2"));
- // TODO: A1 doesn't contain duplicate entries
- //
- // LOGUNIT_ASSERT(Compare::compare(FILTERED_A1, witness1));
- LOGUNIT_ASSERT(Compare::compare(FILTERED_A2, witness2));
- }
+ const File witness1(LOG4CXX_TEST_STR("witness/dom.A1.2"));
+ const File witness2(LOG4CXX_TEST_STR("witness/dom.A2.2"));
+ // TODO: A1 doesn't contain duplicate entries
+ //
+ // LOGUNIT_ASSERT(Compare::compare(FILTERED_A1, witness1));
+ LOGUNIT_ASSERT(Compare::compare(FILTERED_A2, witness2));
+ }
- void common()
- {
- int i = 0;
+ void common()
+ {
+ int i = 0;
- LOG4CXX_DEBUG(logger, "Message " << i);
- LOG4CXX_DEBUG(root, "Message " << i);
+ LOG4CXX_DEBUG(logger, "Message " << i);
+ LOG4CXX_DEBUG(root, "Message " << i);
- i++;
- LOG4CXX_INFO(logger, "Message " << i);
- LOG4CXX_INFO(root, "Message " << i);
+ i++;
+ LOG4CXX_INFO(logger, "Message " << i);
+ LOG4CXX_INFO(root, "Message " << i);
- i++;
- LOG4CXX_WARN(logger, "Message " << i);
- LOG4CXX_WARN(root, "Message " << i);
+ i++;
+ LOG4CXX_WARN(logger, "Message " << i);
+ LOG4CXX_WARN(root, "Message " << i);
- i++;
- LOG4CXX_ERROR(logger, "Message " << i);
- LOG4CXX_ERROR(root, "Message " << i);
+ i++;
+ LOG4CXX_ERROR(logger, "Message " << i);
+ LOG4CXX_ERROR(root, "Message " << i);
- i++;
- LOG4CXX_FATAL(logger, "Message " << i);
- LOG4CXX_FATAL(root, "Message " << i);
- }
+ i++;
+ LOG4CXX_FATAL(logger, "Message " << i);
+ LOG4CXX_FATAL(root, "Message " << i);
+ }
- /**
- * Creates a output file that ends with a superscript 3.
- * Output file is checked by build.xml after completion.
- */
- void test3()
- {
- DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase3.xml"));
- LOG4CXX_INFO(logger, "File name is expected to end with a superscript 3");
+ /**
+ * Creates a output file that ends with a superscript 3.
+ * Output file is checked by build.xml after completion.
+ */
+ void test3()
+ {
+ DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase3.xml"));
+ LOG4CXX_INFO(logger, "File name is expected to end with a superscript 3");
#if LOG4CXX_LOGCHAR_IS_UTF8
- const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xC2), static_cast<logchar>(0xB3), 0 };
+ const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xC2), static_cast<logchar>(0xB3), 0 };
#else
- const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xB3), 0 };
+ const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xB3), 0 };
#endif
- File file;
- file.setPath(fname);
- Pool p;
- bool exists = file.exists(p);
- LOGUNIT_ASSERT(exists);
- }
+ File file;
+ file.setPath(fname);
+ Pool p;
+ bool exists = file.exists(p);
+ LOGUNIT_ASSERT(exists);
+ }
- /**
- * Creates a output file that ends with a ideographic 4.
- * Output file is checked by build.xml after completion.
- */
- void test4()
- {
- DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase4.xml"));
- LOG4CXX_INFO(logger, "File name is expected to end with an ideographic 4");
+ /**
+ * Creates a output file that ends with a ideographic 4.
+ * Output file is checked by build.xml after completion.
+ */
+ void test4()
+ {
+ DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase4.xml"));
+ LOG4CXX_INFO(logger, "File name is expected to end with an ideographic 4");
#if LOG4CXX_LOGCHAR_IS_UTF8
- const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xE3), static_cast<logchar>(0x86), static_cast<logchar>(0x95), 0 };
+ const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xE3), static_cast<logchar>(0x86), static_cast<logchar>(0x95), 0 };
#else
- const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0x3195), 0 };
+ const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0x3195), 0 };
#endif
- File file;
- file.setPath(fname);
- Pool p;
- bool exists = file.exists(p);
- LOGUNIT_ASSERT(exists);
- }
+ File file;
+ file.setPath(fname);
+ Pool p;
+ bool exists = file.exists(p);
+ LOGUNIT_ASSERT(exists);
+ }
};
LOGUNIT_TEST_SUITE_REGISTRATION(DOMTestCase);