LOGCXX-502: Reformatted all source files using AStyle and documented the settings used. Not perfect, but looks better than before.
diff --git a/.astylerc b/.astylerc
new file mode 100644
index 0000000..face8a8
--- /dev/null
+++ b/.astylerc
@@ -0,0 +1,36 @@
+##
+# Why am I here?
+#
+# This file exists to document which settings have been used to reformat the code in general the
+# last time and to somewhat describe main aspects of the code style in use. It's NOT intended to get
+# applied whenever any piece of code is changed! Instead, it IS OK to not follow these settings for
+# some pieces of code, if it makes those pieces more readable in the end. Some pieces of code simply
+# can not be described properly using automatic formatting rules.
+#
+# Example invocation:
+#
+# astyle --project src/main/include/*.h src/main/cpp/*.cpp
+#
+
+--add-braces
+--align-pointer=type
+--align-reference=type
+--break-blocks
+--break-one-line-headers
+--convert-tabs
+
+--indent-classes
+--indent-col1-comments
+--indent-continuation=1
+--indent-preproc-block
+--indent-preproc-define
+--indent-switches
+--indent=spaces=4
+
+--lineend=windows
+--pad-comma
+--pad-header
+--pad-oper
+--recursive
+--style=break
+--suffix=none
diff --git a/src/main/cpp/action.cpp b/src/main/cpp/action.cpp
index 9e440b5..5f0f26f 100644
--- a/src/main/cpp/action.cpp
+++ b/src/main/cpp/action.cpp
@@ -25,44 +25,55 @@
IMPLEMENT_LOG4CXX_OBJECT(Action)
Action::Action() :
- complete(false),
- interrupted(false),
- pool(),
- mutex(pool) {
+ complete(false),
+ interrupted(false),
+ pool(),
+ mutex(pool)
+{
}
-Action::~Action() {
+Action::~Action()
+{
}
/**
* {@inheritDoc}
*/
-void Action::run(log4cxx::helpers::Pool& pool1) {
- synchronized sync(mutex);
- if (!interrupted) {
- try {
- execute(pool1);
- } catch(std::exception& ex) {
- reportException(ex);
- }
- complete = true;
- interrupted = true;
- }
+void Action::run(log4cxx::helpers::Pool& pool1)
+{
+ synchronized sync(mutex);
+
+ if (!interrupted)
+ {
+ try
+ {
+ execute(pool1);
+ }
+ catch (std::exception& ex)
+ {
+ reportException(ex);
+ }
+
+ complete = true;
+ interrupted = true;
+ }
}
- /**
- * {@inheritDoc}
- */
-void Action::close() {
+/**
+ * {@inheritDoc}
+ */
+void Action::close()
+{
synchronized sync(mutex);
interrupted = true;
}
- /**
- * Tests if the action is complete.
- * @return true if action is complete.
- */
-bool Action::isComplete() const {
+/**
+ * Tests if the action is complete.
+ * @return true if action is complete.
+ */
+bool Action::isComplete() const
+{
return complete;
}
@@ -71,5 +82,6 @@
*
* @param ex exception.
*/
-void Action::reportException(const std::exception& /* ex */) {
+void Action::reportException(const std::exception& /* ex */)
+{
}
diff --git a/src/main/cpp/andfilter.cpp b/src/main/cpp/andfilter.cpp
index 9a728a2..a83e7b7 100644
--- a/src/main/cpp/andfilter.cpp
+++ b/src/main/cpp/andfilter.cpp
@@ -29,39 +29,51 @@
AndFilter::AndFilter()
-: headFilter(), tailFilter(), acceptOnMatch(true)
+ : headFilter(), tailFilter(), acceptOnMatch(true)
{
}
-void AndFilter::addFilter(const FilterPtr& filter) {
- if (headFilter == NULL) {
- headFilter = filter;
- tailFilter = filter;
- } else {
- tailFilter->setNext(filter);
+void AndFilter::addFilter(const FilterPtr& filter)
+{
+ if (headFilter == NULL)
+ {
+ headFilter = filter;
+ tailFilter = filter;
+ }
+ else
+ {
+ tailFilter->setNext(filter);
}
}
-void AndFilter::setAcceptOnMatch(bool newValue) {
+void AndFilter::setAcceptOnMatch(bool newValue)
+{
acceptOnMatch = newValue;
}
Filter::FilterDecision AndFilter::decide(
- const spi::LoggingEventPtr& event) const
+ const spi::LoggingEventPtr& event) const
{
bool accepted = true;
FilterPtr f(headFilter);
- while (f != NULL) {
- accepted = accepted && (Filter::ACCEPT == f->decide(event));
- f = f->getNext();
+
+ while (f != NULL)
+ {
+ accepted = accepted && (Filter::ACCEPT == f->decide(event));
+ f = f->getNext();
}
- if (accepted) {
- if(acceptOnMatch) {
- return Filter::ACCEPT;
- }
- return Filter::DENY;
+
+ if (accepted)
+ {
+ if (acceptOnMatch)
+ {
+ return Filter::ACCEPT;
+ }
+
+ return Filter::DENY;
}
+
return Filter::NEUTRAL;
}
diff --git a/src/main/cpp/appenderattachableimpl.cpp b/src/main/cpp/appenderattachableimpl.cpp
index 5bd5a41..9d2f9e6 100644
--- a/src/main/cpp/appenderattachableimpl.cpp
+++ b/src/main/cpp/appenderattachableimpl.cpp
@@ -29,15 +29,18 @@
AppenderAttachableImpl::AppenderAttachableImpl(Pool& pool)
- : appenderList(),
- mutex(pool) {
+ : appenderList(),
+ mutex(pool)
+{
}
-void AppenderAttachableImpl::addRef() const {
+void AppenderAttachableImpl::addRef() const
+{
ObjectImpl::addRef();
}
-void AppenderAttachableImpl::releaseRef() const {
+void AppenderAttachableImpl::releaseRef() const
+{
ObjectImpl::releaseRef();
}
@@ -45,13 +48,13 @@
void AppenderAttachableImpl::addAppender(const AppenderPtr& newAppender)
{
// Null values for newAppender parameter are strictly forbidden.
- if(newAppender == 0)
+ if (newAppender == 0)
{
return;
}
AppenderList::iterator it = std::find(
- appenderList.begin(), appenderList.end(), newAppender);
+ appenderList.begin(), appenderList.end(), newAppender);
if (it == appenderList.end())
{
@@ -64,11 +67,13 @@
Pool& p)
{
for (AppenderList::iterator it = appenderList.begin();
- it != appenderList.end();
- it++) {
+ it != appenderList.end();
+ it++)
+ {
(*it)->doAppend(event, p);
}
- return appenderList.size();
+
+ return appenderList.size();
}
AppenderList AppenderAttachableImpl::getAllAppenders() const
@@ -78,34 +83,36 @@
AppenderPtr AppenderAttachableImpl::getAppender(const LogString& name) const
{
- if (name.empty())
- {
- return 0;
- }
-
- AppenderList::const_iterator it, itEnd = appenderList.end();
- AppenderPtr appender;
- for(it = appenderList.begin(); it != itEnd; it++)
- {
- appender = *it;
- if(name == appender->getName())
- {
- return appender;
- }
- }
-
+ if (name.empty())
+ {
return 0;
+ }
+
+ AppenderList::const_iterator it, itEnd = appenderList.end();
+ AppenderPtr appender;
+
+ for (it = appenderList.begin(); it != itEnd; it++)
+ {
+ appender = *it;
+
+ if (name == appender->getName())
+ {
+ return appender;
+ }
+ }
+
+ return 0;
}
bool AppenderAttachableImpl::isAttached(const AppenderPtr& appender) const
{
- if (appender == 0)
+ if (appender == 0)
{
return false;
}
AppenderList::const_iterator it = std::find(
- appenderList.begin(), appenderList.end(), appender);
+ appenderList.begin(), appenderList.end(), appender);
return it != appenderList.end();
}
@@ -114,7 +121,8 @@
{
AppenderList::iterator it, itEnd = appenderList.end();
AppenderPtr a;
- for(it = appenderList.begin(); it != itEnd; it++)
+
+ for (it = appenderList.begin(); it != itEnd; it++)
{
a = *it;
a->close();
@@ -126,10 +134,12 @@
void AppenderAttachableImpl::removeAppender(const AppenderPtr& appender)
{
if (appender == 0)
+ {
return;
+ }
AppenderList::iterator it = std::find(
- appenderList.begin(), appenderList.end(), appender);
+ appenderList.begin(), appenderList.end(), appender);
if (it != appenderList.end())
{
@@ -139,22 +149,24 @@
void AppenderAttachableImpl::removeAppender(const LogString& name)
{
- if (name.empty())
- {
- return;
- }
+ if (name.empty())
+ {
+ return;
+ }
- AppenderList::iterator it, itEnd = appenderList.end();
- AppenderPtr appender;
- for(it = appenderList.begin(); it != itEnd; it++)
+ AppenderList::iterator it, itEnd = appenderList.end();
+ AppenderPtr appender;
+
+ for (it = appenderList.begin(); it != itEnd; it++)
+ {
+ appender = *it;
+
+ if (name == appender->getName())
{
- appender = *it;
- if(name == appender->getName())
- {
- appenderList.erase(it);
- return;
- }
+ appenderList.erase(it);
+ return;
}
+ }
}
diff --git a/src/main/cpp/appenderskeleton.cpp b/src/main/cpp/appenderskeleton.cpp
index 1d66c21..0d68dcc 100644
--- a/src/main/cpp/appenderskeleton.cpp
+++ b/src/main/cpp/appenderskeleton.cpp
@@ -33,149 +33,154 @@
AppenderSkeleton::AppenderSkeleton()
-: layout(),
- name(),
- threshold(Level::getAll()),
- errorHandler(new OnlyOnceErrorHandler()),
- headFilter(),
- tailFilter(),
- pool(),
- SHARED_MUTEX_INIT(mutex, pool)
+ : layout(),
+ name(),
+ threshold(Level::getAll()),
+ errorHandler(new OnlyOnceErrorHandler()),
+ headFilter(),
+ tailFilter(),
+ pool(),
+ SHARED_MUTEX_INIT(mutex, pool)
{
LOCK_W sync(mutex);
closed = false;
}
AppenderSkeleton::AppenderSkeleton(const LayoutPtr& layout1)
-: layout(layout1),
- name(),
- threshold(Level::getAll()),
- errorHandler(new OnlyOnceErrorHandler()),
- headFilter(),
- tailFilter(),
- pool(),
- SHARED_MUTEX_INIT(mutex, pool)
+ : layout(layout1),
+ name(),
+ threshold(Level::getAll()),
+ errorHandler(new OnlyOnceErrorHandler()),
+ headFilter(),
+ tailFilter(),
+ pool(),
+ SHARED_MUTEX_INIT(mutex, pool)
{
- LOCK_W sync(mutex);
- closed = false;
+ LOCK_W sync(mutex);
+ closed = false;
}
-void AppenderSkeleton::addRef() const {
+void AppenderSkeleton::addRef() const
+{
ObjectImpl::addRef();
}
-void AppenderSkeleton::releaseRef() const {
+void AppenderSkeleton::releaseRef() const
+{
ObjectImpl::releaseRef();
}
void AppenderSkeleton::finalize()
{
-// An appender might be closed then garbage collected. There is no
-// point in closing twice.
- if(closed)
- {
- return;
- }
+ // An appender might be closed then garbage collected. There is no
+ // point in closing twice.
+ if (closed)
+ {
+ return;
+ }
- close();
+ close();
}
void AppenderSkeleton::addFilter(const spi::FilterPtr& newFilter)
{
- LOCK_W sync(mutex);
- if(headFilter == 0)
- {
- headFilter = tailFilter = newFilter;
- }
- else
- {
- tailFilter->setNext(newFilter);
- tailFilter = newFilter;
- }
+ LOCK_W sync(mutex);
+
+ if (headFilter == 0)
+ {
+ headFilter = tailFilter = newFilter;
+ }
+ else
+ {
+ tailFilter->setNext(newFilter);
+ tailFilter = newFilter;
+ }
}
void AppenderSkeleton::clearFilters()
{
- LOCK_W sync(mutex);
- headFilter = tailFilter = 0;
+ LOCK_W sync(mutex);
+ headFilter = tailFilter = 0;
}
bool AppenderSkeleton::isAsSevereAsThreshold(const LevelPtr& level) const
{
- return ((level == 0) || level->isGreaterOrEqual(threshold));
+ return ((level == 0) || level->isGreaterOrEqual(threshold));
}
void AppenderSkeleton::doAppend(const spi::LoggingEventPtr& event, Pool& pool1)
{
- LOCK_W sync(mutex);
+ LOCK_W sync(mutex);
- doAppendImpl(event, pool1);
+ doAppendImpl(event, pool1);
}
void AppenderSkeleton::doAppendImpl(const spi::LoggingEventPtr& event, Pool& pool1)
{
- if(closed)
- {
- LogLog::error(((LogString) LOG4CXX_STR("Attempted to append to closed appender named ["))
+ if (closed)
+ {
+ LogLog::error(((LogString) LOG4CXX_STR("Attempted to append to closed appender named ["))
+ name + LOG4CXX_STR("]."));
- return;
- }
+ return;
+ }
- if(!isAsSevereAsThreshold(event->getLevel()))
+ if (!isAsSevereAsThreshold(event->getLevel()))
+ {
+ return;
+ }
+
+ FilterPtr f = headFilter;
+
+
+ while (f != 0)
+ {
+ switch (f->decide(event))
{
+ case Filter::DENY:
return;
+
+ case Filter::ACCEPT:
+ f = 0;
+ break;
+
+ case Filter::NEUTRAL:
+ f = f->getNext();
}
+ }
- FilterPtr f = headFilter;
-
-
- while(f != 0)
- {
- switch(f->decide(event))
- {
- case Filter::DENY:
- return;
- case Filter::ACCEPT:
- f = 0;
- break;
- case Filter::NEUTRAL:
- f = f->getNext();
- }
- }
-
- append(event, pool1);
+ append(event, pool1);
}
void AppenderSkeleton::setErrorHandler(const spi::ErrorHandlerPtr& errorHandler1)
{
- LOCK_W sync(mutex);
+ LOCK_W sync(mutex);
- if(errorHandler1 == 0)
- {
- // We do not throw exception here since the cause is probably a
- // bad config file.
- LogLog::warn(LOG4CXX_STR("You have tried to set a null error-handler."));
- }
- else
- {
- this->errorHandler = errorHandler1;
- }
+ if (errorHandler1 == 0)
+ {
+ // We do not throw exception here since the cause is probably a
+ // bad config file.
+ LogLog::warn(LOG4CXX_STR("You have tried to set a null error-handler."));
+ }
+ else
+ {
+ this->errorHandler = errorHandler1;
+ }
}
void AppenderSkeleton::setThreshold(const LevelPtr& threshold1)
{
- LOCK_W sync(mutex);
- this->threshold = threshold1;
+ LOCK_W sync(mutex);
+ this->threshold = threshold1;
}
void AppenderSkeleton::setOption(const LogString& option,
- const LogString& value)
+ const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("THRESHOLD"), LOG4CXX_STR("threshold")))
- {
- setThreshold(Level::toLevelLS(value));
- }
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("THRESHOLD"), LOG4CXX_STR("threshold")))
+ {
+ setThreshold(Level::toLevelLS(value));
+ }
}
diff --git a/src/main/cpp/aprinitializer.cpp b/src/main/cpp/aprinitializer.cpp
index 1a90a96..151c056 100644
--- a/src/main/cpp/aprinitializer.cpp
+++ b/src/main/cpp/aprinitializer.cpp
@@ -16,7 +16,7 @@
*/
#include <log4cxx/logstring.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/helpers/aprinitializer.h>
#include <apr_pools.h>
@@ -34,13 +34,16 @@
bool APRInitializer::isDestructed = false;
-namespace {
- extern "C" void tlsDestruct(void* ptr) {
- delete ((ThreadSpecificData*) ptr);
- }
+namespace
+{
+extern "C" void tlsDestruct(void* ptr)
+{
+ delete ((ThreadSpecificData*) ptr);
+}
}
-APRInitializer::APRInitializer() : p(0), mutex(0), startTime(0), tlsKey(0) {
+APRInitializer::APRInitializer() : p(0), mutex(0), startTime(0), tlsKey(0)
+{
apr_initialize();
apr_pool_create(&p, NULL);
apr_atomic_init(p);
@@ -53,45 +56,53 @@
#endif
}
-APRInitializer::~APRInitializer() {
+APRInitializer::~APRInitializer()
+{
{
#if APR_HAS_THREADS
synchronized sync(mutex);
apr_threadkey_private_delete(tlsKey);
#endif
- for(std::list<FileWatchdog*>::iterator iter = watchdogs.begin();
- iter != watchdogs.end();
- iter++) {
+
+ for (std::list<FileWatchdog*>::iterator iter = watchdogs.begin();
+ iter != watchdogs.end();
+ iter++)
+ {
delete *iter;
}
}
-// TODO LOGCXX-322
+ // TODO LOGCXX-322
#ifndef APR_HAS_THREADS
- apr_terminate();
+ apr_terminate();
#endif
isDestructed = true;
}
-APRInitializer& APRInitializer::getInstance() {
- static APRInitializer init;
- return init;
+APRInitializer& APRInitializer::getInstance()
+{
+ static APRInitializer init;
+ return init;
}
-log4cxx_time_t APRInitializer::initialize() {
- return getInstance().startTime;
+log4cxx_time_t APRInitializer::initialize()
+{
+ return getInstance().startTime;
}
-apr_pool_t* APRInitializer::getRootPool() {
- return getInstance().p;
+apr_pool_t* APRInitializer::getRootPool()
+{
+ return getInstance().p;
}
-apr_threadkey_t* APRInitializer::getTlsKey() {
- return getInstance().tlsKey;
+apr_threadkey_t* APRInitializer::getTlsKey()
+{
+ return getInstance().tlsKey;
}
-void APRInitializer::registerCleanup(FileWatchdog* watchdog) {
+void APRInitializer::registerCleanup(FileWatchdog* watchdog)
+{
APRInitializer& instance(getInstance());
#if APR_HAS_THREADS
synchronized sync(instance.mutex);
@@ -99,19 +110,22 @@
instance.watchdogs.push_back(watchdog);
}
-void APRInitializer::unregisterCleanup(FileWatchdog* watchdog) {
+void APRInitializer::unregisterCleanup(FileWatchdog* watchdog)
+{
APRInitializer& instance(getInstance());
#if APR_HAS_THREADS
synchronized sync(instance.mutex);
#endif
- for(std::list<FileWatchdog*>::iterator iter = instance.watchdogs.begin();
- iter != instance.watchdogs.end();
- iter++) {
- if(*iter == watchdog)
- {
- instance.watchdogs.erase(iter);
- return;
- }
+
+ for (std::list<FileWatchdog*>::iterator iter = instance.watchdogs.begin();
+ iter != instance.watchdogs.end();
+ iter++)
+ {
+ if (*iter == watchdog)
+ {
+ instance.watchdogs.erase(iter);
+ return;
+ }
}
}
diff --git a/src/main/cpp/asyncappender.cpp b/src/main/cpp/asyncappender.cpp
index 336d609..0a9930f 100644
--- a/src/main/cpp/asyncappender.cpp
+++ b/src/main/cpp/asyncappender.cpp
@@ -16,7 +16,7 @@
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/asyncappender.h>
@@ -43,147 +43,180 @@
AsyncAppender::AsyncAppender()
-: AppenderSkeleton(),
- buffer(),
- bufferMutex(pool),
- bufferNotFull(pool),
- bufferNotEmpty(pool),
- discardMap(new DiscardMap()),
- bufferSize(DEFAULT_BUFFER_SIZE),
- appenders(new AppenderAttachableImpl(pool)),
- dispatcher(),
- locationInfo(false),
- blocking(true) {
+ : AppenderSkeleton(),
+ buffer(),
+ bufferMutex(pool),
+ bufferNotFull(pool),
+ bufferNotEmpty(pool),
+ discardMap(new DiscardMap()),
+ bufferSize(DEFAULT_BUFFER_SIZE),
+ appenders(new AppenderAttachableImpl(pool)),
+ dispatcher(),
+ locationInfo(false),
+ blocking(true)
+{
#if APR_HAS_THREADS
- dispatcher.run(dispatch, this);
+ dispatcher.run(dispatch, this);
#endif
}
AsyncAppender::~AsyncAppender()
{
- finalize();
- delete discardMap;
+ finalize();
+ delete discardMap;
}
-void AsyncAppender::addRef() const {
+void AsyncAppender::addRef() const
+{
ObjectImpl::addRef();
}
-void AsyncAppender::releaseRef() const {
+void AsyncAppender::releaseRef() const
+{
ObjectImpl::releaseRef();
}
void AsyncAppender::addAppender(const AppenderPtr& newAppender)
{
- synchronized sync(appenders->getMutex());
- appenders->addAppender(newAppender);
+ synchronized sync(appenders->getMutex());
+ appenders->addAppender(newAppender);
}
void AsyncAppender::setOption(const LogString& option,
- const LogString& value) {
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) {
- setLocationInfo(OptionConverter::toBoolean(value, false));
- }
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFERSIZE"), LOG4CXX_STR("buffersize"))) {
- setBufferSize(OptionConverter::toInt(value, DEFAULT_BUFFER_SIZE));
- }
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BLOCKING"), LOG4CXX_STR("blocking"))) {
- setBlocking(OptionConverter::toBoolean(value, true));
- } else {
- AppenderSkeleton::setOption(option, value);
- }
+ const LogString& value)
+{
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo")))
+ {
+ setLocationInfo(OptionConverter::toBoolean(value, false));
+ }
+
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFERSIZE"), LOG4CXX_STR("buffersize")))
+ {
+ setBufferSize(OptionConverter::toInt(value, DEFAULT_BUFFER_SIZE));
+ }
+
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BLOCKING"), LOG4CXX_STR("blocking")))
+ {
+ setBlocking(OptionConverter::toBoolean(value, true));
+ }
+ else
+ {
+ AppenderSkeleton::setOption(option, value);
+ }
}
void AsyncAppender::doAppend(const spi::LoggingEventPtr& event, Pool& pool1)
{
- LOCK_R sync(mutex);
+ LOCK_R sync(mutex);
- doAppendImpl(event, pool1);
+ doAppendImpl(event, pool1);
}
-void AsyncAppender::append(const spi::LoggingEventPtr& event, Pool& p) {
+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) {
- synchronized sync(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.
- LogString ndcVal;
- event->getNDC(ndcVal);
- event->getThreadName();
- // Get a copy of this thread's MDC.
- event->getMDCCopy();
-
-
- {
- synchronized sync(bufferMutex);
- while(true) {
- int previousSize = buffer.size();
- if (previousSize < bufferSize) {
- buffer.push_back(event);
- if (previousSize == 0) {
- bufferNotEmpty.signalAll();
- }
- break;
- }
-
- //
- // Following code is only reachable if buffer is full
- //
- //
- // if blocking and thread is not already interrupted
- // and not the dispatcher then
- // wait for a buffer notification
- bool discard = true;
- if (blocking
- && !Thread::interrupted()
- && !dispatcher.isCurrentThread()) {
- try {
- bufferNotFull.await(bufferMutex);
- discard = false;
- } catch (InterruptedException& e) {
- //
- // reset interrupt status so
- // calling code can see interrupt on
- // their next wait or sleep.
- Thread::currentThreadInterrupt();
- }
- }
-
- //
- // if blocking is false or thread has been interrupted
- // add event to discard map.
- //
- if (discard) {
- LogString loggerName = event->getLoggerName();
- DiscardMap::iterator iter = discardMap->find(loggerName);
- if (iter == discardMap->end()) {
- DiscardSummary summary(event);
- discardMap->insert(DiscardMap::value_type(loggerName, summary));
- } else {
- (*iter).second.add(event);
- }
- break;
- }
- }
- }
-#else
+ //
+ // if dispatcher has died then
+ // append subsequent events synchronously
+ //
+ if (!dispatcher.isAlive() || bufferSize <= 0)
+ {
synchronized sync(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.
+ LogString ndcVal;
+ event->getNDC(ndcVal);
+ event->getThreadName();
+ // Get a copy of this thread's MDC.
+ event->getMDCCopy();
+
+
+ {
+ synchronized sync(bufferMutex);
+
+ while (true)
+ {
+ int previousSize = buffer.size();
+
+ if (previousSize < bufferSize)
+ {
+ buffer.push_back(event);
+
+ if (previousSize == 0)
+ {
+ bufferNotEmpty.signalAll();
+ }
+
+ break;
+ }
+
+ //
+ // Following code is only reachable if buffer is full
+ //
+ //
+ // if blocking and thread is not already interrupted
+ // and not the dispatcher then
+ // wait for a buffer notification
+ bool discard = true;
+
+ if (blocking
+ && !Thread::interrupted()
+ && !dispatcher.isCurrentThread())
+ {
+ try
+ {
+ bufferNotFull.await(bufferMutex);
+ discard = false;
+ }
+ catch (InterruptedException& e)
+ {
+ //
+ // reset interrupt status so
+ // calling code can see interrupt on
+ // their next wait or sleep.
+ Thread::currentThreadInterrupt();
+ }
+ }
+
+ //
+ // if blocking is false or thread has been interrupted
+ // add event to discard map.
+ //
+ if (discard)
+ {
+ LogString loggerName = event->getLoggerName();
+ DiscardMap::iterator iter = discardMap->find(loggerName);
+
+ if (iter == discardMap->end())
+ {
+ DiscardSummary summary(event);
+ discardMap->insert(DiscardMap::value_type(loggerName, summary));
+ }
+ else
+ {
+ (*iter).second.add(event);
+ }
+
+ break;
+ }
+ }
+ }
+#else
+ synchronized sync(appenders->getMutex());
+ appenders->appendLoopOnAppenders(event, p);
#endif
- }
+}
-void AsyncAppender::close() {
+void AsyncAppender::close()
+{
{
synchronized sync(bufferMutex);
closed = true;
@@ -192,44 +225,52 @@
}
#if APR_HAS_THREADS
- try {
+
+ try
+ {
dispatcher.join();
- } catch(InterruptedException& e) {
+ }
+ catch (InterruptedException& e)
+ {
Thread::currentThreadInterrupt();
LogLog::error(LOG4CXX_STR("Got an InterruptedException while waiting for the dispatcher to finish,"), e);
}
+
#endif
{
synchronized sync(appenders->getMutex());
AppenderList appenderList = appenders->getAllAppenders();
+
for (AppenderList::iterator iter = appenderList.begin();
- iter != appenderList.end();
- iter++) {
- (*iter)->close();
+ iter != appenderList.end();
+ iter++)
+ {
+ (*iter)->close();
}
}
}
AppenderList AsyncAppender::getAllAppenders() const
{
- synchronized sync(appenders->getMutex());
- return appenders->getAllAppenders();
+ synchronized sync(appenders->getMutex());
+ return appenders->getAllAppenders();
}
AppenderPtr AsyncAppender::getAppender(const LogString& n) const
{
- synchronized sync(appenders->getMutex());
- return appenders->getAppender(n);
+ synchronized sync(appenders->getMutex());
+ return appenders->getAppender(n);
}
bool AsyncAppender::isAttached(const AppenderPtr& appender) const
{
- synchronized sync(appenders->getMutex());
- return appenders->isAttached(appender);
+ synchronized sync(appenders->getMutex());
+ return appenders->isAttached(appender);
}
-bool AsyncAppender::requiresLayout() const {
+bool AsyncAppender::requiresLayout() const
+{
return false;
}
@@ -251,20 +292,24 @@
appenders->removeAppender(n);
}
-bool AsyncAppender::getLocationInfo() const {
+bool AsyncAppender::getLocationInfo() const
+{
return locationInfo;
}
-void AsyncAppender::setLocationInfo(bool flag) {
+void AsyncAppender::setLocationInfo(bool flag)
+{
locationInfo = flag;
}
void AsyncAppender::setBufferSize(int size)
{
- if (size < 0) {
- throw IllegalArgumentException(LOG4CXX_STR("size argument must be non-negative"));
+ if (size < 0)
+ {
+ throw IllegalArgumentException(LOG4CXX_STR("size argument must be non-negative"));
}
+
synchronized sync(bufferMutex);
bufferSize = (size < 1) ? 1 : size;
bufferNotFull.signalAll();
@@ -272,114 +317,139 @@
int AsyncAppender::getBufferSize() const
{
- return bufferSize;
+ return bufferSize;
}
-void AsyncAppender::setBlocking(bool value) {
+void AsyncAppender::setBlocking(bool value)
+{
synchronized sync(bufferMutex);
blocking = value;
bufferNotFull.signalAll();
}
-bool AsyncAppender::getBlocking() const {
+bool AsyncAppender::getBlocking() const
+{
return blocking;
}
AsyncAppender::DiscardSummary::DiscardSummary(const LoggingEventPtr& event) :
- maxEvent(event), count(1) {
+ maxEvent(event), count(1)
+{
}
AsyncAppender::DiscardSummary::DiscardSummary(const DiscardSummary& src) :
- maxEvent(src.maxEvent), count(src.count) {
+ maxEvent(src.maxEvent), count(src.count)
+{
}
-AsyncAppender::DiscardSummary& AsyncAppender::DiscardSummary::operator=(const DiscardSummary& src) {
- maxEvent = src.maxEvent;
- count = src.count;
- return *this;
+AsyncAppender::DiscardSummary& AsyncAppender::DiscardSummary::operator=(const DiscardSummary& src)
+{
+ maxEvent = src.maxEvent;
+ count = src.count;
+ return *this;
}
-void AsyncAppender::DiscardSummary::add(const LoggingEventPtr& event) {
- if (event->getLevel()->toInt() > maxEvent->getLevel()->toInt()) {
+void AsyncAppender::DiscardSummary::add(const LoggingEventPtr& event)
+{
+ if (event->getLevel()->toInt() > maxEvent->getLevel()->toInt())
+ {
maxEvent = event;
- }
- count++;
+ }
+
+ count++;
}
-LoggingEventPtr AsyncAppender::DiscardSummary::createEvent(Pool& p) {
+LoggingEventPtr AsyncAppender::DiscardSummary::createEvent(Pool& p)
+{
LogString msg(LOG4CXX_STR("Discarded "));
StringHelper::toString(count, p, msg);
msg.append(LOG4CXX_STR(" messages due to a full event buffer including: "));
msg.append(maxEvent->getMessage());
return new LoggingEvent(
- maxEvent->getLoggerName(),
- maxEvent->getLevel(),
- msg,
- LocationInfo::getLocationUnavailable());
+ maxEvent->getLoggerName(),
+ maxEvent->getLevel(),
+ msg,
+ LocationInfo::getLocationUnavailable());
}
::log4cxx::spi::LoggingEventPtr
AsyncAppender::DiscardSummary::createEvent(::log4cxx::helpers::Pool& p,
- size_t discardedCount)
+ size_t discardedCount)
{
- LogString msg(LOG4CXX_STR("Discarded "));
- StringHelper::toString(discardedCount, p, msg);
- msg.append(LOG4CXX_STR(" messages due to a full event buffer"));
+ LogString msg(LOG4CXX_STR("Discarded "));
+ StringHelper::toString(discardedCount, p, msg);
+ msg.append(LOG4CXX_STR(" messages due to a full event buffer"));
return new LoggingEvent(
- LOG4CXX_STR(""),
- log4cxx::Level::getError(),
- msg,
- LocationInfo::getLocationUnavailable());
+ LOG4CXX_STR(""),
+ log4cxx::Level::getError(),
+ msg,
+ LocationInfo::getLocationUnavailable());
}
#if APR_HAS_THREADS
-void* LOG4CXX_THREAD_FUNC AsyncAppender::dispatch(apr_thread_t* /*thread*/, void* data) {
+void* LOG4CXX_THREAD_FUNC AsyncAppender::dispatch(apr_thread_t* /*thread*/, void* data)
+{
AsyncAppender* pThis = (AsyncAppender*) data;
bool isActive = true;
- try {
- while (isActive) {
- //
- // process events after lock on buffer is released.
- //
+
+ try
+ {
+ while (isActive)
+ {
+ //
+ // process events after lock on buffer is released.
+ //
Pool p;
LoggingEventList events;
{
- synchronized sync(pThis->bufferMutex);
- size_t bufferSize = pThis->buffer.size();
- isActive = !pThis->closed;
+ synchronized sync(pThis->bufferMutex);
+ size_t bufferSize = pThis->buffer.size();
+ isActive = !pThis->closed;
- while((bufferSize == 0) && isActive) {
- pThis->bufferNotEmpty.await(pThis->bufferMutex);
- bufferSize = pThis->buffer.size();
- isActive = !pThis->closed;
- }
- for(LoggingEventList::iterator eventIter = pThis->buffer.begin();
- eventIter != pThis->buffer.end();
- eventIter++) {
- events.push_back(*eventIter);
- }
- for(DiscardMap::iterator discardIter = pThis->discardMap->begin();
- discardIter != pThis->discardMap->end();
- discardIter++) {
- events.push_back(discardIter->second.createEvent(p));
- }
- pThis->buffer.clear();
- pThis->discardMap->clear();
- pThis->bufferNotFull.signalAll();
+ while ((bufferSize == 0) && isActive)
+ {
+ pThis->bufferNotEmpty.await(pThis->bufferMutex);
+ bufferSize = pThis->buffer.size();
+ isActive = !pThis->closed;
+ }
+
+ for (LoggingEventList::iterator eventIter = pThis->buffer.begin();
+ eventIter != pThis->buffer.end();
+ eventIter++)
+ {
+ events.push_back(*eventIter);
+ }
+
+ for (DiscardMap::iterator discardIter = pThis->discardMap->begin();
+ discardIter != pThis->discardMap->end();
+ discardIter++)
+ {
+ events.push_back(discardIter->second.createEvent(p));
+ }
+
+ pThis->buffer.clear();
+ pThis->discardMap->clear();
+ pThis->bufferNotFull.signalAll();
}
for (LoggingEventList::iterator iter = events.begin();
- iter != events.end();
- iter++) {
- synchronized sync(pThis->appenders->getMutex());
- pThis->appenders->appendLoopOnAppenders(*iter, p);
+ iter != events.end();
+ iter++)
+ {
+ synchronized sync(pThis->appenders->getMutex());
+ pThis->appenders->appendLoopOnAppenders(*iter, p);
}
}
- } catch(InterruptedException& ex) {
- Thread::currentThreadInterrupt();
- } catch(...) {
}
+ catch (InterruptedException& ex)
+ {
+ Thread::currentThreadInterrupt();
+ }
+ catch (...)
+ {
+ }
+
return 0;
}
#endif
diff --git a/src/main/cpp/asyncappender_nonblocking.cpp b/src/main/cpp/asyncappender_nonblocking.cpp
index 25ad7ff..fca89df 100644
--- a/src/main/cpp/asyncappender_nonblocking.cpp
+++ b/src/main/cpp/asyncappender_nonblocking.cpp
@@ -16,7 +16,7 @@
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/asyncappender.h>
@@ -43,143 +43,167 @@
AsyncAppender::AsyncAppender()
-: AppenderSkeleton(),
- buffer(DEFAULT_BUFFER_SIZE),
- SHARED_MUTEX_INIT(bufferMutex, pool),
- bufferNotFull(pool),
- bufferNotEmpty(pool),
- discardMap(new DiscardMap()),
- bufferSize(DEFAULT_BUFFER_SIZE),
- appenders(new AppenderAttachableImpl(pool)),
- dispatcher(),
- locationInfo(false),
- blocking(true) {
+ : AppenderSkeleton(),
+ buffer(DEFAULT_BUFFER_SIZE),
+ SHARED_MUTEX_INIT(bufferMutex, pool),
+ bufferNotFull(pool),
+ bufferNotEmpty(pool),
+ discardMap(new DiscardMap()),
+ bufferSize(DEFAULT_BUFFER_SIZE),
+ appenders(new AppenderAttachableImpl(pool)),
+ dispatcher(),
+ locationInfo(false),
+ blocking(true)
+{
#if APR_HAS_THREADS
- dispatcher.run(dispatch, this);
+ dispatcher.run(dispatch, this);
#endif
}
AsyncAppender::~AsyncAppender()
{
- finalize();
- delete discardMap;
+ finalize();
+ delete discardMap;
}
-void AsyncAppender::addRef() const {
+void AsyncAppender::addRef() const
+{
ObjectImpl::addRef();
}
-void AsyncAppender::releaseRef() const {
+void AsyncAppender::releaseRef() const
+{
ObjectImpl::releaseRef();
}
void AsyncAppender::addAppender(const AppenderPtr& newAppender)
{
- synchronized sync(appenders->getMutex());
- appenders->addAppender(newAppender);
+ synchronized sync(appenders->getMutex());
+ appenders->addAppender(newAppender);
}
void AsyncAppender::setOption(const LogString& option,
- const LogString& value) {
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo"))) {
- setLocationInfo(OptionConverter::toBoolean(value, false));
- }
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFERSIZE"), LOG4CXX_STR("buffersize"))) {
- setBufferSize(OptionConverter::toInt(value, DEFAULT_BUFFER_SIZE));
- }
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BLOCKING"), LOG4CXX_STR("blocking"))) {
- setBlocking(OptionConverter::toBoolean(value, true));
- } else {
- AppenderSkeleton::setOption(option, value);
- }
+ const LogString& value)
+{
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo")))
+ {
+ setLocationInfo(OptionConverter::toBoolean(value, false));
+ }
+
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFERSIZE"), LOG4CXX_STR("buffersize")))
+ {
+ setBufferSize(OptionConverter::toInt(value, DEFAULT_BUFFER_SIZE));
+ }
+
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BLOCKING"), LOG4CXX_STR("blocking")))
+ {
+ setBlocking(OptionConverter::toBoolean(value, true));
+ }
+ else
+ {
+ AppenderSkeleton::setOption(option, value);
+ }
}
void AsyncAppender::doAppend(const spi::LoggingEventPtr& event, Pool& pool1)
{
- LOCK_R sync(mutex);
+ LOCK_R sync(mutex);
- doAppendImpl(event, pool1);
+ doAppendImpl(event, pool1);
}
-void AsyncAppender::append(const spi::LoggingEventPtr& event, Pool& p) {
+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) {
- synchronized sync(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.
- LogString ndcVal;
- event->getNDC(ndcVal);
- event->getThreadName();
- // Get a copy of this thread's MDC.
- event->getMDCCopy();
-
-
- {
- LOCK_R sync(bufferMutex);
- while(true) {
-
- event->addRef();
- if (buffer.bounded_push(event))
- {
- bufferNotEmpty.signalAll();
- break;
- }
- else
- {
- event->releaseRef();
- }
-
- //
- // Following code is only reachable if buffer is full
- //
- //
- // if blocking and thread is not already interrupted
- // and not the dispatcher then
- // wait for a buffer notification
- bool discard = true;
- if (blocking
- && !Thread::interrupted()
- && !dispatcher.isCurrentThread()) {
- try {
- bufferNotFull.await();
- discard = false;
- } catch (InterruptedException& e) {
- //
- // reset interrupt status so
- // calling code can see interrupt on
- // their next wait or sleep.
- Thread::currentThreadInterrupt();
- }
- }
-
- //
- // if blocking is false or thread has been interrupted
- // add event to discard map.
- //
- if (discard) {
- discardedCount++;
- break;
- }
- }
- }
-#else
+ //
+ // if dispatcher has died then
+ // append subsequent events synchronously
+ //
+ if (!dispatcher.isAlive() || bufferSize <= 0)
+ {
synchronized sync(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.
+ LogString ndcVal;
+ event->getNDC(ndcVal);
+ event->getThreadName();
+ // Get a copy of this thread's MDC.
+ event->getMDCCopy();
+
+
+ {
+ LOCK_R sync(bufferMutex);
+
+ while (true)
+ {
+
+ event->addRef();
+
+ if (buffer.bounded_push(event))
+ {
+ bufferNotEmpty.signalAll();
+ break;
+ }
+ else
+ {
+ event->releaseRef();
+ }
+
+ //
+ // Following code is only reachable if buffer is full
+ //
+ //
+ // if blocking and thread is not already interrupted
+ // and not the dispatcher then
+ // wait for a buffer notification
+ bool discard = true;
+
+ if (blocking
+ && !Thread::interrupted()
+ && !dispatcher.isCurrentThread())
+ {
+ try
+ {
+ bufferNotFull.await();
+ discard = false;
+ }
+ catch (InterruptedException& e)
+ {
+ //
+ // reset interrupt status so
+ // calling code can see interrupt on
+ // their next wait or sleep.
+ Thread::currentThreadInterrupt();
+ }
+ }
+
+ //
+ // if blocking is false or thread has been interrupted
+ // add event to discard map.
+ //
+ if (discard)
+ {
+ discardedCount++;
+ break;
+ }
+ }
+ }
+#else
+ synchronized sync(appenders->getMutex());
+ appenders->appendLoopOnAppenders(event, p);
#endif
- }
+}
-void AsyncAppender::close() {
+void AsyncAppender::close()
+{
{
LOCK_W sync(bufferMutex);
closed = true;
@@ -189,44 +213,52 @@
bufferNotFull.signalAll();
#if APR_HAS_THREADS
- try {
+
+ try
+ {
dispatcher.join();
- } catch(InterruptedException& e) {
+ }
+ catch (InterruptedException& e)
+ {
Thread::currentThreadInterrupt();
LogLog::error(LOG4CXX_STR("Got an InterruptedException while waiting for the dispatcher to finish,"), e);
}
+
#endif
{
synchronized sync(appenders->getMutex());
AppenderList appenderList = appenders->getAllAppenders();
+
for (AppenderList::iterator iter = appenderList.begin();
- iter != appenderList.end();
- iter++) {
- (*iter)->close();
+ iter != appenderList.end();
+ iter++)
+ {
+ (*iter)->close();
}
}
}
AppenderList AsyncAppender::getAllAppenders() const
{
- synchronized sync(appenders->getMutex());
- return appenders->getAllAppenders();
+ synchronized sync(appenders->getMutex());
+ return appenders->getAllAppenders();
}
AppenderPtr AsyncAppender::getAppender(const LogString& n) const
{
- synchronized sync(appenders->getMutex());
- return appenders->getAppender(n);
+ synchronized sync(appenders->getMutex());
+ return appenders->getAppender(n);
}
bool AsyncAppender::isAttached(const AppenderPtr& appender) const
{
- synchronized sync(appenders->getMutex());
- return appenders->isAttached(appender);
+ synchronized sync(appenders->getMutex());
+ return appenders->isAttached(appender);
}
-bool AsyncAppender::requiresLayout() const {
+bool AsyncAppender::requiresLayout() const
+{
return false;
}
@@ -248,19 +280,22 @@
appenders->removeAppender(n);
}
-bool AsyncAppender::getLocationInfo() const {
+bool AsyncAppender::getLocationInfo() const
+{
return locationInfo;
}
-void AsyncAppender::setLocationInfo(bool flag) {
+void AsyncAppender::setLocationInfo(bool flag)
+{
locationInfo = flag;
}
void AsyncAppender::setBufferSize(int size)
{
- if (size < 0) {
- throw IllegalArgumentException(LOG4CXX_STR("size argument must be non-negative"));
+ if (size < 0)
+ {
+ throw IllegalArgumentException(LOG4CXX_STR("size argument must be non-negative"));
}
{
@@ -268,15 +303,17 @@
bufferSize = (size < 1) ? 1 : size;
buffer.reserve_unsafe(bufferSize);
}
+
bufferNotFull.signalAll();
}
int AsyncAppender::getBufferSize() const
{
- return bufferSize;
+ return bufferSize;
}
-void AsyncAppender::setBlocking(bool value) {
+void AsyncAppender::setBlocking(bool value)
+{
{
LOCK_W sync(bufferMutex);
blocking = value;
@@ -284,107 +321,127 @@
bufferNotFull.signalAll();
}
-bool AsyncAppender::getBlocking() const {
+bool AsyncAppender::getBlocking() const
+{
return blocking;
}
AsyncAppender::DiscardSummary::DiscardSummary(const LoggingEventPtr& event) :
- maxEvent(event), count(1) {
+ maxEvent(event), count(1)
+{
}
AsyncAppender::DiscardSummary::DiscardSummary(const DiscardSummary& src) :
- maxEvent(src.maxEvent), count(src.count) {
+ maxEvent(src.maxEvent), count(src.count)
+{
}
-AsyncAppender::DiscardSummary& AsyncAppender::DiscardSummary::operator=(const DiscardSummary& src) {
- maxEvent = src.maxEvent;
- count = src.count;
- return *this;
+AsyncAppender::DiscardSummary& AsyncAppender::DiscardSummary::operator=(const DiscardSummary& src)
+{
+ maxEvent = src.maxEvent;
+ count = src.count;
+ return *this;
}
-void AsyncAppender::DiscardSummary::add(const LoggingEventPtr& event) {
- if (event->getLevel()->toInt() > maxEvent->getLevel()->toInt()) {
+void AsyncAppender::DiscardSummary::add(const LoggingEventPtr& event)
+{
+ if (event->getLevel()->toInt() > maxEvent->getLevel()->toInt())
+ {
maxEvent = event;
- }
- count++;
+ }
+
+ count++;
}
-LoggingEventPtr AsyncAppender::DiscardSummary::createEvent(Pool& p) {
+LoggingEventPtr AsyncAppender::DiscardSummary::createEvent(Pool& p)
+{
LogString msg(LOG4CXX_STR("Discarded "));
StringHelper::toString(count, p, msg);
msg.append(LOG4CXX_STR(" messages due to a full event buffer including: "));
msg.append(maxEvent->getMessage());
return new LoggingEvent(
- maxEvent->getLoggerName(),
- maxEvent->getLevel(),
- msg,
- LocationInfo::getLocationUnavailable());
+ maxEvent->getLoggerName(),
+ maxEvent->getLevel(),
+ msg,
+ LocationInfo::getLocationUnavailable());
}
::log4cxx::spi::LoggingEventPtr
AsyncAppender::DiscardSummary::createEvent(::log4cxx::helpers::Pool& p,
- size_t discardedCount)
+ size_t discardedCount)
{
- LogString msg(LOG4CXX_STR("Discarded "));
- StringHelper::toString(discardedCount, p, msg);
- msg.append(LOG4CXX_STR(" messages due to a full event buffer"));
+ LogString msg(LOG4CXX_STR("Discarded "));
+ StringHelper::toString(discardedCount, p, msg);
+ msg.append(LOG4CXX_STR(" messages due to a full event buffer"));
return new LoggingEvent(
- LOG4CXX_STR(""),
- log4cxx::Level::getError(),
- msg,
- LocationInfo::getLocationUnavailable());
+ LOG4CXX_STR(""),
+ log4cxx::Level::getError(),
+ msg,
+ LocationInfo::getLocationUnavailable());
}
#if APR_HAS_THREADS
-void* LOG4CXX_THREAD_FUNC AsyncAppender::dispatch(apr_thread_t* /*thread*/, void* data) {
+void* LOG4CXX_THREAD_FUNC AsyncAppender::dispatch(apr_thread_t* /*thread*/, void* data)
+{
AsyncAppender* pThis = (AsyncAppender*) data;
- try {
- while (!pThis->closed || !pThis->buffer.empty()) {
- pThis->bufferNotEmpty.await();
+ try
+ {
+ while (!pThis->closed || !pThis->buffer.empty())
+ {
- //
- // process events after lock on buffer is released.
- //
+ pThis->bufferNotEmpty.await();
+
+ //
+ // process events after lock on buffer is released.
+ //
Pool p;
LoggingEventList events;
{
- LOCK_R sync(pThis->bufferMutex);
+ LOCK_R sync(pThis->bufferMutex);
- unsigned count = 0;
- log4cxx::spi::LoggingEvent * logPtr = nullptr;
- while (pThis->buffer.pop(logPtr))
- {
- log4cxx::spi::LoggingEventPtr ptr(logPtr);
- events.push_back(ptr);
- logPtr->releaseRef();
- count++;
- }
+ unsigned count = 0;
+ log4cxx::spi::LoggingEvent* logPtr = nullptr;
- if (pThis->blocking) {
- pThis->bufferNotFull.signalAll();
- }
+ while (pThis->buffer.pop(logPtr))
+ {
+ log4cxx::spi::LoggingEventPtr ptr(logPtr);
+ events.push_back(ptr);
+ logPtr->releaseRef();
+ count++;
+ }
- size_t discarded = pThis->discardedCount.exchange(0);
+ if (pThis->blocking)
+ {
+ pThis->bufferNotFull.signalAll();
+ }
- if (discarded != 0)
- {
- events.push_back(AsyncAppender::DiscardSummary::createEvent(p, discarded));
- }
+ size_t discarded = pThis->discardedCount.exchange(0);
+
+ if (discarded != 0)
+ {
+ events.push_back(AsyncAppender::DiscardSummary::createEvent(p, discarded));
+ }
}
for (LoggingEventList::iterator iter = events.begin();
- iter != events.end();
- iter++) {
- synchronized sync(pThis->appenders->getMutex());
- pThis->appenders->appendLoopOnAppenders(*iter, p);
+ iter != events.end();
+ iter++)
+ {
+ synchronized sync(pThis->appenders->getMutex());
+ pThis->appenders->appendLoopOnAppenders(*iter, p);
}
}
- } catch(InterruptedException& ex) {
- Thread::currentThreadInterrupt();
- } catch(...) {
}
+ catch (InterruptedException& ex)
+ {
+ Thread::currentThreadInterrupt();
+ }
+ catch (...)
+ {
+ }
+
return 0;
}
#endif
diff --git a/src/main/cpp/basicconfigurator.cpp b/src/main/cpp/basicconfigurator.cpp
index d3d84f0..24a46d6 100644
--- a/src/main/cpp/basicconfigurator.cpp
+++ b/src/main/cpp/basicconfigurator.cpp
@@ -25,21 +25,21 @@
void BasicConfigurator::configure()
{
- LogManager::getLoggerRepository()->setConfigured(true);
- LoggerPtr root = Logger::getRootLogger();
- static const LogString TTCC_CONVERSION_PATTERN(LOG4CXX_STR("%r [%t] %p %c %x - %m%n"));
- LayoutPtr layout(new PatternLayout(TTCC_CONVERSION_PATTERN));
- AppenderPtr appender(new ConsoleAppender(layout));
- root->addAppender(appender);
+ LogManager::getLoggerRepository()->setConfigured(true);
+ LoggerPtr root = Logger::getRootLogger();
+ static const LogString TTCC_CONVERSION_PATTERN(LOG4CXX_STR("%r [%t] %p %c %x - %m%n"));
+ LayoutPtr layout(new PatternLayout(TTCC_CONVERSION_PATTERN));
+ AppenderPtr appender(new ConsoleAppender(layout));
+ root->addAppender(appender);
}
void BasicConfigurator::configure(const AppenderPtr& appender)
{
- LoggerPtr root = Logger::getRootLogger();
- root->addAppender(appender);
+ LoggerPtr root = Logger::getRootLogger();
+ root->addAppender(appender);
}
void BasicConfigurator::resetConfiguration()
{
- LogManager::resetConfiguration();
+ LogManager::resetConfiguration();
}
diff --git a/src/main/cpp/bufferedwriter.cpp b/src/main/cpp/bufferedwriter.cpp
index ebb2328..6898d09 100644
--- a/src/main/cpp/bufferedwriter.cpp
+++ b/src/main/cpp/bufferedwriter.cpp
@@ -24,37 +24,49 @@
IMPLEMENT_LOG4CXX_OBJECT(BufferedWriter)
BufferedWriter::BufferedWriter(WriterPtr& out1)
- : out(out1), sz(1024) {
+ : out(out1), sz(1024)
+{
}
BufferedWriter::BufferedWriter(WriterPtr& out1, size_t sz1)
- : out(out1), sz(sz1) {
+ : out(out1), sz(sz1)
+{
}
-BufferedWriter::~BufferedWriter() {
+BufferedWriter::~BufferedWriter()
+{
}
-void BufferedWriter::close(Pool& p) {
- flush(p);
- out->close(p);
+void BufferedWriter::close(Pool& p)
+{
+ flush(p);
+ out->close(p);
}
-void BufferedWriter::flush(Pool& p) {
- if (buf.length() > 0) {
- out->write(buf, p);
- buf.erase(buf.begin(), buf.end());
- }
+void BufferedWriter::flush(Pool& p)
+{
+ if (buf.length() > 0)
+ {
+ out->write(buf, p);
+ buf.erase(buf.begin(), buf.end());
+ }
}
-void BufferedWriter::write(const LogString& str, Pool& p) {
- if (buf.length() + str.length() > sz) {
- out->write(buf, p);
- buf.erase(buf.begin(), buf.end());
- }
- if (str.length() > sz) {
- out->write(str, p);
- } else {
- buf.append(str);
- }
+void BufferedWriter::write(const LogString& str, Pool& p)
+{
+ if (buf.length() + str.length() > sz)
+ {
+ out->write(buf, p);
+ buf.erase(buf.begin(), buf.end());
+ }
+
+ if (str.length() > sz)
+ {
+ out->write(str, p);
+ }
+ else
+ {
+ buf.append(str);
+ }
}
diff --git a/src/main/cpp/bytearrayinputstream.cpp b/src/main/cpp/bytearrayinputstream.cpp
index b1aaaef..20f90f2 100644
--- a/src/main/cpp/bytearrayinputstream.cpp
+++ b/src/main/cpp/bytearrayinputstream.cpp
@@ -29,23 +29,30 @@
IMPLEMENT_LOG4CXX_OBJECT(ByteArrayInputStream)
ByteArrayInputStream::ByteArrayInputStream(const std::vector<unsigned char>& bytes) :
- buf(bytes), pos(0) {
+ buf(bytes), pos(0)
+{
}
-ByteArrayInputStream::~ByteArrayInputStream() {
+ByteArrayInputStream::~ByteArrayInputStream()
+{
}
-void ByteArrayInputStream::close() {
+void ByteArrayInputStream::close()
+{
}
-int ByteArrayInputStream::read(ByteBuffer& dst) {
- if (pos >= buf.size()) {
+int ByteArrayInputStream::read(ByteBuffer& dst)
+{
+ if (pos >= buf.size())
+ {
return -1;
- } else {
+ }
+ else
+ {
size_t bytesCopied = min(dst.remaining(), buf.size() - pos);
memcpy(dst.current(), &buf[pos], bytesCopied);
pos += bytesCopied;
diff --git a/src/main/cpp/bytearrayoutputstream.cpp b/src/main/cpp/bytearrayoutputstream.cpp
index 0a3d4c8..52786c9 100644
--- a/src/main/cpp/bytearrayoutputstream.cpp
+++ b/src/main/cpp/bytearrayoutputstream.cpp
@@ -26,27 +26,33 @@
IMPLEMENT_LOG4CXX_OBJECT(ByteArrayOutputStream)
-ByteArrayOutputStream::ByteArrayOutputStream() {
+ByteArrayOutputStream::ByteArrayOutputStream()
+{
}
-ByteArrayOutputStream::~ByteArrayOutputStream() {
+ByteArrayOutputStream::~ByteArrayOutputStream()
+{
}
-void ByteArrayOutputStream::close(Pool& /* p */) {
+void ByteArrayOutputStream::close(Pool& /* p */)
+{
}
-void ByteArrayOutputStream::flush(Pool& /* p */) {
+void ByteArrayOutputStream::flush(Pool& /* p */)
+{
}
-void ByteArrayOutputStream::write(ByteBuffer& buf, Pool& /* p */ ) {
- size_t sz = array.size();
- array.resize(sz + buf.remaining());
- memcpy(&array[sz], buf.current(), buf.remaining());
- buf.position(buf.limit());
+void ByteArrayOutputStream::write(ByteBuffer& buf, Pool& /* p */ )
+{
+ size_t sz = array.size();
+ array.resize(sz + buf.remaining());
+ memcpy(&array[sz], buf.current(), buf.remaining());
+ buf.position(buf.limit());
}
-std::vector<unsigned char> ByteArrayOutputStream::toByteArray() const {
- return array;
+std::vector<unsigned char> ByteArrayOutputStream::toByteArray() const
+{
+ return array;
}
diff --git a/src/main/cpp/bytebuffer.cpp b/src/main/cpp/bytebuffer.cpp
index d8157cf..e4f2e36 100644
--- a/src/main/cpp/bytebuffer.cpp
+++ b/src/main/cpp/bytebuffer.cpp
@@ -24,42 +24,56 @@
using namespace log4cxx::helpers;
ByteBuffer::ByteBuffer(char* data1, size_t capacity)
- : base(data1), pos(0), lim(capacity), cap(capacity) {
+ : base(data1), pos(0), lim(capacity), cap(capacity)
+{
}
-ByteBuffer::~ByteBuffer() {
+ByteBuffer::~ByteBuffer()
+{
}
-void ByteBuffer::clear() {
- lim = cap;
- pos = 0;
+void ByteBuffer::clear()
+{
+ lim = cap;
+ pos = 0;
}
-void ByteBuffer::flip() {
- lim = pos;
- pos = 0;
+void ByteBuffer::flip()
+{
+ lim = pos;
+ pos = 0;
}
-void ByteBuffer::position(size_t newPosition) {
- if (newPosition < lim) {
- pos = newPosition;
- } else {
- pos = lim;
- }
+void ByteBuffer::position(size_t newPosition)
+{
+ if (newPosition < lim)
+ {
+ pos = newPosition;
+ }
+ else
+ {
+ pos = lim;
+ }
}
-void ByteBuffer::limit(size_t newLimit) {
- if (newLimit > cap) {
- throw IllegalArgumentException(LOG4CXX_STR("newLimit"));
- }
- lim = newLimit;
+void ByteBuffer::limit(size_t newLimit)
+{
+ if (newLimit > cap)
+ {
+ throw IllegalArgumentException(LOG4CXX_STR("newLimit"));
+ }
+
+ lim = newLimit;
}
-bool ByteBuffer::put(char byte) {
- if (pos < lim) {
- base[pos++] = byte;
- return true;
- }
- return false;
+bool ByteBuffer::put(char byte)
+{
+ if (pos < lim)
+ {
+ base[pos++] = byte;
+ return true;
+ }
+
+ return false;
}
diff --git a/src/main/cpp/cacheddateformat.cpp b/src/main/cpp/cacheddateformat.cpp
index 825d85f..90672fe 100644
--- a/src/main/cpp/cacheddateformat.cpp
+++ b/src/main/cpp/cacheddateformat.cpp
@@ -67,19 +67,23 @@
* caching or 1 to only use cache for duplicate requests.
*/
CachedDateFormat::CachedDateFormat(const DateFormatPtr& dateFormat,
- int expiration1) :
- formatter(dateFormat),
- millisecondStart(0),
- slotBegin(std::numeric_limits<log4cxx_time_t>::min()),
- cache(50, 0x20),
- expiration(expiration1),
- previousTime(std::numeric_limits<log4cxx_time_t>::min()) {
- if (dateFormat == NULL) {
- throw IllegalArgumentException(LOG4CXX_STR("dateFormat cannot be null"));
- }
- if (expiration1 < 0) {
- throw IllegalArgumentException(LOG4CXX_STR("expiration must be non-negative"));
- }
+ int expiration1) :
+ formatter(dateFormat),
+ millisecondStart(0),
+ slotBegin(std::numeric_limits<log4cxx_time_t>::min()),
+ cache(50, 0x20),
+ expiration(expiration1),
+ previousTime(std::numeric_limits<log4cxx_time_t>::min())
+{
+ if (dateFormat == NULL)
+ {
+ throw IllegalArgumentException(LOG4CXX_STR("dateFormat cannot be null"));
+ }
+
+ if (expiration1 < 0)
+ {
+ throw IllegalArgumentException(LOG4CXX_STR("expiration must be non-negative"));
+ }
}
@@ -93,70 +97,86 @@
* field (likely RelativeTimeDateFormat)
*/
int CachedDateFormat::findMillisecondStart(
- log4cxx_time_t time, const LogString& formatted,
- const DateFormatPtr& formatter,
- Pool& pool) {
+ log4cxx_time_t time, const LogString& formatted,
+ const DateFormatPtr& formatter,
+ Pool& pool)
+{
- apr_time_t slotBegin = (time / 1000000) * 1000000;
- if (slotBegin > time) {
- slotBegin -= 1000000;
- }
- int millis = (int) (time - slotBegin)/1000;
+ apr_time_t slotBegin = (time / 1000000) * 1000000;
- int magic = magic1;
- LogString magicString(magicString1);
- if (millis == magic1) {
- magic = magic2;
- magicString = magicString2;
- }
+ if (slotBegin > time)
+ {
+ slotBegin -= 1000000;
+ }
- LogString plusMagic;
- formatter->format(plusMagic, slotBegin + magic, pool);
+ int millis = (int) (time - slotBegin) / 1000;
- /**
- * If the string lengths differ then
- * we can't use the cache except for duplicate requests.
- */
- if (plusMagic.length() != formatted.length()) {
- return UNRECOGNIZED_MILLISECONDS;
- } else {
- // find first difference between values
- for (LogString::size_type i = 0; i < formatted.length(); i++) {
- if (formatted[i] != plusMagic[i]) {
- //
- // determine the expected digits for the base time
- const logchar abc[] = { 0x41, 0x42, 0x43, 0 };
- LogString formattedMillis(abc);
- millisecondFormat(millis, formattedMillis, 0);
+ int magic = magic1;
+ LogString magicString(magicString1);
- LogString plusZero;
- formatter->format(plusZero, slotBegin, pool);
+ if (millis == magic1)
+ {
+ magic = magic2;
+ magicString = magicString2;
+ }
- // Test if the next 1..3 characters match the magic string, main problem is that magic
- // available millis in formatted can overlap. Therefore the current i is not always the
- // index of the first millis char, but may be already within the millis. Besides that
- // the millis can occur everywhere in formatted. See LOGCXX-420 and following.
- size_t magicLength = magicString.length();
- size_t overlapping = magicString.find(plusMagic[i]);
- int possibleRetVal = i - overlapping;
- if (plusZero.length() == formatted.length()
- && regionMatches(magicString, 0, plusMagic, possibleRetVal, magicLength)
- && regionMatches(formattedMillis, 0, formatted, possibleRetVal, magicLength)
- && regionMatches(zeroString, 0, plusZero, possibleRetVal, magicLength)
- // The following will and should fail for patterns with more than one SSS because
- // we only seem to be able to change one SSS in e.g. format and need to reformat the
- // whole string in other cases.
- && (formatted.length() == possibleRetVal + magicLength
- || plusZero.compare(possibleRetVal + magicLength,
- LogString::npos, plusMagic, possibleRetVal + magicLength, LogString::npos) == 0)) {
- return possibleRetVal;
- } else {
- return UNRECOGNIZED_MILLISECONDS;
- }
+ LogString plusMagic;
+ formatter->format(plusMagic, slotBegin + magic, pool);
+
+ /**
+ * If the string lengths differ then
+ * we can't use the cache except for duplicate requests.
+ */
+ if (plusMagic.length() != formatted.length())
+ {
+ return UNRECOGNIZED_MILLISECONDS;
+ }
+ else
+ {
+ // find first difference between values
+ for (LogString::size_type i = 0; i < formatted.length(); i++)
+ {
+ if (formatted[i] != plusMagic[i])
+ {
+ //
+ // determine the expected digits for the base time
+ const logchar abc[] = { 0x41, 0x42, 0x43, 0 };
+ LogString formattedMillis(abc);
+ millisecondFormat(millis, formattedMillis, 0);
+
+ LogString plusZero;
+ formatter->format(plusZero, slotBegin, pool);
+
+ // Test if the next 1..3 characters match the magic string, main problem is that magic
+ // available millis in formatted can overlap. Therefore the current i is not always the
+ // index of the first millis char, but may be already within the millis. Besides that
+ // the millis can occur everywhere in formatted. See LOGCXX-420 and following.
+ size_t magicLength = magicString.length();
+ size_t overlapping = magicString.find(plusMagic[i]);
+ int possibleRetVal = i - overlapping;
+
+ if (plusZero.length() == formatted.length()
+ && regionMatches(magicString, 0, plusMagic, possibleRetVal, magicLength)
+ && regionMatches(formattedMillis, 0, formatted, possibleRetVal, magicLength)
+ && regionMatches(zeroString, 0, plusZero, possibleRetVal, magicLength)
+ // The following will and should fail for patterns with more than one SSS because
+ // we only seem to be able to change one SSS in e.g. format and need to reformat the
+ // whole string in other cases.
+ && (formatted.length() == possibleRetVal + magicLength
+ || plusZero.compare(possibleRetVal + magicLength,
+ LogString::npos, plusMagic, possibleRetVal + magicLength, LogString::npos) == 0))
+ {
+ return possibleRetVal;
+ }
+ else
+ {
+ return UNRECOGNIZED_MILLISECONDS;
+ }
+ }
}
- }
- }
- return NO_MILLISECONDS;
+ }
+
+ return NO_MILLISECONDS;
}
@@ -166,63 +186,72 @@
* @param now Number of milliseconds after midnight 1 Jan 1970 GMT.
* @param sbuf the string buffer to write to
*/
- void CachedDateFormat::format(LogString& buf, log4cxx_time_t now, Pool& p) const {
+void CachedDateFormat::format(LogString& buf, log4cxx_time_t now, Pool& p) const
+{
- //
- // If the current requested time is identical to the previously
- // requested time, then append the cache contents.
- //
- if (now == previousTime) {
- buf.append(cache);
- return;
- }
+ //
+ // If the current requested time is identical to the previously
+ // requested time, then append the cache contents.
+ //
+ if (now == previousTime)
+ {
+ buf.append(cache);
+ return;
+ }
- //
- // If millisecond pattern was not unrecognized
- // (that is if it was found or milliseconds did not appear)
- //
- if (millisecondStart != UNRECOGNIZED_MILLISECONDS) {
- // Check if the cache is still valid.
- // If the requested time is within the same integral second
- // as the last request and a shorter expiration was not requested.
- if (now < slotBegin + expiration
- && now >= slotBegin
- && now < slotBegin + 1000000L) {
- //
- // if there was a millisecond field then update it
- //
- if (millisecondStart >= 0) {
- millisecondFormat((int) ((now - slotBegin)/1000), cache, millisecondStart);
- }
- //
- // update the previously requested time
- // (the slot begin should be unchanged)
- previousTime = now;
- buf.append(cache);
+ //
+ // If millisecond pattern was not unrecognized
+ // (that is if it was found or milliseconds did not appear)
+ //
+ if (millisecondStart != UNRECOGNIZED_MILLISECONDS)
+ {
+ // Check if the cache is still valid.
+ // If the requested time is within the same integral second
+ // as the last request and a shorter expiration was not requested.
+ if (now < slotBegin + expiration
+ && now >= slotBegin
+ && now < slotBegin + 1000000L)
+ {
+ //
+ // if there was a millisecond field then update it
+ //
+ if (millisecondStart >= 0)
+ {
+ millisecondFormat((int) ((now - slotBegin) / 1000), cache, millisecondStart);
+ }
- return;
- }
- }
+ //
+ // update the previously requested time
+ // (the slot begin should be unchanged)
+ previousTime = now;
+ buf.append(cache);
- //
- // could not use previous value.
- // Call underlying formatter to format date.
- cache.erase(cache.begin(), cache.end());
- formatter->format(cache, now, p);
- buf.append(cache);
- previousTime = now;
- slotBegin = (previousTime / 1000000) * 1000000;
- if (slotBegin > previousTime) {
- slotBegin -= 1000000;
- }
+ return;
+ }
+ }
- //
- // if the milliseconds field was previous found
- // then reevaluate in case it moved.
- //
- if (millisecondStart >= 0) {
- millisecondStart = findMillisecondStart(now, cache, formatter, p);
- }
+ //
+ // could not use previous value.
+ // Call underlying formatter to format date.
+ cache.erase(cache.begin(), cache.end());
+ formatter->format(cache, now, p);
+ buf.append(cache);
+ previousTime = now;
+ slotBegin = (previousTime / 1000000) * 1000000;
+
+ if (slotBegin > previousTime)
+ {
+ slotBegin -= 1000000;
+ }
+
+ //
+ // if the milliseconds field was previous found
+ // then reevaluate in case it moved.
+ //
+ if (millisecondStart >= 0)
+ {
+ millisecondStart = findMillisecondStart(now, cache, formatter, p);
+ }
}
/**
@@ -233,12 +262,13 @@
* buffer must be at least offset + 3.
*/
void CachedDateFormat::millisecondFormat(int millis,
- LogString& buf,
- int offset) {
- buf[offset] = digits[millis / 100];
- buf[offset + 1] = digits[(millis / 10) % 10];
- buf[offset + 2] = digits[millis % 10];
- }
+ LogString& buf,
+ int offset)
+{
+ buf[offset] = digits[millis / 100];
+ buf[offset + 1] = digits[(millis / 10) % 10];
+ buf[offset + 2] = digits[millis % 10];
+}
/**
* Set timezone.
@@ -247,16 +277,18 @@
* will likely cause caching to misbehave.
* @param timeZone TimeZone new timezone
*/
-void CachedDateFormat::setTimeZone(const TimeZonePtr& timeZone) {
- formatter->setTimeZone(timeZone);
- previousTime = std::numeric_limits<log4cxx_time_t>::min();
- slotBegin = std::numeric_limits<log4cxx_time_t>::min();
+void CachedDateFormat::setTimeZone(const TimeZonePtr& timeZone)
+{
+ formatter->setTimeZone(timeZone);
+ previousTime = std::numeric_limits<log4cxx_time_t>::min();
+ slotBegin = std::numeric_limits<log4cxx_time_t>::min();
}
-void CachedDateFormat::numberFormat(LogString& s, int n, Pool& p) const {
- formatter->numberFormat(s, n, p);
+void CachedDateFormat::numberFormat(LogString& s, int n, Pool& p) const
+{
+ formatter->numberFormat(s, n, p);
}
@@ -267,27 +299,31 @@
* @returns Duration in microseconds from an integral second
* that the cache will return consistent results.
*/
-int CachedDateFormat::getMaximumCacheValidity(const LogString& pattern) {
- //
- // If there are more "S" in the pattern than just one "SSS" then
- // (for example, "HH:mm:ss,SSS SSS"), then set the expiration to
- // one millisecond which should only perform duplicate request caching.
- //
- const logchar S = 0x53;
- const logchar SSS[] = { 0x53, 0x53, 0x53, 0 };
- size_t firstS = pattern.find(S);
- size_t len = pattern.length();
- //
- // if there are no S's or
- // three that start with the first S and no fourth S in the string
- //
- if (firstS == LogString::npos ||
- (len >= firstS + 3 && pattern.compare(firstS, 3, SSS) == 0
- && (len == firstS + 3 ||
- pattern.find(S, firstS + 3) == LogString::npos))) {
- return 1000000;
- }
- return 1000;
+int CachedDateFormat::getMaximumCacheValidity(const LogString& pattern)
+{
+ //
+ // If there are more "S" in the pattern than just one "SSS" then
+ // (for example, "HH:mm:ss,SSS SSS"), then set the expiration to
+ // one millisecond which should only perform duplicate request caching.
+ //
+ const logchar S = 0x53;
+ const logchar SSS[] = { 0x53, 0x53, 0x53, 0 };
+ size_t firstS = pattern.find(S);
+ size_t len = pattern.length();
+
+ //
+ // if there are no S's or
+ // three that start with the first S and no fourth S in the string
+ //
+ if (firstS == LogString::npos ||
+ (len >= firstS + 3 && pattern.compare(firstS, 3, SSS) == 0
+ && (len == firstS + 3 ||
+ pattern.find(S, firstS + 3) == LogString::npos)))
+ {
+ return 1000000;
+ }
+
+ return 1000;
}
@@ -305,7 +341,8 @@
size_t toffset,
const LogString& other,
size_t ooffset,
- size_t len) {
+ size_t len)
+{
return target.compare(toffset, len, other, ooffset, len) == 0;
}
diff --git a/src/main/cpp/charsetdecoder.cpp b/src/main/cpp/charsetdecoder.cpp
index aa5a6a0..4598c03 100644
--- a/src/main/cpp/charsetdecoder.cpp
+++ b/src/main/cpp/charsetdecoder.cpp
@@ -23,7 +23,7 @@
#include <log4cxx/helpers/pool.h>
#include <apr_xlate.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
#include <locale.h>
@@ -39,192 +39,226 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
#if APR_HAS_XLATE
- /**
- * Converts from an arbitrary encoding to LogString
- * using apr_xlate. Requires real iconv implementation,
- * apr-iconv will crash in use.
- */
- class APRCharsetDecoder : public CharsetDecoder
- {
- public:
- /**
- * Creates a new instance.
- * @param frompage name of source encoding.
- */
- APRCharsetDecoder(const LogString& frompage) : pool(), mutex(pool) {
+/**
+ * Converts from an arbitrary encoding to LogString
+ * using apr_xlate. Requires real iconv implementation,
+* apr-iconv will crash in use.
+ */
+class APRCharsetDecoder : public CharsetDecoder
+{
+ public:
+ /**
+ * Creates a new instance.
+ * @param frompage name of source encoding.
+ */
+ APRCharsetDecoder(const LogString& frompage) : pool(), mutex(pool)
+ {
#if LOG4CXX_LOGCHAR_IS_WCHAR
- const char* topage = "WCHAR_T";
+ const char* topage = "WCHAR_T";
#endif
#if LOG4CXX_LOGCHAR_IS_UTF8
- const char* topage = "UTF-8";
+ const char* topage = "UTF-8";
#endif
#if LOG4CXX_LOGCHAR_IS_UNICHAR
- const char* topage = "UTF-16";
+ const char* topage = "UTF-16";
#endif
- std::string fpage(Transcoder::encodeCharsetName(frompage));
- apr_status_t stat = apr_xlate_open(&convset,
- topage,
- fpage.c_str(),
- pool.getAPRPool());
- if (stat != APR_SUCCESS) {
- throw IllegalArgumentException(frompage);
+ std::string fpage(Transcoder::encodeCharsetName(frompage));
+ apr_status_t stat = apr_xlate_open(&convset,
+ topage,
+ fpage.c_str(),
+ pool.getAPRPool());
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IllegalArgumentException(frompage);
+ }
+ }
+
+ /**
+ * Destructor.
+ */
+ virtual ~APRCharsetDecoder()
+ {
+ }
+
+ virtual log4cxx_status_t decode(ByteBuffer& in,
+ LogString& out)
+ {
+ enum { BUFSIZE = 256 };
+ logchar buf[BUFSIZE];
+ const apr_size_t initial_outbytes_left = BUFSIZE * sizeof(logchar);
+ apr_status_t stat = APR_SUCCESS;
+
+ if (in.remaining() == 0)
+ {
+ size_t outbytes_left = initial_outbytes_left;
+ {
+ synchronized sync(mutex);
+ stat = apr_xlate_conv_buffer((apr_xlate_t*) convset,
+ NULL, NULL, (char*) buf, &outbytes_left);
}
- }
-
- /**
- * Destructor.
- */
- virtual ~APRCharsetDecoder() {
- }
-
- virtual log4cxx_status_t decode(ByteBuffer& in,
- LogString& out) {
- enum { BUFSIZE = 256 };
- logchar buf[BUFSIZE];
- const apr_size_t initial_outbytes_left = BUFSIZE * sizeof(logchar);
- apr_status_t stat = APR_SUCCESS;
- if (in.remaining() == 0) {
- size_t outbytes_left = initial_outbytes_left;
+ out.append(buf, (initial_outbytes_left - outbytes_left) / sizeof(logchar));
+ }
+ else
+ {
+ while (in.remaining() > 0 && stat == APR_SUCCESS)
+ {
+ size_t inbytes_left = in.remaining();
+ size_t initial_inbytes_left = inbytes_left;
+ size_t pos = in.position();
+ apr_size_t outbytes_left = initial_outbytes_left;
{
- synchronized sync(mutex);
- stat = apr_xlate_conv_buffer((apr_xlate_t*) convset,
- NULL, NULL, (char*) buf, &outbytes_left);
- }
- out.append(buf, (initial_outbytes_left - outbytes_left)/sizeof(logchar));
- } else {
- while(in.remaining() > 0 && stat == APR_SUCCESS) {
- size_t inbytes_left = in.remaining();
- size_t initial_inbytes_left = inbytes_left;
- size_t pos = in.position();
- apr_size_t outbytes_left = initial_outbytes_left;
- {
synchronized sync(mutex);
stat = apr_xlate_conv_buffer((apr_xlate_t*) convset,
- in.data() + pos,
- &inbytes_left,
- (char*) buf,
- &outbytes_left);
- }
- out.append(buf, (initial_outbytes_left - outbytes_left)/sizeof(logchar));
- in.position(pos + (initial_inbytes_left - inbytes_left));
+ in.data() + pos,
+ &inbytes_left,
+ (char*) buf,
+ &outbytes_left);
}
- }
- return stat;
- }
+ out.append(buf, (initial_outbytes_left - outbytes_left) / sizeof(logchar));
+ in.position(pos + (initial_inbytes_left - inbytes_left));
+ }
+ }
- private:
- APRCharsetDecoder(const APRCharsetDecoder&);
- APRCharsetDecoder& operator=(const APRCharsetDecoder&);
- log4cxx::helpers::Pool pool;
- Mutex mutex;
- apr_xlate_t *convset;
- };
+ return stat;
+ }
+
+ private:
+ APRCharsetDecoder(const APRCharsetDecoder&);
+ APRCharsetDecoder& operator=(const APRCharsetDecoder&);
+ log4cxx::helpers::Pool pool;
+ Mutex mutex;
+ apr_xlate_t* convset;
+};
#endif
#if LOG4CXX_LOGCHAR_IS_WCHAR && LOG4CXX_HAS_MBSRTOWCS
- /**
- * Converts from the default multi-byte string to
- * LogString using mbstowcs.
- *
- */
- class MbstowcsCharsetDecoder : public CharsetDecoder
- {
- public:
- MbstowcsCharsetDecoder() {
- }
+/**
+* Converts from the default multi-byte string to
+* LogString using mbstowcs.
+*
+*/
+class MbstowcsCharsetDecoder : public CharsetDecoder
+{
+ public:
+ MbstowcsCharsetDecoder()
+ {
+ }
- virtual ~MbstowcsCharsetDecoder() {
- }
+ virtual ~MbstowcsCharsetDecoder()
+ {
+ }
- private:
- inline log4cxx_status_t append(LogString& out, const wchar_t* buf) {
- out.append(buf);
- return APR_SUCCESS;
- }
+ private:
+ inline log4cxx_status_t append(LogString& out, const wchar_t* buf)
+ {
+ out.append(buf);
+ return APR_SUCCESS;
+ }
- virtual log4cxx_status_t decode(ByteBuffer& in,
- LogString& out) {
- log4cxx_status_t stat = APR_SUCCESS;
- enum { BUFSIZE = 256 };
- wchar_t buf[BUFSIZE];
+ virtual log4cxx_status_t decode(ByteBuffer& in,
+ LogString& out)
+ {
+ log4cxx_status_t stat = APR_SUCCESS;
+ enum { BUFSIZE = 256 };
+ wchar_t buf[BUFSIZE];
- mbstate_t mbstate;
- memset(&mbstate, 0, sizeof(mbstate));
+ mbstate_t mbstate;
+ memset(&mbstate, 0, sizeof(mbstate));
- while(in.remaining() > 0) {
- size_t requested = in.remaining();
- if (requested > BUFSIZE - 1) {
- requested = BUFSIZE - 1;
- }
+ while (in.remaining() > 0)
+ {
+ size_t requested = in.remaining();
- memset(buf, 0, BUFSIZE*sizeof(wchar_t));
- const char* src = in.current();
- if(*src == 0) {
- out.append(1, (logchar) 0);
- in.position(in.position() + 1);
- } else {
- size_t converted = mbsrtowcs(buf,
- &src,
- requested,
- &mbstate);
- if (converted == (size_t) -1) {
- stat = APR_BADARG;
- in.position(src - in.data());
- break;
- } else {
- stat = append(out, buf);
- in.position(in.position() + requested);
- }
- }
- }
- return stat;
- }
+ if (requested > BUFSIZE - 1)
+ {
+ requested = BUFSIZE - 1;
+ }
+
+ memset(buf, 0, BUFSIZE * sizeof(wchar_t));
+ const char* src = in.current();
+
+ if (*src == 0)
+ {
+ out.append(1, (logchar) 0);
+ in.position(in.position() + 1);
+ }
+ else
+ {
+ size_t converted = mbsrtowcs(buf,
+ &src,
+ requested,
+ &mbstate);
+
+ if (converted == (size_t) -1)
+ {
+ stat = APR_BADARG;
+ in.position(src - in.data());
+ break;
+ }
+ else
+ {
+ stat = append(out, buf);
+ in.position(in.position() + requested);
+ }
+ }
+ }
+
+ return stat;
+ }
- private:
- MbstowcsCharsetDecoder(const MbstowcsCharsetDecoder&);
- MbstowcsCharsetDecoder& operator=(const MbstowcsCharsetDecoder&);
- };
+ private:
+ MbstowcsCharsetDecoder(const MbstowcsCharsetDecoder&);
+ MbstowcsCharsetDecoder& operator=(const MbstowcsCharsetDecoder&);
+};
#endif
- /**
- * Decoder used when the external and internal charsets
- * are the same.
- *
- */
- class TrivialCharsetDecoder : public CharsetDecoder
- {
- public:
- TrivialCharsetDecoder() {
- }
+/**
+* Decoder used when the external and internal charsets
+* are the same.
+*
+*/
+class TrivialCharsetDecoder : public CharsetDecoder
+{
+ public:
+ TrivialCharsetDecoder()
+ {
+ }
- virtual ~TrivialCharsetDecoder() {
- }
+ virtual ~TrivialCharsetDecoder()
+ {
+ }
- virtual log4cxx_status_t decode(ByteBuffer& in,
- LogString& out) {
- size_t remaining = in.remaining();
- if( remaining > 0) {
- const logchar* src = (const logchar*) (in.data() + in.position());
- size_t count = remaining / sizeof(logchar);
- out.append(src, count);
- in.position(in.position() + remaining);
- }
- return APR_SUCCESS;
- }
+ virtual log4cxx_status_t decode(ByteBuffer& in,
+ LogString& out)
+ {
+ size_t remaining = in.remaining();
+
+ if ( remaining > 0)
+ {
+ const logchar* src = (const logchar*) (in.data() + in.position());
+ size_t count = remaining / sizeof(logchar);
+ out.append(src, count);
+ in.position(in.position() + remaining);
+ }
+
+ return APR_SUCCESS;
+ }
- private:
- TrivialCharsetDecoder(const TrivialCharsetDecoder&);
- TrivialCharsetDecoder& operator=(const TrivialCharsetDecoder&);
- };
+ private:
+ TrivialCharsetDecoder(const TrivialCharsetDecoder&);
+ TrivialCharsetDecoder& operator=(const TrivialCharsetDecoder&);
+};
#if LOG4CXX_LOGCHAR_IS_UTF8
@@ -236,35 +270,47 @@
*/
class UTF8CharsetDecoder : public CharsetDecoder
{
-public:
- UTF8CharsetDecoder() {
- }
-
- virtual ~UTF8CharsetDecoder() {
- }
-
-private:
- virtual log4cxx_status_t decode(ByteBuffer& in,
- LogString& out) {
- if (in.remaining() > 0) {
- std::string tmp(in.current(), in.remaining());
- std::string::const_iterator iter = tmp.begin();
- while(iter != tmp.end()) {
- unsigned int sv = Transcoder::decode(tmp, iter);
- if (sv == 0xFFFF) {
- size_t offset = iter - tmp.begin();
- in.position(in.position() + offset);
- return APR_BADARG;
- } else {
- Transcoder::encode(sv, out);
- }
- }
- in.position(in.limit());
+ public:
+ UTF8CharsetDecoder()
+ {
}
- return APR_SUCCESS;
- }
-private:
+ virtual ~UTF8CharsetDecoder()
+ {
+ }
+
+ private:
+ virtual log4cxx_status_t decode(ByteBuffer& in,
+ LogString& out)
+ {
+ if (in.remaining() > 0)
+ {
+ std::string tmp(in.current(), in.remaining());
+ std::string::const_iterator iter = tmp.begin();
+
+ while (iter != tmp.end())
+ {
+ unsigned int sv = Transcoder::decode(tmp, iter);
+
+ if (sv == 0xFFFF)
+ {
+ size_t offset = iter - tmp.begin();
+ in.position(in.position() + offset);
+ return APR_BADARG;
+ }
+ else
+ {
+ Transcoder::encode(sv, out);
+ }
+ }
+
+ in.position(in.limit());
+ }
+
+ return APR_SUCCESS;
+ }
+
+ private:
UTF8CharsetDecoder(const UTF8CharsetDecoder&);
UTF8CharsetDecoder& operator=(const UTF8CharsetDecoder&);
};
@@ -276,32 +322,40 @@
*/
class ISOLatinCharsetDecoder : public CharsetDecoder
{
-public:
- ISOLatinCharsetDecoder() {
- }
-
- virtual ~ISOLatinCharsetDecoder() {
- }
-
-private:
- virtual log4cxx_status_t decode(ByteBuffer& in,
- LogString& out) {
- if (in.remaining() > 0) {
-
- const unsigned char* src = (unsigned char*) in.current();
- const unsigned char* srcEnd = src + in.remaining();
- while(src < srcEnd) {
- unsigned int sv = *(src++);
- Transcoder::encode(sv, out);
- }
- in.position(in.limit());
+ public:
+ ISOLatinCharsetDecoder()
+ {
}
- return APR_SUCCESS;
- }
+
+ virtual ~ISOLatinCharsetDecoder()
+ {
+ }
+
+ private:
+ virtual log4cxx_status_t decode(ByteBuffer& in,
+ LogString& out)
+ {
+ if (in.remaining() > 0)
+ {
+
+ const unsigned char* src = (unsigned char*) in.current();
+ const unsigned char* srcEnd = src + in.remaining();
+
+ while (src < srcEnd)
+ {
+ unsigned int sv = *(src++);
+ Transcoder::encode(sv, out);
+ }
+
+ in.position(in.limit());
+ }
+
+ return APR_SUCCESS;
+ }
-private:
+ private:
ISOLatinCharsetDecoder(const ISOLatinCharsetDecoder&);
ISOLatinCharsetDecoder& operator=(const ISOLatinCharsetDecoder&);
};
@@ -313,117 +367,152 @@
*/
class USASCIICharsetDecoder : public CharsetDecoder
{
-public:
- USASCIICharsetDecoder() {
- }
-
- virtual ~USASCIICharsetDecoder() {
- }
-
-private:
-
- virtual log4cxx_status_t decode(ByteBuffer& in,
- LogString& out) {
- log4cxx_status_t stat = APR_SUCCESS;
- if (in.remaining() > 0) {
-
- const unsigned char* src = (unsigned char*) in.current();
- const unsigned char* srcEnd = src + in.remaining();
- while(src < srcEnd) {
- unsigned char sv = *src;
- if (sv < 0x80) {
- src++;
- Transcoder::encode(sv, out);
- } else {
- stat = APR_BADARG;
- break;
- }
+ public:
+ USASCIICharsetDecoder()
+ {
}
- in.position(src - (const unsigned char*) in.data());
- }
- return stat;
- }
+
+ virtual ~USASCIICharsetDecoder()
+ {
+ }
+
+ private:
+
+ virtual log4cxx_status_t decode(ByteBuffer& in,
+ LogString& out)
+ {
+ log4cxx_status_t stat = APR_SUCCESS;
+
+ if (in.remaining() > 0)
+ {
+
+ const unsigned char* src = (unsigned char*) in.current();
+ const unsigned char* srcEnd = src + in.remaining();
+
+ while (src < srcEnd)
+ {
+ unsigned char sv = *src;
+
+ if (sv < 0x80)
+ {
+ src++;
+ Transcoder::encode(sv, out);
+ }
+ else
+ {
+ stat = APR_BADARG;
+ break;
+ }
+ }
+
+ in.position(src - (const unsigned char*) in.data());
+ }
+
+ return stat;
+ }
-private:
+ private:
USASCIICharsetDecoder(const USASCIICharsetDecoder&);
USASCIICharsetDecoder& operator=(const USASCIICharsetDecoder&);
};
- /**
- * Charset decoder that uses an embedded CharsetDecoder consistent
- * with current locale settings.
- */
- class LocaleCharsetDecoder : public CharsetDecoder {
- public:
- LocaleCharsetDecoder() : pool(), mutex(pool), decoder(), encoding() {
- }
- virtual ~LocaleCharsetDecoder() {
- }
- virtual log4cxx_status_t decode(ByteBuffer& in,
- LogString& out) {
- const char* p = in.current();
- size_t i = in.position();
+/**
+ * Charset decoder that uses an embedded CharsetDecoder consistent
+ * with current locale settings.
+ */
+class LocaleCharsetDecoder : public CharsetDecoder
+{
+ public:
+ LocaleCharsetDecoder() : pool(), mutex(pool), decoder(), encoding()
+ {
+ }
+ virtual ~LocaleCharsetDecoder()
+ {
+ }
+ virtual log4cxx_status_t decode(ByteBuffer& in,
+ LogString& out)
+ {
+ const char* p = in.current();
+ size_t i = in.position();
#if !LOG4CXX_CHARSET_EBCDIC
- for (; i < in.limit() && ((unsigned int) *p) < 0x80; i++, p++) {
- out.append(1, *p);
- }
- in.position(i);
+
+ for (; i < in.limit() && ((unsigned int) *p) < 0x80; i++, p++)
+ {
+ out.append(1, *p);
+ }
+
+ in.position(i);
#endif
- if (i < in.limit()) {
- Pool subpool;
- const char* enc = apr_os_locale_encoding(subpool.getAPRPool());
- {
- synchronized sync(mutex);
- if (enc == 0) {
- if (decoder == 0) {
- encoding = "C";
- decoder = new USASCIICharsetDecoder();
- }
- } else if (encoding != enc) {
- encoding = enc;
- try {
- LogString e;
- Transcoder::decode(encoding, e);
- decoder = getDecoder(e);
- } catch (IllegalArgumentException& ex) {
- decoder = new USASCIICharsetDecoder();
- }
- }
- }
- return decoder->decode(in, out);
- }
- return APR_SUCCESS;
- }
- private:
- Pool pool;
- Mutex mutex;
- CharsetDecoderPtr decoder;
- std::string encoding;
- };
+
+ if (i < in.limit())
+ {
+ Pool subpool;
+ const char* enc = apr_os_locale_encoding(subpool.getAPRPool());
+ {
+ synchronized sync(mutex);
+
+ if (enc == 0)
+ {
+ if (decoder == 0)
+ {
+ encoding = "C";
+ decoder = new USASCIICharsetDecoder();
+ }
+ }
+ else if (encoding != enc)
+ {
+ encoding = enc;
+
+ try
+ {
+ LogString e;
+ Transcoder::decode(encoding, e);
+ decoder = getDecoder(e);
+ }
+ catch (IllegalArgumentException& ex)
+ {
+ decoder = new USASCIICharsetDecoder();
+ }
+ }
+ }
+ return decoder->decode(in, out);
+ }
+
+ return APR_SUCCESS;
+ }
+ private:
+ Pool pool;
+ Mutex mutex;
+ CharsetDecoderPtr decoder;
+ std::string encoding;
+};
- } // namespace helpers
+} // namespace helpers
} //namespace log4cxx
-CharsetDecoder::CharsetDecoder() {
+CharsetDecoder::CharsetDecoder()
+{
}
-CharsetDecoder::~CharsetDecoder() {
+CharsetDecoder::~CharsetDecoder()
+{
}
-CharsetDecoder* CharsetDecoder::createDefaultDecoder() {
+CharsetDecoder* CharsetDecoder::createDefaultDecoder()
+{
#if LOG4CXX_CHARSET_UTF8
- return new UTF8CharsetDecoder();
+ return new UTF8CharsetDecoder();
#elif LOG4CXX_CHARSET_ISO88591 || defined(_WIN32_WCE)
- return new ISOLatinCharsetDecoder();
+ return new ISOLatinCharsetDecoder();
#elif LOG4CXX_CHARSET_USASCII
- return new USASCIICharsetDecoder();
+ return new USASCIICharsetDecoder();
#elif LOG4CXX_LOGCHAR_IS_WCHAR && LOG4CXX_HAS_MBSRTOWCS
return new MbstowcsCharsetDecoder();
#else
@@ -431,51 +520,67 @@
#endif
}
-CharsetDecoderPtr CharsetDecoder::getDefaultDecoder() {
+CharsetDecoderPtr CharsetDecoder::getDefaultDecoder()
+{
static CharsetDecoderPtr decoder(createDefaultDecoder());
+
//
// if invoked after static variable destruction
// (if logging is called in the destructor of a static object)
// then create a new decoder.
//
- if (decoder == 0) {
- return createDefaultDecoder();
+ if (decoder == 0)
+ {
+ return createDefaultDecoder();
}
+
return decoder;
}
-CharsetDecoderPtr CharsetDecoder::getUTF8Decoder() {
+CharsetDecoderPtr CharsetDecoder::getUTF8Decoder()
+{
static CharsetDecoderPtr decoder(new UTF8CharsetDecoder());
+
//
// if invoked after static variable destruction
// (if logging is called in the destructor of a static object)
// then create a new decoder.
//
- if (decoder == 0) {
- return new UTF8CharsetDecoder();
+ if (decoder == 0)
+ {
+ return new UTF8CharsetDecoder();
}
+
return decoder;
}
-CharsetDecoderPtr CharsetDecoder::getISOLatinDecoder() {
+CharsetDecoderPtr CharsetDecoder::getISOLatinDecoder()
+{
return new ISOLatinCharsetDecoder();
}
-CharsetDecoderPtr CharsetDecoder::getDecoder(const LogString& charset) {
+CharsetDecoderPtr CharsetDecoder::getDecoder(const LogString& charset)
+{
if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-8"), LOG4CXX_STR("utf-8")) ||
- StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF8"), LOG4CXX_STR("utf8"))) {
+ StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF8"), LOG4CXX_STR("utf8")))
+ {
return new UTF8CharsetDecoder();
- } else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("C"), LOG4CXX_STR("c")) ||
- charset == LOG4CXX_STR("646") ||
- StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("US-ASCII"), LOG4CXX_STR("us-ascii")) ||
- StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO646-US"), LOG4CXX_STR("iso646-US")) ||
- StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ANSI_X3.4-1968"), LOG4CXX_STR("ansi_x3.4-1968"))) {
+ }
+ else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("C"), LOG4CXX_STR("c")) ||
+ charset == LOG4CXX_STR("646") ||
+ StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("US-ASCII"), LOG4CXX_STR("us-ascii")) ||
+ StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO646-US"), LOG4CXX_STR("iso646-US")) ||
+ StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ANSI_X3.4-1968"), LOG4CXX_STR("ansi_x3.4-1968")))
+ {
return new USASCIICharsetDecoder();
- } else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO-8859-1"), LOG4CXX_STR("iso-8859-1")) ||
- StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO-LATIN-1"), LOG4CXX_STR("iso-latin-1"))) {
+ }
+ else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO-8859-1"), LOG4CXX_STR("iso-8859-1")) ||
+ StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO-LATIN-1"), LOG4CXX_STR("iso-latin-1")))
+ {
return new ISOLatinCharsetDecoder();
}
+
#if APR_HAS_XLATE
return new APRCharsetDecoder(charset);
#else
diff --git a/src/main/cpp/charsetencoder.cpp b/src/main/cpp/charsetencoder.cpp
index 1b0c626..6fb7ab9 100644
--- a/src/main/cpp/charsetencoder.cpp
+++ b/src/main/cpp/charsetencoder.cpp
@@ -23,7 +23,7 @@
#include <log4cxx/helpers/transcoder.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
@@ -32,7 +32,7 @@
#include <log4cxx/helpers/synchronized.h>
#ifdef LOG4CXX_HAS_WCSTOMBS
-#include <stdlib.h>
+ #include <stdlib.h>
#endif
using namespace log4cxx;
@@ -43,247 +43,301 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
#if APR_HAS_XLATE
- /**
- * A character encoder implemented using apr_xlate.
- */
- class APRCharsetEncoder : public CharsetEncoder
- {
- public:
- APRCharsetEncoder(const LogString& topage) : pool(), mutex(pool) {
+/**
+* A character encoder implemented using apr_xlate.
+*/
+class APRCharsetEncoder : public CharsetEncoder
+{
+ public:
+ APRCharsetEncoder(const LogString& topage) : pool(), mutex(pool)
+ {
#if LOG4CXX_LOGCHAR_IS_WCHAR
- const char* frompage = "WCHAR_T";
+ const char* frompage = "WCHAR_T";
#endif
#if LOG4CXX_LOGCHAR_IS_UTF8
- const char* frompage = "UTF-8";
+ const char* frompage = "UTF-8";
#endif
#if LOG4CXX_LOGCHAR_IS_UNICHAR
- const char* frompage = "UTF-16";
+ const char* frompage = "UTF-16";
#endif
- std::string tpage(Transcoder::encodeCharsetName(topage));
- apr_status_t stat = apr_xlate_open(&convset,
- tpage.c_str(),
- frompage,
- pool.getAPRPool());
- if (stat != APR_SUCCESS) {
- throw IllegalArgumentException(topage);
- }
- }
+ std::string tpage(Transcoder::encodeCharsetName(topage));
+ apr_status_t stat = apr_xlate_open(&convset,
+ tpage.c_str(),
+ frompage,
+ pool.getAPRPool());
- virtual ~APRCharsetEncoder() {
- }
+ if (stat != APR_SUCCESS)
+ {
+ throw IllegalArgumentException(topage);
+ }
+ }
- virtual log4cxx_status_t encode(const LogString& in,
- LogString::const_iterator& iter,
- ByteBuffer& out) {
- apr_status_t stat;
- size_t outbytes_left = out.remaining();
- size_t initial_outbytes_left = outbytes_left;
- size_t position = out.position();
- if (iter == in.end()) {
- synchronized sync(mutex);
- stat = apr_xlate_conv_buffer(convset, NULL, NULL,
- out.data() + position, &outbytes_left);
- } else {
- LogString::size_type inOffset = (iter - in.begin());
- apr_size_t inbytes_left =
- (in.size() - inOffset) * sizeof(LogString::value_type);
- apr_size_t initial_inbytes_left = inbytes_left;
- {
- synchronized sync(mutex);
- stat = apr_xlate_conv_buffer(convset,
- (const char*) (in.data() + inOffset),
- &inbytes_left,
- out.data() + position,
- &outbytes_left);
- }
- iter += ((initial_inbytes_left - inbytes_left) / sizeof(LogString::value_type));
- }
- out.position(out.position() + (initial_outbytes_left - outbytes_left));
- return stat;
- }
+ virtual ~APRCharsetEncoder()
+ {
+ }
- private:
- APRCharsetEncoder(const APRCharsetEncoder&);
- APRCharsetEncoder& operator=(const APRCharsetEncoder&);
- Pool pool;
- Mutex mutex;
- apr_xlate_t *convset;
- };
+ virtual log4cxx_status_t encode(const LogString& in,
+ LogString::const_iterator& iter,
+ ByteBuffer& out)
+ {
+ apr_status_t stat;
+ size_t outbytes_left = out.remaining();
+ size_t initial_outbytes_left = outbytes_left;
+ size_t position = out.position();
+
+ if (iter == in.end())
+ {
+ synchronized sync(mutex);
+ stat = apr_xlate_conv_buffer(convset, NULL, NULL,
+ out.data() + position, &outbytes_left);
+ }
+ else
+ {
+ LogString::size_type inOffset = (iter - in.begin());
+ apr_size_t inbytes_left =
+ (in.size() - inOffset) * sizeof(LogString::value_type);
+ apr_size_t initial_inbytes_left = inbytes_left;
+ {
+ synchronized sync(mutex);
+ stat = apr_xlate_conv_buffer(convset,
+ (const char*) (in.data() + inOffset),
+ &inbytes_left,
+ out.data() + position,
+ &outbytes_left);
+ }
+ iter += ((initial_inbytes_left - inbytes_left) / sizeof(LogString::value_type));
+ }
+
+ out.position(out.position() + (initial_outbytes_left - outbytes_left));
+ return stat;
+ }
+
+ private:
+ APRCharsetEncoder(const APRCharsetEncoder&);
+ APRCharsetEncoder& operator=(const APRCharsetEncoder&);
+ Pool pool;
+ Mutex mutex;
+ apr_xlate_t* convset;
+};
#endif
#if LOG4CXX_LOGCHAR_IS_WCHAR && LOG4CXX_HAS_WCSTOMBS
- /**
- * A character encoder implemented using wcstombs.
- */
- class WcstombsCharsetEncoder : public CharsetEncoder
- {
- public:
- WcstombsCharsetEncoder() {
- }
+/**
+ * A character encoder implemented using wcstombs.
+*/
+class WcstombsCharsetEncoder : public CharsetEncoder
+{
+ public:
+ WcstombsCharsetEncoder()
+ {
+ }
- /**
- * Converts a wchar_t to the default external multibyte encoding.
- */
- log4cxx_status_t encode(const LogString& in,
- LogString::const_iterator& iter,
- ByteBuffer& out) {
- log4cxx_status_t stat = APR_SUCCESS;
+ /**
+ * Converts a wchar_t to the default external multibyte encoding.
+ */
+ log4cxx_status_t encode(const LogString& in,
+ LogString::const_iterator& iter,
+ ByteBuffer& out)
+ {
+ log4cxx_status_t stat = APR_SUCCESS;
- if (iter != in.end()) {
- size_t outbytes_left = out.remaining();
- size_t position = out.position();
- std::wstring::size_type inOffset = (iter - in.begin());
- enum { BUFSIZE = 256 };
- wchar_t buf[BUFSIZE];
- size_t chunkSize = BUFSIZE - 1;
- if (chunkSize * MB_LEN_MAX > outbytes_left) {
- chunkSize = outbytes_left / MB_LEN_MAX;
- }
- if (chunkSize > in.length() - inOffset) {
- chunkSize = in.length() - inOffset;
- }
- memset(buf, 0, BUFSIZE * sizeof(wchar_t));
- memcpy(buf,
- in.data() + inOffset,
- chunkSize * sizeof(wchar_t));
- size_t converted = wcstombs(out.data() + position, buf, outbytes_left);
+ if (iter != in.end())
+ {
+ size_t outbytes_left = out.remaining();
+ size_t position = out.position();
+ std::wstring::size_type inOffset = (iter - in.begin());
+ enum { BUFSIZE = 256 };
+ wchar_t buf[BUFSIZE];
+ size_t chunkSize = BUFSIZE - 1;
- if (converted == (size_t) -1) {
- stat = APR_BADARG;
- //
- // if unconvertable character was encountered
- // repeatedly halve source to get fragment that
- // can be converted
- for(chunkSize /= 2;
- chunkSize > 0;
- chunkSize /= 2) {
- buf[chunkSize] = 0;
- converted = wcstombs(out.data() + position, buf, outbytes_left);
- if (converted != (size_t) -1) {
- iter += chunkSize;
- out.position(out.position() + converted);
- break;
- }
- }
- } else {
+ if (chunkSize * MB_LEN_MAX > outbytes_left)
+ {
+ chunkSize = outbytes_left / MB_LEN_MAX;
+ }
+
+ if (chunkSize > in.length() - inOffset)
+ {
+ chunkSize = in.length() - inOffset;
+ }
+
+ memset(buf, 0, BUFSIZE * sizeof(wchar_t));
+ memcpy(buf,
+ in.data() + inOffset,
+ chunkSize * sizeof(wchar_t));
+ size_t converted = wcstombs(out.data() + position, buf, outbytes_left);
+
+ if (converted == (size_t) -1)
+ {
+ stat = APR_BADARG;
+
+ //
+ // if unconvertable character was encountered
+ // repeatedly halve source to get fragment that
+ // can be converted
+ for (chunkSize /= 2;
+ chunkSize > 0;
+ chunkSize /= 2)
+ {
+ buf[chunkSize] = 0;
+ converted = wcstombs(out.data() + position, buf, outbytes_left);
+
+ if (converted != (size_t) -1)
+ {
iter += chunkSize;
out.position(out.position() + converted);
- }
- }
- return stat;
- }
+ break;
+ }
+ }
+ }
+ else
+ {
+ iter += chunkSize;
+ out.position(out.position() + converted);
+ }
+ }
+
+ return stat;
+ }
- private:
- WcstombsCharsetEncoder(const WcstombsCharsetEncoder&);
- WcstombsCharsetEncoder& operator=(const WcstombsCharsetEncoder&);
- };
+ private:
+ WcstombsCharsetEncoder(const WcstombsCharsetEncoder&);
+ WcstombsCharsetEncoder& operator=(const WcstombsCharsetEncoder&);
+};
#endif
- /**
- * Encodes a LogString to US-ASCII.
- */
- class USASCIICharsetEncoder : public CharsetEncoder
- {
- public:
- USASCIICharsetEncoder() {
- }
+/**
+* Encodes a LogString to US-ASCII.
+*/
+class USASCIICharsetEncoder : public CharsetEncoder
+{
+ public:
+ USASCIICharsetEncoder()
+ {
+ }
- virtual log4cxx_status_t encode(const LogString& in,
- LogString::const_iterator& iter,
- ByteBuffer& out) {
- log4cxx_status_t stat = APR_SUCCESS;
- if (iter != in.end()) {
- while(out.remaining() > 0 && iter != in.end()) {
- LogString::const_iterator prev(iter);
- unsigned int sv = Transcoder::decode(in, iter);
- if (sv <= 0x7F) {
- out.put((char) sv);
- } else {
- iter = prev;
- stat = APR_BADARG;
- break;
- }
- }
- }
- return stat;
- }
+ virtual log4cxx_status_t encode(const LogString& in,
+ LogString::const_iterator& iter,
+ ByteBuffer& out)
+ {
+ log4cxx_status_t stat = APR_SUCCESS;
- private:
- USASCIICharsetEncoder(const USASCIICharsetEncoder&);
- USASCIICharsetEncoder& operator=(const USASCIICharsetEncoder&);
- };
+ if (iter != in.end())
+ {
+ while (out.remaining() > 0 && iter != in.end())
+ {
+ LogString::const_iterator prev(iter);
+ unsigned int sv = Transcoder::decode(in, iter);
- /**
- * Converts a LogString to ISO-8859-1.
- */
- class ISOLatinCharsetEncoder : public CharsetEncoder
- {
- public:
- ISOLatinCharsetEncoder() {
- }
+ if (sv <= 0x7F)
+ {
+ out.put((char) sv);
+ }
+ else
+ {
+ iter = prev;
+ stat = APR_BADARG;
+ break;
+ }
+ }
+ }
- virtual log4cxx_status_t encode(const LogString& in,
- LogString::const_iterator& iter,
- ByteBuffer& out) {
- log4cxx_status_t stat = APR_SUCCESS;
- if (iter != in.end()) {
- while(out.remaining() > 0 && iter != in.end()) {
- LogString::const_iterator prev(iter);
- unsigned int sv = Transcoder::decode(in, iter);
- if (sv <= 0xFF) {
- out.put((char) sv);
- } else {
- iter = prev;
- stat = APR_BADARG;
- break;
- }
- }
- }
- return stat;
- }
+ return stat;
+ }
- private:
- ISOLatinCharsetEncoder(const ISOLatinCharsetEncoder&);
- ISOLatinCharsetEncoder& operator=(const ISOLatinCharsetEncoder&);
- };
+ private:
+ USASCIICharsetEncoder(const USASCIICharsetEncoder&);
+ USASCIICharsetEncoder& operator=(const USASCIICharsetEncoder&);
+};
- /**
- * Encodes a LogString to a byte array when the encodings are identical.
- */
- class TrivialCharsetEncoder : public CharsetEncoder
- {
- public:
- TrivialCharsetEncoder() {
- }
+/**
+* Converts a LogString to ISO-8859-1.
+*/
+class ISOLatinCharsetEncoder : public CharsetEncoder
+{
+ public:
+ ISOLatinCharsetEncoder()
+ {
+ }
+
+ virtual log4cxx_status_t encode(const LogString& in,
+ LogString::const_iterator& iter,
+ ByteBuffer& out)
+ {
+ log4cxx_status_t stat = APR_SUCCESS;
+
+ if (iter != in.end())
+ {
+ while (out.remaining() > 0 && iter != in.end())
+ {
+ LogString::const_iterator prev(iter);
+ unsigned int sv = Transcoder::decode(in, iter);
+
+ if (sv <= 0xFF)
+ {
+ out.put((char) sv);
+ }
+ else
+ {
+ iter = prev;
+ stat = APR_BADARG;
+ break;
+ }
+ }
+ }
+
+ return stat;
+ }
+
+ private:
+ ISOLatinCharsetEncoder(const ISOLatinCharsetEncoder&);
+ ISOLatinCharsetEncoder& operator=(const ISOLatinCharsetEncoder&);
+};
+
+/**
+* Encodes a LogString to a byte array when the encodings are identical.
+*/
+class TrivialCharsetEncoder : public CharsetEncoder
+{
+ public:
+ TrivialCharsetEncoder()
+ {
+ }
- virtual log4cxx_status_t encode(const LogString& in,
- LogString::const_iterator& iter,
- ByteBuffer& out) {
- if(iter != in.end()) {
- size_t requested = in.length() - (iter - in.begin());
- if (requested > out.remaining()/sizeof(logchar)) {
- requested = out.remaining()/sizeof(logchar);
- }
- memcpy(out.current(),
+ virtual log4cxx_status_t encode(const LogString& in,
+ LogString::const_iterator& iter,
+ ByteBuffer& out)
+ {
+ if (iter != in.end())
+ {
+ size_t requested = in.length() - (iter - in.begin());
+
+ if (requested > out.remaining() / sizeof(logchar))
+ {
+ requested = out.remaining() / sizeof(logchar);
+ }
+
+ memcpy(out.current(),
(const char*) in.data() + (iter - in.begin()),
- requested * sizeof(logchar));
- iter += requested;
- out.position(out.position() + requested * sizeof(logchar));
- }
- return APR_SUCCESS;
- }
+ requested * sizeof(logchar));
+ iter += requested;
+ out.position(out.position() + requested * sizeof(logchar));
+ }
- private:
- TrivialCharsetEncoder(const TrivialCharsetEncoder&);
- TrivialCharsetEncoder& operator=(const TrivialCharsetEncoder&);
- };
+ return APR_SUCCESS;
+ }
+
+ private:
+ TrivialCharsetEncoder(const TrivialCharsetEncoder&);
+ TrivialCharsetEncoder& operator=(const TrivialCharsetEncoder&);
+};
#if LOG4CXX_LOGCHAR_IS_UTF8
typedef TrivialCharsetEncoder UTF8CharsetEncoder;
@@ -291,205 +345,267 @@
/**
* Converts a LogString to UTF-8.
*/
-class UTF8CharsetEncoder : public CharsetEncoder {
-public:
- UTF8CharsetEncoder() {
- }
+class UTF8CharsetEncoder : public CharsetEncoder
+{
+ public:
+ UTF8CharsetEncoder()
+ {
+ }
- virtual log4cxx_status_t encode(const LogString& in,
- LogString::const_iterator& iter,
- ByteBuffer& out) {
- while(iter != in.end() && out.remaining() >= 8) {
- unsigned int sv = Transcoder::decode(in, iter);
- if (sv == 0xFFFF) {
- return APR_BADARG;
- }
- Transcoder::encodeUTF8(sv, out);
- }
- return APR_SUCCESS;
- }
+ virtual log4cxx_status_t encode(const LogString& in,
+ LogString::const_iterator& iter,
+ ByteBuffer& out)
+ {
+ while (iter != in.end() && out.remaining() >= 8)
+ {
+ unsigned int sv = Transcoder::decode(in, iter);
-private:
- UTF8CharsetEncoder(const UTF8CharsetEncoder&);
- UTF8CharsetEncoder& operator=(const UTF8CharsetEncoder&);
+ if (sv == 0xFFFF)
+ {
+ return APR_BADARG;
+ }
+
+ Transcoder::encodeUTF8(sv, out);
+ }
+
+ return APR_SUCCESS;
+ }
+
+ private:
+ UTF8CharsetEncoder(const UTF8CharsetEncoder&);
+ UTF8CharsetEncoder& operator=(const UTF8CharsetEncoder&);
};
#endif
/**
* Encodes a LogString to UTF16-BE.
*/
-class UTF16BECharsetEncoder : public CharsetEncoder {
-public:
- UTF16BECharsetEncoder() {
- }
+class UTF16BECharsetEncoder : public CharsetEncoder
+{
+ public:
+ UTF16BECharsetEncoder()
+ {
+ }
- virtual log4cxx_status_t encode(const LogString& in,
- LogString::const_iterator& iter,
- ByteBuffer& out) {
- while(iter != in.end() && out.remaining() >= 4) {
- unsigned int sv = Transcoder::decode(in, iter);
- if (sv == 0xFFFF) {
- return APR_BADARG;
- }
- Transcoder::encodeUTF16BE(sv, out);
- }
- return APR_SUCCESS;
- }
+ virtual log4cxx_status_t encode(const LogString& in,
+ LogString::const_iterator& iter,
+ ByteBuffer& out)
+ {
+ while (iter != in.end() && out.remaining() >= 4)
+ {
+ unsigned int sv = Transcoder::decode(in, iter);
-private:
- UTF16BECharsetEncoder(const UTF16BECharsetEncoder&);
- UTF16BECharsetEncoder& operator=(const UTF16BECharsetEncoder&);
+ if (sv == 0xFFFF)
+ {
+ return APR_BADARG;
+ }
+
+ Transcoder::encodeUTF16BE(sv, out);
+ }
+
+ return APR_SUCCESS;
+ }
+
+ private:
+ UTF16BECharsetEncoder(const UTF16BECharsetEncoder&);
+ UTF16BECharsetEncoder& operator=(const UTF16BECharsetEncoder&);
};
/**
* Encodes a LogString to UTF16-LE.
*/
-class UTF16LECharsetEncoder : public CharsetEncoder {
-public:
- UTF16LECharsetEncoder() {
- }
+class UTF16LECharsetEncoder : public CharsetEncoder
+{
+ public:
+ UTF16LECharsetEncoder()
+ {
+ }
- virtual log4cxx_status_t encode(const LogString& in,
- LogString::const_iterator& iter,
- ByteBuffer& out) {
- while(iter != in.end() && out.remaining() >= 4) {
- unsigned int sv = Transcoder::decode(in, iter);
- if (sv == 0xFFFF) {
- return APR_BADARG;
- }
- Transcoder::encodeUTF16LE(sv, out);
- }
- return APR_SUCCESS;
- }
-private:
- UTF16LECharsetEncoder(const UTF16LECharsetEncoder&);
- UTF16LECharsetEncoder& operator=(const UTF16LECharsetEncoder&);
+ virtual log4cxx_status_t encode(const LogString& in,
+ LogString::const_iterator& iter,
+ ByteBuffer& out)
+ {
+ while (iter != in.end() && out.remaining() >= 4)
+ {
+ unsigned int sv = Transcoder::decode(in, iter);
+
+ if (sv == 0xFFFF)
+ {
+ return APR_BADARG;
+ }
+
+ Transcoder::encodeUTF16LE(sv, out);
+ }
+
+ return APR_SUCCESS;
+ }
+ private:
+ UTF16LECharsetEncoder(const UTF16LECharsetEncoder&);
+ UTF16LECharsetEncoder& operator=(const UTF16LECharsetEncoder&);
};
/**
* Charset encoder that uses an embedded CharsetEncoder consistent
* with current locale settings.
*/
-class LocaleCharsetEncoder : public CharsetEncoder {
-public:
- LocaleCharsetEncoder() : pool(), mutex(pool), encoder(), encoding() {
- }
- virtual ~LocaleCharsetEncoder() {
- }
- virtual log4cxx_status_t encode(const LogString& in,
- LogString::const_iterator& iter,
- ByteBuffer& out) {
+class LocaleCharsetEncoder : public CharsetEncoder
+{
+ public:
+ LocaleCharsetEncoder() : pool(), mutex(pool), encoder(), encoding()
+ {
+ }
+ virtual ~LocaleCharsetEncoder()
+ {
+ }
+ virtual log4cxx_status_t encode(const LogString& in,
+ LogString::const_iterator& iter,
+ ByteBuffer& out)
+ {
#if !LOG4CXX_CHARSET_EBCDIC
char* current = out.current();
size_t remain = out.remaining();
- for(;
- iter != in.end() && ((unsigned int) *iter) < 0x80 && remain > 0;
- iter++, remain--, current++) {
+
+ for (;
+ iter != in.end() && ((unsigned int) *iter) < 0x80 && remain > 0;
+ iter++, remain--, current++)
+ {
*current = *iter;
}
+
out.position(current - out.data());
#endif
- if (iter != in.end() && out.remaining() > 0) {
- Pool subpool;
- const char* enc = apr_os_locale_encoding(subpool.getAPRPool());
- {
- synchronized sync(mutex);
- if (enc == 0) {
- if (encoder == 0) {
- encoding = "C";
- encoder = new USASCIICharsetEncoder();
- }
- } else if (encoding != enc) {
- encoding = enc;
- LogString ename;
- Transcoder::decode(encoding, ename);
- try {
- encoder = CharsetEncoder::getEncoder(ename);
- } catch(IllegalArgumentException &ex) {
- encoder = new USASCIICharsetEncoder();
- }
- }
- }
- return encoder->encode(in, iter, out);
- }
- return APR_SUCCESS;
- }
-private:
- LocaleCharsetEncoder(const LocaleCharsetEncoder&);
- LocaleCharsetEncoder& operator=(const LocaleCharsetEncoder&);
- Pool pool;
- Mutex mutex;
- CharsetEncoderPtr encoder;
- std::string encoding;
+ if (iter != in.end() && out.remaining() > 0)
+ {
+ Pool subpool;
+ const char* enc = apr_os_locale_encoding(subpool.getAPRPool());
+ {
+ synchronized sync(mutex);
+
+ if (enc == 0)
+ {
+ if (encoder == 0)
+ {
+ encoding = "C";
+ encoder = new USASCIICharsetEncoder();
+ }
+ }
+ else if (encoding != enc)
+ {
+ encoding = enc;
+ LogString ename;
+ Transcoder::decode(encoding, ename);
+
+ try
+ {
+ encoder = CharsetEncoder::getEncoder(ename);
+ }
+ catch (IllegalArgumentException& ex)
+ {
+ encoder = new USASCIICharsetEncoder();
+ }
+ }
+ }
+ return encoder->encode(in, iter, out);
+ }
+
+ return APR_SUCCESS;
+ }
+
+ private:
+ LocaleCharsetEncoder(const LocaleCharsetEncoder&);
+ LocaleCharsetEncoder& operator=(const LocaleCharsetEncoder&);
+ Pool pool;
+ Mutex mutex;
+ CharsetEncoderPtr encoder;
+ std::string encoding;
};
- } // namespace helpers
+} // namespace helpers
} //namespace log4cxx
-CharsetEncoder::CharsetEncoder() {
+CharsetEncoder::CharsetEncoder()
+{
}
-CharsetEncoder::~CharsetEncoder() {
+CharsetEncoder::~CharsetEncoder()
+{
}
-CharsetEncoderPtr CharsetEncoder::getDefaultEncoder() {
- static CharsetEncoderPtr encoder(createDefaultEncoder());
- //
- // if invoked after static variable destruction
- // (if logging is called in the destructor of a static object)
- // then create a new decoder.
- //
- if (encoder == 0) {
- return createDefaultEncoder();
- }
- return encoder;
+CharsetEncoderPtr CharsetEncoder::getDefaultEncoder()
+{
+ static CharsetEncoderPtr encoder(createDefaultEncoder());
+
+ //
+ // if invoked after static variable destruction
+ // (if logging is called in the destructor of a static object)
+ // then create a new decoder.
+ //
+ if (encoder == 0)
+ {
+ return createDefaultEncoder();
+ }
+
+ return encoder;
}
-CharsetEncoder* CharsetEncoder::createDefaultEncoder() {
+CharsetEncoder* CharsetEncoder::createDefaultEncoder()
+{
#if LOG4CXX_CHARSET_UTF8
- return new UTF8CharsetEncoder();
+ return new UTF8CharsetEncoder();
#elif LOG4CXX_CHARSET_ISO88591
- return new ISOLatinCharsetEncoder();
+ return new ISOLatinCharsetEncoder();
#elif LOG4CXX_CHARSET_USASCII
- return new USASCIICharsetEncoder();
+ return new USASCIICharsetEncoder();
#elif LOG4CXX_LOGCHAR_IS_WCHAR && LOG4CXX_HAS_WCSTOMBS
- return new WcstombsCharsetEncoder();
+ return new WcstombsCharsetEncoder();
#else
- return new LocaleCharsetEncoder();
+ return new LocaleCharsetEncoder();
#endif
}
-CharsetEncoderPtr CharsetEncoder::getUTF8Encoder() {
+CharsetEncoderPtr CharsetEncoder::getUTF8Encoder()
+{
return new UTF8CharsetEncoder();
}
-CharsetEncoderPtr CharsetEncoder::getEncoder(const LogString& charset) {
- if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-8"), LOG4CXX_STR("utf-8"))) {
+CharsetEncoderPtr CharsetEncoder::getEncoder(const LogString& charset)
+{
+ if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-8"), LOG4CXX_STR("utf-8")))
+ {
return new UTF8CharsetEncoder();
- } else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("C"), LOG4CXX_STR("c")) ||
- charset == LOG4CXX_STR("646") ||
- StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("US-ASCII"), LOG4CXX_STR("us-ascii")) ||
- StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO646-US"), LOG4CXX_STR("iso646-US")) ||
- StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ANSI_X3.4-1968"), LOG4CXX_STR("ansi_x3.4-1968"))) {
+ }
+ else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("C"), LOG4CXX_STR("c")) ||
+ charset == LOG4CXX_STR("646") ||
+ StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("US-ASCII"), LOG4CXX_STR("us-ascii")) ||
+ StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO646-US"), LOG4CXX_STR("iso646-US")) ||
+ StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ANSI_X3.4-1968"), LOG4CXX_STR("ansi_x3.4-1968")))
+ {
return new USASCIICharsetEncoder();
- } else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO-8859-1"), LOG4CXX_STR("iso-8859-1")) ||
- StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO-LATIN-1"), LOG4CXX_STR("iso-latin-1"))) {
+ }
+ else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO-8859-1"), LOG4CXX_STR("iso-8859-1")) ||
+ StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("ISO-LATIN-1"), LOG4CXX_STR("iso-latin-1")))
+ {
return new ISOLatinCharsetEncoder();
- } else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-16BE"), LOG4CXX_STR("utf-16be"))
- || StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-16"), LOG4CXX_STR("utf-16"))) {
+ }
+ else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-16BE"), LOG4CXX_STR("utf-16be"))
+ || StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-16"), LOG4CXX_STR("utf-16")))
+ {
return new UTF16BECharsetEncoder();
- } else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-16LE"), LOG4CXX_STR("utf-16le"))) {
+ }
+ else if (StringHelper::equalsIgnoreCase(charset, LOG4CXX_STR("UTF-16LE"), LOG4CXX_STR("utf-16le")))
+ {
return new UTF16LECharsetEncoder();
}
+
#if APR_HAS_XLATE
return new APRCharsetEncoder(charset);
#else
@@ -498,27 +614,34 @@
}
-void CharsetEncoder::reset() {
+void CharsetEncoder::reset()
+{
}
-void CharsetEncoder::flush(ByteBuffer& /* out */ ) {
+void CharsetEncoder::flush(ByteBuffer& /* out */ )
+{
}
void CharsetEncoder::encode(CharsetEncoderPtr& enc,
- const LogString& src,
- LogString::const_iterator& iter,
- ByteBuffer& dst) {
+ const LogString& src,
+ LogString::const_iterator& iter,
+ ByteBuffer& dst)
+{
log4cxx_status_t stat = enc->encode(src, iter, dst);
- if (stat != APR_SUCCESS && iter != src.end()) {
+
+ if (stat != APR_SUCCESS && iter != src.end())
+ {
#if LOG4CXX_LOGCHAR_IS_WCHAR || LOG4CXX_LOGCHAR_IS_UNICHAR
- iter++;
+ iter++;
#elif LOG4CXX_LOGCHAR_IS_UTF8
- // advance past this character and all continuation characters
- while((*(++iter) & 0xC0) == 0x80);
+
+ // advance past this character and all continuation characters
+ while ((*(++iter) & 0xC0) == 0x80);
+
#else
#error logchar is unrecognized
#endif
- dst.put(Transcoder::LOSSCHAR);
+ dst.put(Transcoder::LOSSCHAR);
}
}
diff --git a/src/main/cpp/class.cpp b/src/main/cpp/class.cpp
index 74e36c3..149c150 100644
--- a/src/main/cpp/class.cpp
+++ b/src/main/cpp/class.cpp
@@ -16,7 +16,7 @@
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -27,7 +27,7 @@
#include <log4cxx/helpers/stringhelper.h>
#include <log4cxx/log4cxx.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
#include <log4cxx/rollingfileappender.h>
@@ -39,10 +39,10 @@
#include <log4cxx/fileappender.h>
#include <log4cxx/db/odbcappender.h>
#if defined(WIN32) || defined(_WIN32)
-#if !defined(_WIN32_WCE)
-#include <log4cxx/nt/nteventlogappender.h>
-#endif
-#include <log4cxx/nt/outputdebugstringappender.h>
+ #if !defined(_WIN32_WCE)
+ #include <log4cxx/nt/nteventlogappender.h>
+ #endif
+ #include <log4cxx/nt/outputdebugstringappender.h>
#endif
#include <log4cxx/net/smtpappender.h>
#include <log4cxx/net/socketappender.h>
@@ -81,7 +81,8 @@
using namespace log4cxx::xml;
using namespace log4cxx::rolling;
-Class::Class() {
+Class::Class()
+{
}
Class::~Class()
@@ -90,103 +91,117 @@
LogString Class::toString() const
{
- return getName();
+ return getName();
}
ObjectPtr Class::newInstance() const
{
- throw InstantiationException(LOG4CXX_STR("Cannot create new instances of Class."));
+ throw InstantiationException(LOG4CXX_STR("Cannot create new instances of Class."));
#if LOG4CXX_RETURN_AFTER_THROW
- return 0;
+ return 0;
#endif
}
-Class::ClassMap& Class::getRegistry() {
+Class::ClassMap& Class::getRegistry()
+{
static ClassMap registry;
return registry;
}
const Class& Class::forName(const LogString& className)
{
- LogString lowerName(StringHelper::toLowerCase(className));
- //
- // check registry using full class name
- //
- const Class* clazz = getRegistry()[lowerName];
- if (clazz == 0) {
- LogString::size_type pos = className.find_last_of(LOG4CXX_STR(".$"));
- if (pos != LogString::npos) {
- LogString terminalName(lowerName, pos + 1, LogString::npos);
- clazz = getRegistry()[terminalName];
- if (clazz == 0) {
- registerClasses();
- clazz = getRegistry()[lowerName];
- if (clazz == 0) {
- clazz = getRegistry()[terminalName];
- }
- }
- } else {
+ LogString lowerName(StringHelper::toLowerCase(className));
+ //
+ // check registry using full class name
+ //
+ const Class* clazz = getRegistry()[lowerName];
+
+ if (clazz == 0)
+ {
+ LogString::size_type pos = className.find_last_of(LOG4CXX_STR(".$"));
+
+ if (pos != LogString::npos)
+ {
+ LogString terminalName(lowerName, pos + 1, LogString::npos);
+ clazz = getRegistry()[terminalName];
+
+ if (clazz == 0)
+ {
registerClasses();
clazz = getRegistry()[lowerName];
+
+ if (clazz == 0)
+ {
+ clazz = getRegistry()[terminalName];
+ }
}
}
- if (clazz == 0) {
- throw ClassNotFoundException(className);
+ else
+ {
+ registerClasses();
+ clazz = getRegistry()[lowerName];
}
+ }
- return *clazz;
+ if (clazz == 0)
+ {
+ throw ClassNotFoundException(className);
+ }
+
+ return *clazz;
}
bool Class::registerClass(const Class& newClass)
{
- getRegistry()[StringHelper::toLowerCase(newClass.getName())] = &newClass;
- return true;
+ getRegistry()[StringHelper::toLowerCase(newClass.getName())] = &newClass;
+ return true;
}
-void Class::registerClasses() {
+void Class::registerClasses()
+{
#if APR_HAS_THREADS
- AsyncAppender::registerClass();
+ AsyncAppender::registerClass();
#endif
- ConsoleAppender::registerClass();
- FileAppender::registerClass();
- log4cxx::db::ODBCAppender::registerClass();
+ ConsoleAppender::registerClass();
+ FileAppender::registerClass();
+ log4cxx::db::ODBCAppender::registerClass();
#if (defined(WIN32) || defined(_WIN32))
#if !defined(_WIN32_WCE)
- log4cxx::nt::NTEventLogAppender::registerClass();
+ log4cxx::nt::NTEventLogAppender::registerClass();
#endif
- log4cxx::nt::OutputDebugStringAppender::registerClass();
+ log4cxx::nt::OutputDebugStringAppender::registerClass();
#endif
- log4cxx::RollingFileAppender::registerClass();
- SMTPAppender::registerClass();
- SocketAppender::registerClass();
+ log4cxx::RollingFileAppender::registerClass();
+ SMTPAppender::registerClass();
+ SocketAppender::registerClass();
#if APR_HAS_THREADS
- SocketHubAppender::registerClass();
+ SocketHubAppender::registerClass();
#endif
- SyslogAppender::registerClass();
+ SyslogAppender::registerClass();
#if APR_HAS_THREADS
- TelnetAppender::registerClass();
+ TelnetAppender::registerClass();
#endif
- XMLSocketAppender::registerClass();
- DateLayout::registerClass();
- HTMLLayout::registerClass();
- PatternLayout::registerClass();
- SimpleLayout::registerClass();
- TTCCLayout::registerClass();
- XMLLayout::registerClass();
- LevelMatchFilter::registerClass();
- LevelRangeFilter::registerClass();
- StringMatchFilter::registerClass();
- log4cxx::RollingFileAppender::registerClass();
- log4cxx::rolling::RollingFileAppender::registerClass();
- DailyRollingFileAppender::registerClass();
- log4cxx::rolling::SizeBasedTriggeringPolicy::registerClass();
- log4cxx::rolling::TimeBasedRollingPolicy::registerClass();
- log4cxx::rolling::ManualTriggeringPolicy::registerClass();
- log4cxx::rolling::FixedWindowRollingPolicy::registerClass();
- log4cxx::rolling::FilterBasedTriggeringPolicy::registerClass();
- log4cxx::xml::DOMConfigurator::registerClass();
- log4cxx::PropertyConfigurator::registerClass();
+ XMLSocketAppender::registerClass();
+ DateLayout::registerClass();
+ HTMLLayout::registerClass();
+ PatternLayout::registerClass();
+ SimpleLayout::registerClass();
+ TTCCLayout::registerClass();
+ XMLLayout::registerClass();
+ LevelMatchFilter::registerClass();
+ LevelRangeFilter::registerClass();
+ StringMatchFilter::registerClass();
+ log4cxx::RollingFileAppender::registerClass();
+ log4cxx::rolling::RollingFileAppender::registerClass();
+ DailyRollingFileAppender::registerClass();
+ log4cxx::rolling::SizeBasedTriggeringPolicy::registerClass();
+ log4cxx::rolling::TimeBasedRollingPolicy::registerClass();
+ log4cxx::rolling::ManualTriggeringPolicy::registerClass();
+ log4cxx::rolling::FixedWindowRollingPolicy::registerClass();
+ log4cxx::rolling::FilterBasedTriggeringPolicy::registerClass();
+ log4cxx::xml::DOMConfigurator::registerClass();
+ log4cxx::PropertyConfigurator::registerClass();
}
diff --git a/src/main/cpp/classnamepatternconverter.cpp b/src/main/cpp/classnamepatternconverter.cpp
index 26246b9..75a1730 100644
--- a/src/main/cpp/classnamepatternconverter.cpp
+++ b/src/main/cpp/classnamepatternconverter.cpp
@@ -16,7 +16,7 @@
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -24,33 +24,38 @@
#include <log4cxx/spi/loggingevent.h>
#include <log4cxx/spi/location/locationinfo.h>
- using namespace log4cxx;
- using namespace log4cxx::pattern;
- using namespace log4cxx::spi;
- using namespace log4cxx::helpers;
+using namespace log4cxx;
+using namespace log4cxx::pattern;
+using namespace log4cxx::spi;
+using namespace log4cxx::helpers;
IMPLEMENT_LOG4CXX_OBJECT(ClassNamePatternConverter)
ClassNamePatternConverter::ClassNamePatternConverter(
const std::vector<LogString>& options) :
NamePatternConverter(LOG4CXX_STR("Class Name"),
- LOG4CXX_STR("class name"), options) {
+ LOG4CXX_STR("class name"), options)
+{
}
PatternConverterPtr ClassNamePatternConverter::newInstance(
- const std::vector<LogString>& options) {
- if (options.size() == 0) {
- static PatternConverterPtr def(new ClassNamePatternConverter(options));
- return def;
+ const std::vector<LogString>& options)
+{
+ if (options.size() == 0)
+ {
+ static PatternConverterPtr def(new ClassNamePatternConverter(options));
+ return def;
}
+
return new ClassNamePatternConverter(options);
}
void ClassNamePatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- Pool& /* p */) const {
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ Pool& /* p */) const
+{
int initialLength = toAppendTo.length();
append(toAppendTo, event->getLocationInformation().getClassName());
abbreviate(initialLength, toAppendTo);
- }
+}
diff --git a/src/main/cpp/classregistration.cpp b/src/main/cpp/classregistration.cpp
index 094177e..b5678d9 100644
--- a/src/main/cpp/classregistration.cpp
+++ b/src/main/cpp/classregistration.cpp
@@ -21,7 +21,8 @@
using namespace log4cxx;
using namespace log4cxx::helpers;
-ClassRegistration::ClassRegistration(ClassAccessor accessor) {
+ClassRegistration::ClassRegistration(ClassAccessor accessor)
+{
Class::registerClass((*accessor)());
}
diff --git a/src/main/cpp/condition.cpp b/src/main/cpp/condition.cpp
index fdb7815..b8b5ec1 100644
--- a/src/main/cpp/condition.cpp
+++ b/src/main/cpp/condition.cpp
@@ -30,41 +30,50 @@
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);
- }
+ 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);
+ apr_thread_cond_destroy(condition);
#endif
}
log4cxx_status_t Condition::signalAll()
{
#if APR_HAS_THREADS
- return apr_thread_cond_broadcast(condition);
+ return apr_thread_cond_broadcast(condition);
#else
- return APR_SUCCESS;
+ 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);
- }
+
+ 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/configurator.cpp b/src/main/cpp/configurator.cpp
index 78e910b..4252dc1 100644
--- a/src/main/cpp/configurator.cpp
+++ b/src/main/cpp/configurator.cpp
@@ -28,5 +28,6 @@
-Configurator::Configurator() {
+Configurator::Configurator()
+{
}
diff --git a/src/main/cpp/consoleappender.cpp b/src/main/cpp/consoleappender.cpp
index 732fb80..3fdc79e 100644
--- a/src/main/cpp/consoleappender.cpp
+++ b/src/main/cpp/consoleappender.cpp
@@ -28,12 +28,12 @@
IMPLEMENT_LOG4CXX_OBJECT(ConsoleAppender)
ConsoleAppender::ConsoleAppender()
- : target(getSystemOut())
+ : target(getSystemOut())
{
}
ConsoleAppender::ConsoleAppender(const LayoutPtr& layout1)
- :target(getSystemOut())
+ : target(getSystemOut())
{
setLayout(layout1);
Pool p;
@@ -43,88 +43,91 @@
}
ConsoleAppender::ConsoleAppender(const LayoutPtr& layout1, const LogString& target1)
- : target(target1)
+ : target(target1)
{
- setLayout(layout1);
- Pool p;
- ConsoleAppender::activateOptions(p);
+ setLayout(layout1);
+ Pool p;
+ ConsoleAppender::activateOptions(p);
}
ConsoleAppender::~ConsoleAppender()
{
- finalize();
+ finalize();
}
-const LogString& ConsoleAppender::getSystemOut() {
- static const LogString name(LOG4CXX_STR("System.out"));
- return name;
+const LogString& ConsoleAppender::getSystemOut()
+{
+ static const LogString name(LOG4CXX_STR("System.out"));
+ return name;
}
-const LogString& ConsoleAppender::getSystemErr() {
- static const LogString name(LOG4CXX_STR("System.err"));
- return name;
+const LogString& ConsoleAppender::getSystemErr()
+{
+ static const LogString name(LOG4CXX_STR("System.err"));
+ return name;
}
void ConsoleAppender::setTarget(const LogString& value)
{
- LogString v = StringHelper::trim(value);
+ LogString v = StringHelper::trim(value);
- if (StringHelper::equalsIgnoreCase(v,
- LOG4CXX_STR("SYSTEM.OUT"), LOG4CXX_STR("system.out")))
- {
- target = getSystemOut();
- }
- else if (StringHelper::equalsIgnoreCase(v,
- LOG4CXX_STR("SYSTEM.ERR"), LOG4CXX_STR("system.err")))
- {
- target = getSystemErr();
- }
- else
- {
- targetWarn(value);
- }
+ if (StringHelper::equalsIgnoreCase(v,
+ LOG4CXX_STR("SYSTEM.OUT"), LOG4CXX_STR("system.out")))
+ {
+ target = getSystemOut();
+ }
+ else if (StringHelper::equalsIgnoreCase(v,
+ LOG4CXX_STR("SYSTEM.ERR"), LOG4CXX_STR("system.err")))
+ {
+ target = getSystemErr();
+ }
+ else
+ {
+ targetWarn(value);
+ }
}
LogString ConsoleAppender::getTarget() const
{
- return target;
+ return target;
}
void ConsoleAppender::targetWarn(const LogString& val)
{
- LogLog::warn(((LogString) LOG4CXX_STR("["))
- + val + LOG4CXX_STR("] should be system.out or system.err."));
- LogLog::warn(LOG4CXX_STR("Using previously set target, System.out by default."));
+ LogLog::warn(((LogString) LOG4CXX_STR("["))
+ + val + LOG4CXX_STR("] should be system.out or system.err."));
+ LogLog::warn(LOG4CXX_STR("Using previously set target, System.out by default."));
}
void ConsoleAppender::activateOptions(Pool& p)
{
- if(StringHelper::equalsIgnoreCase(target,
- LOG4CXX_STR("SYSTEM.OUT"), LOG4CXX_STR("system.out")))
- {
- WriterPtr writer1(new SystemOutWriter());
- setWriter(writer1);
- }
- else if (StringHelper::equalsIgnoreCase(target,
- LOG4CXX_STR("SYSTEM.ERR"), LOG4CXX_STR("system.err")))
- {
- WriterPtr writer1(new SystemErrWriter());
- setWriter(writer1);
- }
- WriterAppender::activateOptions(p);
+ if (StringHelper::equalsIgnoreCase(target,
+ LOG4CXX_STR("SYSTEM.OUT"), LOG4CXX_STR("system.out")))
+ {
+ WriterPtr writer1(new SystemOutWriter());
+ setWriter(writer1);
+ }
+ else if (StringHelper::equalsIgnoreCase(target,
+ LOG4CXX_STR("SYSTEM.ERR"), LOG4CXX_STR("system.err")))
+ {
+ WriterPtr writer1(new SystemErrWriter());
+ setWriter(writer1);
+ }
+
+ WriterAppender::activateOptions(p);
}
void ConsoleAppender::setOption(const LogString& option, const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("TARGET"), LOG4CXX_STR("target")))
- {
- setTarget(value);
- }
- else
- {
- WriterAppender::setOption(option, value);
- }
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("TARGET"), LOG4CXX_STR("target")))
+ {
+ setTarget(value);
+ }
+ else
+ {
+ WriterAppender::setOption(option, value);
+ }
}
diff --git a/src/main/cpp/cyclicbuffer.cpp b/src/main/cpp/cyclicbuffer.cpp
index 9167238..0be9cdd 100644
--- a/src/main/cpp/cyclicbuffer.cpp
+++ b/src/main/cpp/cyclicbuffer.cpp
@@ -32,17 +32,17 @@
@param maxSize The maximum number of elements in the buffer.
*/
CyclicBuffer::CyclicBuffer(int maxSize1)
-: ea(maxSize1), first(0), last(0), numElems(0), maxSize(maxSize1)
+ : ea(maxSize1), first(0), last(0), numElems(0), maxSize(maxSize1)
{
- if(maxSize1 < 1)
- {
- LogString msg(LOG4CXX_STR("The maxSize argument ("));
- Pool p;
- StringHelper::toString(maxSize1, p, msg);
- msg.append(LOG4CXX_STR(") is not a positive integer."));
- throw IllegalArgumentException(msg);
- }
- }
+ if (maxSize1 < 1)
+ {
+ LogString msg(LOG4CXX_STR("The maxSize argument ("));
+ Pool p;
+ StringHelper::toString(maxSize1, p, msg);
+ msg.append(LOG4CXX_STR(") is not a positive integer."));
+ throw IllegalArgumentException(msg);
+ }
+}
CyclicBuffer::~CyclicBuffer()
{
@@ -53,21 +53,22 @@
*/
void CyclicBuffer::add(const spi::LoggingEventPtr& event)
{
- ea[last] = event;
- if(++last == maxSize)
- {
- last = 0;
- }
+ ea[last] = event;
- if(numElems < maxSize)
- {
- numElems++;
- }
- else if(++first == maxSize)
- {
- first = 0;
- }
- }
+ if (++last == maxSize)
+ {
+ last = 0;
+ }
+
+ if (numElems < maxSize)
+ {
+ numElems++;
+ }
+ else if (++first == maxSize)
+ {
+ first = 0;
+ }
+}
/**
@@ -77,10 +78,12 @@
*/
spi::LoggingEventPtr CyclicBuffer::get(int i)
{
- if(i < 0 || i >= numElems)
- return 0;
+ if (i < 0 || i >= numElems)
+ {
+ return 0;
+ }
- return ea[(first + i) % maxSize];
+ return ea[(first + i) % maxSize];
}
/**
@@ -89,18 +92,21 @@
*/
spi::LoggingEventPtr CyclicBuffer::get()
{
- LoggingEventPtr r;
- if(numElems > 0)
+ LoggingEventPtr r;
+
+ if (numElems > 0)
+ {
+ numElems--;
+ r = ea[first];
+ ea[first] = 0;
+
+ if (++first == maxSize)
{
- numElems--;
- r = ea[first];
- ea[first] = 0;
- if(++first == maxSize)
- {
- first = 0;
- }
+ first = 0;
}
- return r;
+ }
+
+ return r;
}
/**
@@ -109,40 +115,47 @@
*/
void CyclicBuffer::resize(int newSize)
{
- if(newSize < 0)
- {
- LogString msg(LOG4CXX_STR("Negative array size ["));
- Pool p;
- StringHelper::toString(newSize, p, msg);
- msg.append(LOG4CXX_STR("] not allowed."));
- throw IllegalArgumentException(msg);
- }
- if(newSize == numElems)
- return; // nothing to do
+ if (newSize < 0)
+ {
+ LogString msg(LOG4CXX_STR("Negative array size ["));
+ Pool p;
+ StringHelper::toString(newSize, p, msg);
+ msg.append(LOG4CXX_STR("] not allowed."));
+ throw IllegalArgumentException(msg);
+ }
- LoggingEventList temp(newSize);
+ if (newSize == numElems)
+ {
+ return; // nothing to do
+ }
- int loopLen = newSize < numElems ? newSize : numElems;
- int i;
+ LoggingEventList temp(newSize);
- for(i = 0; i < loopLen; i++)
- {
- temp[i] = ea[first];
- ea[first] = 0;
- if(++first == numElems)
- first = 0;
- }
+ int loopLen = newSize < numElems ? newSize : numElems;
+ int i;
- ea = temp;
- first = 0;
- numElems = loopLen;
- maxSize = newSize;
- if (loopLen == newSize)
+ for (i = 0; i < loopLen; i++)
+ {
+ temp[i] = ea[first];
+ ea[first] = 0;
+
+ if (++first == numElems)
{
- last = 0;
+ first = 0;
}
- else
- {
- last = loopLen;
- }
+ }
+
+ ea = temp;
+ first = 0;
+ numElems = loopLen;
+ maxSize = newSize;
+
+ if (loopLen == newSize)
+ {
+ last = 0;
+ }
+ else
+ {
+ last = loopLen;
+ }
}
diff --git a/src/main/cpp/dailyrollingfileappender.cpp b/src/main/cpp/dailyrollingfileappender.cpp
index 87f7891..390271c 100644
--- a/src/main/cpp/dailyrollingfileappender.cpp
+++ b/src/main/cpp/dailyrollingfileappender.cpp
@@ -37,70 +37,85 @@
DailyRollingFileAppender::DailyRollingFileAppender(
- const LayoutPtr& l,
- const LogString& filename,
- const LogString& datePattern1)
- : datePattern(datePattern1) {
+ const LayoutPtr& l,
+ const LogString& filename,
+ const LogString& datePattern1)
+ : datePattern(datePattern1)
+{
setLayout(l);
setFile(filename);
Pool p;
activateOptions(p);
}
-void DailyRollingFileAppender::setDatePattern(const LogString& newPattern) {
- datePattern = newPattern;
+void DailyRollingFileAppender::setDatePattern(const LogString& newPattern)
+{
+ datePattern = newPattern;
}
-LogString DailyRollingFileAppender::getDatePattern() {
- return datePattern;
+LogString DailyRollingFileAppender::getDatePattern()
+{
+ return datePattern;
}
-void DailyRollingFileAppender::activateOptions(log4cxx::helpers::Pool& p) {
- TimeBasedRollingPolicyPtr policy = new TimeBasedRollingPolicy();
- LogString pattern(getFile());
- bool inLiteral = false;
- bool inPattern = false;
+void DailyRollingFileAppender::activateOptions(log4cxx::helpers::Pool& p)
+{
+ TimeBasedRollingPolicyPtr policy = new TimeBasedRollingPolicy();
+ LogString pattern(getFile());
+ bool inLiteral = false;
+ bool inPattern = false;
- for (size_t i = 0; i < datePattern.length(); i++) {
- if (datePattern[i] == 0x27 /* '\'' */) {
- inLiteral = !inLiteral;
+ for (size_t i = 0; i < datePattern.length(); i++)
+ {
+ if (datePattern[i] == 0x27 /* '\'' */)
+ {
+ inLiteral = !inLiteral;
- if (inLiteral && inPattern) {
- pattern.append(1, (logchar) 0x7D /* '}' */);
- inPattern = false;
- }
- } else {
- if (!inLiteral && !inPattern) {
- const logchar dbrace[] = { 0x25, 0x64, 0x7B, 0 }; // "%d{"
- pattern.append(dbrace);
- inPattern = true;
- }
+ if (inLiteral && inPattern)
+ {
+ pattern.append(1, (logchar) 0x7D /* '}' */);
+ inPattern = false;
+ }
+ }
+ else
+ {
+ if (!inLiteral && !inPattern)
+ {
+ const logchar dbrace[] = { 0x25, 0x64, 0x7B, 0 }; // "%d{"
+ pattern.append(dbrace);
+ inPattern = true;
+ }
- pattern.append(1, datePattern[i]);
+ pattern.append(1, datePattern[i]);
+ }
}
- }
- if (inPattern) {
- pattern.append(1, (logchar) 0x7D /* '}' */);
- }
+ if (inPattern)
+ {
+ pattern.append(1, (logchar) 0x7D /* '}' */);
+ }
- policy->setFileNamePattern(pattern);
- policy->activateOptions(p);
- setTriggeringPolicy(policy);
- setRollingPolicy(policy);
+ policy->setFileNamePattern(pattern);
+ policy->activateOptions(p);
+ setTriggeringPolicy(policy);
+ setRollingPolicy(policy);
- RollingFileAppenderSkeleton::activateOptions(p);
+ RollingFileAppenderSkeleton::activateOptions(p);
}
void DailyRollingFileAppender::setOption(const LogString& option,
- const LogString& value) {
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("DATEPATTERN"), LOG4CXX_STR("datepattern"))) {
- setDatePattern(value);
- } else {
- RollingFileAppenderSkeleton::setOption(option, value);
- }
+ const LogString& value)
+{
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("DATEPATTERN"), LOG4CXX_STR("datepattern")))
+ {
+ setDatePattern(value);
+ }
+ else
+ {
+ RollingFileAppenderSkeleton::setOption(option, value);
+ }
}
diff --git a/src/main/cpp/datagrampacket.cpp b/src/main/cpp/datagrampacket.cpp
index b815f62..0b6710b 100644
--- a/src/main/cpp/datagrampacket.cpp
+++ b/src/main/cpp/datagrampacket.cpp
@@ -24,32 +24,32 @@
/** Constructs a DatagramPacket for receiving packets of length
<code>length</code>. */
-DatagramPacket::DatagramPacket(void * buf1, int length1)
-: buf(buf1), offset(0), length(length1), address(), port(0)
+DatagramPacket::DatagramPacket(void* buf1, int length1)
+ : buf(buf1), offset(0), length(length1), address(), port(0)
{
}
/** Constructs a datagram packet for sending packets of length
<code>length/<code> to the specified port number on the specified
host. */
-DatagramPacket::DatagramPacket(void * buf1, int length1, InetAddressPtr address1,
-int port1)
-: buf(buf1), offset(0), length(length1), address(address1), port(port1)
+DatagramPacket::DatagramPacket(void* buf1, int length1, InetAddressPtr address1,
+ int port1)
+ : buf(buf1), offset(0), length(length1), address(address1), port(port1)
{
}
/** Constructs a DatagramPacket for receiving packets of length
<code>length</code>, specifying an offset into the buffer. */
-DatagramPacket::DatagramPacket(void * buf1, int offset1, int length1)
-: buf(buf1), offset(offset1), length(length1), address(), port(0)
+DatagramPacket::DatagramPacket(void* buf1, int offset1, int length1)
+ : buf(buf1), offset(offset1), length(length1), address(), port(0)
{
}
/** Constructs a datagram packet for sending packets of length
<code>length</code> with offset <code>offset</code> to the
specified port number on the specified host. */
-DatagramPacket::DatagramPacket(void * buf1, int offset1, int length1,
-InetAddressPtr address1, int port1)
-: buf(buf1), offset(offset1), length(length1), address(address1), port(port1)
+DatagramPacket::DatagramPacket(void* buf1, int offset1, int length1,
+ InetAddressPtr address1, int port1)
+ : buf(buf1), offset(offset1), length(length1), address(address1), port(port1)
{
}
diff --git a/src/main/cpp/datagramsocket.cpp b/src/main/cpp/datagramsocket.cpp
index 617980a..14636fe 100644
--- a/src/main/cpp/datagramsocket.cpp
+++ b/src/main/cpp/datagramsocket.cpp
@@ -28,159 +28,180 @@
IMPLEMENT_LOG4CXX_OBJECT(DatagramSocket)
DatagramSocket::DatagramSocket()
- : socket(0), address(), localAddress(), port(0), localPort(0)
+ : socket(0), address(), localAddress(), port(0), localPort(0)
{
- create();
+ create();
}
DatagramSocket::DatagramSocket(int localPort1)
- : socket(0), address(), localAddress(), port(0), localPort(0)
+ : socket(0), address(), localAddress(), port(0), localPort(0)
{
- InetAddressPtr bindAddr = InetAddress::anyAddress();
+ InetAddressPtr bindAddr = InetAddress::anyAddress();
- create();
- bind(localPort1, bindAddr);
+ create();
+ bind(localPort1, bindAddr);
}
DatagramSocket::DatagramSocket(int localPort1, InetAddressPtr localAddress1)
- : socket(0), address(), localAddress(), port(0), localPort(0)
+ : socket(0), address(), localAddress(), port(0), localPort(0)
{
- create();
- bind(localPort1, localAddress1);
+ create();
+ bind(localPort1, localAddress1);
}
DatagramSocket::~DatagramSocket()
{
- try
- {
- close();
- }
- catch(SocketException&)
- {
- }
+ try
+ {
+ close();
+ }
+ catch (SocketException&)
+ {
+ }
}
/** Binds a datagram socket to a local port and address.*/
void DatagramSocket::bind(int localPort1, InetAddressPtr localAddress1)
{
- Pool addrPool;
+ Pool addrPool;
- // Create server socket address (including port number)
- LOG4CXX_ENCODE_CHAR(hostAddr, localAddress1->getHostAddress());
- apr_sockaddr_t *server_addr;
- apr_status_t status =
- apr_sockaddr_info_get(&server_addr, hostAddr.c_str(), APR_INET,
- localPort1, 0, addrPool.getAPRPool());
- if (status != APR_SUCCESS) {
- throw BindException(status);
- }
+ // Create server socket address (including port number)
+ LOG4CXX_ENCODE_CHAR(hostAddr, localAddress1->getHostAddress());
+ apr_sockaddr_t* server_addr;
+ apr_status_t status =
+ apr_sockaddr_info_get(&server_addr, hostAddr.c_str(), APR_INET,
+ localPort1, 0, addrPool.getAPRPool());
- // bind the socket to the address
- status = apr_socket_bind(socket, server_addr);
- if (status != APR_SUCCESS) {
- throw BindException(status);
- }
+ if (status != APR_SUCCESS)
+ {
+ throw BindException(status);
+ }
- this->localPort = localPort1;
- this->localAddress = localAddress1;
+ // bind the socket to the address
+ status = apr_socket_bind(socket, server_addr);
+
+ if (status != APR_SUCCESS)
+ {
+ throw BindException(status);
+ }
+
+ this->localPort = localPort1;
+ this->localAddress = localAddress1;
}
/** Close the socket.*/
void DatagramSocket::close()
{
- if (socket != 0) {
- apr_status_t status = apr_socket_close(socket);
- if (status != APR_SUCCESS) {
- throw SocketException(status);
- }
+ if (socket != 0)
+ {
+ apr_status_t status = apr_socket_close(socket);
- socket = 0;
- localPort = 0;
- }
+ if (status != APR_SUCCESS)
+ {
+ throw SocketException(status);
+ }
+
+ socket = 0;
+ localPort = 0;
+ }
}
void DatagramSocket::connect(InetAddressPtr address1, int port1)
{
- this->address = address1;
- this->port = port1;
+ this->address = address1;
+ this->port = port1;
- Pool addrPool;
+ Pool addrPool;
- // create socket address
- LOG4CXX_ENCODE_CHAR(hostAddr, address1->getHostAddress());
- apr_sockaddr_t *client_addr;
- apr_status_t status =
- apr_sockaddr_info_get(&client_addr, hostAddr.c_str(), APR_INET,
- port, 0, addrPool.getAPRPool());
- if (status != APR_SUCCESS) {
- throw ConnectException(status);
- }
+ // create socket address
+ LOG4CXX_ENCODE_CHAR(hostAddr, address1->getHostAddress());
+ apr_sockaddr_t* client_addr;
+ apr_status_t status =
+ apr_sockaddr_info_get(&client_addr, hostAddr.c_str(), APR_INET,
+ port, 0, addrPool.getAPRPool());
- // connect the socket
- status = apr_socket_connect(socket, client_addr);
- if (status != APR_SUCCESS) {
- throw ConnectException(status);
- }
+ if (status != APR_SUCCESS)
+ {
+ throw ConnectException(status);
+ }
+
+ // connect the socket
+ status = apr_socket_connect(socket, client_addr);
+
+ if (status != APR_SUCCESS)
+ {
+ throw ConnectException(status);
+ }
}
/** Creates a datagram socket.*/
void DatagramSocket::create()
{
- apr_socket_t* newSocket;
- apr_status_t status =
- apr_socket_create(&newSocket, APR_INET, SOCK_DGRAM,
- APR_PROTO_UDP, socketPool.getAPRPool());
- socket = newSocket;
- if (status != APR_SUCCESS) {
- throw SocketException(status);
- }
+ apr_socket_t* newSocket;
+ apr_status_t status =
+ apr_socket_create(&newSocket, APR_INET, SOCK_DGRAM,
+ APR_PROTO_UDP, socketPool.getAPRPool());
+ socket = newSocket;
+
+ if (status != APR_SUCCESS)
+ {
+ throw SocketException(status);
+ }
}
/** Receive the datagram packet.*/
void DatagramSocket::receive(DatagramPacketPtr& p)
{
- Pool addrPool;
+ Pool addrPool;
- // Create the address from which to receive the datagram packet
- LOG4CXX_ENCODE_CHAR(hostAddr, p->getAddress()->getHostAddress());
- apr_sockaddr_t *addr;
- apr_status_t status =
- apr_sockaddr_info_get(&addr, hostAddr.c_str(), APR_INET,
- p->getPort(), 0, addrPool.getAPRPool());
- if (status != APR_SUCCESS) {
- throw SocketException(status);
- }
+ // Create the address from which to receive the datagram packet
+ LOG4CXX_ENCODE_CHAR(hostAddr, p->getAddress()->getHostAddress());
+ apr_sockaddr_t* addr;
+ apr_status_t status =
+ apr_sockaddr_info_get(&addr, hostAddr.c_str(), APR_INET,
+ p->getPort(), 0, addrPool.getAPRPool());
- // receive the datagram packet
- apr_size_t len = p->getLength();
- status = apr_socket_recvfrom(addr, socket, 0,
- (char *)p->getData(), &len);
- if (status != APR_SUCCESS) {
- throw IOException(status);
- }
+ if (status != APR_SUCCESS)
+ {
+ throw SocketException(status);
+ }
+
+ // receive the datagram packet
+ apr_size_t len = p->getLength();
+ status = apr_socket_recvfrom(addr, socket, 0,
+ (char*)p->getData(), &len);
+
+ if (status != APR_SUCCESS)
+ {
+ throw IOException(status);
+ }
}
/** Sends a datagram packet.*/
void DatagramSocket::send(DatagramPacketPtr& p)
{
- Pool addrPool;
+ Pool addrPool;
- // create the adress to which to send the datagram packet
- LOG4CXX_ENCODE_CHAR(hostAddr, p->getAddress()->getHostAddress());
- apr_sockaddr_t *addr;
- apr_status_t status =
- apr_sockaddr_info_get(&addr, hostAddr.c_str(), APR_INET, p->getPort(),
- 0, addrPool.getAPRPool());
- if (status != APR_SUCCESS) {
- throw SocketException(status);
- }
+ // create the adress to which to send the datagram packet
+ LOG4CXX_ENCODE_CHAR(hostAddr, p->getAddress()->getHostAddress());
+ apr_sockaddr_t* addr;
+ apr_status_t status =
+ apr_sockaddr_info_get(&addr, hostAddr.c_str(), APR_INET, p->getPort(),
+ 0, addrPool.getAPRPool());
- // send the datagram packet
- apr_size_t len = p->getLength();
- status = apr_socket_sendto(socket, addr, 0,
- (char *)p->getData(), &len);
- if (status != APR_SUCCESS) {
- throw IOException(status);
- }
+ if (status != APR_SUCCESS)
+ {
+ throw SocketException(status);
+ }
+
+ // send the datagram packet
+ apr_size_t len = p->getLength();
+ status = apr_socket_sendto(socket, addr, 0,
+ (char*)p->getData(), &len);
+
+ if (status != APR_SUCCESS)
+ {
+ throw IOException(status);
+ }
}
diff --git a/src/main/cpp/date.cpp b/src/main/cpp/date.cpp
index e7703a8..1beddc2 100644
--- a/src/main/cpp/date.cpp
+++ b/src/main/cpp/date.cpp
@@ -19,7 +19,7 @@
#include <apr_time.h>
#ifndef INT64_C
-#define INT64_C(x) x ## LL
+ #define INT64_C(x) x ## LL
#endif
using namespace log4cxx;
@@ -27,24 +27,30 @@
IMPLEMENT_LOG4CXX_OBJECT(Date)
-Date::Date() : time(apr_time_now()) {
+Date::Date() : time(apr_time_now())
+{
}
-Date::Date(log4cxx_time_t t) : time(t) {
+Date::Date(log4cxx_time_t t) : time(t)
+{
}
-Date::~Date() {
+Date::~Date()
+{
}
-log4cxx_time_t Date::getMicrosecondsPerDay() {
- return APR_INT64_C(86400000000);
+log4cxx_time_t Date::getMicrosecondsPerDay()
+{
+ return APR_INT64_C(86400000000);
}
-log4cxx_time_t Date::getMicrosecondsPerSecond() {
- return APR_USEC_PER_SEC;
+log4cxx_time_t Date::getMicrosecondsPerSecond()
+{
+ return APR_USEC_PER_SEC;
}
-log4cxx_time_t Date::getNextSecond() const {
+log4cxx_time_t Date::getNextSecond() const
+{
return ((time / APR_USEC_PER_SEC) + 1) * APR_USEC_PER_SEC;
}
diff --git a/src/main/cpp/dateformat.cpp b/src/main/cpp/dateformat.cpp
index 19fd1a1..ac1f338 100644
--- a/src/main/cpp/dateformat.cpp
+++ b/src/main/cpp/dateformat.cpp
@@ -29,7 +29,8 @@
void DateFormat::setTimeZone(const TimeZonePtr&) {}
-void DateFormat::numberFormat(LogString& s, int n, Pool& p) const {
+void DateFormat::numberFormat(LogString& s, int n, Pool& p) const
+{
StringHelper::toString(n, p, s);
}
diff --git a/src/main/cpp/datelayout.cpp b/src/main/cpp/datelayout.cpp
index 63bc7e5..5e3fc4c 100644
--- a/src/main/cpp/datelayout.cpp
+++ b/src/main/cpp/datelayout.cpp
@@ -30,7 +30,7 @@
using namespace log4cxx::spi;
DateLayout::DateLayout(const LogString& dateFormatOption1) :
- timeZoneID(), dateFormatOption(dateFormatOption1), dateFormat(0)
+ timeZoneID(), dateFormatOption(dateFormatOption1), dateFormat(0)
{
}
@@ -42,80 +42,86 @@
void DateLayout::setOption(const LogString& option, const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("DATEFORMAT"), LOG4CXX_STR("dateformat")))
- {
- dateFormatOption = value;
- }
- else if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("TIMEZONE"), LOG4CXX_STR("timezone")))
- {
- timeZoneID = value;
- }
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("DATEFORMAT"), LOG4CXX_STR("dateformat")))
+ {
+ dateFormatOption = value;
+ }
+ else if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("TIMEZONE"), LOG4CXX_STR("timezone")))
+ {
+ timeZoneID = value;
+ }
}
void DateLayout::activateOptions(Pool&)
{
- if(!dateFormatOption.empty())
- {
+ if (!dateFormatOption.empty())
+ {
- if(dateFormatOption.empty())
- {
- dateFormat = 0;
- }
- else if(StringHelper::equalsIgnoreCase(dateFormatOption,
- LOG4CXX_STR("NULL"), LOG4CXX_STR("null")))
- {
- dateFormat = 0;
- dateFormatOption = LOG4CXX_STR("NULL");
- }
- else if(StringHelper::equalsIgnoreCase(dateFormatOption,
- LOG4CXX_STR("RELATIVE"), LOG4CXX_STR("relative")))
- {
- dateFormat = new RelativeTimeDateFormat();
- dateFormatOption = LOG4CXX_STR("RELATIVE");
- }
- else if(StringHelper::equalsIgnoreCase(dateFormatOption,
- LOG4CXX_STR("ABSOLUTE"), LOG4CXX_STR("absolute")))
- {
- dateFormat = new AbsoluteTimeDateFormat();
- dateFormatOption = LOG4CXX_STR("ABSOLUTE");
- }
- else if(StringHelper::equalsIgnoreCase(dateFormatOption,
- LOG4CXX_STR("DATE"), LOG4CXX_STR("date")))
- {
- dateFormat = new DateTimeDateFormat();
- dateFormatOption = LOG4CXX_STR("DATE");
- }
- else if(StringHelper::equalsIgnoreCase(dateFormatOption,
- LOG4CXX_STR("ISO8601"), LOG4CXX_STR("iso8601")))
- {
- dateFormat = new ISO8601DateFormat();
- dateFormatOption = LOG4CXX_STR("iso8601");
- }
- else
- {
- dateFormat = new SimpleDateFormat(dateFormatOption);
- }
+ if (dateFormatOption.empty())
+ {
+ dateFormat = 0;
}
- if (dateFormat != NULL) {
- if (timeZoneID.empty()) {
- dateFormat->setTimeZone(TimeZone::getDefault());
- } else {
- dateFormat->setTimeZone(TimeZone::getTimeZone(timeZoneID));
- }
+ else if (StringHelper::equalsIgnoreCase(dateFormatOption,
+ LOG4CXX_STR("NULL"), LOG4CXX_STR("null")))
+ {
+ dateFormat = 0;
+ dateFormatOption = LOG4CXX_STR("NULL");
}
+ else if (StringHelper::equalsIgnoreCase(dateFormatOption,
+ LOG4CXX_STR("RELATIVE"), LOG4CXX_STR("relative")))
+ {
+ dateFormat = new RelativeTimeDateFormat();
+ dateFormatOption = LOG4CXX_STR("RELATIVE");
+ }
+ else if (StringHelper::equalsIgnoreCase(dateFormatOption,
+ LOG4CXX_STR("ABSOLUTE"), LOG4CXX_STR("absolute")))
+ {
+ dateFormat = new AbsoluteTimeDateFormat();
+ dateFormatOption = LOG4CXX_STR("ABSOLUTE");
+ }
+ else if (StringHelper::equalsIgnoreCase(dateFormatOption,
+ LOG4CXX_STR("DATE"), LOG4CXX_STR("date")))
+ {
+ dateFormat = new DateTimeDateFormat();
+ dateFormatOption = LOG4CXX_STR("DATE");
+ }
+ else if (StringHelper::equalsIgnoreCase(dateFormatOption,
+ LOG4CXX_STR("ISO8601"), LOG4CXX_STR("iso8601")))
+ {
+ dateFormat = new ISO8601DateFormat();
+ dateFormatOption = LOG4CXX_STR("iso8601");
+ }
+ else
+ {
+ dateFormat = new SimpleDateFormat(dateFormatOption);
+ }
+ }
+
+ if (dateFormat != NULL)
+ {
+ if (timeZoneID.empty())
+ {
+ dateFormat->setTimeZone(TimeZone::getDefault());
+ }
+ else
+ {
+ dateFormat->setTimeZone(TimeZone::getTimeZone(timeZoneID));
+ }
+ }
}
-void DateLayout::formatDate(LogString &s,
+void DateLayout::formatDate(LogString& s,
const spi::LoggingEventPtr& event,
- Pool& p) const {
+ Pool& p) const
+{
- if(dateFormat != 0)
- {
- dateFormat->format(s, event->getTimeStamp(), p);
- s.append(1, (logchar) 0x20 /* ' ' */);
- }
+ if (dateFormat != 0)
+ {
+ dateFormat->format(s, event->getTimeStamp(), p);
+ s.append(1, (logchar) 0x20 /* ' ' */);
+ }
}
diff --git a/src/main/cpp/datepatternconverter.cpp b/src/main/cpp/datepatternconverter.cpp
index b869e36..80db01c 100644
--- a/src/main/cpp/datepatternconverter.cpp
+++ b/src/main/cpp/datepatternconverter.cpp
@@ -16,7 +16,7 @@
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -40,96 +40,132 @@
IMPLEMENT_LOG4CXX_OBJECT(DatePatternConverter)
DatePatternConverter::DatePatternConverter(
- const std::vector<LogString>& options) :
- LoggingEventPatternConverter(LOG4CXX_STR("Class Name"),
- LOG4CXX_STR("class name")), df(getDateFormat(options)) {
+ const std::vector<LogString>& options) :
+ LoggingEventPatternConverter(LOG4CXX_STR("Class Name"),
+ LOG4CXX_STR("class name")), df(getDateFormat(options))
+{
}
-DateFormatPtr DatePatternConverter::getDateFormat(const OptionsList& options) {
- DateFormatPtr df;
- int maximumCacheValidity = 1000000;
- if (options.size() == 0) {
- df = new ISO8601DateFormat();
- } else {
- LogString dateFormatStr(options[0]);
+DateFormatPtr DatePatternConverter::getDateFormat(const OptionsList& options)
+{
+ DateFormatPtr df;
+ int maximumCacheValidity = 1000000;
- if(dateFormatStr.empty() ||
- StringHelper::equalsIgnoreCase(dateFormatStr,
- LOG4CXX_STR("ISO8601"), LOG4CXX_STR("iso8601"))) {
- df = new ISO8601DateFormat();
- } else if(StringHelper::equalsIgnoreCase(dateFormatStr,
- LOG4CXX_STR("ABSOLUTE"), LOG4CXX_STR("absolute"))) {
- df = new AbsoluteTimeDateFormat();
- } else if(StringHelper::equalsIgnoreCase(dateFormatStr,
- LOG4CXX_STR("DATE"), LOG4CXX_STR("date"))) {
- df = new DateTimeDateFormat();
- } else {
- if (dateFormatStr.find(0x25 /*'%'*/) == std::string::npos) {
- try {
- df = new SimpleDateFormat(dateFormatStr);
- maximumCacheValidity =
- CachedDateFormat::getMaximumCacheValidity(dateFormatStr);
- } catch(IllegalArgumentException& e) {
- df = new ISO8601DateFormat();
- LogLog::warn(((LogString)
- LOG4CXX_STR("Could not instantiate SimpleDateFormat with pattern "))
- + dateFormatStr, e);
- }
- } else {
- df = new StrftimeDateFormat(dateFormatStr);
- }
- }
- if (options.size() >= 2) {
- TimeZonePtr tz(TimeZone::getTimeZone(options[1]));
- if (tz != NULL) {
- df->setTimeZone(tz);
- }
- }
- }
- if (maximumCacheValidity > 0) {
- df = new CachedDateFormat(df, maximumCacheValidity);
- }
- return df;
+ if (options.size() == 0)
+ {
+ df = new ISO8601DateFormat();
+ }
+ else
+ {
+ LogString dateFormatStr(options[0]);
+
+ if (dateFormatStr.empty() ||
+ StringHelper::equalsIgnoreCase(dateFormatStr,
+ LOG4CXX_STR("ISO8601"), LOG4CXX_STR("iso8601")))
+ {
+ df = new ISO8601DateFormat();
+ }
+ else if (StringHelper::equalsIgnoreCase(dateFormatStr,
+ LOG4CXX_STR("ABSOLUTE"), LOG4CXX_STR("absolute")))
+ {
+ df = new AbsoluteTimeDateFormat();
+ }
+ else if (StringHelper::equalsIgnoreCase(dateFormatStr,
+ LOG4CXX_STR("DATE"), LOG4CXX_STR("date")))
+ {
+ df = new DateTimeDateFormat();
+ }
+ else
+ {
+ if (dateFormatStr.find(0x25 /*'%'*/) == std::string::npos)
+ {
+ try
+ {
+ df = new SimpleDateFormat(dateFormatStr);
+ maximumCacheValidity =
+ CachedDateFormat::getMaximumCacheValidity(dateFormatStr);
+ }
+ catch (IllegalArgumentException& e)
+ {
+ df = new ISO8601DateFormat();
+ LogLog::warn(((LogString)
+ LOG4CXX_STR("Could not instantiate SimpleDateFormat with pattern "))
+ + dateFormatStr, e);
+ }
+ }
+ else
+ {
+ df = new StrftimeDateFormat(dateFormatStr);
+ }
+ }
+
+ if (options.size() >= 2)
+ {
+ TimeZonePtr tz(TimeZone::getTimeZone(options[1]));
+
+ if (tz != NULL)
+ {
+ df->setTimeZone(tz);
+ }
+ }
+ }
+
+ if (maximumCacheValidity > 0)
+ {
+ df = new CachedDateFormat(df, maximumCacheValidity);
+ }
+
+ return df;
}
PatternConverterPtr DatePatternConverter::newInstance(
- const std::vector<LogString>& options) {
- return new DatePatternConverter(options);
+ const std::vector<LogString>& options)
+{
+ return new DatePatternConverter(options);
}
void DatePatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- Pool& p) const {
- df->format(toAppendTo, event->getTimeStamp(), p);
- }
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ Pool& p) const
+{
+ df->format(toAppendTo, event->getTimeStamp(), p);
+}
- /**
- * {@inheritDoc}
- */
+/**
+ * {@inheritDoc}
+ */
void DatePatternConverter::format(
const ObjectPtr& obj,
LogString& toAppendTo,
- Pool& p) const {
+ Pool& p) const
+{
DatePtr date(obj);
- if (date != NULL) {
- format(date, toAppendTo, p);
- } else {
- LoggingEventPtr event(obj);
- if (event != NULL) {
- format(event, toAppendTo, p);
- }
+
+ if (date != NULL)
+ {
+ format(date, toAppendTo, p);
+ }
+ else
+ {
+ LoggingEventPtr event(obj);
+
+ if (event != NULL)
+ {
+ format(event, toAppendTo, p);
+ }
}
}
- /**
- * Append formatted date to string buffer.
- * @param date date
- * @param toAppendTo buffer to which formatted date is appended.
- */
+/**
+ * Append formatted date to string buffer.
+ * @param date date
+ * @param toAppendTo buffer to which formatted date is appended.
+ */
void DatePatternConverter::format(
const DatePtr& date,
LogString& toAppendTo,
- Pool& p) const {
+ Pool& p) const
+{
df->format(toAppendTo, date->getTime(), p);
}
diff --git a/src/main/cpp/defaultconfigurator.cpp b/src/main/cpp/defaultconfigurator.cpp
index 4e10667..b592242 100644
--- a/src/main/cpp/defaultconfigurator.cpp
+++ b/src/main/cpp/defaultconfigurator.cpp
@@ -29,75 +29,87 @@
void DefaultConfigurator::configure(LoggerRepository* repository)
{
- repository->setConfigured(true);
- const LogString configuratorClassName(getConfiguratorClass());
+ repository->setConfigured(true);
+ const LogString configuratorClassName(getConfiguratorClass());
- LogString configurationOptionStr(getConfigurationFileName());
- Pool pool;
- File configuration;
+ LogString configurationOptionStr(getConfigurationFileName());
+ Pool pool;
+ File configuration;
+
+ if (configurationOptionStr.empty())
+ {
+ const char* names[] = { "log4cxx.xml", "log4cxx.properties", "log4j.xml", "log4j.properties", 0 };
+
+ for (int i = 0; names[i] != 0; i++)
+ {
+ File candidate(names[i]);
+
+ if (candidate.exists(pool))
+ {
+ configuration = candidate;
+ break;
+ }
+ }
+ }
+ else
+ {
+ configuration.setPath(configurationOptionStr);
+ }
+
+ if (configuration.exists(pool))
+ {
+ LogString msg(LOG4CXX_STR("Using configuration file ["));
+ msg += configuration.getPath();
+ msg += LOG4CXX_STR("] for automatic log4cxx configuration");
+ LogLog::debug(msg);
+
+ LoggerRepositoryPtr repo(repository);
+ OptionConverter::selectAndConfigure(
+ configuration,
+ configuratorClassName,
+ repo);
+ }
+ else
+ {
if (configurationOptionStr.empty())
{
- const char* names[] = { "log4cxx.xml", "log4cxx.properties", "log4j.xml", "log4j.properties", 0 };
- for (int i = 0; names[i] != 0; i++) {
- File candidate(names[i]);
- if (candidate.exists(pool)) {
- configuration = candidate;
- break;
- }
- }
- } else {
- configuration.setPath(configurationOptionStr);
- }
-
- if (configuration.exists(pool))
- {
- LogString msg(LOG4CXX_STR("Using configuration file ["));
- msg += configuration.getPath();
- msg += LOG4CXX_STR("] for automatic log4cxx configuration");
- LogLog::debug(msg);
-
- LoggerRepositoryPtr repo(repository);
- OptionConverter::selectAndConfigure(
- configuration,
- configuratorClassName,
- repo);
+ LogLog::debug(LOG4CXX_STR("Could not find default configuration file."));
}
else
{
- if (configurationOptionStr.empty()) {
- LogLog::debug(LOG4CXX_STR("Could not find default configuration file."));
- } else {
- LogString msg(LOG4CXX_STR("Could not find configuration file: ["));
- msg += configurationOptionStr;
- msg += LOG4CXX_STR("].");
- LogLog::debug(msg);
- }
+ LogString msg(LOG4CXX_STR("Could not find configuration file: ["));
+ msg += configurationOptionStr;
+ msg += LOG4CXX_STR("].");
+ LogLog::debug(msg);
}
+ }
}
-const LogString DefaultConfigurator::getConfiguratorClass() {
+const LogString DefaultConfigurator::getConfiguratorClass()
+{
- // Use automatic configration to configure the default hierarchy
- const LogString log4jConfiguratorClassName(
- OptionConverter::getSystemProperty(LOG4CXX_STR("log4j.configuratorClass"),LOG4CXX_STR("")));
- const LogString configuratorClassName(
+ // Use automatic configration to configure the default hierarchy
+ const LogString log4jConfiguratorClassName(
+ OptionConverter::getSystemProperty(LOG4CXX_STR("log4j.configuratorClass"), LOG4CXX_STR("")));
+ const LogString configuratorClassName(
OptionConverter::getSystemProperty(LOG4CXX_STR("LOG4CXX_CONFIGURATOR_CLASS"),
- log4jConfiguratorClassName));
- return configuratorClassName;
+ log4jConfiguratorClassName));
+ return configuratorClassName;
}
-const LogString DefaultConfigurator::getConfigurationFileName() {
- static const LogString LOG4CXX_DEFAULT_CONFIGURATION_KEY(LOG4CXX_STR("LOG4CXX_CONFIGURATION"));
- static const LogString LOG4J_DEFAULT_CONFIGURATION_KEY(LOG4CXX_STR("log4j.configuration"));
- const LogString log4jConfigurationOptionStr(
- OptionConverter::getSystemProperty(LOG4J_DEFAULT_CONFIGURATION_KEY, LOG4CXX_STR("")));
- const LogString configurationOptionStr(
- OptionConverter::getSystemProperty(LOG4CXX_DEFAULT_CONFIGURATION_KEY,
- log4jConfigurationOptionStr));
- return configurationOptionStr;
+const LogString DefaultConfigurator::getConfigurationFileName()
+{
+ static const LogString LOG4CXX_DEFAULT_CONFIGURATION_KEY(LOG4CXX_STR("LOG4CXX_CONFIGURATION"));
+ static const LogString LOG4J_DEFAULT_CONFIGURATION_KEY(LOG4CXX_STR("log4j.configuration"));
+ const LogString log4jConfigurationOptionStr(
+ OptionConverter::getSystemProperty(LOG4J_DEFAULT_CONFIGURATION_KEY, LOG4CXX_STR("")));
+ const LogString configurationOptionStr(
+ OptionConverter::getSystemProperty(LOG4CXX_DEFAULT_CONFIGURATION_KEY,
+ log4jConfigurationOptionStr));
+ return configurationOptionStr;
}
diff --git a/src/main/cpp/defaultrepositoryselector.cpp b/src/main/cpp/defaultrepositoryselector.cpp
index 1085adb..0afb650 100644
--- a/src/main/cpp/defaultrepositoryselector.cpp
+++ b/src/main/cpp/defaultrepositoryselector.cpp
@@ -23,18 +23,22 @@
DefaultRepositorySelector::DefaultRepositorySelector(const LoggerRepositoryPtr& repository1)
- : repository(repository1) {
+ : repository(repository1)
+{
}
-void DefaultRepositorySelector::addRef() const {
+void DefaultRepositorySelector::addRef() const
+{
ObjectImpl::addRef();
}
-void DefaultRepositorySelector::releaseRef() const {
+void DefaultRepositorySelector::releaseRef() const
+{
ObjectImpl::releaseRef();
}
-LoggerRepositoryPtr& DefaultRepositorySelector::getLoggerRepository() {
+LoggerRepositoryPtr& DefaultRepositorySelector::getLoggerRepository()
+{
return repository;
}
diff --git a/src/main/cpp/domconfigurator.cpp b/src/main/cpp/domconfigurator.cpp
index 618048a..bf997b8 100644
--- a/src/main/cpp/domconfigurator.cpp
+++ b/src/main/cpp/domconfigurator.cpp
@@ -60,28 +60,28 @@
#if APR_HAS_THREADS
namespace log4cxx
{
- namespace xml
- {
- class XMLWatchdog : public FileWatchdog
- {
- public:
- XMLWatchdog(const File& filename) : FileWatchdog(filename)
- {
- }
+namespace xml
+{
+class XMLWatchdog : public FileWatchdog
+{
+ 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());
+ }
+};
}
-XMLWatchdog *DOMConfigurator::xdog = NULL;
+}
+XMLWatchdog* DOMConfigurator::xdog = NULL;
#endif
@@ -116,39 +116,51 @@
#define INTERNAL_DEBUG_ATTR "debug"
DOMConfigurator::DOMConfigurator()
- : props(), repository() {
+ : props(), repository()
+{
}
-void DOMConfigurator::addRef() const {
- ObjectImpl::addRef();
+void DOMConfigurator::addRef() const
+{
+ ObjectImpl::addRef();
}
-void DOMConfigurator::releaseRef() const {
- ObjectImpl::releaseRef();
+void DOMConfigurator::releaseRef() const
+{
+ 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);
- 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) {
+
+ if (element->next && !appender)
+ {
appender = findAppenderByName(p, utf8Decoder, element->next, doc, appenderName, appenders);
}
+
return appender;
}
@@ -156,132 +168,155 @@
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;
- 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));
- }
+ 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 (appender)
+ {
+ appenders.insert(AppenderMap::value_type(appenderName, appender));
}
- if (!appender) {
- LogLog::error(LOG4CXX_STR("No appender named [")+
- appenderName+LOG4CXX_STR("] could be found."));
- }
- return appender;
+ }
+
+ if (!appender)
+ {
+ LogLog::error(LOG4CXX_STR("No appender named [") +
+ appenderName + LOG4CXX_STR("] could be found."));
+ }
+
+ 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("]"));
+ LogLog::debug(LOG4CXX_STR("Class name: [") + className + LOG4CXX_STR("]"));
+
try
+ {
+ ObjectPtr instance = Loader::loadClass(className).newInstance();
+ AppenderPtr appender = instance;
+ PropertySetter propSetter(appender);
+
+ appender->setName(subst(getAttribute(utf8Decoder, appenderElement, NAME_ATTR)));
+
+ for (apr_xml_elem* currentElement = appenderElement->first_child;
+ currentElement;
+ currentElement = currentElement->next)
{
- ObjectPtr instance = Loader::loadClass(className).newInstance();
- AppenderPtr appender = instance;
- PropertySetter propSetter(appender);
- appender->setName(subst(getAttribute(utf8Decoder, appenderElement, NAME_ATTR)));
+ std::string tagName(currentElement->name);
- for(apr_xml_elem* currentElement = appenderElement->first_child;
- currentElement;
- currentElement = currentElement->next) {
+ // 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);
- 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);
- 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->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(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."));
- }
- }
+ for (std::vector<log4cxx::spi::FilterPtr>::iterator iter = filters.begin();
+ iter != filters.end();
+ iter++)
+ {
+ appender->addFilter(*iter);
}
- propSetter.activate(p);
- return appender;
+ }
+ 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->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 (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;
+ {
+ LogLog::error(LOG4CXX_STR("Could not create an Appender. Reported error follows."),
+ oops);
+ return 0;
}
}
@@ -297,45 +332,50 @@
{
ErrorHandlerPtr eh = OptionConverter::instantiateByClassName(
- subst(getAttribute(utf8Decoder, element, CLASS_ATTR)),
- ErrorHandler::getStaticClass(),
- 0);
+ subst(getAttribute(utf8Decoder, element, CLASS_ATTR)),
+ ErrorHandler::getStaticClass(),
+ 0);
- if(eh != 0)
+ if (eh != 0)
+ {
+ eh->setAppender(appender);
+
+ PropertySetter propSetter(eh);
+
+ for (apr_xml_elem* currentElement = element->first_child;
+ currentElement;
+ currentElement = currentElement->next)
{
- eh->setAppender(appender);
+ std::string tagName(currentElement->name);
- PropertySetter propSetter(eh);
+ 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);
+ }
+ }
- 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);
- }
- }
- propSetter.activate(p);
- ObjectPtrT<AppenderSkeleton> appSkeleton(appender);
- if (appSkeleton != 0) {
- appSkeleton->setErrorHandler(eh);
- }
+ propSetter.activate(p);
+ ObjectPtrT<AppenderSkeleton> appSkeleton(appender);
+
+ if (appSkeleton != 0)
+ {
+ appSkeleton->setErrorHandler(eh);
+ }
}
}
@@ -347,119 +387,124 @@
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)
+ if (filter != 0)
+ {
+ PropertySetter propSetter(filter);
+
+ for (apr_xml_elem* currentElement = element->first_child;
+ currentElement;
+ currentElement = currentElement->next)
{
- PropertySetter propSetter(filter);
+ 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);
- }
- }
- propSetter.activate(p);
- filters.push_back(filter);
+ if (tagName == PARAM_TAG)
+ {
+ setParameter(p, utf8Decoder, currentElement, propSetter);
+ }
}
+
+ 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.
+ LOCK_W sync(logger->getMutex());
+ 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("]."));
+ logger->setAdditivity(additivity);
+ parseChildrenOfLoggerElement(p, utf8Decoder, loggerElement, logger, false, doc, appenders);
}
/**
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);
- if (tagName == PARAM_TAG) {
- setParameter(p, utf8Decoder, currentElement, propSetter);
- }
- }
+ 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);
+ }
}
+ }
}
/**
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();
+ // logger configuration needs to be atomic
+ LOCK_W sync(root->getMutex());
+ parseChildrenOfLoggerElement(p, utf8Decoder, rootElement, root, true, doc, appenders);
}
/**
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)
{
PropertySetter propSetter(logger);
@@ -470,41 +515,44 @@
for (apr_xml_elem* currentElement = loggerElement->first_child;
- currentElement;
- currentElement = currentElement->next) {
- std::string tagName(currentElement->name);
+ currentElement;
+ currentElement = currentElement->next)
+ {
+ std::string tagName(currentElement->name);
- 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."));
- }
+ if (tagName == APPENDER_REF_TAG)
+ {
+ AppenderPtr appender = findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders);
+ LogString refName = subst(getAttribute(utf8Decoder, currentElement, REF_ATTR));
- logger->addAppender(appender);
+ 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."));
+ }
- }
- 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);
- }
+ 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);
}
@@ -512,122 +560,135 @@
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("\""));
- try
- {
- ObjectPtr instance = Loader::loadClass(className).newInstance();
- LayoutPtr layout = instance;
- PropertySetter propSetter(layout);
+ LogString className(subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR)));
+ LogLog::debug(LOG4CXX_STR("Parsing layout of class: \"") + className + LOG4CXX_STR("\""));
- 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);
- }
- }
+ try
+ {
+ ObjectPtr instance = Loader::loadClass(className).newInstance();
+ LayoutPtr layout = instance;
+ PropertySetter propSetter(layout);
- propSetter.activate(p);
- return layout;
- }
- catch (Exception& oops)
+ for (apr_xml_elem* currentElement = layout_element->first_child;
+ currentElement;
+ currentElement = currentElement->next)
{
- LogLog::error(LOG4CXX_STR("Could not create the Layout. Reported error follows."),
- oops);
- return 0;
+ std::string tagName(currentElement->name);
+
+ 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;
+ }
}
/**
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("\""));
- try
- {
- ObjectPtr instance = Loader::loadClass(className).newInstance();
- PropertySetter propSetter(instance);
+ LogString className = subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR));
+ LogLog::debug(LOG4CXX_STR("Parsing triggering policy of class: \"") + className + LOG4CXX_STR("\""));
- 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 (fbtp != NULL) {
- for(std::vector<log4cxx::spi::FilterPtr>::iterator iter = filters.begin();
- iter != filters.end();
- iter++) {
- fbtp->addFilter(*iter);
- }
- }
- }
+ 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);
+
+ 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);
+ }
}
+ }
+ }
- 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("\""));
- try
- {
- ObjectPtr instance = Loader::loadClass(className).newInstance();
- RollingPolicyPtr layout = instance;
- PropertySetter propSetter(layout);
+ LogString className = subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR));
+ LogLog::debug(LOG4CXX_STR("Parsing rolling policy of class: \"") + className + LOG4CXX_STR("\""));
- 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);
- }
- }
+ try
+ {
+ ObjectPtr instance = Loader::loadClass(className).newInstance();
+ RollingPolicyPtr layout = instance;
+ PropertySetter propSetter(layout);
- propSetter.activate(p);
- return layout;
- }
- catch (Exception& oops)
+ for (apr_xml_elem* currentElement = layout_element->first_child;
+ currentElement;
+ currentElement = currentElement->next)
{
- LogLog::error(LOG4CXX_STR("Could not create the RollingPolicy. Reported error follows."),
- oops);
- return 0;
+ std::string tagName(currentElement->name);
+
+ 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;
+ }
}
@@ -636,130 +697,141 @@
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();
- 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("]."));
+ 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 (StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("INHERITED"), LOG4CXX_STR("inherited"))
+ || StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("NULL"), LOG4CXX_STR("null")))
+ {
+ if (isRoot)
{
- if(isRoot)
- {
- LogLog::error(LOG4CXX_STR("Root level cannot be inherited. Ignoring directive."));
- }
- else
- {
- logger->setLevel(0);
- }
- }
+ LogLog::error(LOG4CXX_STR("Root level cannot be inherited. Ignoring directive."));
+ }
else
{
- LogString className(subst(getAttribute(utf8Decoder, element, CLASS_ATTR)));
+ 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);
- if (rv != APR_SUCCESS) {
- LogString msg2(LOG4CXX_STR("Could not open file ["));
+ 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)
+ {
+ char errbuf[2000];
+ char errbufXML[2000];
+ LogString msg2(LOG4CXX_STR("Error parsing 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(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);
+ 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);
}
+
+ LogLog::error(msg2);
}
+ else
+ {
+ AppenderMap appenders;
+ CharsetDecoderPtr utf8Decoder(CharsetDecoder::getUTF8Decoder());
+ parse(p, utf8Decoder, doc->root, doc, appenders);
+ }
+ }
}
void DOMConfigurator::configure(const std::string& filename)
@@ -795,43 +867,45 @@
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;
- }
- xdog = new XMLWatchdog(file);
- APRInitializer::registerCleanup(xdog);
- xdog->setDelay(delay);
- xdog->start();
+
+ if ( xdog )
+ {
+ APRInitializer::unregisterCleanup(xdog);
+ delete xdog;
+ }
+
+ xdog = new XMLWatchdog(file);
+ APRInitializer::registerCleanup(xdog);
+ xdog->setDelay(delay);
+ xdog->start();
#else
DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
#endif
@@ -840,17 +914,19 @@
#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;
- }
- xdog = new XMLWatchdog(file);
- APRInitializer::registerCleanup(xdog);
- xdog->setDelay(delay);
- xdog->start();
+
+ if ( xdog )
+ {
+ APRInitializer::unregisterCleanup(xdog);
+ delete xdog;
+ }
+
+ xdog = new XMLWatchdog(file);
+ APRInitializer::registerCleanup(xdog);
+ xdog->setDelay(delay);
+ xdog->start();
#else
DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
#endif
@@ -860,17 +936,19 @@
#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;
- }
- xdog = new XMLWatchdog(file);
- APRInitializer::registerCleanup(xdog);
- xdog->setDelay(delay);
- xdog->start();
+
+ if ( xdog )
+ {
+ APRInitializer::unregisterCleanup(xdog);
+ delete xdog;
+ }
+
+ xdog = new XMLWatchdog(file);
+ APRInitializer::registerCleanup(xdog);
+ xdog->setDelay(delay);
+ xdog->start();
#else
DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
#endif
@@ -880,17 +958,19 @@
#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;
- }
- xdog = new XMLWatchdog(file);
- APRInitializer::registerCleanup(xdog);
- xdog->setDelay(delay);
- xdog->start();
+
+ if ( xdog )
+ {
+ APRInitializer::unregisterCleanup(xdog);
+ delete xdog;
+ }
+
+ xdog = new XMLWatchdog(file);
+ APRInitializer::registerCleanup(xdog);
+ xdog->setDelay(delay);
+ xdog->start();
#else
DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
#endif
@@ -898,122 +978,134 @@
#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);
if (rootElementName != CONFIGURATION_TAG)
+ {
+ if (rootElementName == OLD_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;
- }
+ //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));
static const LogString NuLL(LOG4CXX_STR("NULL"));
- LogLog::debug(LOG4CXX_STR("debug attribute= \"") + debugAttrib +LOG4CXX_STR("\"."));
+ 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));
+ if (!debugAttrib.empty() && debugAttrib != NuLL)
+ {
+ LogLog::setInternalDebugging(OptionConverter::toBoolean(debugAttrib, true));
}
- else
- {
- LogLog::debug(LOG4CXX_STR("Ignoring internalDebug attribute."));
+ else
+ {
+ LogLog::debug(LOG4CXX_STR("Ignoring internalDebug attribute."));
}
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("\"."));
- if(!thresholdStr.empty() && thresholdStr != NuLL)
- {
- repository->setThreshold(thresholdStr);
+ LogLog::debug(LOG4CXX_STR("Threshold =\"") + thresholdStr + LOG4CXX_STR("\"."));
+
+ if (!thresholdStr.empty() && thresholdStr != NuLL)
+ {
+ repository->setThreshold(thresholdStr);
}
LogString strstrValue = subst(getAttribute(utf8Decoder, element, STRINGSTREAM_ATTR));
- LogLog::debug(LOG4CXX_STR("Stringstream =\"") + strstrValue +LOG4CXX_STR("\"."));
- if(!strstrValue.empty() && strstrValue != NuLL)
+ LogLog::debug(LOG4CXX_STR("Stringstream =\"") + strstrValue + LOG4CXX_STR("\"."));
+
+ if (!strstrValue.empty() && strstrValue != NuLL)
{
MessageBufferUseStaticStream();
}
apr_xml_elem* currentElement;
- for(currentElement = element->first_child;
- currentElement;
- currentElement = currentElement->next) {
- std::string tagName(currentElement->name);
- if (tagName == CATEGORY_FACTORY_TAG)
- {
- parseLoggerFactory(p, utf8Decoder, currentElement);
- }
+ for (currentElement = element->first_child;
+ currentElement;
+ currentElement = currentElement->next)
+ {
+ std::string tagName(currentElement->name);
+
+ 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);
+ {
+ return OptionConverter::substVars(value, props);
}
- catch(IllegalArgumentException& e)
- {
- LogLog::warn(LOG4CXX_STR("Could not perform variable substitution."), e);
- return value;
+ 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;
- for(apr_xml_attr* attr = element->attr;
- attr;
- attr = attr->next) {
- if (attrName == attr->name) {
+
+ 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;
}
diff --git a/src/main/cpp/exception.cpp b/src/main/cpp/exception.cpp
index 7ac2bfb..f8bdd0f 100644
--- a/src/main/cpp/exception.cpp
+++ b/src/main/cpp/exception.cpp
@@ -26,402 +26,488 @@
using namespace log4cxx;
using namespace log4cxx::helpers;
-Exception::Exception(const LogString& msg1) {
- std::string m;
- Transcoder::encode(msg1, m);
- size_t len = m.size();
- if (len > MSG_SIZE) {
- len = MSG_SIZE;
- }
+Exception::Exception(const LogString& msg1)
+{
+ std::string m;
+ Transcoder::encode(msg1, m);
+ size_t len = m.size();
+
+ if (len > MSG_SIZE)
+ {
+ len = MSG_SIZE;
+ }
+
#if defined(__STDC_LIB_EXT1__) || defined(__STDC_SECURE_LIB__)
- memcpy_s(msg, sizeof msg, m.data(), len);
+ memcpy_s(msg, sizeof msg, m.data(), len);
#else
- memcpy(msg, m.data(), len);
+ memcpy(msg, m.data(), len);
#endif
- msg[len] = 0;
+ msg[len] = 0;
}
-Exception::Exception(const char* m) {
+Exception::Exception(const char* m)
+{
#if defined(__STDC_LIB_EXT1__) || defined(__STDC_SECURE_LIB__)
- strncpy_s(msg, sizeof msg, m, MSG_SIZE);
+ strncpy_s(msg, sizeof msg, m, MSG_SIZE);
#else
- strncpy(msg, m, MSG_SIZE);
+ strncpy(msg, m, MSG_SIZE);
#endif
- msg[MSG_SIZE] = 0;
+ msg[MSG_SIZE] = 0;
}
-Exception::Exception(const Exception& src) : std::exception() {
+Exception::Exception(const Exception& src) : std::exception()
+{
#if defined(__STDC_LIB_EXT1__) || defined(__STDC_SECURE_LIB__)
- strcpy_s(msg, sizeof msg, src.msg);
+ strcpy_s(msg, sizeof msg, src.msg);
#else
- strcpy(msg, src.msg);
+ strcpy(msg, src.msg);
#endif
}
-Exception& Exception::operator=(const Exception& src) {
+Exception& Exception::operator=(const Exception& src)
+{
#if defined(__STDC_LIB_EXT1__) || defined(__STDC_SECURE_LIB__)
- strcpy_s(msg, sizeof msg, src.msg);
+ strcpy_s(msg, sizeof msg, src.msg);
#else
- strcpy(msg, src.msg);
+ strcpy(msg, src.msg);
#endif
- return *this;
+ return *this;
}
-const char* Exception::what() const throw() {
- return msg;
+const char* Exception::what() const throw()
+{
+ return msg;
}
RuntimeException::RuntimeException(log4cxx_status_t stat)
- : Exception(formatMessage(stat)) {
+ : Exception(formatMessage(stat))
+{
}
RuntimeException::RuntimeException(const LogString& msg1)
- : Exception(msg1) {
+ : Exception(msg1)
+{
}
RuntimeException::RuntimeException(const RuntimeException& src)
- : Exception(src) {
+ : Exception(src)
+{
}
-RuntimeException& RuntimeException::operator=(const RuntimeException& src) {
- Exception::operator=(src);
- return *this;
+RuntimeException& RuntimeException::operator=(const RuntimeException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
-LogString RuntimeException::formatMessage(log4cxx_status_t stat) {
- LogString s(LOG4CXX_STR("RuntimeException: return code = "));
- Pool p;
- StringHelper::toString(stat, p, s);
- return s;
+LogString RuntimeException::formatMessage(log4cxx_status_t stat)
+{
+ LogString s(LOG4CXX_STR("RuntimeException: return code = "));
+ Pool p;
+ StringHelper::toString(stat, p, s);
+ return s;
}
NullPointerException::NullPointerException(const LogString& msg1)
- : RuntimeException(msg1) {
+ : RuntimeException(msg1)
+{
}
NullPointerException::NullPointerException(const NullPointerException& src)
- : RuntimeException(src) {
+ : RuntimeException(src)
+{
}
-NullPointerException& NullPointerException::operator=(const NullPointerException& src) {
- RuntimeException::operator=(src);
- return *this;
+NullPointerException& NullPointerException::operator=(const NullPointerException& src)
+{
+ RuntimeException::operator=(src);
+ return *this;
}
IllegalArgumentException::IllegalArgumentException(const LogString& msg1)
- : RuntimeException(msg1) {
+ : RuntimeException(msg1)
+{
}
IllegalArgumentException::IllegalArgumentException(const IllegalArgumentException& src)
- : RuntimeException(src) {
+ : RuntimeException(src)
+{
}
-IllegalArgumentException& IllegalArgumentException::operator=(const IllegalArgumentException& src) {
- RuntimeException::operator=(src);
- return *this;
+IllegalArgumentException& IllegalArgumentException::operator=(const IllegalArgumentException& src)
+{
+ RuntimeException::operator=(src);
+ return *this;
}
IOException::IOException()
- : Exception(LOG4CXX_STR("IO exception")) {
+ : Exception(LOG4CXX_STR("IO exception"))
+{
}
IOException::IOException(log4cxx_status_t stat)
- : Exception(formatMessage(stat)) {
+ : Exception(formatMessage(stat))
+{
}
IOException::IOException(const LogString& msg1)
- : Exception(msg1) {
+ : Exception(msg1)
+{
}
IOException::IOException(const IOException& src)
- : Exception(src) {
+ : Exception(src)
+{
}
-IOException& IOException::operator=(const IOException& src) {
- Exception::operator=(src);
- return *this;
+IOException& IOException::operator=(const IOException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
-LogString IOException::formatMessage(log4cxx_status_t stat) {
- LogString s(LOG4CXX_STR("IO Exception : status code = "));
- Pool p;
- StringHelper::toString(stat, p, s);
- return s;
+LogString IOException::formatMessage(log4cxx_status_t stat)
+{
+ LogString s(LOG4CXX_STR("IO Exception : status code = "));
+ Pool p;
+ StringHelper::toString(stat, p, s);
+ return s;
}
MissingResourceException::MissingResourceException(const LogString& key)
- : Exception(formatMessage(key)) {
+ : Exception(formatMessage(key))
+{
}
MissingResourceException::MissingResourceException(const MissingResourceException& src)
- : Exception(src) {
+ : Exception(src)
+{
}
-MissingResourceException& MissingResourceException::operator=(const MissingResourceException& src) {
- Exception::operator=(src);
- return *this;
+MissingResourceException& MissingResourceException::operator=(const MissingResourceException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
-LogString MissingResourceException::formatMessage(const LogString& key) {
- LogString s(LOG4CXX_STR("MissingResourceException: resource key = \""));
- s.append(key);
- s.append(LOG4CXX_STR("\"."));
- return s;
+LogString MissingResourceException::formatMessage(const LogString& key)
+{
+ LogString s(LOG4CXX_STR("MissingResourceException: resource key = \""));
+ s.append(key);
+ s.append(LOG4CXX_STR("\"."));
+ return s;
}
PoolException::PoolException(log4cxx_status_t stat)
- : Exception(formatMessage(stat)) {
+ : Exception(formatMessage(stat))
+{
}
-PoolException::PoolException(const PoolException &src)
- : Exception(src) {
+PoolException::PoolException(const PoolException& src)
+ : Exception(src)
+{
}
-PoolException& PoolException::operator=(const PoolException& src) {
- Exception::operator=(src);
- return *this;
+PoolException& PoolException::operator=(const PoolException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
-LogString PoolException::formatMessage(log4cxx_status_t) {
- return LOG4CXX_STR("Pool exception");
+LogString PoolException::formatMessage(log4cxx_status_t)
+{
+ return LOG4CXX_STR("Pool exception");
}
TranscoderException::TranscoderException(log4cxx_status_t stat)
- : Exception(formatMessage(stat)) {
+ : Exception(formatMessage(stat))
+{
}
-TranscoderException::TranscoderException(const TranscoderException &src)
- : Exception(src) {
+TranscoderException::TranscoderException(const TranscoderException& src)
+ : Exception(src)
+{
}
-TranscoderException& TranscoderException::operator=(const TranscoderException& src) {
- Exception::operator=(src);
- return *this;
+TranscoderException& TranscoderException::operator=(const TranscoderException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
-LogString TranscoderException::formatMessage(log4cxx_status_t) {
- return LOG4CXX_STR("Transcoder exception");
+LogString TranscoderException::formatMessage(log4cxx_status_t)
+{
+ return LOG4CXX_STR("Transcoder exception");
}
MutexException::MutexException(log4cxx_status_t stat)
- : Exception(formatMessage(stat)) {
+ : Exception(formatMessage(stat))
+{
}
-MutexException::MutexException(const MutexException &src)
- : Exception(src) {
+MutexException::MutexException(const MutexException& src)
+ : Exception(src)
+{
}
-MutexException& MutexException::operator=(const MutexException& src) {
- Exception::operator=(src);
- return *this;
+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;
+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")) {
+InterruptedException::InterruptedException() : Exception(LOG4CXX_STR("Thread was interrupted"))
+{
}
InterruptedException::InterruptedException(log4cxx_status_t stat)
- : Exception(formatMessage(stat)) {
+ : Exception(formatMessage(stat))
+{
}
-InterruptedException::InterruptedException(const InterruptedException &src)
- : Exception(src) {
+InterruptedException::InterruptedException(const InterruptedException& src)
+ : Exception(src)
+{
}
-InterruptedException& InterruptedException::operator=(const InterruptedException& src) {
- Exception::operator=(src);
- return *this;
+InterruptedException& InterruptedException::operator=(const InterruptedException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
-LogString InterruptedException::formatMessage(log4cxx_status_t stat) {
- LogString s(LOG4CXX_STR("InterruptedException: stat = "));
- Pool p;
- StringHelper::toString(stat, p, s);
- return s;
+LogString InterruptedException::formatMessage(log4cxx_status_t stat)
+{
+ LogString s(LOG4CXX_STR("InterruptedException: stat = "));
+ Pool p;
+ StringHelper::toString(stat, p, s);
+ return s;
}
ThreadException::ThreadException(log4cxx_status_t stat)
- : Exception(formatMessage(stat)) {
+ : Exception(formatMessage(stat))
+{
}
ThreadException::ThreadException(const LogString& msg)
- : Exception(msg) {
+ : Exception(msg)
+{
}
-ThreadException::ThreadException(const ThreadException &src)
- : Exception(src) {
+ThreadException::ThreadException(const ThreadException& src)
+ : Exception(src)
+{
}
-ThreadException& ThreadException::operator=(const ThreadException& src) {
- Exception::operator=(src);
- return *this;
+ThreadException& ThreadException::operator=(const ThreadException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
-LogString ThreadException::formatMessage(log4cxx_status_t stat) {
- LogString s(LOG4CXX_STR("Thread exception: stat = "));
- Pool p;
- StringHelper::toString(stat, p, s);
- return s;
+LogString ThreadException::formatMessage(log4cxx_status_t stat)
+{
+ LogString s(LOG4CXX_STR("Thread exception: stat = "));
+ Pool p;
+ StringHelper::toString(stat, p, s);
+ return s;
}
IllegalMonitorStateException::IllegalMonitorStateException(const LogString& msg1)
- : Exception(msg1) {
+ : Exception(msg1)
+{
}
IllegalMonitorStateException::IllegalMonitorStateException(const IllegalMonitorStateException& src)
- : Exception(src) {
+ : Exception(src)
+{
}
-IllegalMonitorStateException& IllegalMonitorStateException::operator=(const IllegalMonitorStateException& src) {
- Exception::operator=(src);
- return *this;
+IllegalMonitorStateException& IllegalMonitorStateException::operator=(const IllegalMonitorStateException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
InstantiationException::InstantiationException(const LogString& msg1)
- : Exception(msg1) {
+ : Exception(msg1)
+{
}
InstantiationException::InstantiationException(const InstantiationException& src)
- : Exception(src) {
+ : Exception(src)
+{
}
-InstantiationException& InstantiationException::operator=(const InstantiationException& src) {
- Exception::operator=(src);
- return *this;
+InstantiationException& InstantiationException::operator=(const InstantiationException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
ClassNotFoundException::ClassNotFoundException(const LogString& className)
- : Exception(formatMessage(className)) {
+ : Exception(formatMessage(className))
+{
}
ClassNotFoundException::ClassNotFoundException(const ClassNotFoundException& src)
- : Exception(src) {
+ : Exception(src)
+{
}
-ClassNotFoundException& ClassNotFoundException::operator=(const ClassNotFoundException& src) {
- Exception::operator=(src);
- return *this;
+ClassNotFoundException& ClassNotFoundException::operator=(const ClassNotFoundException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
-LogString ClassNotFoundException::formatMessage(const LogString& className) {
- LogString s(LOG4CXX_STR("Class not found: "));
- s.append(className);
- return s;
+LogString ClassNotFoundException::formatMessage(const LogString& className)
+{
+ LogString s(LOG4CXX_STR("Class not found: "));
+ s.append(className);
+ return s;
}
NoSuchElementException::NoSuchElementException()
- : Exception(LOG4CXX_STR("No such element")) {
+ : Exception(LOG4CXX_STR("No such element"))
+{
}
NoSuchElementException::NoSuchElementException(const NoSuchElementException& src)
- : Exception(src) {
+ : Exception(src)
+{
}
-NoSuchElementException& NoSuchElementException::operator=(const NoSuchElementException& src) {
- Exception::operator=(src);
- return *this;
+NoSuchElementException& NoSuchElementException::operator=(const NoSuchElementException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
IllegalStateException::IllegalStateException()
- : Exception(LOG4CXX_STR("Illegal state")) {
+ : Exception(LOG4CXX_STR("Illegal state"))
+{
}
IllegalStateException::IllegalStateException(const IllegalStateException& src)
- : Exception(src) {
+ : Exception(src)
+{
}
-IllegalStateException& IllegalStateException::operator=(const IllegalStateException& src) {
- Exception::operator=(src);
- return *this;
+IllegalStateException& IllegalStateException::operator=(const IllegalStateException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
-SocketException::SocketException(const LogString& msg) : IOException(msg) {
+SocketException::SocketException(const LogString& msg) : IOException(msg)
+{
}
-SocketException::SocketException(log4cxx_status_t status) : IOException(status) {
+SocketException::SocketException(log4cxx_status_t status) : IOException(status)
+{
}
SocketException::SocketException(const SocketException& src)
- : IOException(src) {
+ : IOException(src)
+{
}
-SocketException& SocketException::operator=(const SocketException& src) {
- IOException::operator=(src);
- return *this;
+SocketException& SocketException::operator=(const SocketException& src)
+{
+ IOException::operator=(src);
+ return *this;
}
-ConnectException::ConnectException(log4cxx_status_t status) : SocketException(status) {
+ConnectException::ConnectException(log4cxx_status_t status) : SocketException(status)
+{
}
ConnectException::ConnectException(const ConnectException& src)
- : SocketException(src) {
+ : SocketException(src)
+{
}
-ConnectException& ConnectException::operator=(const ConnectException& src) {
- SocketException::operator=(src);
- return *this;
+ConnectException& ConnectException::operator=(const ConnectException& src)
+{
+ SocketException::operator=(src);
+ return *this;
}
-ClosedChannelException::ClosedChannelException() : SocketException(LOG4CXX_STR("Attempt to write to closed socket")) {
+ClosedChannelException::ClosedChannelException() : SocketException(LOG4CXX_STR("Attempt to write to closed socket"))
+{
}
ClosedChannelException::ClosedChannelException(const ClosedChannelException& src)
- : SocketException(src) {
+ : SocketException(src)
+{
}
-ClosedChannelException& ClosedChannelException::operator=(const ClosedChannelException& src) {
- SocketException::operator=(src);
- return *this;
+ClosedChannelException& ClosedChannelException::operator=(const ClosedChannelException& src)
+{
+ SocketException::operator=(src);
+ return *this;
}
-BindException::BindException(log4cxx_status_t status) : SocketException(status) {
+BindException::BindException(log4cxx_status_t status) : SocketException(status)
+{
}
BindException::BindException(const BindException& src)
- : SocketException(src) {
+ : SocketException(src)
+{
}
-BindException& BindException::operator=(const BindException& src) {
- SocketException::operator=(src);
- return *this;
+BindException& BindException::operator=(const BindException& src)
+{
+ SocketException::operator=(src);
+ return *this;
}
-InterruptedIOException::InterruptedIOException(const LogString& msg) : IOException(msg) {
+InterruptedIOException::InterruptedIOException(const LogString& msg) : IOException(msg)
+{
}
InterruptedIOException::InterruptedIOException(const InterruptedIOException& src)
- : IOException(src) {
+ : IOException(src)
+{
}
-InterruptedIOException& InterruptedIOException::operator=(const InterruptedIOException& src) {
- IOException::operator=(src);
- return *this;
+InterruptedIOException& InterruptedIOException::operator=(const InterruptedIOException& src)
+{
+ IOException::operator=(src);
+ return *this;
}
SocketTimeoutException::SocketTimeoutException()
- : InterruptedIOException(LOG4CXX_STR("SocketTimeoutException")) {
+ : InterruptedIOException(LOG4CXX_STR("SocketTimeoutException"))
+{
}
SocketTimeoutException::SocketTimeoutException(const SocketTimeoutException& src)
- : InterruptedIOException(src) {
+ : InterruptedIOException(src)
+{
}
-SocketTimeoutException& SocketTimeoutException::operator=(const SocketTimeoutException& src) {
- InterruptedIOException::operator=(src);
- return *this;
+SocketTimeoutException& SocketTimeoutException::operator=(const SocketTimeoutException& src)
+{
+ InterruptedIOException::operator=(src);
+ return *this;
}
diff --git a/src/main/cpp/fallbackerrorhandler.cpp b/src/main/cpp/fallbackerrorhandler.cpp
index 972621d..36509cc 100644
--- a/src/main/cpp/fallbackerrorhandler.cpp
+++ b/src/main/cpp/fallbackerrorhandler.cpp
@@ -35,65 +35,68 @@
{
}
-void FallbackErrorHandler::addRef() const {
- ObjectImpl::addRef();
+void FallbackErrorHandler::addRef() const
+{
+ ObjectImpl::addRef();
}
-void FallbackErrorHandler::releaseRef() const {
- ObjectImpl::releaseRef();
+void FallbackErrorHandler::releaseRef() const
+{
+ ObjectImpl::releaseRef();
}
void FallbackErrorHandler::setLogger(const LoggerPtr& logger)
{
- LogLog::debug(((LogString) LOG4CXX_STR("FB: Adding logger ["))
- + logger->getName() + LOG4CXX_STR("]."));
- loggers.push_back(logger);
+ LogLog::debug(((LogString) LOG4CXX_STR("FB: Adding logger ["))
+ + logger->getName() + LOG4CXX_STR("]."));
+ loggers.push_back(logger);
}
void FallbackErrorHandler::error(const LogString& message,
- const std::exception& e,
- int errorCode) const
+ const std::exception& e,
+ int errorCode) const
{
- error(message, e, errorCode, 0);
+ error(message, e, errorCode, 0);
}
void FallbackErrorHandler::error(const LogString& message,
- const std::exception& e,
- int, const spi::LoggingEventPtr&) const
+ const std::exception& e,
+ int, const spi::LoggingEventPtr&) const
{
- LogLog::debug(((LogString) LOG4CXX_STR("FB: The following error reported: "))
- + message, e);
- LogLog::debug(LOG4CXX_STR("FB: INITIATING FALLBACK PROCEDURE."));
- for(size_t i = 0; i < loggers.size(); i++)
- {
- LoggerPtr& l = (LoggerPtr&)loggers.at(i);
- LogLog::debug(((LogString) LOG4CXX_STR("FB: Searching for ["))
- + primary->getName() + LOG4CXX_STR("] in logger [")
- + l->getName() + LOG4CXX_STR("]."));
- LogLog::debug(((LogString) LOG4CXX_STR("FB: Replacing ["))
- + primary->getName() + LOG4CXX_STR("] by [")
- + backup->getName() + LOG4CXX_STR("] in logger [")
- + l->getName() + LOG4CXX_STR("]."));
- l->removeAppender(primary);
- LogLog::debug(((LogString) LOG4CXX_STR("FB: Adding appender ["))
- + backup->getName() + LOG4CXX_STR("] to logger ")
- + l->getName());
- l->addAppender(backup);
- }
+ LogLog::debug(((LogString) LOG4CXX_STR("FB: The following error reported: "))
+ + message, e);
+ LogLog::debug(LOG4CXX_STR("FB: INITIATING FALLBACK PROCEDURE."));
+
+ for (size_t i = 0; i < loggers.size(); i++)
+ {
+ LoggerPtr& l = (LoggerPtr&)loggers.at(i);
+ LogLog::debug(((LogString) LOG4CXX_STR("FB: Searching for ["))
+ + primary->getName() + LOG4CXX_STR("] in logger [")
+ + l->getName() + LOG4CXX_STR("]."));
+ LogLog::debug(((LogString) LOG4CXX_STR("FB: Replacing ["))
+ + primary->getName() + LOG4CXX_STR("] by [")
+ + backup->getName() + LOG4CXX_STR("] in logger [")
+ + l->getName() + LOG4CXX_STR("]."));
+ l->removeAppender(primary);
+ LogLog::debug(((LogString) LOG4CXX_STR("FB: Adding appender ["))
+ + backup->getName() + LOG4CXX_STR("] to logger ")
+ + l->getName());
+ l->addAppender(backup);
+ }
}
void FallbackErrorHandler::setAppender(const AppenderPtr& primary1)
{
- LogLog::debug(((LogString) LOG4CXX_STR("FB: Setting primary appender to ["))
- + primary1->getName() + LOG4CXX_STR("]."));
- this->primary = primary1;
+ LogLog::debug(((LogString) LOG4CXX_STR("FB: Setting primary appender to ["))
+ + primary1->getName() + LOG4CXX_STR("]."));
+ this->primary = primary1;
}
void FallbackErrorHandler::setBackupAppender(const AppenderPtr& backup1)
{
- LogLog::debug(((LogString) LOG4CXX_STR("FB: Setting backup appender to ["))
- + backup1->getName() + LOG4CXX_STR("]."));
- this->backup = backup1;
+ LogLog::debug(((LogString) LOG4CXX_STR("FB: Setting backup appender to ["))
+ + backup1->getName() + LOG4CXX_STR("]."));
+ this->backup = backup1;
}
void FallbackErrorHandler::activateOptions(Pool&)
diff --git a/src/main/cpp/file.cpp b/src/main/cpp/file.cpp
index 3e9d087..bddea7e 100644
--- a/src/main/cpp/file.cpp
+++ b/src/main/cpp/file.cpp
@@ -27,20 +27,26 @@
using namespace log4cxx;
using namespace log4cxx::helpers;
-File::File() {
+File::File()
+{
}
template<class S>
-static LogString decodeLS(const S* src) {
+static LogString decodeLS(const S* src)
+{
LogString dst;
- if (src != 0) {
- Transcoder::decode(src, dst);
+
+ if (src != 0)
+ {
+ Transcoder::decode(src, dst);
}
+
return dst;
}
template<class S>
-static LogString decodeLS(const std::basic_string<S>& src) {
+static LogString decodeLS(const std::basic_string<S>& src)
+{
LogString dst;
Transcoder::decode(src, dst);
return dst;
@@ -48,193 +54,259 @@
File::File(const std::string& name1)
- : path(decodeLS(name1)) {
+ : path(decodeLS(name1))
+{
}
File::File(const char* name1)
- : path(decodeLS(name1)) {
+ : path(decodeLS(name1))
+{
}
#if LOG4CXX_WCHAR_T_API
File::File(const std::wstring& name1)
- : path(decodeLS(name1)) {
+ : path(decodeLS(name1))
+{
}
File::File(const wchar_t* name1)
- : path(decodeLS(name1)) {
+ : path(decodeLS(name1))
+{
}
#endif
#if LOG4CXX_UNICHAR_API
File::File(const std::basic_string<UniChar>& name1)
- : path(decodeLS(name1)) {
+ : path(decodeLS(name1))
+{
}
File::File(const UniChar* name1)
- : path(decodeLS(name1)) {
+ : path(decodeLS(name1))
+{
}
#endif
#if LOG4CXX_CFSTRING_API
File::File(const CFStringRef& name1)
- : path(decodeLS(name1)) {
+ : path(decodeLS(name1))
+{
}
#endif
File::File(const File& src)
- : path(src.path) {
+ : path(src.path)
+{
}
-File& File::operator=(const File& src) {
- if (this == &src) return *this;
+File& File::operator=(const File& src)
+{
+ if (this == &src)
+ {
+ return *this;
+ }
- path.assign(src.path);
+ path.assign(src.path);
- return *this;
+ return *this;
}
-File::~File() {
+File::~File()
+{
}
-LogString File::getPath() const {
+LogString File::getPath() const
+{
return path;
}
-File& File::setPath(const LogString& newName) {
+File& File::setPath(const LogString& newName)
+{
path.assign(newName);
return *this;
}
-LogString File::getName() const {
+LogString File::getName() const
+{
const logchar slashes[] = { 0x2F, 0x5C, 0 };
size_t lastSlash = path.find_last_of(slashes);
- if (lastSlash != LogString::npos) {
- return path.substr(lastSlash+1);
+
+ if (lastSlash != LogString::npos)
+ {
+ return path.substr(lastSlash + 1);
}
+
return path;
}
-char* File::getPath(Pool& p) const {
+char* File::getPath(Pool& p) const
+{
int style = APR_FILEPATH_ENCODING_UNKNOWN;
apr_filepath_encoding(&style, p.getAPRPool());
char* retval = NULL;
- if (style == APR_FILEPATH_ENCODING_UTF8) {
+
+ if (style == APR_FILEPATH_ENCODING_UTF8)
+ {
retval = Transcoder::encodeUTF8(path, p);
- } else {
+ }
+ else
+ {
retval = Transcoder::encode(path, p);
}
+
return retval;
}
log4cxx_status_t File::open(apr_file_t** file, int flags,
- int perm, Pool& p) const {
+ int perm, Pool& p) const
+{
return apr_file_open(file, getPath(p), flags, perm, p.getAPRPool());
}
-bool File::exists(Pool& p) const {
- apr_finfo_t finfo;
- apr_status_t rv = apr_stat(&finfo, getPath(p),
- 0, p.getAPRPool());
- return rv == APR_SUCCESS;
+bool File::exists(Pool& p) const
+{
+ apr_finfo_t finfo;
+ apr_status_t rv = apr_stat(&finfo, getPath(p),
+ 0, p.getAPRPool());
+ return rv == APR_SUCCESS;
}
-char* File::convertBackSlashes(char* src) {
- for(char* c = src; *c != 0; c++) {
- if(*c == '\\') {
- *c = '/';
- }
- }
- return src;
+char* File::convertBackSlashes(char* src)
+{
+ for (char* c = src; *c != 0; c++)
+ {
+ if (*c == '\\')
+ {
+ *c = '/';
+ }
+ }
+
+ return src;
}
-bool File::deleteFile(Pool& p) const {
- apr_status_t rv = apr_file_remove(convertBackSlashes(getPath(p)),
- p.getAPRPool());
- return rv == APR_SUCCESS;
+bool File::deleteFile(Pool& p) const
+{
+ apr_status_t rv = apr_file_remove(convertBackSlashes(getPath(p)),
+ p.getAPRPool());
+ return rv == APR_SUCCESS;
}
-bool File::renameTo(const File& dest, Pool& p) const {
- apr_status_t rv = apr_file_rename(convertBackSlashes(getPath(p)),
- convertBackSlashes(dest.getPath(p)),
- p.getAPRPool());
- return rv == APR_SUCCESS;
+bool File::renameTo(const File& dest, Pool& p) const
+{
+ apr_status_t rv = apr_file_rename(convertBackSlashes(getPath(p)),
+ convertBackSlashes(dest.getPath(p)),
+ p.getAPRPool());
+ return rv == APR_SUCCESS;
}
-size_t File::length(Pool& pool) const {
- apr_finfo_t finfo;
- apr_status_t rv = apr_stat(&finfo, getPath(pool),
- APR_FINFO_SIZE, pool.getAPRPool());
- if (rv == APR_SUCCESS) {
- return (size_t) finfo.size;
- }
- return 0;
+size_t File::length(Pool& pool) const
+{
+ apr_finfo_t finfo;
+ apr_status_t rv = apr_stat(&finfo, getPath(pool),
+ APR_FINFO_SIZE, pool.getAPRPool());
+
+ if (rv == APR_SUCCESS)
+ {
+ return (size_t) finfo.size;
+ }
+
+ return 0;
}
-log4cxx_time_t File::lastModified(Pool& pool) const {
- apr_finfo_t finfo;
- apr_status_t rv = apr_stat(&finfo, getPath(pool),
- APR_FINFO_MTIME, pool.getAPRPool());
- if (rv == APR_SUCCESS) {
- return finfo.mtime;
- }
- return 0;
+log4cxx_time_t File::lastModified(Pool& pool) const
+{
+ apr_finfo_t finfo;
+ apr_status_t rv = apr_stat(&finfo, getPath(pool),
+ APR_FINFO_MTIME, pool.getAPRPool());
+
+ if (rv == APR_SUCCESS)
+ {
+ return finfo.mtime;
+ }
+
+ return 0;
}
-std::vector<LogString> File::list(Pool& p) const {
- apr_dir_t *dir;
+std::vector<LogString> File::list(Pool& p) const
+{
+ apr_dir_t* dir;
apr_finfo_t entry;
std::vector<LogString> filenames;
apr_status_t stat = apr_dir_open(&dir,
- convertBackSlashes(getPath(p)),
- p.getAPRPool());
- if(stat == APR_SUCCESS) {
+ convertBackSlashes(getPath(p)),
+ p.getAPRPool());
+
+ if (stat == APR_SUCCESS)
+ {
int style = APR_FILEPATH_ENCODING_UNKNOWN;
apr_filepath_encoding(&style, p.getAPRPool());
stat = apr_dir_read(&entry, APR_FINFO_DIRENT, dir);
- while(stat == APR_SUCCESS) {
- if (entry.name != NULL) {
- LogString filename;
- if(style == APR_FILEPATH_ENCODING_UTF8) {
- Transcoder::decodeUTF8(entry.name, filename);
- } else {
- Transcoder::decode(entry.name, filename);
- }
- filenames.push_back(filename);
+
+ while (stat == APR_SUCCESS)
+ {
+ if (entry.name != NULL)
+ {
+ LogString filename;
+
+ if (style == APR_FILEPATH_ENCODING_UTF8)
+ {
+ Transcoder::decodeUTF8(entry.name, filename);
+ }
+ else
+ {
+ Transcoder::decode(entry.name, filename);
+ }
+
+ filenames.push_back(filename);
}
+
stat = apr_dir_read(&entry, APR_FINFO_DIRENT, dir);
}
+
stat = apr_dir_close(dir);
}
+
return filenames;
}
-LogString File::getParent(Pool&) const {
- LogString::size_type slashPos = path.rfind(LOG4CXX_STR('/'));
- LogString::size_type backPos = path.rfind(LOG4CXX_STR('\\'));
- if (slashPos == LogString::npos) {
- slashPos = backPos;
- } else {
- if (backPos != LogString::npos && backPos > slashPos) {
- slashPos = backPos;
- }
- }
- LogString parent;
- if (slashPos != LogString::npos && slashPos > 0) {
- parent.assign(path, 0, slashPos);
- }
- return parent;
+LogString File::getParent(Pool&) const
+{
+ LogString::size_type slashPos = path.rfind(LOG4CXX_STR('/'));
+ LogString::size_type backPos = path.rfind(LOG4CXX_STR('\\'));
+
+ if (slashPos == LogString::npos)
+ {
+ slashPos = backPos;
+ }
+ else
+ {
+ if (backPos != LogString::npos && backPos > slashPos)
+ {
+ slashPos = backPos;
+ }
+ }
+
+ LogString parent;
+
+ if (slashPos != LogString::npos && slashPos > 0)
+ {
+ parent.assign(path, 0, slashPos);
+ }
+
+ return parent;
}
-bool File::mkdirs(Pool& p) const {
- apr_status_t stat = apr_dir_make_recursive(convertBackSlashes(getPath(p)),
- APR_OS_DEFAULT, p.getAPRPool());
- return stat == APR_SUCCESS;
+bool File::mkdirs(Pool& p) const
+{
+ apr_status_t stat = apr_dir_make_recursive(convertBackSlashes(getPath(p)),
+ APR_OS_DEFAULT, p.getAPRPool());
+ return stat == APR_SUCCESS;
}
diff --git a/src/main/cpp/fileappender.cpp b/src/main/cpp/fileappender.cpp
index 70d42bd..79af437 100644
--- a/src/main/cpp/fileappender.cpp
+++ b/src/main/cpp/fileappender.cpp
@@ -35,7 +35,8 @@
IMPLEMENT_LOG4CXX_OBJECT(FileAppender)
-FileAppender::FileAppender() {
+FileAppender::FileAppender()
+{
LOCK_W sync(mutex);
fileAppend = true;
bufferedIO = false;
@@ -43,44 +44,47 @@
}
FileAppender::FileAppender(const LayoutPtr& layout1, const LogString& fileName1,
- bool append1, bool bufferedIO1, int bufferSize1)
- : WriterAppender(layout1) {
- {
- LOCK_W sync(mutex);
- fileAppend = append1;
- fileName = fileName1;
- bufferedIO = bufferedIO1;
- bufferSize = bufferSize1;
- }
- Pool p;
- activateOptions(p);
+ bool append1, bool bufferedIO1, int bufferSize1)
+ : WriterAppender(layout1)
+{
+ {
+ LOCK_W sync(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) {
- {
- LOCK_W sync(mutex);
- fileAppend = append1;
- fileName = fileName1;
- bufferedIO = false;
- bufferSize = 8 * 1024;
- }
- Pool p;
- activateOptions(p);
+ bool append1)
+ : WriterAppender(layout1)
+{
+ {
+ LOCK_W sync(mutex);
+ fileAppend = append1;
+ fileName = fileName1;
+ bufferedIO = false;
+ bufferSize = 8 * 1024;
+ }
+ Pool p;
+ activateOptions(p);
}
FileAppender::FileAppender(const LayoutPtr& layout1, const LogString& fileName1)
-: WriterAppender(layout1) {
- {
- LOCK_W sync(mutex);
- fileAppend = true;
- fileName = fileName1;
- bufferedIO = false;
- bufferSize = 8 * 1024;
- }
- Pool p;
- activateOptions(p);
+ : WriterAppender(layout1)
+{
+ {
+ LOCK_W sync(mutex);
+ fileAppend = true;
+ fileName = fileName1;
+ bufferedIO = false;
+ bufferSize = 8 * 1024;
+ }
+ Pool p;
+ activateOptions(p);
}
FileAppender::~FileAppender()
@@ -88,89 +92,100 @@
finalize();
}
-void FileAppender::setAppend(bool fileAppend1) {
+void FileAppender::setAppend(bool fileAppend1)
+{
LOCK_W sync(mutex);
this->fileAppend = fileAppend1;
}
void FileAppender::setFile(const LogString& file)
{
- LOCK_W sync(mutex);
- fileName = file;
+ LOCK_W sync(mutex);
+ fileName = file;
}
void FileAppender::setBufferedIO(bool bufferedIO1)
{
- LOCK_W sync(mutex);
- this->bufferedIO = bufferedIO1;
- if(bufferedIO1)
- {
- setImmediateFlush(false);
- }
+ LOCK_W sync(mutex);
+ this->bufferedIO = bufferedIO1;
+
+ 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")))
+ {
+ 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);
+ }
}
void FileAppender::activateOptions(Pool& p)
{
- LOCK_W sync(mutex);
- int errors = 0;
- 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);
+ LOCK_W sync(mutex);
+ int errors = 0;
+
+ 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?"));
- }
- if(errors == 0) {
- WriterAppender::activateOptions(p);
- }
+ 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);
+ }
}
@@ -185,32 +200,46 @@
*
*
*/
-LogString FileAppender::stripDuplicateBackslashes(const LogString& src) {
+LogString FileAppender::stripDuplicateBackslashes(const LogString& src)
+{
logchar backslash = 0x5C; // '\\'
LogString::size_type i = src.find_last_of(backslash);
- if (i != LogString::npos) {
+
+ if (i != LogString::npos)
+ {
LogString tmp(src);
- for(;
- i != LogString::npos && i > 0;
- i = tmp.find_last_of(backslash, i - 1)) {
+
+ 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) {
+ if (tmp[i - 1] == backslash)
+ {
tmp.erase(i, 1);
i--;
- if (i == 0) break;
- } else {
+
+ 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;
}
@@ -235,75 +264,97 @@
*/
void FileAppender::setFile(
- const LogString& filename,
- bool append1,
- bool bufferedIO1,
- size_t bufferSize1,
- Pool& p) {
- LOCK_W sync(mutex);
+ 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();
+ 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;
- }
- }
+ bool writeBOM = false;
- OutputStreamPtr outStream;
- try {
- outStream = new FileOutputStream(filename, append1);
- } catch(IOException& ex) {
- 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 (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& ex)
+ {
+ 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);
- }
+ //
+ // 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));
+ WriterPtr newWriter(createWriter(outStream));
- if (bufferedIO1) {
- newWriter = new BufferedWriter(newWriter, bufferSize1);
- }
- setWriter(newWriter);
+ if (bufferedIO1)
+ {
+ newWriter = new BufferedWriter(newWriter, bufferSize1);
+ }
- this->fileAppend = append1;
- this->bufferedIO = bufferedIO1;
- this->fileName = filename;
- this->bufferSize = bufferSize1;
- writeHeader(p);
+ setWriter(newWriter);
+
+ this->fileAppend = append1;
+ this->bufferedIO = bufferedIO1;
+ this->fileName = filename;
+ this->bufferSize = bufferSize1;
+ writeHeader(p);
}
diff --git a/src/main/cpp/filedatepatternconverter.cpp b/src/main/cpp/filedatepatternconverter.cpp
index 950fa70..0433454 100644
--- a/src/main/cpp/filedatepatternconverter.cpp
+++ b/src/main/cpp/filedatepatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -28,12 +28,15 @@
using namespace log4cxx::helpers;
PatternConverterPtr FileDatePatternConverter::newInstance(
- const std::vector<LogString>& options) {
- if (options.size() == 0) {
- std::vector<LogString> altOptions;
- altOptions.push_back(LOG4CXX_STR("yyyy-MM-dd"));
- return DatePatternConverter::newInstance(altOptions);
- }
- return DatePatternConverter::newInstance(options);
+ const std::vector<LogString>& options)
+{
+ if (options.size() == 0)
+ {
+ std::vector<LogString> altOptions;
+ altOptions.push_back(LOG4CXX_STR("yyyy-MM-dd"));
+ return DatePatternConverter::newInstance(altOptions);
+ }
+
+ return DatePatternConverter::newInstance(options);
}
diff --git a/src/main/cpp/fileinputstream.cpp b/src/main/cpp/fileinputstream.cpp
index 6061d63..f3231df 100644
--- a/src/main/cpp/fileinputstream.cpp
+++ b/src/main/cpp/fileinputstream.cpp
@@ -22,7 +22,7 @@
#include <apr_file_io.h>
#include <log4cxx/helpers/transcoder.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/helpers/aprinitializer.h>
@@ -31,64 +31,84 @@
IMPLEMENT_LOG4CXX_OBJECT(FileInputStream)
-FileInputStream::FileInputStream(const LogString& filename) : fileptr(0) {
+FileInputStream::FileInputStream(const LogString& filename) : fileptr(0)
+{
open(filename);
}
-FileInputStream::FileInputStream(const logchar* filename) : fileptr(0) {
+FileInputStream::FileInputStream(const logchar* filename) : fileptr(0)
+{
LogString fn(filename);
open(fn);
}
-void FileInputStream::open(const LogString& filename) {
+void FileInputStream::open(const LogString& filename)
+{
apr_fileperms_t perm = APR_OS_DEFAULT;
apr_int32_t flags = APR_READ;
apr_status_t stat = File().setPath(filename).open(&fileptr, flags, perm, pool);
- if (stat != APR_SUCCESS) {
- throw IOException(stat);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
}
}
-FileInputStream::FileInputStream(const File& aFile) {
+FileInputStream::FileInputStream(const File& aFile)
+{
apr_fileperms_t perm = APR_OS_DEFAULT;
apr_int32_t flags = APR_READ;
apr_status_t stat = aFile.open(&fileptr, flags, perm, pool);
- if (stat != APR_SUCCESS) {
- throw IOException(stat);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
}
}
-FileInputStream::~FileInputStream() {
- if (fileptr != NULL && !APRInitializer::isDestructed) {
- apr_file_close(fileptr);
- }
-}
-
-
-void FileInputStream::close() {
- apr_status_t stat = apr_file_close(fileptr);
- if (stat == APR_SUCCESS) {
- fileptr = NULL;
- } else {
- throw IOException(stat);
- }
-}
-
-
-int FileInputStream::read(ByteBuffer& buf) {
- apr_size_t bytesRead = buf.remaining();
- apr_status_t stat = apr_file_read(fileptr, buf.current(), &bytesRead);
- int retval = -1;
- if (!APR_STATUS_IS_EOF(stat)) {
- if (stat != APR_SUCCESS) {
- throw IOException(stat);
+FileInputStream::~FileInputStream()
+{
+ if (fileptr != NULL && !APRInitializer::isDestructed)
+ {
+ apr_file_close(fileptr);
}
- buf.position(buf.position() + bytesRead);
- retval = bytesRead;
- }
+}
- return retval;
+
+void FileInputStream::close()
+{
+ apr_status_t stat = apr_file_close(fileptr);
+
+ if (stat == APR_SUCCESS)
+ {
+ fileptr = NULL;
+ }
+ else
+ {
+ throw IOException(stat);
+ }
+}
+
+
+int FileInputStream::read(ByteBuffer& buf)
+{
+ apr_size_t bytesRead = buf.remaining();
+ apr_status_t stat = apr_file_read(fileptr, buf.current(), &bytesRead);
+ int retval = -1;
+
+ if (!APR_STATUS_IS_EOF(stat))
+ {
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
+
+ buf.position(buf.position() + bytesRead);
+ retval = bytesRead;
+ }
+
+ return retval;
}
diff --git a/src/main/cpp/filelocationpatternconverter.cpp b/src/main/cpp/filelocationpatternconverter.cpp
index 950659a..fdd81e9 100644
--- a/src/main/cpp/filelocationpatternconverter.cpp
+++ b/src/main/cpp/filelocationpatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -24,27 +24,30 @@
#include <log4cxx/spi/loggingevent.h>
#include <log4cxx/spi/location/locationinfo.h>
- using namespace log4cxx;
- using namespace log4cxx::pattern;
- using namespace log4cxx::spi;
- using namespace helpers;
+using namespace log4cxx;
+using namespace log4cxx::pattern;
+using namespace log4cxx::spi;
+using namespace helpers;
IMPLEMENT_LOG4CXX_OBJECT(FileLocationPatternConverter)
FileLocationPatternConverter::FileLocationPatternConverter() :
LoggingEventPatternConverter(LOG4CXX_STR("File Location"),
- LOG4CXX_STR("file")) {
+ LOG4CXX_STR("file"))
+{
}
PatternConverterPtr FileLocationPatternConverter::newInstance(
- const std::vector<LogString>& /* options */ ) {
+ const std::vector<LogString>& /* options */ )
+{
static PatternConverterPtr instance(new FileLocationPatternConverter());
return instance;
}
void FileLocationPatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- Pool& /* p */ ) const {
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ Pool& /* p */ ) const
+{
append(toAppendTo, event->getLocationInformation().getFileName());
}
diff --git a/src/main/cpp/fileoutputstream.cpp b/src/main/cpp/fileoutputstream.cpp
index 18a9df0..b4cc809 100644
--- a/src/main/cpp/fileoutputstream.cpp
+++ b/src/main/cpp/fileoutputstream.cpp
@@ -22,7 +22,7 @@
#include <apr_file_io.h>
#include <log4cxx/helpers/transcoder.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/helpers/aprinitializer.h>
@@ -32,67 +32,94 @@
IMPLEMENT_LOG4CXX_OBJECT(FileOutputStream)
FileOutputStream::FileOutputStream(const LogString& filename,
- bool append) : pool(), fileptr(open(filename, append, pool)) {
+ bool append) : pool(), fileptr(open(filename, append, pool))
+{
}
FileOutputStream::FileOutputStream(const logchar* filename,
- bool append) : pool(), fileptr(open(filename, append, pool)) {
+ bool append) : pool(), fileptr(open(filename, append, pool))
+{
}
apr_file_t* FileOutputStream::open(const LogString& filename,
- bool append, Pool& pool) {
+ bool append, Pool& pool)
+{
apr_fileperms_t perm = APR_OS_DEFAULT;
apr_int32_t flags = APR_WRITE | APR_CREATE;
- if (append) {
+
+ if (append)
+ {
flags |= APR_APPEND;
- } else {
+ }
+ else
+ {
flags |= APR_TRUNCATE;
}
+
File fn;
fn.setPath(filename);
apr_file_t* fileptr = 0;
apr_status_t stat = fn.open(&fileptr, flags, perm, pool);
- if (stat != APR_SUCCESS) {
- throw IOException(stat);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
}
+
return fileptr;
}
-FileOutputStream::~FileOutputStream() {
- if (fileptr != NULL && !APRInitializer::isDestructed) {
- apr_file_close(fileptr);
- }
-}
-
-void FileOutputStream::close(Pool& /* p */) {
- if (fileptr != NULL) {
- apr_status_t stat = apr_file_close(fileptr);
- if (stat != APR_SUCCESS) {
- throw IOException(stat);
+FileOutputStream::~FileOutputStream()
+{
+ if (fileptr != NULL && !APRInitializer::isDestructed)
+ {
+ apr_file_close(fileptr);
}
- fileptr = NULL;
- }
}
-void FileOutputStream::flush(Pool& /* p */) {
-}
+void FileOutputStream::close(Pool& /* p */)
+{
+ if (fileptr != NULL)
+ {
+ apr_status_t stat = apr_file_close(fileptr);
-void FileOutputStream::write(ByteBuffer& buf, Pool& /* p */ ) {
- if (fileptr == NULL) {
- throw IOException(-1);
- }
- size_t nbytes = buf.remaining();
- size_t pos = buf.position();
- const char* data = buf.data();
- while(nbytes > 0) {
- apr_status_t stat = apr_file_write(
- fileptr, data + pos, &nbytes);
- if (stat != APR_SUCCESS) {
- throw IOException(stat);
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
+
+ fileptr = NULL;
}
- pos += nbytes;
- buf.position(pos);
- nbytes = buf.remaining();
- }
+}
+
+void FileOutputStream::flush(Pool& /* p */)
+{
+}
+
+void FileOutputStream::write(ByteBuffer& buf, Pool& /* p */ )
+{
+ if (fileptr == NULL)
+ {
+ throw IOException(-1);
+ }
+
+ size_t nbytes = buf.remaining();
+ size_t pos = buf.position();
+ const char* data = buf.data();
+
+ while (nbytes > 0)
+ {
+ apr_status_t stat = apr_file_write(
+ fileptr, data + pos, &nbytes);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
+
+ pos += nbytes;
+ buf.position(pos);
+ nbytes = buf.remaining();
+ }
}
diff --git a/src/main/cpp/filerenameaction.cpp b/src/main/cpp/filerenameaction.cpp
index 03818f2..3559aa8 100644
--- a/src/main/cpp/filerenameaction.cpp
+++ b/src/main/cpp/filerenameaction.cpp
@@ -25,11 +25,13 @@
IMPLEMENT_LOG4CXX_OBJECT(FileRenameAction)
FileRenameAction::FileRenameAction(const File& toRename,
- const File& renameTo,
- bool renameEmptyFile1)
- : source(toRename), destination(renameTo), renameEmptyFile(renameEmptyFile1) {
+ const File& renameTo,
+ bool renameEmptyFile1)
+ : source(toRename), destination(renameTo), renameEmptyFile(renameEmptyFile1)
+{
}
-bool FileRenameAction::execute(log4cxx::helpers::Pool& pool1) const {
- return source.renameTo(destination, pool1);
+bool FileRenameAction::execute(log4cxx::helpers::Pool& pool1) const
+{
+ return source.renameTo(destination, pool1);
}
diff --git a/src/main/cpp/filewatchdog.cpp b/src/main/cpp/filewatchdog.cpp
index c9ea95a..b672bbb 100644
--- a/src/main/cpp/filewatchdog.cpp
+++ b/src/main/cpp/filewatchdog.cpp
@@ -32,66 +32,79 @@
#if APR_HAS_THREADS
FileWatchdog::FileWatchdog(const File& file1)
- : file(file1), delay(DEFAULT_DELAY), lastModif(0),
-warnedAlready(false), interrupted(0), thread()
+ : file(file1), delay(DEFAULT_DELAY), lastModif(0),
+ warnedAlready(false), interrupted(0), thread()
{
}
-FileWatchdog::~FileWatchdog() {
- apr_atomic_set32(&interrupted, 0xFFFF);
- try {
+FileWatchdog::~FileWatchdog()
+{
+ apr_atomic_set32(&interrupted, 0xFFFF);
+
+ try
+ {
thread.interrupt();
thread.join();
- } catch(Exception &e) {
- }
+ }
+ catch (Exception& e)
+ {
+ }
}
void FileWatchdog::checkAndConfigure()
{
Pool pool1;
- if (!file.exists(pool1))
- {
- if(!warnedAlready)
- {
- LogLog::debug(((LogString) LOG4CXX_STR("["))
- + file.getPath()
- + LOG4CXX_STR("] does not exist."));
- warnedAlready = true;
- }
- }
- else
- {
+
+ if (!file.exists(pool1))
+ {
+ if (!warnedAlready)
+ {
+ LogLog::debug(((LogString) LOG4CXX_STR("["))
+ + file.getPath()
+ + LOG4CXX_STR("] does not exist."));
+ warnedAlready = true;
+ }
+ }
+ else
+ {
apr_time_t thisMod = file.lastModified(pool1);
- if (thisMod > lastModif)
- {
- lastModif = thisMod;
- doOnChange();
- warnedAlready = false;
- }
- }
+
+ if (thisMod > lastModif)
+ {
+ lastModif = thisMod;
+ doOnChange();
+ warnedAlready = false;
+ }
+ }
}
-void* APR_THREAD_FUNC FileWatchdog::run(apr_thread_t* /* thread */, void* data) {
- FileWatchdog* pThis = (FileWatchdog*) data;
+void* APR_THREAD_FUNC FileWatchdog::run(apr_thread_t* /* thread */, void* data)
+{
+ FileWatchdog* pThis = (FileWatchdog*) data;
- unsigned int interrupted = apr_atomic_read32(&pThis->interrupted);
- while(!interrupted)
- {
- try {
- Thread::sleep(pThis->delay);
- pThis->checkAndConfigure();
- } catch(InterruptedException& ex) {
- interrupted = apr_atomic_read32(&pThis->interrupted);
- }
+ unsigned int interrupted = apr_atomic_read32(&pThis->interrupted);
+
+ while (!interrupted)
+ {
+ try
+ {
+ Thread::sleep(pThis->delay);
+ pThis->checkAndConfigure();
+ }
+ catch (InterruptedException& ex)
+ {
+ interrupted = apr_atomic_read32(&pThis->interrupted);
+ }
}
- return NULL;
+
+ return NULL;
}
void FileWatchdog::start()
{
- checkAndConfigure();
+ checkAndConfigure();
- thread.run(run, this);
+ thread.run(run, this);
}
#endif
diff --git a/src/main/cpp/filter.cpp b/src/main/cpp/filter.cpp
index 2d1855d..72526d4 100644
--- a/src/main/cpp/filter.cpp
+++ b/src/main/cpp/filter.cpp
@@ -22,28 +22,35 @@
using namespace log4cxx::spi;
using namespace log4cxx::helpers;
-Filter::Filter() : next() {
+Filter::Filter() : next()
+{
}
-void Filter::addRef() const {
+void Filter::addRef() const
+{
ObjectImpl::addRef();
}
-void Filter::releaseRef() const {
+void Filter::releaseRef() const
+{
ObjectImpl::releaseRef();
}
-FilterPtr Filter::getNext() const {
- return next;
+FilterPtr Filter::getNext() const
+{
+ return next;
}
-void Filter::setNext(const FilterPtr& newNext) {
+void Filter::setNext(const FilterPtr& newNext)
+{
next = newNext;
}
-void Filter::activateOptions(Pool&) {
+void Filter::activateOptions(Pool&)
+{
}
-void Filter::setOption(const LogString&, const LogString&) {
+void Filter::setOption(const LogString&, const LogString&)
+{
}
diff --git a/src/main/cpp/filterbasedtriggeringpolicy.cpp b/src/main/cpp/filterbasedtriggeringpolicy.cpp
index 549d1e4..1f7e2c6 100644
--- a/src/main/cpp/filterbasedtriggeringpolicy.cpp
+++ b/src/main/cpp/filterbasedtriggeringpolicy.cpp
@@ -25,71 +25,88 @@
IMPLEMENT_LOG4CXX_OBJECT(FilterBasedTriggeringPolicy)
-FilterBasedTriggeringPolicy::FilterBasedTriggeringPolicy() {
+FilterBasedTriggeringPolicy::FilterBasedTriggeringPolicy()
+{
}
-FilterBasedTriggeringPolicy::~FilterBasedTriggeringPolicy() {
+FilterBasedTriggeringPolicy::~FilterBasedTriggeringPolicy()
+{
}
bool FilterBasedTriggeringPolicy::isTriggeringEvent(
- Appender* /* appender */,
- const log4cxx::spi::LoggingEventPtr& event,
- const LogString& /* filename */,
- size_t /* fileLength */ ) {
- if (headFilter == NULL) {
- return false;
- }
- for(log4cxx::spi::FilterPtr f = headFilter; f != NULL; f = f->getNext()) {
- switch(f->decide(event)) {
- case Filter::DENY:
- return false;
-
- case Filter::ACCEPT:
- return true;
-
- case Filter::NEUTRAL:
- break;
+ Appender* /* appender */,
+ const log4cxx::spi::LoggingEventPtr& event,
+ const LogString& /* filename */,
+ size_t /* fileLength */ )
+{
+ if (headFilter == NULL)
+ {
+ return false;
}
- }
- return true;
+
+ for (log4cxx::spi::FilterPtr f = headFilter; f != NULL; f = f->getNext())
+ {
+ switch (f->decide(event))
+ {
+ case Filter::DENY:
+ return false;
+
+ case Filter::ACCEPT:
+ return true;
+
+ case Filter::NEUTRAL:
+ break;
+ }
+ }
+
+ return true;
}
/**
* Add a filter to end of the filter list.
* @param newFilter filter to add to end of list.
*/
-void FilterBasedTriggeringPolicy::addFilter(const log4cxx::spi::FilterPtr& newFilter) {
- if (headFilter == NULL) {
- headFilter = newFilter;
- tailFilter = newFilter;
- } else {
- tailFilter->setNext(newFilter);
- tailFilter = newFilter;
- }
+void FilterBasedTriggeringPolicy::addFilter(const log4cxx::spi::FilterPtr& newFilter)
+{
+ if (headFilter == NULL)
+ {
+ headFilter = newFilter;
+ tailFilter = newFilter;
+ }
+ else
+ {
+ tailFilter->setNext(newFilter);
+ tailFilter = newFilter;
+ }
}
-void FilterBasedTriggeringPolicy::clearFilters() {
- log4cxx::spi::FilterPtr empty;
- headFilter = empty;
- tailFilter = empty;
+void FilterBasedTriggeringPolicy::clearFilters()
+{
+ log4cxx::spi::FilterPtr empty;
+ headFilter = empty;
+ tailFilter = empty;
}
-log4cxx::spi::FilterPtr& FilterBasedTriggeringPolicy::getFilter() {
- return headFilter;
+log4cxx::spi::FilterPtr& FilterBasedTriggeringPolicy::getFilter()
+{
+ return headFilter;
}
/**
* Prepares the instance for use.
*/
-void FilterBasedTriggeringPolicy::activateOptions(log4cxx::helpers::Pool& p) {
- for(log4cxx::spi::FilterPtr f = headFilter; f != NULL; f = f->getNext()) {
- f->activateOptions(p);
- }
+void FilterBasedTriggeringPolicy::activateOptions(log4cxx::helpers::Pool& p)
+{
+ for (log4cxx::spi::FilterPtr f = headFilter; f != NULL; f = f->getNext())
+ {
+ f->activateOptions(p);
+ }
}
-void FilterBasedTriggeringPolicy::setOption(const LogString& /* option */, const LogString& /* value */ ) {
+void FilterBasedTriggeringPolicy::setOption(const LogString& /* option */, const LogString& /* value */ )
+{
}
diff --git a/src/main/cpp/fixedwindowrollingpolicy.cpp b/src/main/cpp/fixedwindowrollingpolicy.cpp
index 57f71aa..f186053 100644
--- a/src/main/cpp/fixedwindowrollingpolicy.cpp
+++ b/src/main/cpp/fixedwindowrollingpolicy.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -41,167 +41,184 @@
IMPLEMENT_LOG4CXX_OBJECT(FixedWindowRollingPolicy)
FixedWindowRollingPolicy::FixedWindowRollingPolicy() :
- minIndex(1), maxIndex(7) {
+ minIndex(1), maxIndex(7)
+{
}
-void FixedWindowRollingPolicy::setMaxIndex(int maxIndex1) {
+void FixedWindowRollingPolicy::setMaxIndex(int maxIndex1)
+{
this->maxIndex = maxIndex1;
}
-void FixedWindowRollingPolicy::setMinIndex(int minIndex1) {
+void FixedWindowRollingPolicy::setMinIndex(int minIndex1)
+{
this->minIndex = minIndex1;
}
void FixedWindowRollingPolicy::setOption(const LogString& option,
- const LogString& value) {
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("MININDEX"),
- LOG4CXX_STR("minindex"))) {
- minIndex = OptionConverter::toInt(value, 1);
- } else if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("MAXINDEX"),
- LOG4CXX_STR("maxindex"))) {
- maxIndex = OptionConverter::toInt(value, 7);
- } else {
+ const LogString& value)
+{
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("MININDEX"),
+ LOG4CXX_STR("minindex")))
+ {
+ minIndex = OptionConverter::toInt(value, 1);
+ }
+ else if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("MAXINDEX"),
+ LOG4CXX_STR("maxindex")))
+ {
+ maxIndex = OptionConverter::toInt(value, 7);
+ }
+ else
+ {
RollingPolicyBase::setOption(option, value);
- }
+ }
}
/**
* {@inheritDoc}
*/
-void FixedWindowRollingPolicy::activateOptions(Pool& p) {
- RollingPolicyBase::activateOptions(p);
+void FixedWindowRollingPolicy::activateOptions(Pool& p)
+{
+ RollingPolicyBase::activateOptions(p);
- if (maxIndex < minIndex) {
- LogLog::warn(
- LOG4CXX_STR("MaxIndex cannot be smaller than MinIndex."));
- maxIndex = minIndex;
- }
+ if (maxIndex < minIndex)
+ {
+ LogLog::warn(
+ LOG4CXX_STR("MaxIndex cannot be smaller than MinIndex."));
+ maxIndex = minIndex;
+ }
- if ((maxIndex - minIndex) > MAX_WINDOW_SIZE) {
- LogLog::warn(LOG4CXX_STR("Large window sizes are not allowed."));
- maxIndex = minIndex + MAX_WINDOW_SIZE;
- }
+ if ((maxIndex - minIndex) > MAX_WINDOW_SIZE)
+ {
+ LogLog::warn(LOG4CXX_STR("Large window sizes are not allowed."));
+ maxIndex = minIndex + MAX_WINDOW_SIZE;
+ }
- PatternConverterPtr itc = getIntegerPatternConverter();
+ PatternConverterPtr itc = getIntegerPatternConverter();
- if (itc == NULL) {
- throw IllegalStateException();
- }
+ if (itc == NULL)
+ {
+ throw IllegalStateException();
+ }
}
/**
* {@inheritDoc}
*/
RolloverDescriptionPtr FixedWindowRollingPolicy::initialize(
- const LogString& currentActiveFile,
- const bool append,
- Pool& pool)
+ const LogString& currentActiveFile,
+ const bool append,
+ Pool& pool)
{
- LogString newActiveFile(currentActiveFile);
- explicitActiveFile = false;
+ LogString newActiveFile(currentActiveFile);
+ explicitActiveFile = false;
- if (currentActiveFile.length() > 0) {
- explicitActiveFile = true;
- newActiveFile = currentActiveFile;
- }
+ if (currentActiveFile.length() > 0)
+ {
+ explicitActiveFile = true;
+ newActiveFile = currentActiveFile;
+ }
- if (!explicitActiveFile) {
- LogString buf;
- ObjectPtr obj(new Integer(minIndex));
- formatFileName(obj, buf, pool);
- newActiveFile = buf;
- }
+ if (!explicitActiveFile)
+ {
+ LogString buf;
+ ObjectPtr obj(new Integer(minIndex));
+ formatFileName(obj, buf, pool);
+ newActiveFile = buf;
+ }
- ActionPtr noAction;
+ ActionPtr noAction;
- return new RolloverDescription(newActiveFile, append, noAction, noAction);
+ return new RolloverDescription(newActiveFile, append, noAction, noAction);
}
/**
* {@inheritDoc}
*/
RolloverDescriptionPtr FixedWindowRollingPolicy::rollover(
- const LogString& currentActiveFile,
- const bool append,
- Pool& pool)
+ const LogString& currentActiveFile,
+ const bool append,
+ Pool& pool)
{
- RolloverDescriptionPtr desc;
+ RolloverDescriptionPtr desc;
- if (maxIndex < 0)
- {
- return desc;
- }
+ if (maxIndex < 0)
+ {
+ return desc;
+ }
- int purgeStart = minIndex;
+ int purgeStart = minIndex;
- if (!explicitActiveFile)
- {
- purgeStart++;
- }
+ if (!explicitActiveFile)
+ {
+ purgeStart++;
+ }
- if (!purge(purgeStart, maxIndex, pool))
- {
- return desc;
- }
+ if (!purge(purgeStart, maxIndex, pool))
+ {
+ return desc;
+ }
- LogString buf;
- ObjectPtr obj(new Integer(purgeStart));
- formatFileName(obj, buf, pool);
+ LogString buf;
+ ObjectPtr obj(new Integer(purgeStart));
+ formatFileName(obj, buf, pool);
- LogString renameTo(buf);
- LogString compressedName(renameTo);
- ActionPtr compressAction ;
+ LogString renameTo(buf);
+ LogString compressedName(renameTo);
+ ActionPtr compressAction ;
- if (StringHelper::endsWith(renameTo, LOG4CXX_STR(".gz")))
- {
- renameTo.resize(renameTo.size() - 3);
- compressAction =
- new GZCompressAction(
- File().setPath(renameTo),
- File().setPath(compressedName),
- true);
- }
- else if (StringHelper::endsWith(renameTo, LOG4CXX_STR(".zip")))
- {
- renameTo.resize(renameTo.size() - 4);
- compressAction =
- new ZipCompressAction(
- File().setPath(renameTo),
- File().setPath(compressedName),
- true);
- }
+ if (StringHelper::endsWith(renameTo, LOG4CXX_STR(".gz")))
+ {
+ renameTo.resize(renameTo.size() - 3);
+ compressAction =
+ new GZCompressAction(
+ File().setPath(renameTo),
+ File().setPath(compressedName),
+ true);
+ }
+ else if (StringHelper::endsWith(renameTo, LOG4CXX_STR(".zip")))
+ {
+ renameTo.resize(renameTo.size() - 4);
+ compressAction =
+ new ZipCompressAction(
+ File().setPath(renameTo),
+ File().setPath(compressedName),
+ true);
+ }
- FileRenameActionPtr renameAction =
- new FileRenameAction(
- File().setPath(currentActiveFile),
- File().setPath(renameTo),
- false);
+ FileRenameActionPtr renameAction =
+ new FileRenameAction(
+ File().setPath(currentActiveFile),
+ File().setPath(renameTo),
+ false);
- desc = new RolloverDescription(
- currentActiveFile, append,
- renameAction, compressAction);
+ desc = new RolloverDescription(
+ currentActiveFile, append,
+ renameAction, compressAction);
- return desc;
+ return desc;
}
/**
* Get index of oldest log file to be retained.
* @return index of oldest log file.
*/
-int FixedWindowRollingPolicy::getMaxIndex() const {
- return maxIndex;
+int FixedWindowRollingPolicy::getMaxIndex() const
+{
+ return maxIndex;
}
/**
* Get index of most recent log file.
* @return index of oldest log file.
*/
-int FixedWindowRollingPolicy::getMinIndex() const {
- return minIndex;
+int FixedWindowRollingPolicy::getMinIndex() const
+{
+ return minIndex;
}
@@ -212,105 +229,128 @@
* index will be deleted if needed.
* @return true if purge was successful and rollover should be attempted.
*/
-bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex, Pool& p) const {
- int suffixLength = 0;
+bool FixedWindowRollingPolicy::purge(int lowIndex, int highIndex, Pool& p) const
+{
+ int suffixLength = 0;
- std::vector<FileRenameActionPtr> renames;
- LogString buf;
- ObjectPtr obj = new Integer(lowIndex);
- formatFileName(obj, buf, p);
+ std::vector<FileRenameActionPtr> renames;
+ LogString buf;
+ ObjectPtr obj = new Integer(lowIndex);
+ formatFileName(obj, buf, p);
- LogString lowFilename(buf);
+ LogString lowFilename(buf);
- if (lowFilename.compare(lowFilename.length() - 3, 3, LOG4CXX_STR(".gz")) == 0) {
- suffixLength = 3;
- } else if (lowFilename.compare(lowFilename.length() - 4, 4, LOG4CXX_STR(".zip")) == 0) {
- suffixLength = 4;
- }
-
- for (int i = lowIndex; i <= highIndex; i++) {
- File toRenameCompressed;
- toRenameCompressed.setPath(lowFilename);
- File toRenameBase;
- toRenameBase.setPath(lowFilename.substr(0, lowFilename.length() - suffixLength));
- File* toRename = &toRenameCompressed;
- bool isBase = false;
- bool exists = toRenameCompressed.exists(p);
-
- if (suffixLength > 0) {
- if (exists) {
- if (toRenameBase.exists(p)) {
- toRenameBase.deleteFile(p);
- }
- } else {
- toRename = &toRenameBase;
- exists = toRenameBase.exists(p);
- isBase = true;
- }
+ if (lowFilename.compare(lowFilename.length() - 3, 3, LOG4CXX_STR(".gz")) == 0)
+ {
+ suffixLength = 3;
+ }
+ else if (lowFilename.compare(lowFilename.length() - 4, 4, LOG4CXX_STR(".zip")) == 0)
+ {
+ suffixLength = 4;
}
- if (exists) {
- //
- // if at upper index then
- // attempt to delete last file
- // if that fails then abandon purge
- if (i == highIndex) {
- if (!toRename->deleteFile(p)) {
- return false;
+ for (int i = lowIndex; i <= highIndex; i++)
+ {
+ File toRenameCompressed;
+ toRenameCompressed.setPath(lowFilename);
+ File toRenameBase;
+ toRenameBase.setPath(lowFilename.substr(0, lowFilename.length() - suffixLength));
+ File* toRename = &toRenameCompressed;
+ bool isBase = false;
+ bool exists = toRenameCompressed.exists(p);
+
+ if (suffixLength > 0)
+ {
+ if (exists)
+ {
+ if (toRenameBase.exists(p))
+ {
+ toRenameBase.deleteFile(p);
+ }
+ }
+ else
+ {
+ toRename = &toRenameBase;
+ exists = toRenameBase.exists(p);
+ isBase = true;
+ }
}
- break;
- }
+ if (exists)
+ {
+ //
+ // if at upper index then
+ // attempt to delete last file
+ // if that fails then abandon purge
+ if (i == highIndex)
+ {
+ if (!toRename->deleteFile(p))
+ {
+ return false;
+ }
- //
- // if intermediate index
- // add a rename action to the list
- buf.erase(buf.begin(), buf.end());
- obj = new Integer(i + 1);
- formatFileName(obj, buf, p);
+ break;
+ }
- LogString highFilename(buf);
- LogString renameTo(highFilename);
+ //
+ // if intermediate index
+ // add a rename action to the list
+ buf.erase(buf.begin(), buf.end());
+ obj = new Integer(i + 1);
+ formatFileName(obj, buf, p);
- if (isBase) {
- renameTo =
- highFilename.substr(0, highFilename.length() - suffixLength);
- }
+ LogString highFilename(buf);
+ LogString renameTo(highFilename);
- renames.push_back(new FileRenameAction(*toRename, File().setPath(renameTo), true));
- lowFilename = highFilename;
- } else {
- break;
+ if (isBase)
+ {
+ renameTo =
+ highFilename.substr(0, highFilename.length() - suffixLength);
+ }
+
+ renames.push_back(new FileRenameAction(*toRename, File().setPath(renameTo), true));
+ lowFilename = highFilename;
+ }
+ else
+ {
+ break;
+ }
}
- }
- //
- // work renames backwards
- //
- for(std::vector<FileRenameActionPtr>::reverse_iterator iter = renames.rbegin();
- iter != renames.rend();
- iter++) {
+ //
+ // work renames backwards
+ //
+ for (std::vector<FileRenameActionPtr>::reverse_iterator iter = renames.rbegin();
+ iter != renames.rend();
+ iter++)
+ {
- try {
- if (!(*iter)->execute(p)) {
+ try
+ {
+ if (!(*iter)->execute(p))
+ {
+ return false;
+ }
+ }
+ catch (std::exception& ex)
+ {
+ LogLog::warn(LOG4CXX_STR("Exception during purge in RollingFileAppender"));
+
return false;
- }
- } catch (std::exception& ex) {
- LogLog::warn(LOG4CXX_STR("Exception during purge in RollingFileAppender"));
+ }
+ }
- return false;
- }
- }
- return true;
+ return true;
}
#define RULES_PUT(spec, cls) \
-specs.insert(PatternMap::value_type(LogString(LOG4CXX_STR(spec)), (PatternConstructor) cls ::newInstance))
+ specs.insert(PatternMap::value_type(LogString(LOG4CXX_STR(spec)), (PatternConstructor) cls ::newInstance))
-log4cxx::pattern::PatternMap FixedWindowRollingPolicy::getFormatSpecifiers() const {
- PatternMap specs;
- RULES_PUT("i", IntegerPatternConverter);
- RULES_PUT("index", IntegerPatternConverter);
- return specs;
+log4cxx::pattern::PatternMap FixedWindowRollingPolicy::getFormatSpecifiers() const
+{
+ PatternMap specs;
+ RULES_PUT("i", IntegerPatternConverter);
+ RULES_PUT("index", IntegerPatternConverter);
+ return specs;
}
diff --git a/src/main/cpp/formattinginfo.cpp b/src/main/cpp/formattinginfo.cpp
index 5c900c0..c50d635 100644
--- a/src/main/cpp/formattinginfo.cpp
+++ b/src/main/cpp/formattinginfo.cpp
@@ -24,45 +24,54 @@
IMPLEMENT_LOG4CXX_OBJECT(FormattingInfo)
- /**
- * Creates new instance.
- * @param leftAlign left align if true.
- * @param minLength minimum length.
- * @param maxLength maximum length.
- */
+/**
+ * Creates new instance.
+ * @param leftAlign left align if true.
+ * @param minLength minimum length.
+ * @param maxLength maximum length.
+ */
FormattingInfo::FormattingInfo(
const bool leftAlign1, const int minLength1, const int maxLength1) :
minLength(minLength1),
maxLength(maxLength1),
- leftAlign(leftAlign1) {
+ leftAlign(leftAlign1)
+{
}
- /**
- * Gets default instance.
- * @return default instance.
- */
-FormattingInfoPtr FormattingInfo::getDefault() {
+/**
+ * Gets default instance.
+ * @return default instance.
+ */
+FormattingInfoPtr FormattingInfo::getDefault()
+{
static FormattingInfoPtr def(new FormattingInfo(false, 0, INT_MAX));
return def;
}
- /**
- * Adjust the content of the buffer based on the specified lengths and alignment.
- *
- * @param fieldStart start of field in buffer.
- * @param buffer buffer to be modified.
- */
-void FormattingInfo::format(const int fieldStart, LogString& buffer) const {
+/**
+ * Adjust the content of the buffer based on the specified lengths and alignment.
+ *
+ * @param fieldStart start of field in buffer.
+ * @param buffer buffer to be modified.
+ */
+void FormattingInfo::format(const int fieldStart, LogString& buffer) const
+{
int rawLength = buffer.length() - fieldStart;
- if (rawLength > maxLength) {
- buffer.erase(buffer.begin() + fieldStart,
- buffer.begin() + fieldStart + (rawLength - maxLength));
- } else if (rawLength < minLength) {
- if (leftAlign) {
- buffer.append(minLength - rawLength, (logchar) 0x20 /* ' ' */);
- } else {
- buffer.insert(fieldStart, minLength - rawLength, 0x20 /* ' ' */);
- }
+ if (rawLength > maxLength)
+ {
+ buffer.erase(buffer.begin() + fieldStart,
+ buffer.begin() + fieldStart + (rawLength - maxLength));
}
- }
+ else if (rawLength < minLength)
+ {
+ if (leftAlign)
+ {
+ buffer.append(minLength - rawLength, (logchar) 0x20 /* ' ' */);
+ }
+ else
+ {
+ buffer.insert(fieldStart, minLength - rawLength, 0x20 /* ' ' */);
+ }
+ }
+}
diff --git a/src/main/cpp/fulllocationpatternconverter.cpp b/src/main/cpp/fulllocationpatternconverter.cpp
index a73da7b..8dc0cb9 100644
--- a/src/main/cpp/fulllocationpatternconverter.cpp
+++ b/src/main/cpp/fulllocationpatternconverter.cpp
@@ -16,7 +16,7 @@
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -33,24 +33,27 @@
IMPLEMENT_LOG4CXX_OBJECT(FullLocationPatternConverter)
FullLocationPatternConverter::FullLocationPatternConverter() :
- LoggingEventPatternConverter(LOG4CXX_STR("Full Location"),
- LOG4CXX_STR("fullLocation")) {
+ LoggingEventPatternConverter(LOG4CXX_STR("Full Location"),
+ LOG4CXX_STR("fullLocation"))
+{
}
PatternConverterPtr FullLocationPatternConverter::newInstance(
- const std::vector<LogString>& /* options */) {
- static PatternConverterPtr instance(new FullLocationPatternConverter());
- return instance;
+ const std::vector<LogString>& /* options */)
+{
+ static PatternConverterPtr instance(new FullLocationPatternConverter());
+ return instance;
}
void FullLocationPatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- Pool& p) const {
- append(toAppendTo, event->getLocationInformation().getFileName());
- toAppendTo.append(1, (logchar) 0x28 /* '(' */);
- StringHelper::toString(
- event->getLocationInformation().getLineNumber(),
- p, toAppendTo);
- toAppendTo.append(1, (logchar) 0x29 /* ')' */);
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ Pool& p) const
+{
+ append(toAppendTo, event->getLocationInformation().getFileName());
+ toAppendTo.append(1, (logchar) 0x28 /* '(' */);
+ StringHelper::toString(
+ event->getLocationInformation().getLineNumber(),
+ p, toAppendTo);
+ toAppendTo.append(1, (logchar) 0x29 /* ')' */);
}
diff --git a/src/main/cpp/gzcompressaction.cpp b/src/main/cpp/gzcompressaction.cpp
index b6d0739..ccde682 100644
--- a/src/main/cpp/gzcompressaction.cpp
+++ b/src/main/cpp/gzcompressaction.cpp
@@ -28,48 +28,77 @@
IMPLEMENT_LOG4CXX_OBJECT(GZCompressAction)
GZCompressAction::GZCompressAction(const File& src,
- const File& dest,
- bool del)
- : source(src), destination(dest), deleteSource(del) {
+ const File& dest,
+ bool del)
+ : source(src), destination(dest), deleteSource(del)
+{
}
-bool GZCompressAction::execute(log4cxx::helpers::Pool& p) const {
- if (source.exists(p)) {
+bool GZCompressAction::execute(log4cxx::helpers::Pool& p) const
+{
+ if (source.exists(p))
+ {
apr_pool_t* aprpool = p.getAPRPool();
apr_procattr_t* attr;
apr_status_t stat = apr_procattr_create(&attr, aprpool);
- if (stat != APR_SUCCESS) throw IOException(stat);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
stat = apr_procattr_io_set(attr, APR_NO_PIPE, APR_FULL_BLOCK, APR_FULL_BLOCK);
- if (stat != APR_SUCCESS) throw IOException(stat);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
stat = apr_procattr_cmdtype_set(attr, APR_PROGRAM_PATH);
- if (stat != APR_SUCCESS) throw IOException(stat);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
//
// set child process output to destination file
//
apr_file_t* child_out;
apr_int32_t flags = APR_FOPEN_READ | APR_FOPEN_WRITE |
- APR_FOPEN_CREATE | APR_FOPEN_TRUNCATE;
+ APR_FOPEN_CREATE | APR_FOPEN_TRUNCATE;
stat = destination.open(&child_out, flags, APR_OS_DEFAULT, p);
- if (stat != APR_SUCCESS) throw IOException(stat);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
stat = apr_procattr_child_out_set(attr, child_out, NULL);
- if (stat != APR_SUCCESS) throw IOException(stat);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
//
// redirect the child's error stream to this processes' error stream
//
apr_file_t* child_err;
stat = apr_file_open_stderr(&child_err, aprpool);
- if (stat == APR_SUCCESS) {
- stat = apr_procattr_child_err_set(attr, child_err, NULL);
- if (stat != APR_SUCCESS) throw IOException(stat);
+
+ if (stat == APR_SUCCESS)
+ {
+ stat = apr_procattr_child_err_set(attr, child_err, NULL);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
}
const char** args = (const char**)
- apr_palloc(aprpool, 4 *sizeof(*args));
+ apr_palloc(aprpool, 4 * sizeof(*args));
int i = 0;
args[i++] = "gzip";
args[i++] = "-c";
@@ -79,17 +108,28 @@
apr_proc_t pid;
stat = apr_proc_create(&pid, "gzip", args, NULL, attr, aprpool);
- if (stat != APR_SUCCESS) throw IOException(stat);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
apr_proc_wait(&pid, NULL, NULL, APR_WAIT);
stat = apr_file_close(child_out);
- if (stat != APR_SUCCESS) throw IOException(stat);
- if (deleteSource) {
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
+
+ if (deleteSource)
+ {
source.deleteFile(p);
}
+
return true;
}
+
return false;
}
diff --git a/src/main/cpp/hierarchy.cpp b/src/main/cpp/hierarchy.cpp
index fc80d77..7d1078e 100644
--- a/src/main/cpp/hierarchy.cpp
+++ b/src/main/cpp/hierarchy.cpp
@@ -16,7 +16,7 @@
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -33,7 +33,7 @@
#include <log4cxx/logstring.h>
#include <log4cxx/helpers/stringhelper.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/helpers/aprinitializer.h>
#include <log4cxx/defaultconfigurator.h>
@@ -49,118 +49,125 @@
IMPLEMENT_LOG4CXX_OBJECT(Hierarchy)
Hierarchy::Hierarchy() :
-pool(),
-mutex(pool),
-loggers(new LoggerMap()),
-provisionNodes(new ProvisionNodeMap())
+ pool(),
+ mutex(pool),
+ loggers(new LoggerMap()),
+ provisionNodes(new ProvisionNodeMap())
{
- synchronized sync(mutex);
- root = new RootLogger(pool, Level::getDebug());
- root->setHierarchy(this);
- defaultFactory = new DefaultLoggerFactory();
- emittedNoAppenderWarning = false;
- configured = false;
- thresholdInt = Level::ALL_INT;
- threshold = Level::getAll();
- emittedNoResourceBundleWarning = false;
+ synchronized sync(mutex);
+ root = new RootLogger(pool, Level::getDebug());
+ root->setHierarchy(this);
+ defaultFactory = new DefaultLoggerFactory();
+ emittedNoAppenderWarning = false;
+ configured = false;
+ thresholdInt = Level::ALL_INT;
+ threshold = Level::getAll();
+ emittedNoResourceBundleWarning = false;
}
Hierarchy::~Hierarchy()
{
-// TODO LOGCXX-430
-// https://issues.apache.org/jira/browse/LOGCXX-430?focusedCommentId=15175254&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15175254
+ // TODO LOGCXX-430
+ // https://issues.apache.org/jira/browse/LOGCXX-430?focusedCommentId=15175254&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15175254
#ifndef APR_HAS_THREADS
- delete loggers;
- delete provisionNodes;
+ delete loggers;
+ delete provisionNodes;
#endif
}
-void Hierarchy::addRef() const {
+void Hierarchy::addRef() const
+{
ObjectImpl::addRef();
}
-void Hierarchy::releaseRef() const {
+void Hierarchy::releaseRef() const
+{
ObjectImpl::releaseRef();
}
void Hierarchy::addHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener)
{
- synchronized sync(mutex);
- if (std::find(listeners.begin(), listeners.end(), listener) != listeners.end())
- {
- LogLog::warn(LOG4CXX_STR("Ignoring attempt to add an existent listener."));
- }
- else
- {
- listeners.push_back(listener);
- }
+ synchronized sync(mutex);
+
+ if (std::find(listeners.begin(), listeners.end(), listener) != listeners.end())
+ {
+ LogLog::warn(LOG4CXX_STR("Ignoring attempt to add an existent listener."));
+ }
+ else
+ {
+ listeners.push_back(listener);
+ }
}
void Hierarchy::clear()
{
- synchronized sync(mutex);
- loggers->clear();
+ synchronized sync(mutex);
+ loggers->clear();
}
void Hierarchy::emitNoAppenderWarning(const LoggerPtr& logger)
{
- bool emitWarning = false;
- {
- synchronized sync(mutex);
- emitWarning = !emittedNoAppenderWarning;
- emittedNoAppenderWarning = true;
- }
+ bool emitWarning = false;
+ {
+ synchronized sync(mutex);
+ emitWarning = !emittedNoAppenderWarning;
+ emittedNoAppenderWarning = true;
+ }
- // No appender in hierarchy, warn user only once.
- if(emitWarning)
- {
- LogLog::warn(((LogString) LOG4CXX_STR("No appender could be found for logger ("))
- + logger->getName() + LOG4CXX_STR(")."));
- LogLog::warn(LOG4CXX_STR("Please initialize the log4cxx system properly."));
- }
+ // No appender in hierarchy, warn user only once.
+ if (emitWarning)
+ {
+ LogLog::warn(((LogString) LOG4CXX_STR("No appender could be found for logger ("))
+ + logger->getName() + LOG4CXX_STR(")."));
+ LogLog::warn(LOG4CXX_STR("Please initialize the log4cxx system properly."));
+ }
}
LoggerPtr Hierarchy::exists(const LogString& name)
{
- synchronized sync(mutex);
+ synchronized sync(mutex);
- LoggerPtr logger;
- LoggerMap::iterator it = loggers->find(name);
- if (it != loggers->end())
- {
- logger = it->second;
- }
+ LoggerPtr logger;
+ LoggerMap::iterator it = loggers->find(name);
+
+ if (it != loggers->end())
+ {
+ logger = it->second;
+ }
- return logger;
+ return logger;
}
void Hierarchy::setThreshold(const LevelPtr& l)
{
- if (l != 0)
+ if (l != 0)
+ {
+ synchronized sync(mutex);
+ thresholdInt = l->toInt();
+ threshold = l;
+
+ if (thresholdInt != Level::ALL_INT)
{
- synchronized sync(mutex);
- thresholdInt = l->toInt();
- threshold = l;
- if (thresholdInt != Level::ALL_INT) {
- setConfigured(true);
- }
+ setConfigured(true);
}
+ }
}
-void Hierarchy::setThreshold(const LogString& levelStr) {
- LevelPtr l(Level::toLevelLS(levelStr, 0));
+void Hierarchy::setThreshold(const LogString& levelStr)
+{
+ LevelPtr l(Level::toLevelLS(levelStr, 0));
- if(l != 0)
- {
- setThreshold(l);
- }
- else
- {
- LogLog::warn(((LogString) LOG4CXX_STR("No level could be found named \""))
- + levelStr + LOG4CXX_STR("\"."));
- }
+ if (l != 0)
+ {
+ setThreshold(l);
+ }
+ else
+ {
+ LogLog::warn(((LogString) LOG4CXX_STR("No level could be found named \""))
+ + levelStr + LOG4CXX_STR("\"."));
+ }
}
void Hierarchy::fireAddAppenderEvent(const LoggerPtr& logger, const AppenderPtr& appender)
@@ -168,18 +175,18 @@
setConfigured(true);
HierarchyEventListenerList clonedList;
{
- synchronized sync(mutex);
- clonedList = listeners;
+ synchronized sync(mutex);
+ clonedList = listeners;
}
HierarchyEventListenerList::iterator it, itEnd = clonedList.end();
HierarchyEventListenerPtr listener;
- for(it = clonedList.begin(); it != itEnd; it++)
- {
- listener = *it;
- listener->addAppenderEvent(logger, appender);
- }
+ for (it = clonedList.begin(); it != itEnd; it++)
+ {
+ listener = *it;
+ listener->addAppenderEvent(logger, appender);
+ }
}
void Hierarchy::fireRemoveAppenderEvent(const LoggerPtr& logger, const AppenderPtr& appender)
@@ -187,217 +194,226 @@
{
HierarchyEventListenerList clonedList;
{
- synchronized sync(mutex);
- clonedList = listeners;
+ synchronized sync(mutex);
+ clonedList = listeners;
}
HierarchyEventListenerList::iterator it, itEnd = clonedList.end();
HierarchyEventListenerPtr listener;
- for(it = clonedList.begin(); it != itEnd; it++)
- {
- listener = *it;
- listener->removeAppenderEvent(logger, appender);
- }
+ for (it = clonedList.begin(); it != itEnd; it++)
+ {
+ listener = *it;
+ listener->removeAppenderEvent(logger, appender);
+ }
}
const LevelPtr& Hierarchy::getThreshold() const
{
- return threshold;
+ return threshold;
}
LoggerPtr Hierarchy::getLogger(const LogString& name)
{
- return getLogger(name, defaultFactory);
+ return getLogger(name, defaultFactory);
}
LoggerPtr Hierarchy::getLogger(const LogString& name,
- const spi::LoggerFactoryPtr& factory)
+ const spi::LoggerFactoryPtr& factory)
{
- synchronized sync(mutex);
+ synchronized sync(mutex);
- LoggerMap::iterator it = loggers->find(name);
+ LoggerMap::iterator it = loggers->find(name);
- if (it != loggers->end())
+ if (it != loggers->end())
+ {
+ return it->second;
+ }
+ else
+ {
+ LoggerPtr logger(factory->makeNewLoggerInstance(pool, name));
+ logger->setHierarchy(this);
+ loggers->insert(LoggerMap::value_type(name, logger));
+
+ ProvisionNodeMap::iterator it2 = provisionNodes->find(name);
+
+ if (it2 != provisionNodes->end())
{
- return it->second;
+ updateChildren(it2->second, logger);
+ provisionNodes->erase(it2);
}
- else
- {
- LoggerPtr logger(factory->makeNewLoggerInstance(pool, name));
- logger->setHierarchy(this);
- loggers->insert(LoggerMap::value_type(name, logger));
- ProvisionNodeMap::iterator it2 = provisionNodes->find(name);
- if (it2 != provisionNodes->end())
- {
- updateChildren(it2->second, logger);
- provisionNodes->erase(it2);
- }
-
- updateParents(logger);
- return logger;
- }
+ updateParents(logger);
+ return logger;
+ }
}
LoggerList Hierarchy::getCurrentLoggers() const
{
- synchronized sync(mutex);
+ synchronized sync(mutex);
- LoggerList v;
- LoggerMap::const_iterator it, itEnd = loggers->end();
+ LoggerList v;
+ LoggerMap::const_iterator it, itEnd = loggers->end();
- for (it = loggers->begin(); it != itEnd; it++)
- {
- v.push_back(it->second);
- }
+ for (it = loggers->begin(); it != itEnd; it++)
+ {
+ v.push_back(it->second);
+ }
- return v;
+ return v;
}
LoggerPtr Hierarchy::getRootLogger() const
{
- return root;
+ return root;
}
bool Hierarchy::isDisabled(int level) const
{
- if(!configured) {
- synchronized sync(mutex);
- if (!configured) {
- DefaultConfigurator::configure(
- const_cast<Hierarchy*>(this));
- }
- }
+ if (!configured)
+ {
+ synchronized sync(mutex);
- return thresholdInt > level;
+ if (!configured)
+ {
+ DefaultConfigurator::configure(
+ const_cast<Hierarchy*>(this));
+ }
+ }
+
+ return thresholdInt > level;
}
void Hierarchy::resetConfiguration()
{
- synchronized sync(mutex);
+ synchronized sync(mutex);
- getRootLogger()->setLevel(Level::getDebug());
- root->setResourceBundle(0);
- setThreshold(Level::getAll());
+ getRootLogger()->setLevel(Level::getDebug());
+ root->setResourceBundle(0);
+ setThreshold(Level::getAll());
- shutdown(); // nested locks are OK
+ shutdown(); // nested locks are OK
- LoggerList loggers1 = getCurrentLoggers();
- LoggerList::iterator it, itEnd = loggers1.end();
+ LoggerList loggers1 = getCurrentLoggers();
+ LoggerList::iterator it, itEnd = loggers1.end();
- for (it = loggers1.begin(); it != itEnd; it++)
- {
- LoggerPtr& logger = *it;
- logger->setLevel(0);
- logger->setAdditivity(true);
- logger->setResourceBundle(0);
- }
+ for (it = loggers1.begin(); it != itEnd; it++)
+ {
+ LoggerPtr& logger = *it;
+ logger->setLevel(0);
+ logger->setAdditivity(true);
+ logger->setResourceBundle(0);
+ }
- //rendererMap.clear();
+ //rendererMap.clear();
}
void Hierarchy::shutdown()
{
- synchronized sync(mutex);
+ synchronized sync(mutex);
- setConfigured(false);
+ setConfigured(false);
- LoggerPtr root1 = getRootLogger();
+ LoggerPtr root1 = getRootLogger();
- // begin by closing nested appenders
- root1->closeNestedAppenders();
+ // begin by closing nested appenders
+ root1->closeNestedAppenders();
- LoggerList loggers1 = getCurrentLoggers();
- LoggerList::iterator it, itEnd = loggers1.end();
+ LoggerList loggers1 = getCurrentLoggers();
+ LoggerList::iterator it, itEnd = loggers1.end();
- for (it = loggers1.begin(); it != itEnd; it++)
- {
- LoggerPtr& logger = *it;
- logger->closeNestedAppenders();
- }
+ 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();
- }
+ // then, remove all appenders
+ root1->removeAllAppenders();
+
+ for (it = loggers1.begin(); it != itEnd; it++)
+ {
+ LoggerPtr& logger = *it;
+ logger->removeAllAppenders();
+ }
}
void Hierarchy::updateParents(LoggerPtr logger)
{
- synchronized sync(mutex);
- const LogString name(logger->getName());
- int length = name.size();
- bool parentFound = false;
+ synchronized sync(mutex);
+ const LogString name(logger->getName());
+ int length = name.size();
+ bool parentFound = false;
- // if name = "w.x.y.z", loop through "w.x.y", "w.x" and "w", but not "w.x.y.z"
- for(size_t i = name.find_last_of(0x2E /* '.' */, length-1);
+ // if name = "w.x.y.z", loop through "w.x.y", "w.x" and "w", but not "w.x.y.z"
+ for (size_t i = name.find_last_of(0x2E /* '.' */, length - 1);
(i != LogString::npos) && (i != 0);
- i = name.find_last_of(0x2E /* '.' */, i-1))
- {
- LogString substr = name.substr(0, i);
+ i = name.find_last_of(0x2E /* '.' */, i - 1))
+ {
+ LogString substr = name.substr(0, i);
- LoggerMap::iterator it = loggers->find(substr);
- if(it != loggers->end())
- {
- parentFound = true;
- logger->parent = it->second;
- break; // no need to update the ancestors of the closest ancestor
- }
- else
- {
- ProvisionNodeMap::iterator it2 = provisionNodes->find(substr);
- if (it2 != provisionNodes->end())
- {
- it2->second.push_back(logger);
- }
- else
- {
- ProvisionNode node(1, logger);
- provisionNodes->insert(
- ProvisionNodeMap::value_type(substr, node));
- }
- }
- }
+ LoggerMap::iterator it = loggers->find(substr);
- // If we could not find any existing parents, then link with root.
- if(!parentFound)
+ if (it != loggers->end())
{
- logger->parent = root;
+ parentFound = true;
+ logger->parent = it->second;
+ break; // no need to update the ancestors of the closest ancestor
}
+ else
+ {
+ ProvisionNodeMap::iterator it2 = provisionNodes->find(substr);
+
+ if (it2 != provisionNodes->end())
+ {
+ it2->second.push_back(logger);
+ }
+ else
+ {
+ ProvisionNode node(1, logger);
+ provisionNodes->insert(
+ ProvisionNodeMap::value_type(substr, node));
+ }
+ }
+ }
+
+ // If we could not find any existing parents, then link with root.
+ if (!parentFound)
+ {
+ logger->parent = root;
+ }
}
void Hierarchy::updateChildren(ProvisionNode& pn, LoggerPtr logger)
{
- ProvisionNode::iterator it, itEnd = pn.end();
+ ProvisionNode::iterator it, itEnd = pn.end();
- for(it = pn.begin(); it != itEnd; it++)
+ for (it = pn.begin(); it != itEnd; it++)
+ {
+ LoggerPtr& l = *it;
+
+ // Unless this child already points to a correct (lower) parent,
+ // make cat.parent point to l.parent and l.parent to cat.
+ if (!StringHelper::startsWith(l->parent->name, logger->name))
{
- LoggerPtr& l = *it;
-
- // Unless this child already points to a correct (lower) parent,
- // make cat.parent point to l.parent and l.parent to cat.
- if(!StringHelper::startsWith(l->parent->name, logger->name))
- {
- logger->parent = l->parent;
- l->parent = logger;
- }
+ logger->parent = l->parent;
+ l->parent = logger;
}
+ }
}
-void Hierarchy::setConfigured(bool newValue) {
+void Hierarchy::setConfigured(bool newValue)
+{
synchronized sync(mutex);
configured = newValue;
}
-bool Hierarchy::isConfigured() {
+bool Hierarchy::isConfigured()
+{
return configured;
}
diff --git a/src/main/cpp/htmllayout.cpp b/src/main/cpp/htmllayout.cpp
index 8538b82..21ba54b 100644
--- a/src/main/cpp/htmllayout.cpp
+++ b/src/main/cpp/htmllayout.cpp
@@ -37,184 +37,190 @@
HTMLLayout::HTMLLayout()
-: locationInfo(false), title(LOG4CXX_STR("Log4cxx Log Messages")),
-dateFormat()
+ : locationInfo(false), title(LOG4CXX_STR("Log4cxx Log Messages")),
+ dateFormat()
{
- dateFormat.setTimeZone(TimeZone::getGMT());
+ dateFormat.setTimeZone(TimeZone::getGMT());
}
void HTMLLayout::setOption(const LogString& option,
- const LogString& value)
+ const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("TITLE"), LOG4CXX_STR("title")))
- {
- setTitle(value);
- }
- else if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo")))
- {
- setLocationInfo(OptionConverter::toBoolean(value, false));
- }
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("TITLE"), LOG4CXX_STR("title")))
+ {
+ setTitle(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo")))
+ {
+ setLocationInfo(OptionConverter::toBoolean(value, false));
+ }
}
void HTMLLayout::format(LogString& output,
- const spi::LoggingEventPtr& event,
- Pool& p) const
+ const spi::LoggingEventPtr& event,
+ Pool& p) const
{
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<tr>"));
- output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<tr>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<td>"));
+
+ dateFormat.format(output, event->getTimeStamp(), p);
+
+
+ output.append(LOG4CXX_STR("</td>"));
+ output.append(LOG4CXX_EOL);
+
+ output.append(LOG4CXX_STR("<td title=\""));
+ LogString threadName(event->getThreadName());
+ output.append(threadName);
+ output.append(LOG4CXX_STR(" thread\">"));
+ output.append(threadName);
+ output.append(LOG4CXX_STR("</td>"));
+ output.append(LOG4CXX_EOL);
+
+ output.append(LOG4CXX_STR("<td title=\"Level\">"));
+
+ if (event->getLevel()->equals(Level::getDebug()))
+ {
+ output.append(LOG4CXX_STR("<font color=\"#339933\">"));
+ output.append(event->getLevel()->toString());
+ output.append(LOG4CXX_STR("</font>"));
+ }
+ else if (event->getLevel()->isGreaterOrEqual(Level::getWarn()))
+ {
+ output.append(LOG4CXX_STR("<font color=\"#993300\"><strong>"));
+ output.append(event->getLevel()->toString());
+ output.append(LOG4CXX_STR("</strong></font>"));
+ }
+ else
+ {
+ output.append(event->getLevel()->toString());
+ }
+
+ output.append(LOG4CXX_STR("</td>"));
+ output.append(LOG4CXX_EOL);
+
+ output.append(LOG4CXX_STR("<td title=\""));
+ output.append(event->getLoggerName());
+ output.append(LOG4CXX_STR(" logger\">"));
+ Transform::appendEscapingTags(output, event->getLoggerName());
+ output.append(LOG4CXX_STR("</td>"));
+ output.append(LOG4CXX_EOL);
+
+ if (locationInfo)
+ {
output.append(LOG4CXX_STR("<td>"));
+ const LocationInfo& locInfo = event->getLocationInformation();
+ LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName());
+ Transform::appendEscapingTags(output, fileName);
+ output.append(1, (logchar) 0x3A /* ':' */);
+ int line = event->getLocationInformation().getLineNumber();
- dateFormat.format(output, event->getTimeStamp(), p);
-
-
- output.append(LOG4CXX_STR("</td>"));
- output.append(LOG4CXX_EOL);
-
- output.append(LOG4CXX_STR("<td title=\""));
- LogString threadName(event->getThreadName());
- output.append(threadName);
- output.append(LOG4CXX_STR(" thread\">"));
- output.append(threadName);
- output.append(LOG4CXX_STR("</td>"));
- output.append(LOG4CXX_EOL);
-
- output.append(LOG4CXX_STR("<td title=\"Level\">"));
- if (event->getLevel()->equals(Level::getDebug()))
+ if (line != 0)
{
- output.append(LOG4CXX_STR("<font color=\"#339933\">"));
- output.append(event->getLevel()->toString());
- output.append(LOG4CXX_STR("</font>"));
- }
- else if(event->getLevel()->isGreaterOrEqual(Level::getWarn()))
- {
- output.append(LOG4CXX_STR("<font color=\"#993300\"><strong>"));
- output.append(event->getLevel()->toString());
- output.append(LOG4CXX_STR("</strong></font>"));
- }
- else
- {
- output.append(event->getLevel()->toString());
+ StringHelper::toString(line, p, output);
}
output.append(LOG4CXX_STR("</td>"));
output.append(LOG4CXX_EOL);
+ }
- output.append(LOG4CXX_STR("<td title=\""));
- output.append(event->getLoggerName());
- output.append(LOG4CXX_STR(" logger\">"));
- Transform::appendEscapingTags(output, event->getLoggerName());
- output.append(LOG4CXX_STR("</td>"));
+ output.append(LOG4CXX_STR("<td title=\"Message\">"));
+ Transform::appendEscapingTags(output, event->getRenderedMessage());
+ output.append(LOG4CXX_STR("</td>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("</tr>"));
+ output.append(LOG4CXX_EOL);
+
+ LogString ndcVal;
+
+ if (event->getNDC(ndcVal))
+ {
+ output.append(LOG4CXX_STR("<tr><td bgcolor=\"#EEEEEE\" "));
+ output.append(LOG4CXX_STR("style=\"font-size : xx-small;\" colspan=\"6\" "));
+ output.append(LOG4CXX_STR("title=\"Nested Diagnostic Context\">"));
+ output.append(LOG4CXX_STR("NDC: "));
+ Transform::appendEscapingTags(output, ndcVal);
+ output.append(LOG4CXX_STR("</td></tr>"));
output.append(LOG4CXX_EOL);
-
- if(locationInfo)
- {
- output.append(LOG4CXX_STR("<td>"));
- const LocationInfo& locInfo = event->getLocationInformation();
- LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName());
- Transform::appendEscapingTags(output, fileName);
- output.append(1, (logchar) 0x3A /* ':' */);
- int line = event->getLocationInformation().getLineNumber();
- if (line != 0)
- {
- StringHelper::toString(line, p, output);
- }
- output.append(LOG4CXX_STR("</td>"));
- output.append(LOG4CXX_EOL);
- }
-
- output.append(LOG4CXX_STR("<td title=\"Message\">"));
- Transform::appendEscapingTags(output, event->getRenderedMessage());
- output.append(LOG4CXX_STR("</td>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("</tr>"));
- output.append(LOG4CXX_EOL);
-
- LogString ndcVal;
- if (event->getNDC(ndcVal))
- {
- output.append(LOG4CXX_STR("<tr><td bgcolor=\"#EEEEEE\" "));
- output.append(LOG4CXX_STR("style=\"font-size : xx-small;\" colspan=\"6\" "));
- output.append(LOG4CXX_STR("title=\"Nested Diagnostic Context\">"));
- output.append(LOG4CXX_STR("NDC: "));
- Transform::appendEscapingTags(output, ndcVal);
- output.append(LOG4CXX_STR("</td></tr>"));
- output.append(LOG4CXX_EOL);
- }
+ }
}
void HTMLLayout::appendHeader(LogString& output, Pool& p)
{
- output.append(LOG4CXX_STR("<!DOCTYPE HTML PUBLIC "));
- output.append(LOG4CXX_STR("\"-//W3C//DTD HTML 4.01 Transitional//EN\" "));
- output.append(LOG4CXX_STR("\"http://www.w3.org/TR/html4/loose.dtd\">"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<html>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<head>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<title>"));
- output.append(title);
- output.append(LOG4CXX_STR("</title>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<style type=\"text/css\">"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<!--"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("body, table {font-family: arial,sans-serif; font-size: x-small;}"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("th {background: #336699; color: #FFFFFF; text-align: left;}"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("-->"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("</style>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("</head>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<hr size=\"1\" noshade>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("Log session start time "));
+ output.append(LOG4CXX_STR("<!DOCTYPE HTML PUBLIC "));
+ output.append(LOG4CXX_STR("\"-//W3C//DTD HTML 4.01 Transitional//EN\" "));
+ output.append(LOG4CXX_STR("\"http://www.w3.org/TR/html4/loose.dtd\">"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<html>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<head>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<title>"));
+ output.append(title);
+ output.append(LOG4CXX_STR("</title>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<style type=\"text/css\">"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<!--"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("body, table {font-family: arial,sans-serif; font-size: x-small;}"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("th {background: #336699; color: #FFFFFF; text-align: left;}"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("-->"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("</style>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("</head>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<body bgcolor=\"#FFFFFF\" topmargin=\"6\" leftmargin=\"6\">"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<hr size=\"1\" noshade>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("Log session start time "));
- dateFormat.format(output, apr_time_now(), p);
+ dateFormat.format(output, apr_time_now(), p);
- output.append(LOG4CXX_STR("<br>"));
+ output.append(LOG4CXX_STR("<br>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<br>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<tr>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<th>Time</th>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<th>Thread</th>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<th>Level</th>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<th>Logger</th>"));
+ output.append(LOG4CXX_EOL);
+
+ if (locationInfo)
+ {
+ output.append(LOG4CXX_STR("<th>File:Line</th>"));
output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<br>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" bordercolor=\"#224466\" width=\"100%\">"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<tr>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<th>Time</th>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<th>Thread</th>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<th>Level</th>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<th>Logger</th>"));
- output.append(LOG4CXX_EOL);
- if(locationInfo)
- {
- output.append(LOG4CXX_STR("<th>File:Line</th>"));
- output.append(LOG4CXX_EOL);
- }
- output.append(LOG4CXX_STR("<th>Message</th>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("</tr>"));
- output.append(LOG4CXX_EOL);
+ }
+
+ output.append(LOG4CXX_STR("<th>Message</th>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("</tr>"));
+ output.append(LOG4CXX_EOL);
}
void HTMLLayout::appendFooter(LogString& output, Pool& /* pool */ )
{
- output.append(LOG4CXX_STR("</table>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("<br>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_STR("</body></html>"));
+ output.append(LOG4CXX_STR("</table>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("<br>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_STR("</body></html>"));
}
diff --git a/src/main/cpp/inetaddress.cpp b/src/main/cpp/inetaddress.cpp
index 65f4c69..473adf1 100644
--- a/src/main/cpp/inetaddress.cpp
+++ b/src/main/cpp/inetaddress.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -32,60 +32,73 @@
IMPLEMENT_LOG4CXX_OBJECT(InetAddress)
UnknownHostException::UnknownHostException(const LogString& msg1)
- : Exception(msg1) {
+ : Exception(msg1)
+{
}
UnknownHostException::UnknownHostException(const UnknownHostException& src)
- : Exception(src) {
+ : Exception(src)
+{
}
-UnknownHostException& UnknownHostException::operator=(const UnknownHostException& src) {
- Exception::operator=(src);
- return *this;
+UnknownHostException& UnknownHostException::operator=(const UnknownHostException& src)
+{
+ Exception::operator=(src);
+ return *this;
}
InetAddress::InetAddress(const LogString& hostName, const LogString& hostAddr)
- : ipAddrString(hostAddr), hostNameString(hostName) {
+ : ipAddrString(hostAddr), hostNameString(hostName)
+{
}
/** Determines all the IP addresses of a host, given the host's name.
*/
-std::vector<InetAddressPtr> InetAddress::getAllByName(const LogString& host) {
+std::vector<InetAddressPtr> InetAddress::getAllByName(const LogString& host)
+{
LOG4CXX_ENCODE_CHAR(encodedHost, host);
// retrieve information about the given host
Pool addrPool;
- apr_sockaddr_t *address = 0;
+ apr_sockaddr_t* address = 0;
apr_status_t status =
apr_sockaddr_info_get(&address, encodedHost.c_str(),
APR_INET, 0, 0, addrPool.getAPRPool());
- if (status != APR_SUCCESS) {
- LogString msg(LOG4CXX_STR("Cannot get information about host: "));
- msg.append(host);
- LogLog::error(msg);
- throw UnknownHostException(msg);
+
+ if (status != APR_SUCCESS)
+ {
+ LogString msg(LOG4CXX_STR("Cannot get information about host: "));
+ msg.append(host);
+ LogLog::error(msg);
+ throw UnknownHostException(msg);
}
std::vector<InetAddressPtr> result;
- apr_sockaddr_t *currentAddr = address;
- while(currentAddr != NULL) {
+ apr_sockaddr_t* currentAddr = address;
+
+ while (currentAddr != NULL)
+ {
// retrieve the IP address of this InetAddress.
LogString ipAddrString;
- char *ipAddr;
+ char* ipAddr;
status = apr_sockaddr_ip_get(&ipAddr, currentAddr);
- if (status == APR_SUCCESS) {
+
+ if (status == APR_SUCCESS)
+ {
std::string ip(ipAddr);
Transcoder::decode(ip, ipAddrString);
}
// retrieve the host name of this InetAddress.
LogString hostNameString;
- char *hostName;
+ char* hostName;
status = apr_getnameinfo(&hostName, currentAddr, 0);
- if (status == APR_SUCCESS) {
+
+ if (status == APR_SUCCESS)
+ {
std::string host(hostName);
Transcoder::decode(host, hostNameString);
}
@@ -100,7 +113,8 @@
/** Determines the IP address of a host, given the host's name.
*/
-InetAddressPtr InetAddress::getByName(const LogString& host) {
+InetAddressPtr InetAddress::getByName(const LogString& host)
+{
return getAllByName(host)[0];
}
@@ -126,7 +140,8 @@
}
-InetAddressPtr InetAddress::anyAddress() {
+InetAddressPtr InetAddress::anyAddress()
+{
// APR_ANYADDR does not work with the LOG4CXX_STR macro
return getByName(LOG4CXX_STR("0.0.0.0"));
}
@@ -136,9 +151,9 @@
*/
LogString InetAddress::toString() const
{
- LogString rv(getHostName());
- rv.append(LOG4CXX_STR("/"));
- rv.append(getHostAddress());
- return rv;
+ LogString rv(getHostName());
+ rv.append(LOG4CXX_STR("/"));
+ rv.append(getHostAddress());
+ return rv;
}
diff --git a/src/main/cpp/inputstream.cpp b/src/main/cpp/inputstream.cpp
index dec830b..555c04c 100644
--- a/src/main/cpp/inputstream.cpp
+++ b/src/main/cpp/inputstream.cpp
@@ -23,8 +23,10 @@
IMPLEMENT_LOG4CXX_OBJECT(InputStream)
-InputStream::InputStream() {
+InputStream::InputStream()
+{
}
-InputStream::~InputStream() {
+InputStream::~InputStream()
+{
}
diff --git a/src/main/cpp/inputstreamreader.cpp b/src/main/cpp/inputstreamreader.cpp
index cacdf1b..752adad 100644
--- a/src/main/cpp/inputstreamreader.cpp
+++ b/src/main/cpp/inputstreamreader.cpp
@@ -30,47 +30,63 @@
IMPLEMENT_LOG4CXX_OBJECT(InputStreamReader)
InputStreamReader::InputStreamReader(const InputStreamPtr& in1)
- : in(in1), dec(CharsetDecoder::getDefaultDecoder()) {
- if (in1 == 0) {
- throw NullPointerException(LOG4CXX_STR("in parameter may not be null."));
- }
-}
-
-InputStreamReader::InputStreamReader(const InputStreamPtr& in1, const CharsetDecoderPtr &dec1)
- : in(in1), dec(dec1) {
- if (in1 == 0) {
- throw NullPointerException(LOG4CXX_STR("in parameter may not be null."));
- }
- if (dec1 == 0) {
- throw NullPointerException(LOG4CXX_STR("dec parameter may not be null."));
+ : in(in1), dec(CharsetDecoder::getDefaultDecoder())
+{
+ if (in1 == 0)
+ {
+ throw NullPointerException(LOG4CXX_STR("in parameter may not be null."));
}
}
-InputStreamReader::~InputStreamReader() {
+InputStreamReader::InputStreamReader(const InputStreamPtr& in1, const CharsetDecoderPtr& dec1)
+ : in(in1), dec(dec1)
+{
+ if (in1 == 0)
+ {
+ throw NullPointerException(LOG4CXX_STR("in parameter may not be null."));
+ }
+
+ if (dec1 == 0)
+ {
+ throw NullPointerException(LOG4CXX_STR("dec parameter may not be null."));
+ }
}
-void InputStreamReader::close(Pool& ) {
- in->close();
+InputStreamReader::~InputStreamReader()
+{
}
-LogString InputStreamReader::read(Pool& p) {
+void InputStreamReader::close(Pool& )
+{
+ in->close();
+}
+
+LogString InputStreamReader::read(Pool& p)
+{
const size_t BUFSIZE = 4096;
ByteBuffer buf(p.pstralloc(BUFSIZE), BUFSIZE);
LogString output;
// read whole file
- while(in->read(buf) >= 0) {
- buf.flip();
- log4cxx_status_t stat = dec->decode(buf, output);
- if (stat != 0) {
- throw IOException(stat);
- }
- if (buf.remaining() > 0) {
- memmove(buf.data(), buf.current(), buf.remaining());
- buf.limit(buf.remaining());
- } else {
- buf.clear();
- }
+ while (in->read(buf) >= 0)
+ {
+ buf.flip();
+ log4cxx_status_t stat = dec->decode(buf, output);
+
+ if (stat != 0)
+ {
+ throw IOException(stat);
+ }
+
+ if (buf.remaining() > 0)
+ {
+ memmove(buf.data(), buf.current(), buf.remaining());
+ buf.limit(buf.remaining());
+ }
+ else
+ {
+ buf.clear();
+ }
}
return output;
diff --git a/src/main/cpp/integer.cpp b/src/main/cpp/integer.cpp
index 1523c06..561e889 100644
--- a/src/main/cpp/integer.cpp
+++ b/src/main/cpp/integer.cpp
@@ -24,11 +24,14 @@
IMPLEMENT_LOG4CXX_OBJECT(Integer)
-Integer::Integer() : val(0){
+Integer::Integer() : val(0)
+{
}
-Integer::Integer(int val1) : val(val1) {
+Integer::Integer(int val1) : val(val1)
+{
}
-Integer::~Integer() {
+Integer::~Integer()
+{
}
diff --git a/src/main/cpp/integerpatternconverter.cpp b/src/main/cpp/integerpatternconverter.cpp
index 1f3d9f7..4eeb10f 100644
--- a/src/main/cpp/integerpatternconverter.cpp
+++ b/src/main/cpp/integerpatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -31,22 +31,27 @@
IMPLEMENT_LOG4CXX_OBJECT(IntegerPatternConverter)
IntegerPatternConverter::IntegerPatternConverter() :
- PatternConverter(LOG4CXX_STR("Integer"),
- LOG4CXX_STR("integer")) {
+ PatternConverter(LOG4CXX_STR("Integer"),
+ LOG4CXX_STR("integer"))
+{
}
PatternConverterPtr IntegerPatternConverter::newInstance(
- const std::vector<LogString>& /* options */) {
- static PatternConverterPtr instance(new IntegerPatternConverter());
- return instance;
+ const std::vector<LogString>& /* options */)
+{
+ static PatternConverterPtr instance(new IntegerPatternConverter());
+ return instance;
}
void IntegerPatternConverter::format(
- const ObjectPtr& obj,
- LogString& toAppendTo,
- Pool& p) const {
- IntegerPtr i(obj);
- if (i != NULL) {
- StringHelper::toString(i->intValue(), p, toAppendTo);
- }
+ const ObjectPtr& obj,
+ LogString& toAppendTo,
+ Pool& p) const
+{
+ IntegerPtr i(obj);
+
+ if (i != NULL)
+ {
+ StringHelper::toString(i->intValue(), p, toAppendTo);
+ }
}
diff --git a/src/main/cpp/layout.cpp b/src/main/cpp/layout.cpp
index 1490938..acaf730 100644
--- a/src/main/cpp/layout.cpp
+++ b/src/main/cpp/layout.cpp
@@ -25,15 +25,20 @@
Layout::~Layout() {}
-void Layout::addRef() const {
+void Layout::addRef() const
+{
ObjectImpl::addRef();
}
-void Layout::releaseRef() const {
+void Layout::releaseRef() const
+{
ObjectImpl::releaseRef();
}
-LogString Layout::getContentType() const { return LOG4CXX_STR("text/plain"); }
+LogString Layout::getContentType() const
+{
+ return LOG4CXX_STR("text/plain");
+}
void Layout::appendHeader(LogString&, log4cxx::helpers::Pool&) {}
diff --git a/src/main/cpp/level.cpp b/src/main/cpp/level.cpp
index ce679a4..6a18f9c 100644
--- a/src/main/cpp/level.cpp
+++ b/src/main/cpp/level.cpp
@@ -20,7 +20,7 @@
#include <log4cxx/helpers/stringhelper.h>
#include <log4cxx/helpers/transcoder.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/helpers/aprinitializer.h>
@@ -29,46 +29,54 @@
IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(Level, LevelClass)
-LevelPtr Level::getOff() {
- return LevelPtr(new Level(Level::OFF_INT, LOG4CXX_STR("OFF"), 0));
+LevelPtr Level::getOff()
+{
+ return LevelPtr(new Level(Level::OFF_INT, LOG4CXX_STR("OFF"), 0));
}
-LevelPtr Level::getFatal() {
- return LevelPtr(new Level(Level::FATAL_INT, LOG4CXX_STR("FATAL"), 0));
+LevelPtr Level::getFatal()
+{
+ return LevelPtr(new Level(Level::FATAL_INT, LOG4CXX_STR("FATAL"), 0));
}
-LevelPtr Level::getError() {
- return LevelPtr(new Level(Level::ERROR_INT, LOG4CXX_STR("ERROR"), 3));
+LevelPtr Level::getError()
+{
+ return LevelPtr(new Level(Level::ERROR_INT, LOG4CXX_STR("ERROR"), 3));
}
-LevelPtr Level::getWarn() {
- return LevelPtr(new Level(Level::WARN_INT, LOG4CXX_STR("WARN"), 4));
+LevelPtr Level::getWarn()
+{
+ return LevelPtr(new Level(Level::WARN_INT, LOG4CXX_STR("WARN"), 4));
}
-LevelPtr Level::getInfo() {
- return LevelPtr(new Level(Level::INFO_INT, LOG4CXX_STR("INFO"), 6));
+LevelPtr Level::getInfo()
+{
+ return LevelPtr(new Level(Level::INFO_INT, LOG4CXX_STR("INFO"), 6));
}
-LevelPtr Level::getDebug() {
- return LevelPtr(new Level(Level::DEBUG_INT, LOG4CXX_STR("DEBUG"), 7));
+LevelPtr Level::getDebug()
+{
+ return LevelPtr(new Level(Level::DEBUG_INT, LOG4CXX_STR("DEBUG"), 7));
}
-LevelPtr Level::getTrace() {
- return LevelPtr(new Level(Level::TRACE_INT, LOG4CXX_STR("TRACE"), 7));
+LevelPtr Level::getTrace()
+{
+ return LevelPtr(new Level(Level::TRACE_INT, LOG4CXX_STR("TRACE"), 7));
}
-LevelPtr Level::getAll() {
- return LevelPtr(new Level(Level::ALL_INT, LOG4CXX_STR("ALL"), 7));
+LevelPtr Level::getAll()
+{
+ return LevelPtr(new Level(Level::ALL_INT, LOG4CXX_STR("ALL"), 7));
}
Level::Level(int level1,
- const LogString& name1, int syslogEquivalent1)
-: level(level1), name(name1), syslogEquivalent(syslogEquivalent1)
+ const LogString& name1, int syslogEquivalent1)
+ : level(level1), name(name1), syslogEquivalent(syslogEquivalent1)
{
- APRInitializer::initialize();
+ APRInitializer::initialize();
}
@@ -77,7 +85,8 @@
return toLevelLS(sArg, Level::getDebug());
}
-LogString Level::toString() const {
+LogString Level::toString() const
+{
return name;
}
@@ -89,17 +98,34 @@
LevelPtr Level::toLevel(int val, const LevelPtr& defaultLevel)
{
- switch(val)
+ switch (val)
{
- case ALL_INT: return getAll();
- case DEBUG_INT: return getDebug();
- case TRACE_INT: return getTrace();
- case INFO_INT: return getInfo();
- case WARN_INT: return getWarn();
- case ERROR_INT: return getError();
- case FATAL_INT: return getFatal();
- case OFF_INT: return getOff();
- default: return defaultLevel;
+ case ALL_INT:
+ return getAll();
+
+ case DEBUG_INT:
+ return getDebug();
+
+ case TRACE_INT:
+ return getTrace();
+
+ case INFO_INT:
+ return getInfo();
+
+ case WARN_INT:
+ return getWarn();
+
+ case ERROR_INT:
+ return getError();
+
+ case FATAL_INT:
+ return getFatal();
+
+ case OFF_INT:
+ return getOff();
+
+ default:
+ return defaultLevel;
}
}
@@ -114,7 +140,8 @@
return toLevelLS(s, defaultLevel);
}
-void Level::toString(std::string& dst) const {
+void Level::toString(std::string& dst) const
+{
Transcoder::encode(name, dst);
}
@@ -130,7 +157,8 @@
return toLevelLS(s, defaultLevel);
}
-void Level::toString(std::wstring& dst) const {
+void Level::toString(std::wstring& dst) const
+{
Transcoder::encode(name, dst);
}
@@ -148,7 +176,8 @@
return toLevelLS(s, defaultLevel);
}
-void Level::toString(std::basic_string<UniChar>& dst) const {
+void Level::toString(std::basic_string<UniChar>& dst) const
+{
Transcoder::encode(name, dst);
}
@@ -167,7 +196,8 @@
return toLevelLS(s, defaultLevel);
}
-void Level::toString(CFStringRef& dst) const {
+void Level::toString(CFStringRef& dst) const
+{
dst = Transcoder::encode(name);
}
#endif
@@ -178,37 +208,57 @@
const LogString trimmed(StringHelper::trim(sArg));
const size_t len = trimmed.length();
- if (len == 4) {
- if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("INFO"), LOG4CXX_STR("info"))) {
- return getInfo();
- }
- if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("WARN"), LOG4CXX_STR("warn"))) {
- return getWarn();
- }
- } else {
- if (len == 5) {
- if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("DEBUG"), LOG4CXX_STR("debug"))) {
- return getDebug();
+ if (len == 4)
+ {
+ if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("INFO"), LOG4CXX_STR("info")))
+ {
+ return getInfo();
}
- if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("TRACE"), LOG4CXX_STR("trace"))) {
- return getTrace();
+
+ if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("WARN"), LOG4CXX_STR("warn")))
+ {
+ return getWarn();
}
- if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("ERROR"), LOG4CXX_STR("error"))) {
- return getError();
+ }
+ else
+ {
+ if (len == 5)
+ {
+ if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("DEBUG"), LOG4CXX_STR("debug")))
+ {
+ return getDebug();
+ }
+
+ if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("TRACE"), LOG4CXX_STR("trace")))
+ {
+ return getTrace();
+ }
+
+ if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("ERROR"), LOG4CXX_STR("error")))
+ {
+ return getError();
+ }
+
+ if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("FATAL"), LOG4CXX_STR("fatal")))
+ {
+ return getFatal();
+ }
}
- if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("FATAL"), LOG4CXX_STR("fatal"))) {
- return getFatal();
+ else
+ {
+ if (len == 3)
+ {
+ if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("OFF"), LOG4CXX_STR("off")))
+ {
+ return getOff();
+ }
+
+ if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("ALL"), LOG4CXX_STR("all")))
+ {
+ return getAll();
+ }
+ }
}
- } else {
- if (len == 3) {
- if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("OFF"), LOG4CXX_STR("off"))) {
- return getOff();
- }
- if (StringHelper::equalsIgnoreCase(trimmed, LOG4CXX_STR("ALL"), LOG4CXX_STR("all"))) {
- return getAll();
- }
- }
- }
}
return defaultLevel;
@@ -217,7 +267,7 @@
bool Level::equals(const LevelPtr& level1) const
{
- return (this->level == level1->level);
+ return (this->level == level1->level);
}
bool Level::isGreaterOrEqual(const LevelPtr& level1) const
diff --git a/src/main/cpp/levelmatchfilter.cpp b/src/main/cpp/levelmatchfilter.cpp
index 1f7d74e..c898b39 100644
--- a/src/main/cpp/levelmatchfilter.cpp
+++ b/src/main/cpp/levelmatchfilter.cpp
@@ -31,54 +31,54 @@
LevelMatchFilter::LevelMatchFilter()
-: acceptOnMatch(true)
+ : acceptOnMatch(true)
{
}
void LevelMatchFilter::setOption(const LogString& option,
- const LogString& value)
+ const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("LEVELTOMATCH"), LOG4CXX_STR("leveltomatch")))
- {
- setLevelToMatch(value);
- }
- else if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("ACCEPTONMATCH"), LOG4CXX_STR("acceptonmatch")))
- {
- acceptOnMatch = OptionConverter::toBoolean(value, acceptOnMatch);
- }
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("LEVELTOMATCH"), LOG4CXX_STR("leveltomatch")))
+ {
+ setLevelToMatch(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("ACCEPTONMATCH"), LOG4CXX_STR("acceptonmatch")))
+ {
+ acceptOnMatch = OptionConverter::toBoolean(value, acceptOnMatch);
+ }
}
void LevelMatchFilter::setLevelToMatch(const LogString& levelToMatch1)
{
- this->levelToMatch = OptionConverter::toLevel(levelToMatch1, this->levelToMatch);
+ this->levelToMatch = OptionConverter::toLevel(levelToMatch1, this->levelToMatch);
}
LogString LevelMatchFilter::getLevelToMatch() const
{
- return levelToMatch->toString();
+ return levelToMatch->toString();
}
Filter::FilterDecision LevelMatchFilter::decide(
- const log4cxx::spi::LoggingEventPtr& event) const
+ const log4cxx::spi::LoggingEventPtr& event) const
{
- if(levelToMatch != 0 && levelToMatch->equals(event->getLevel()))
- {
- if(acceptOnMatch)
- {
- return Filter::ACCEPT;
- }
- else
- {
- return Filter::DENY;
- }
- }
- else
- {
- return Filter::NEUTRAL;
- }
+ if (levelToMatch != 0 && levelToMatch->equals(event->getLevel()))
+ {
+ if (acceptOnMatch)
+ {
+ return Filter::ACCEPT;
+ }
+ else
+ {
+ return Filter::DENY;
+ }
+ }
+ else
+ {
+ return Filter::NEUTRAL;
+ }
}
diff --git a/src/main/cpp/levelpatternconverter.cpp b/src/main/cpp/levelpatternconverter.cpp
index 7ae2bdc..ad1e356 100644
--- a/src/main/cpp/levelpatternconverter.cpp
+++ b/src/main/cpp/levelpatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -33,55 +33,62 @@
IMPLEMENT_LOG4CXX_OBJECT(LevelPatternConverter)
LevelPatternConverter::LevelPatternConverter() :
- LoggingEventPatternConverter(LOG4CXX_STR("Level"),
- LOG4CXX_STR("level")) {
+ LoggingEventPatternConverter(LOG4CXX_STR("Level"),
+ LOG4CXX_STR("level"))
+{
}
PatternConverterPtr LevelPatternConverter::newInstance(
- const std::vector<LogString>& /* options */) {
- static PatternConverterPtr def(new LevelPatternConverter());
- return def;
+ const std::vector<LogString>& /* options */)
+{
+ static PatternConverterPtr def(new LevelPatternConverter());
+ return def;
}
void LevelPatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& /* p */) const {
- toAppendTo.append(event->getLevel()->toString());
- }
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& /* p */) const
+{
+ toAppendTo.append(event->getLevel()->toString());
+}
- /**
- * {@inheritDoc}
- */
-LogString LevelPatternConverter::getStyleClass(const ObjectPtr& obj) const {
+/**
+ * {@inheritDoc}
+ */
+LogString LevelPatternConverter::getStyleClass(const ObjectPtr& obj) const
+{
LoggingEventPtr e(obj);
- if (e != NULL) {
- int lint = e->getLevel()->toInt();
- switch (lint) {
- case Level::TRACE_INT:
- return LOG4CXX_STR("level trace");
+ if (e != NULL)
+ {
+ int lint = e->getLevel()->toInt();
- case Level::DEBUG_INT:
- return LOG4CXX_STR("level debug");
+ switch (lint)
+ {
+ case Level::TRACE_INT:
+ return LOG4CXX_STR("level trace");
- case Level::INFO_INT:
- return LOG4CXX_STR("level info");
+ case Level::DEBUG_INT:
+ return LOG4CXX_STR("level debug");
- case Level::WARN_INT:
- return LOG4CXX_STR("level warn");
+ case Level::INFO_INT:
+ return LOG4CXX_STR("level info");
- case Level::ERROR_INT:
- return LOG4CXX_STR("level error");
+ case Level::WARN_INT:
+ return LOG4CXX_STR("level warn");
- case Level::FATAL_INT:
- return LOG4CXX_STR("level fatal");
+ case Level::ERROR_INT:
+ return LOG4CXX_STR("level error");
- default:
- return LogString(LOG4CXX_STR("level ")) + e->getLevel()->toString();
- }
+ case Level::FATAL_INT:
+ return LOG4CXX_STR("level fatal");
+
+ default:
+ return LogString(LOG4CXX_STR("level ")) + e->getLevel()->toString();
+ }
}
return LOG4CXX_STR("level");
- }
+}
diff --git a/src/main/cpp/levelrangefilter.cpp b/src/main/cpp/levelrangefilter.cpp
index cb3a8df..00eba07 100644
--- a/src/main/cpp/levelrangefilter.cpp
+++ b/src/main/cpp/levelrangefilter.cpp
@@ -31,59 +31,59 @@
LevelRangeFilter::LevelRangeFilter()
-: acceptOnMatch(false), levelMin(Level::getAll()), levelMax(Level::getOff())
+ : acceptOnMatch(false), levelMin(Level::getAll()), levelMax(Level::getOff())
{
}
void LevelRangeFilter::setOption(const LogString& option,
- const LogString& value)
+ const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("LEVELMIN"), LOG4CXX_STR("levelmin")))
- {
- levelMin = OptionConverter::toLevel(value, levelMin);
- }
- else if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("LEVELMAX"), LOG4CXX_STR("levelmax")))
- {
- levelMax = OptionConverter::toLevel(value, levelMax);
- }
- else if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("ACCEPTONMATCH"), LOG4CXX_STR("acceptonmatch")))
- {
- acceptOnMatch = OptionConverter::toBoolean(value, acceptOnMatch);
- }
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("LEVELMIN"), LOG4CXX_STR("levelmin")))
+ {
+ levelMin = OptionConverter::toLevel(value, levelMin);
+ }
+ else if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("LEVELMAX"), LOG4CXX_STR("levelmax")))
+ {
+ levelMax = OptionConverter::toLevel(value, levelMax);
+ }
+ else if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("ACCEPTONMATCH"), LOG4CXX_STR("acceptonmatch")))
+ {
+ acceptOnMatch = OptionConverter::toBoolean(value, acceptOnMatch);
+ }
}
Filter::FilterDecision LevelRangeFilter::decide(
- const spi::LoggingEventPtr& event) const
+ const spi::LoggingEventPtr& event) const
{
- if (levelMin != 0 && !event->getLevel()->isGreaterOrEqual(levelMin))
- {
- // level of event is less than minimum
- return Filter::DENY;
- }
+ if (levelMin != 0 && !event->getLevel()->isGreaterOrEqual(levelMin))
+ {
+ // level of event is less than minimum
+ return Filter::DENY;
+ }
- if (levelMax != 0 && event->getLevel()->toInt() > levelMax->toInt())
- {
- // level of event is greater than maximum
- // Alas, there is no Level.isGreater method. and using
- // a combo of isGreaterOrEqual && !Equal seems worse than
- // checking the int values of the level objects..
- return Filter::DENY;
- }
+ if (levelMax != 0 && event->getLevel()->toInt() > levelMax->toInt())
+ {
+ // level of event is greater than maximum
+ // Alas, there is no Level.isGreater method. and using
+ // a combo of isGreaterOrEqual && !Equal seems worse than
+ // checking the int values of the level objects..
+ return Filter::DENY;
+ }
- if (acceptOnMatch)
- {
- // this filter set up to bypass later filters and always return
- // accept if level in range
- return Filter::ACCEPT;
- }
- else
- {
- // event is ok for this filter; allow later filters to have a look..
- return Filter::NEUTRAL;
- }
+ if (acceptOnMatch)
+ {
+ // this filter set up to bypass later filters and always return
+ // accept if level in range
+ return Filter::ACCEPT;
+ }
+ else
+ {
+ // event is ok for this filter; allow later filters to have a look..
+ return Filter::NEUTRAL;
+ }
}
diff --git a/src/main/cpp/linelocationpatternconverter.cpp b/src/main/cpp/linelocationpatternconverter.cpp
index 4e3c739..d42aec0 100644
--- a/src/main/cpp/linelocationpatternconverter.cpp
+++ b/src/main/cpp/linelocationpatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -32,21 +32,24 @@
IMPLEMENT_LOG4CXX_OBJECT(LineLocationPatternConverter)
LineLocationPatternConverter::LineLocationPatternConverter() :
- LoggingEventPatternConverter(LOG4CXX_STR("Line"),
- LOG4CXX_STR("line")) {
+ LoggingEventPatternConverter(LOG4CXX_STR("Line"),
+ LOG4CXX_STR("line"))
+{
}
PatternConverterPtr LineLocationPatternConverter::newInstance(
- const std::vector<LogString>& /* options */) {
- static PatternConverterPtr instance(new LineLocationPatternConverter());
- return instance;
+ const std::vector<LogString>& /* options */)
+{
+ static PatternConverterPtr instance(new LineLocationPatternConverter());
+ return instance;
}
void LineLocationPatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- Pool& p) const {
- StringHelper::toString(
- event->getLocationInformation().getLineNumber(),
- p, toAppendTo);
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ Pool& p) const
+{
+ StringHelper::toString(
+ event->getLocationInformation().getLineNumber(),
+ p, toAppendTo);
}
diff --git a/src/main/cpp/lineseparatorpatternconverter.cpp b/src/main/cpp/lineseparatorpatternconverter.cpp
index 799e7ce..9cfb44f 100644
--- a/src/main/cpp/lineseparatorpatternconverter.cpp
+++ b/src/main/cpp/lineseparatorpatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -32,26 +32,30 @@
IMPLEMENT_LOG4CXX_OBJECT(LineSeparatorPatternConverter)
LineSeparatorPatternConverter::LineSeparatorPatternConverter() :
- LoggingEventPatternConverter(LOG4CXX_STR("Line Sep"),
- LOG4CXX_STR("lineSep")) {
+ LoggingEventPatternConverter(LOG4CXX_STR("Line Sep"),
+ LOG4CXX_STR("lineSep"))
+{
}
PatternConverterPtr LineSeparatorPatternConverter::newInstance(
- const std::vector<LogString>& /* options */) {
- static PatternConverterPtr instance(new LineSeparatorPatternConverter());
- return instance;
+ const std::vector<LogString>& /* options */)
+{
+ static PatternConverterPtr instance(new LineSeparatorPatternConverter());
+ return instance;
}
void LineSeparatorPatternConverter::format(
- const LoggingEventPtr& /* event */,
- LogString& toAppendTo,
- Pool& /* p */) const {
- toAppendTo.append(LOG4CXX_EOL);
- }
+ const LoggingEventPtr& /* event */,
+ LogString& toAppendTo,
+ Pool& /* p */) const
+{
+ toAppendTo.append(LOG4CXX_EOL);
+}
void LineSeparatorPatternConverter::format(
- const ObjectPtr& /* event */,
- LogString& toAppendTo,
- Pool& /* p */) const {
- toAppendTo.append(LOG4CXX_EOL);
- }
+ const ObjectPtr& /* event */,
+ LogString& toAppendTo,
+ Pool& /* p */) const
+{
+ toAppendTo.append(LOG4CXX_EOL);
+}
diff --git a/src/main/cpp/literalpatternconverter.cpp b/src/main/cpp/literalpatternconverter.cpp
index b010be4..805d13c 100644
--- a/src/main/cpp/literalpatternconverter.cpp
+++ b/src/main/cpp/literalpatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -32,31 +32,37 @@
IMPLEMENT_LOG4CXX_OBJECT(LiteralPatternConverter)
LiteralPatternConverter::LiteralPatternConverter(const LogString& literal1) :
- LoggingEventPatternConverter(LOG4CXX_STR("Literal"),LOG4CXX_STR("literal")),
- literal(literal1) {
+ LoggingEventPatternConverter(LOG4CXX_STR("Literal"), LOG4CXX_STR("literal")),
+ literal(literal1)
+{
}
PatternConverterPtr LiteralPatternConverter::newInstance(
- const LogString& literal) {
- if (literal.length() == 1 && literal[0] == 0x20 /* ' ' */) {
- static PatternConverterPtr blank(new LiteralPatternConverter(literal));
- return blank;
- }
- PatternConverterPtr pattern(new LiteralPatternConverter(literal));
- return pattern;
+ const LogString& literal)
+{
+ if (literal.length() == 1 && literal[0] == 0x20 /* ' ' */)
+ {
+ static PatternConverterPtr blank(new LiteralPatternConverter(literal));
+ return blank;
+ }
+
+ PatternConverterPtr pattern(new LiteralPatternConverter(literal));
+ return pattern;
}
void LiteralPatternConverter::format(
- const LoggingEventPtr& /* event */,
- LogString& toAppendTo,
- Pool& /* p */) const {
- toAppendTo.append(literal);
- }
+ const LoggingEventPtr& /* event */,
+ LogString& toAppendTo,
+ Pool& /* p */) const
+{
+ toAppendTo.append(literal);
+}
void LiteralPatternConverter::format(
- const ObjectPtr& /* event */,
- LogString& toAppendTo,
- Pool& /* p */) const {
- toAppendTo.append(literal);
- }
+ const ObjectPtr& /* event */,
+ LogString& toAppendTo,
+ Pool& /* p */) const
+{
+ toAppendTo.append(literal);
+}
diff --git a/src/main/cpp/loader.cpp b/src/main/cpp/loader.cpp
index 8b13390..2f22b2a 100644
--- a/src/main/cpp/loader.cpp
+++ b/src/main/cpp/loader.cpp
@@ -56,16 +56,20 @@
const Class& Loader::loadClass(const LogString& clazz)
{
- return Class::forName(clazz);
+ return Class::forName(clazz);
}
-InputStreamPtr Loader::getResourceAsStream(const LogString& name) {
+InputStreamPtr Loader::getResourceAsStream(const LogString& name)
+{
- try {
- return new FileInputStream(name);
- } catch(const IOException& ioex) {
- }
+ try
+ {
+ return new FileInputStream(name);
+ }
+ catch (const IOException& ioex)
+ {
+ }
- return 0;
+ return 0;
}
diff --git a/src/main/cpp/locale.cpp b/src/main/cpp/locale.cpp
index d4db617..fc5a6dd 100644
--- a/src/main/cpp/locale.cpp
+++ b/src/main/cpp/locale.cpp
@@ -22,34 +22,34 @@
Locale::Locale(const LogString& language1)
- : language(language1)
+ : language(language1)
{
}
Locale::Locale(const LogString& language1, const LogString& country1)
- : language(language1), country(country1)
+ : language(language1), country(country1)
{
}
Locale::Locale(const LogString& language1, const LogString& country1,
- const LogString& variant1)
-: language(language1), country(country1), variant(variant1)
+ const LogString& variant1)
+ : language(language1), country(country1), variant(variant1)
{
}
const LogString& Locale::getLanguage() const
{
- return language;
+ return language;
}
const LogString& Locale::getCountry() const
{
- return country;
+ return country;
}
const LogString& Locale::getVariant() const
{
- return variant;
+ return variant;
}
diff --git a/src/main/cpp/locationinfo.cpp b/src/main/cpp/locationinfo.cpp
index a848c95..f2c9a3d 100644
--- a/src/main/cpp/locationinfo.cpp
+++ b/src/main/cpp/locationinfo.cpp
@@ -24,69 +24,74 @@
using namespace ::log4cxx::spi;
using namespace log4cxx::helpers;
- /**
- When location information is not available the constant
- <code>NA</code> is returned. Current value of this string
- constant is <b>?</b>. */
- const char* const LocationInfo::NA = "?";
- const char* const LocationInfo::NA_METHOD = "?::?";
+/**
+ When location information is not available the constant
+ <code>NA</code> is returned. Current value of this string
+ constant is <b>?</b>. */
+const char* const LocationInfo::NA = "?";
+const char* const LocationInfo::NA_METHOD = "?::?";
- const LocationInfo& LocationInfo::getLocationUnavailable() {
- static const LocationInfo unavailable;
- return unavailable;
- }
+const LocationInfo& LocationInfo::getLocationUnavailable()
+{
+ static const LocationInfo unavailable;
+ return unavailable;
+}
/**
* Constructor.
* @remarks Used by LOG4CXX_LOCATION to generate
* location info for current code site
*/
- LocationInfo::LocationInfo( const char * const fileName1,
- const char * const methodName1,
- int lineNumber1 )
- : lineNumber( lineNumber1 ),
- fileName( fileName1 ),
- methodName( methodName1 ) {
+LocationInfo::LocationInfo( const char* const fileName1,
+ const char* const methodName1,
+ int lineNumber1 )
+ : lineNumber( lineNumber1 ),
+ fileName( fileName1 ),
+ methodName( methodName1 )
+{
}
/**
* Default constructor.
*/
- LocationInfo::LocationInfo()
- : lineNumber( -1 ),
- fileName(LocationInfo::NA),
- methodName(LocationInfo::NA_METHOD) {
+LocationInfo::LocationInfo()
+ : lineNumber( -1 ),
+ fileName(LocationInfo::NA),
+ methodName(LocationInfo::NA_METHOD)
+{
}
/**
* Copy constructor.
* @param src source location
*/
- LocationInfo::LocationInfo( const LocationInfo & src )
- : lineNumber( src.lineNumber ),
- fileName( src.fileName ),
- methodName( src.methodName ) {
+LocationInfo::LocationInfo( const LocationInfo& src )
+ : lineNumber( src.lineNumber ),
+ fileName( src.fileName ),
+ methodName( src.methodName )
+{
}
/**
* Assignment operator.
* @param src source location
*/
- LocationInfo & LocationInfo::operator = ( const LocationInfo & src )
+LocationInfo& LocationInfo::operator = ( const LocationInfo& src )
{
- fileName = src.fileName;
- methodName = src.methodName;
- lineNumber = src.lineNumber;
- return * this;
+ fileName = src.fileName;
+ methodName = src.methodName;
+ lineNumber = src.lineNumber;
+ return * this;
}
/**
* Resets location info to default state.
*/
- void LocationInfo::clear() {
- fileName = NA;
- methodName = NA_METHOD;
- lineNumber = -1;
+void LocationInfo::clear()
+{
+ fileName = NA;
+ methodName = NA_METHOD;
+ lineNumber = -1;
}
@@ -94,101 +99,138 @@
* Return the file name of the caller.
* @returns file name, may be null.
*/
- const char * LocationInfo::getFileName() const
+const char* LocationInfo::getFileName() const
{
- return fileName;
+ return fileName;
}
/**
* Returns the line number of the caller.
* @returns line number, -1 if not available.
*/
- int LocationInfo::getLineNumber() const
+int LocationInfo::getLineNumber() const
{
- return lineNumber;
+ return lineNumber;
}
/** Returns the method name of the caller. */
- const std::string LocationInfo::getMethodName() const
+const std::string LocationInfo::getMethodName() const
{
std::string tmp(methodName);
size_t parenPos = tmp.find('(');
- if (parenPos != std::string::npos) {
- tmp.erase(parenPos);
+
+ if (parenPos != std::string::npos)
+ {
+ tmp.erase(parenPos);
}
+
size_t colonPos = tmp.rfind("::");
- if (colonPos != std::string::npos) {
- tmp.erase(0, colonPos + 2);
- } else {
- size_t spacePos = tmp.find(' ');
- if (spacePos != std::string::npos) {
- tmp.erase(0, spacePos + 1);
- }
+
+ if (colonPos != std::string::npos)
+ {
+ tmp.erase(0, colonPos + 2);
}
+ else
+ {
+ size_t spacePos = tmp.find(' ');
+
+ if (spacePos != std::string::npos)
+ {
+ tmp.erase(0, spacePos + 1);
+ }
+ }
+
return tmp;
}
-const std::string LocationInfo::getClassName() const {
- std::string tmp(methodName);
- size_t parenPos = tmp.find('(');
- if (parenPos != std::string::npos) {
- tmp.erase(parenPos);
+const std::string LocationInfo::getClassName() const
+{
+ std::string tmp(methodName);
+ size_t parenPos = tmp.find('(');
+
+ if (parenPos != std::string::npos)
+ {
+ tmp.erase(parenPos);
+ }
+
+ size_t colonPos = tmp.rfind("::");
+
+ if (colonPos != std::string::npos)
+ {
+ tmp.erase(colonPos);
+ size_t spacePos = tmp.find_last_of(' ');
+
+ if (spacePos != std::string::npos)
+ {
+ tmp.erase(0, spacePos + 1);
}
- size_t colonPos = tmp.rfind("::");
- if (colonPos != std::string::npos) {
- tmp.erase(colonPos);
- size_t spacePos = tmp.find_last_of(' ');
- if (spacePos != std::string::npos) {
- tmp.erase(0, spacePos + 1);
- }
- return tmp;
- }
- tmp.erase(0, tmp.length() );
+
return tmp;
+ }
+
+ tmp.erase(0, tmp.length() );
+ return tmp;
}
-void LocationInfo::write(ObjectOutputStream& os, Pool& p) const {
- if (lineNumber == -1 && fileName == NA && methodName == NA_METHOD) {
- os.writeNull(p);
- } else {
- unsigned char prolog[] = {
- 0x72,
- 0x00,
- 0x21, 0x6F, 0x72, 0x67, 0x2E, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2E,
- 0x6C, 0x6F, 0x67, 0x34, 0x6A, 0x2E, 0x73, 0x70, 0x69, 0x2E, 0x4C, 0x6F,
- 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x49, 0x6E, 0x66, 0x6F, 0xED, 0x99,
- 0xBB, 0xE1, 0x4A, 0x91, 0xA5, 0x7C, 0x02,
- 0x00,
- 0x01, 0x4C,
- 0x00,
- 0x08, 0x66, 0x75, 0x6C, 0x6C, 0x49, 0x6E, 0x66, 0x6F, 0x74,
- 0x00,
- 0x12, 0x4C, 0x6A, 0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 0x2F,
- 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B, 0x78, 0x70
+void LocationInfo::write(ObjectOutputStream& os, Pool& p) const
+{
+ if (lineNumber == -1 && fileName == NA && methodName == NA_METHOD)
+ {
+ os.writeNull(p);
+ }
+ else
+ {
+ unsigned char prolog[] =
+ {
+ 0x72,
+ 0x00,
+ 0x21, 0x6F, 0x72, 0x67, 0x2E, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2E,
+ 0x6C, 0x6F, 0x67, 0x34, 0x6A, 0x2E, 0x73, 0x70, 0x69, 0x2E, 0x4C, 0x6F,
+ 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x49, 0x6E, 0x66, 0x6F, 0xED, 0x99,
+ 0xBB, 0xE1, 0x4A, 0x91, 0xA5, 0x7C, 0x02,
+ 0x00,
+ 0x01, 0x4C,
+ 0x00,
+ 0x08, 0x66, 0x75, 0x6C, 0x6C, 0x49, 0x6E, 0x66, 0x6F, 0x74,
+ 0x00,
+ 0x12, 0x4C, 0x6A, 0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 0x2F,
+ 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B, 0x78, 0x70
};
- os.writeProlog("org.apache.log4j.spi.LocationInfo", 2, (char*) prolog, sizeof(prolog), p);
+ os.writeProlog("org.apache.log4j.spi.LocationInfo", 2, (char*) prolog, sizeof(prolog), p);
char* line = p.itoa(lineNumber);
//
// construct Java-like fullInfo (replace "::" with ".")
//
std::string fullInfo(methodName);
size_t openParen = fullInfo.find('(');
- if (openParen != std::string::npos) {
+
+ if (openParen != std::string::npos)
+ {
size_t space = fullInfo.find(' ');
- if (space != std::string::npos && space < openParen) {
+
+ if (space != std::string::npos && space < openParen)
+ {
fullInfo.erase(0, space + 1);
}
}
+
openParen = fullInfo.find('(');
- if (openParen != std::string::npos) {
+
+ if (openParen != std::string::npos)
+ {
size_t classSep = fullInfo.rfind("::", openParen);
- if (classSep != std::string::npos) {
+
+ if (classSep != std::string::npos)
+ {
fullInfo.replace(classSep, 2, ".");
- } else {
+ }
+ else
+ {
fullInfo.insert(0, ".");
}
}
+
fullInfo.append(1, '(');
fullInfo.append(fileName);
fullInfo.append(1, ':');
diff --git a/src/main/cpp/logger.cpp b/src/main/cpp/logger.cpp
index 8c9a379..e1a76a2 100644
--- a/src/main/cpp/logger.cpp
+++ b/src/main/cpp/logger.cpp
@@ -30,7 +30,7 @@
#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,8 +42,8 @@
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(), SHARED_MUTEX_INIT(mutex, p)
{
name = name1;
additive = true;
@@ -53,287 +53,293 @@
{
}
-void Logger::addRef() const {
+void Logger::addRef() const
+{
ObjectImpl::addRef();
}
-void Logger::releaseRef() const {
+void Logger::releaseRef() const
+{
ObjectImpl::releaseRef();
}
void Logger::addAppender(const AppenderPtr& newAppender)
{
- log4cxx::spi::LoggerRepository* rep = 0;
- {
+ log4cxx::spi::LoggerRepository* rep = 0;
+ {
LOCK_W sync(mutex);
if (aai == 0)
{
- aai = new AppenderAttachableImpl(*pool);
+ aai = new AppenderAttachableImpl(*pool);
}
+
aai->addAppender(newAppender);
rep = repository;
- }
- if (rep != 0) {
- rep->fireAddAppenderEvent(this, newAppender);
- }
+ }
+
+ if (rep != 0)
+ {
+ rep->fireAddAppenderEvent(this, newAppender);
+ }
}
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)
+ for (LoggerPtr logger(const_cast<Logger*>(this));
+ logger != 0;
+ logger = logger->parent)
+ {
+ // Protected against simultaneous call to addAppender, removeAppender,...
+ LOCK_R sync(logger->mutex);
+
+ if (logger->aai != 0)
{
- // Protected against simultaneous call to addAppender, removeAppender,...
- LOCK_R sync(logger->mutex);
-
- if (logger->aai != 0)
- {
- writes += logger->aai->appendLoopOnAppenders(event, p);
- }
-
- if(!logger->additive)
- {
- break;
- }
+ writes += logger->aai->appendLoopOnAppenders(event, p);
}
- if(writes == 0 && repository != 0)
+ if (!logger->additive)
{
- repository->emitNoAppenderWarning(const_cast<Logger*>(this));
+ break;
}
+ }
+
+ if (writes == 0 && repository != 0)
+ {
+ repository->emitNoAppenderWarning(const_cast<Logger*>(this));
+ }
}
void Logger::closeNestedAppenders()
{
AppenderList appenders = getAllAppenders();
- for(AppenderList::iterator it=appenders.begin(); it!=appenders.end(); ++it)
+
+ for (AppenderList::iterator it = appenders.begin(); it != appenders.end(); ++it)
{
- (*it)->close();
+ (*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);
+ LOCK_W sync(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);
+ LOCK_W sync(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)
+ for (const Logger* l = this; l != 0; l = l->parent)
+ {
+ if (l->level != 0)
{
- if(l->level != 0)
- {
- return l->level;
- }
+ 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)
+ for (LoggerPtr l(const_cast<Logger*>(this)); l != 0; l = l->parent)
+ {
+ if (l->resourceBundle != 0)
{
- if (l->resourceBundle != 0)
- {
- return l->resourceBundle;
- }
+ 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)
+ // 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 LogString();
+ return rb->getString(key);
}
- else
+ catch (MissingResourceException&)
{
- try
- {
- return rb->getString(key);
- }
- catch (MissingResourceException&)
- {
- logLS(Level::getError(), LOG4CXX_STR("No resource is associated with key \"") +
+ 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);
+ LOCK_R sync(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,
@@ -364,255 +370,292 @@
void Logger::l7dlog(const LevelPtr& level1, const LogString& key,
const LocationInfo& location, const std::vector<LogString>& params) const
{
- if (repository == 0 || repository->isDisabled(level1->toInt()))
+ if (repository == 0 || repository->isDisabled(level1->toInt()))
+ {
+ return;
+ }
+
+ if (level1->isGreaterOrEqual(getEffectiveLevel()))
+ {
+ LogString pattern = getResourceBundleString(key);
+ LogString msg;
+
+ if (pattern.empty())
{
- return;
+ msg = key;
+ }
+ else
+ {
+ msg = StringHelper::format(pattern, params);
}
- if (level1->isGreaterOrEqual(getEffectiveLevel()))
- {
- LogString pattern = getResourceBundleString(key);
- LogString msg;
-
- 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 {
- LOG4CXX_DECODE_CHAR(lkey, key);
+ const LocationInfo& location) const
+{
+ 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 {
- LOG4CXX_DECODE_CHAR(lkey, key);
- LOG4CXX_DECODE_CHAR(lval1, val1);
+ const LocationInfo& location, const std::string& val1) const
+{
+ 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 {
- LOG4CXX_DECODE_CHAR(lkey, key);
- LOG4CXX_DECODE_CHAR(lval1, val1);
- LOG4CXX_DECODE_CHAR(lval2, val2);
+ const std::string& val1, const std::string& val2) const
+{
+ 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 {
- LOG4CXX_DECODE_CHAR(lkey, key);
- LOG4CXX_DECODE_CHAR(lval1, val1);
- LOG4CXX_DECODE_CHAR(lval2, val2);
- LOG4CXX_DECODE_CHAR(lval3, val3);
+ 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);
- 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);
+ LOCK_W sync(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);
+ LOCK_W sync(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);
+ LOCK_W sync(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;
+ LOCK_W sync(mutex);
+ this->additive = additive1;
}
-void Logger::setHierarchy(spi::LoggerRepository * repository1)
+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();
+LoggerPtr Logger::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 {
+void Logger::getName(std::string& rv) const
+{
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);
- }
-}
-
-
-void Logger::trace(const std::string& msg) const {
- 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);
- }
-}
-
-void Logger::debug(const std::string& msg) const {
- 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);
- }
-}
-
-
-void Logger::error(const std::string& msg) const {
- 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);
- }
-}
-
-void Logger::fatal(const std::string& msg) const {
- 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);
- }
-}
-
-void Logger::info(const std::string& msg) const {
- if (isInfoEnabled()) {
- forcedLog(log4cxx::Level::getInfo(), msg);
- }
-}
-
-void Logger::log(const LevelPtr& level1, const std::string& message,
- const log4cxx::spi::LocationInfo& location) const {
- if (isEnabledFor(level1)) {
- forcedLog(level1, message, location);
+void Logger::trace(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isTraceEnabled())
+ {
+ forcedLog(log4cxx::Level::getTrace(), msg, location);
}
}
-void Logger::log(const LevelPtr& level1, const std::string& message) const {
- if (isEnabledFor(level1)) {
- forcedLog(level1, message);
+
+void Logger::trace(const std::string& msg) const
+{
+ 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);
+ }
+}
+
+void Logger::debug(const std::string& msg) const
+{
+ 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);
+ }
+}
+
+
+void Logger::error(const std::string& msg) const
+{
+ 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);
+ }
+}
+
+void Logger::fatal(const std::string& msg) const
+{
+ 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);
+ }
+}
+
+void Logger::info(const std::string& msg) const
+{
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg);
+ }
+}
+
+void Logger::log(const LevelPtr& level1, const std::string& message,
+ const log4cxx::spi::LocationInfo& location) const
+{
+ if (isEnabledFor(level1))
+ {
+ forcedLog(level1, message, location);
+ }
+}
+
+void Logger::log(const LevelPtr& level1, const std::string& message) const
+{
+ if (isEnabledFor(level1))
+ {
+ forcedLog(level1, message);
}
}
void Logger::logLS(const LevelPtr& level1, const LogString& message,
- const log4cxx::spi::LocationInfo& location) const {
- if (isEnabledFor(level1)) {
- forcedLogLS(level1, message, location);
+ const log4cxx::spi::LocationInfo& location) const
+{
+ 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);
- }
+void Logger::warn(const std::string& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg, location);
+ }
}
-void Logger::warn(const std::string& msg) const {
- if (isWarnEnabled()) {
- forcedLog(log4cxx::Level::getWarn(), msg);
- }
+void Logger::warn(const std::string& msg) const
+{
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg);
+ }
}
-LoggerPtr Logger::getLoggerLS(const LogString& name) {
- return LogManager::getLoggerLS(name);
+LoggerPtr Logger::getLoggerLS(const LogString& name)
+{
+ return LogManager::getLoggerLS(name);
}
@@ -620,121 +663,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 {
+void Logger::getName(std::wstring& rv) const
+{
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);
- }
+void Logger::trace(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isTraceEnabled())
+ {
+ forcedLog(log4cxx::Level::getTrace(), msg, location);
+ }
}
-void Logger::trace(const std::wstring& msg) const {
- if (isTraceEnabled()) {
- forcedLog(log4cxx::Level::getTrace(), msg);
- }
+void Logger::trace(const std::wstring& msg) const
+{
+ 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);
- }
+void Logger::debug(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isDebugEnabled())
+ {
+ forcedLog(log4cxx::Level::getDebug(), msg, location);
+ }
}
-void Logger::debug(const std::wstring& msg) const {
- if (isDebugEnabled()) {
- forcedLog(log4cxx::Level::getDebug(), msg);
- }
+void Logger::debug(const std::wstring& msg) const
+{
+ 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);
- }
+void Logger::error(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isErrorEnabled())
+ {
+ forcedLog(log4cxx::Level::getError(), msg, location);
+ }
}
-void Logger::error(const std::wstring& msg) const {
- if (isErrorEnabled()) {
- forcedLog(log4cxx::Level::getError(), msg);
- }
+void Logger::error(const std::wstring& msg) const
+{
+ 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);
- }
+void Logger::fatal(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isFatalEnabled())
+ {
+ forcedLog(log4cxx::Level::getFatal(), msg, location);
+ }
}
-void Logger::fatal(const std::wstring& msg) const {
- if (isFatalEnabled()) {
- forcedLog(log4cxx::Level::getFatal(), msg);
- }
+void Logger::fatal(const std::wstring& msg) const
+{
+ 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);
- }
+void Logger::info(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg, location);
+ }
}
-void Logger::info(const std::wstring& msg) const {
- if (isInfoEnabled()) {
- forcedLog(log4cxx::Level::getInfo(), msg);
- }
+void Logger::info(const std::wstring& msg) const
+{
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg);
+ }
}
void Logger::log(const LevelPtr& level1, const std::wstring& message,
- const log4cxx::spi::LocationInfo& location) const {
- if (isEnabledFor(level1)) {
- forcedLog(level1, message, location);
+ const log4cxx::spi::LocationInfo& location) const
+{
+ if (isEnabledFor(level1))
+ {
+ forcedLog(level1, message, location);
}
}
-void Logger::log(const LevelPtr& level1, const std::wstring& message) const {
- if (isEnabledFor(level1)) {
- forcedLog(level1, message);
+void Logger::log(const LevelPtr& level1, const std::wstring& message) const
+{
+ 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);
- }
+void Logger::warn(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg, location);
+ }
}
-void Logger::warn(const std::wstring& msg) const {
- if (isWarnEnabled()) {
- forcedLog(log4cxx::Level::getWarn(), msg);
- }
+void Logger::warn(const std::wstring& msg) const
+{
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg);
+ }
}
#endif
@@ -742,118 +814,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 {
+void Logger::getName(std::basic_string<UniChar>& rv) const
+{
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);
- }
+void Logger::trace(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ 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);
- }
+void Logger::trace(const std::basic_string<UniChar>& msg) const
+{
+ 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);
- }
+void Logger::debug(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ 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);
- }
+void Logger::debug(const std::basic_string<UniChar>& msg) const
+{
+ 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);
- }
+void Logger::error(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ 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);
- }
+void Logger::error(const std::basic_string<UniChar>& msg) const
+{
+ 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);
- }
+void Logger::fatal(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ 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);
- }
+void Logger::fatal(const std::basic_string<UniChar>& msg) const
+{
+ 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);
- }
+void Logger::info(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ 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);
- }
+void Logger::info(const std::basic_string<UniChar>& msg) const
+{
+ 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 {
- if (isEnabledFor(level1)) {
- forcedLog(level1, message, location);
+ const log4cxx::spi::LocationInfo& location) const
+{
+ 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);
+void Logger::log(const LevelPtr& level1, const std::basic_string<UniChar>& message) const
+{
+ 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);
- }
+void Logger::warn(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ 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);
- }
+void Logger::warn(const std::basic_string<UniChar>& msg) const
+{
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg);
+ }
}
#endif
@@ -861,116 +962,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 {
+void Logger::getName(CFStringRef& rv) const
+{
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);
- }
+void Logger::trace(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isTraceEnabled())
+ {
+ forcedLog(log4cxx::Level::getTrace(), msg, location);
+ }
}
-void Logger::trace(const CFStringRef& msg) const {
- if (isTraceEnabled()) {
- forcedLog(log4cxx::Level::getTrace(), msg);
- }
+void Logger::trace(const CFStringRef& msg) const
+{
+ 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);
- }
+void Logger::debug(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isDebugEnabled())
+ {
+ forcedLog(log4cxx::Level::getDebug(), msg, location);
+ }
}
-void Logger::debug(const CFStringRef& msg) const {
- if (isDebugEnabled()) {
- forcedLog(log4cxx::Level::getDebug(), msg);
- }
+void Logger::debug(const CFStringRef& msg) const
+{
+ 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);
- }
+void Logger::error(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isErrorEnabled())
+ {
+ forcedLog(log4cxx::Level::getError(), msg, location);
+ }
}
-void Logger::error(const CFStringRef& msg) const {
- if (isErrorEnabled()) {
- forcedLog(log4cxx::Level::getError(), msg);
- }
+void Logger::error(const CFStringRef& msg) const
+{
+ 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);
- }
+void Logger::fatal(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isFatalEnabled())
+ {
+ forcedLog(log4cxx::Level::getFatal(), msg, location);
+ }
}
-void Logger::fatal(const CFStringRef& msg) const {
- if (isFatalEnabled()) {
- forcedLog(log4cxx::Level::getFatal(), msg);
- }
+void Logger::fatal(const CFStringRef& msg) const
+{
+ 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);
- }
+void Logger::info(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg, location);
+ }
}
-void Logger::info(const CFStringRef& msg) const {
- if (isInfoEnabled()) {
- forcedLog(log4cxx::Level::getInfo(), msg);
- }
+void Logger::info(const CFStringRef& msg) const
+{
+ if (isInfoEnabled())
+ {
+ forcedLog(log4cxx::Level::getInfo(), msg);
+ }
}
void Logger::log(const LevelPtr& level1, const CFStringRef& message,
- const log4cxx::spi::LocationInfo& location) const {
- if (isEnabledFor(level1)) {
- forcedLog(level1, message, location);
+ const log4cxx::spi::LocationInfo& location) const
+{
+ if (isEnabledFor(level1))
+ {
+ forcedLog(level1, message, location);
}
}
-void Logger::log(const LevelPtr& level1, const CFStringRef& message) const {
- if (isEnabledFor(level1)) {
- forcedLog(level1, message);
+void Logger::log(const LevelPtr& level1, const CFStringRef& message) const
+{
+ 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);
- }
+void Logger::warn(const CFStringRef& msg, const log4cxx::spi::LocationInfo& location) const
+{
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg, location);
+ }
}
-void Logger::warn(const CFStringRef& msg) const {
- if (isWarnEnabled()) {
- forcedLog(log4cxx::Level::getWarn(), msg);
- }
+void Logger::warn(const CFStringRef& msg) const
+{
+ if (isWarnEnabled())
+ {
+ forcedLog(log4cxx::Level::getWarn(), msg);
+ }
}
#endif
diff --git a/src/main/cpp/loggermatchfilter.cpp b/src/main/cpp/loggermatchfilter.cpp
index 4a4d59f..3b7957b 100644
--- a/src/main/cpp/loggermatchfilter.cpp
+++ b/src/main/cpp/loggermatchfilter.cpp
@@ -30,46 +30,55 @@
LoggerMatchFilter::LoggerMatchFilter()
-: acceptOnMatch(true), loggerToMatch(LOG4CXX_STR("root"))
+ : acceptOnMatch(true), loggerToMatch(LOG4CXX_STR("root"))
{
}
-void LoggerMatchFilter::setLoggerToMatch(const LogString& value) {
+void LoggerMatchFilter::setLoggerToMatch(const LogString& value)
+{
loggerToMatch = value;
}
-LogString LoggerMatchFilter::getLoggerToMatch() const {
+LogString LoggerMatchFilter::getLoggerToMatch() const
+{
return loggerToMatch;
}
void LoggerMatchFilter::setOption(const LogString& option,
- const LogString& value)
+ const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("LOGGERTOMATCH"), LOG4CXX_STR("loggertomatch")))
- {
- setLoggerToMatch(value);
- }
- else if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("ACCEPTONMATCH"), LOG4CXX_STR("acceptonmatch")))
- {
- acceptOnMatch = OptionConverter::toBoolean(value, acceptOnMatch);
- }
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("LOGGERTOMATCH"), LOG4CXX_STR("loggertomatch")))
+ {
+ setLoggerToMatch(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("ACCEPTONMATCH"), LOG4CXX_STR("acceptonmatch")))
+ {
+ acceptOnMatch = OptionConverter::toBoolean(value, acceptOnMatch);
+ }
}
Filter::FilterDecision LoggerMatchFilter::decide(
- const spi::LoggingEventPtr& event) const
+ const spi::LoggingEventPtr& event) const
{
bool matchOccured = loggerToMatch == event->getLoggerName();
- if (matchOccured) {
- if (acceptOnMatch) {
- return Filter::ACCEPT;
- } else {
- return Filter::DENY;
- }
- } else {
- return Filter::NEUTRAL;
+
+ if (matchOccured)
+ {
+ if (acceptOnMatch)
+ {
+ return Filter::ACCEPT;
+ }
+ else
+ {
+ return Filter::DENY;
+ }
+ }
+ else
+ {
+ return Filter::NEUTRAL;
}
}
diff --git a/src/main/cpp/loggerpatternconverter.cpp b/src/main/cpp/loggerpatternconverter.cpp
index 2c5a677..bea407b 100644
--- a/src/main/cpp/loggerpatternconverter.cpp
+++ b/src/main/cpp/loggerpatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -31,25 +31,30 @@
IMPLEMENT_LOG4CXX_OBJECT(LoggerPatternConverter)
LoggerPatternConverter::LoggerPatternConverter(
- const std::vector<LogString>& options) :
- NamePatternConverter(LOG4CXX_STR("Logger"),
- LOG4CXX_STR("logger"), options) {
+ const std::vector<LogString>& options) :
+ NamePatternConverter(LOG4CXX_STR("Logger"),
+ LOG4CXX_STR("logger"), options)
+{
}
PatternConverterPtr LoggerPatternConverter::newInstance(
- const std::vector<LogString>& options) {
- if (options.size() == 0) {
- static PatternConverterPtr def(new LoggerPatternConverter(options));
- return def;
- }
- return new LoggerPatternConverter(options);
+ const std::vector<LogString>& options)
+{
+ if (options.size() == 0)
+ {
+ static PatternConverterPtr def(new LoggerPatternConverter(options));
+ return def;
+ }
+
+ return new LoggerPatternConverter(options);
}
void LoggerPatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- Pool& /* p */ ) const {
- int initialLength = toAppendTo.length();
- toAppendTo.append(event->getLoggerName());
- abbreviate(initialLength, toAppendTo);
- }
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ Pool& /* p */ ) const
+{
+ int initialLength = toAppendTo.length();
+ toAppendTo.append(event->getLoggerName());
+ abbreviate(initialLength, toAppendTo);
+}
diff --git a/src/main/cpp/loggingevent.cpp b/src/main/cpp/loggingevent.cpp
index 56140ad..f3ccc41 100644
--- a/src/main/cpp/loggingevent.cpp
+++ b/src/main/cpp/loggingevent.cpp
@@ -23,7 +23,7 @@
#include <log4cxx/helpers/system.h>
#include <log4cxx/helpers/socket.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/helpers/aprinitializer.h>
#include <log4cxx/helpers/threadspecificdata.h>
@@ -48,76 +48,84 @@
//
// Accessor for start time.
//
-log4cxx_time_t LoggingEvent::getStartTime() {
- return log4cxx::helpers::APRInitializer::initialize();
+log4cxx_time_t LoggingEvent::getStartTime()
+{
+ return log4cxx::helpers::APRInitializer::initialize();
}
LoggingEvent::LoggingEvent() :
- ndc(0),
- mdcCopy(0),
- properties(0),
- ndcLookupRequired(true),
- mdcCopyLookupRequired(true),
- timeStamp(0),
- locationInfo() {
+ ndc(0),
+ mdcCopy(0),
+ properties(0),
+ ndcLookupRequired(true),
+ mdcCopyLookupRequired(true),
+ timeStamp(0),
+ locationInfo()
+{
}
LoggingEvent::LoggingEvent(
- const LogString& logger1, const LevelPtr& level1,
- const LogString& message1, const LocationInfo& locationInfo1) :
- logger(logger1),
- level(level1),
- ndc(0),
- mdcCopy(0),
- properties(0),
- ndcLookupRequired(true),
- mdcCopyLookupRequired(true),
- message(message1),
- timeStamp(apr_time_now()),
- locationInfo(locationInfo1),
- threadName(getCurrentThreadName()) {
+ const LogString& logger1, const LevelPtr& level1,
+ const LogString& message1, const LocationInfo& locationInfo1) :
+ logger(logger1),
+ level(level1),
+ ndc(0),
+ mdcCopy(0),
+ properties(0),
+ ndcLookupRequired(true),
+ mdcCopyLookupRequired(true),
+ message(message1),
+ timeStamp(apr_time_now()),
+ locationInfo(locationInfo1),
+ threadName(getCurrentThreadName())
+{
}
LoggingEvent::~LoggingEvent()
{
- delete ndc;
- delete mdcCopy;
- delete properties;
+ delete ndc;
+ delete mdcCopy;
+ delete properties;
}
bool LoggingEvent::getNDC(LogString& dest) const
{
- if(ndcLookupRequired)
+ if (ndcLookupRequired)
+ {
+ ndcLookupRequired = false;
+ LogString val;
+
+ if (NDC::get(val))
{
- ndcLookupRequired = false;
- LogString val;
- if(NDC::get(val)) {
- ndc = new LogString(val);
- }
+ ndc = new LogString(val);
}
- if (ndc) {
- dest.append(*ndc);
- return true;
- }
- return false;
+ }
+
+ if (ndc)
+ {
+ dest.append(*ndc);
+ return true;
+ }
+
+ return false;
}
bool LoggingEvent::getMDC(const LogString& key, LogString& dest) const
{
- // Note the mdcCopy is used if it exists. Otherwise we use the MDC
+ // Note the mdcCopy is used if it exists. Otherwise we use the MDC
// that is associated with the thread.
if (mdcCopy != 0 && !mdcCopy->empty())
- {
- MDC::Map::const_iterator it = mdcCopy->find(key);
+ {
+ MDC::Map::const_iterator it = mdcCopy->find(key);
- if (it != mdcCopy->end())
- {
- if (!it->second.empty())
- {
- dest.append(it->second);
- return true;
- }
- }
+ if (it != mdcCopy->end())
+ {
+ if (!it->second.empty())
+ {
+ dest.append(it->second);
+ return true;
+ }
+ }
}
return MDC::get(key, dest);
@@ -126,117 +134,129 @@
LoggingEvent::KeySet LoggingEvent::getMDCKeySet() const
{
- LoggingEvent::KeySet set;
+ LoggingEvent::KeySet set;
- if (mdcCopy != 0 && !mdcCopy->empty())
+ if (mdcCopy != 0 && !mdcCopy->empty())
+ {
+ MDC::Map::const_iterator it;
+
+ for (it = mdcCopy->begin(); it != mdcCopy->end(); it++)
{
- MDC::Map::const_iterator it;
- for (it = mdcCopy->begin(); it != mdcCopy->end(); it++)
- {
- set.push_back(it->first);
+ set.push_back(it->first);
- }
}
- else
+ }
+ else
+ {
+ ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
+
+ if (data != 0)
{
- ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
- MDC::Map& m = data->getMap();
+ MDC::Map& m = data->getMap();
- for(MDC::Map::const_iterator it = m.begin(); it != m.end(); it++) {
- set.push_back(it->first);
- }
- }
+ for (MDC::Map::const_iterator it = m.begin(); it != m.end(); it++)
+ {
+ set.push_back(it->first);
+ }
}
+ }
- return set;
+ return set;
}
void LoggingEvent::getMDCCopy() const
{
- if(mdcCopyLookupRequired)
+ if (mdcCopyLookupRequired)
+ {
+ mdcCopyLookupRequired = false;
+ // the clone call is required for asynchronous logging.
+ ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
+
+ if (data != 0)
{
- mdcCopyLookupRequired = false;
- // the clone call is required for asynchronous logging.
- ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
- mdcCopy = new MDC::Map(data->getMap());
- } else {
- mdcCopy = new MDC::Map();
- }
- }
+ mdcCopy = new MDC::Map(data->getMap());
+ }
+ else
+ {
+ mdcCopy = new MDC::Map();
+ }
+ }
}
bool LoggingEvent::getProperty(const LogString& key, LogString& dest) const
{
- if (properties == 0)
- {
- return false;
- }
-
- std::map<LogString, LogString>::const_iterator it = properties->find(key);
-
- if (it != properties->end())
- {
- dest.append(it->second);
- return true;
- }
-
+ if (properties == 0)
+ {
return false;
+ }
+
+ std::map<LogString, LogString>::const_iterator it = properties->find(key);
+
+ if (it != properties->end())
+ {
+ dest.append(it->second);
+ return true;
+ }
+
+ return false;
}
LoggingEvent::KeySet LoggingEvent::getPropertyKeySet() const
{
- LoggingEvent::KeySet set;
+ LoggingEvent::KeySet set;
- if (properties != 0)
+ if (properties != 0)
+ {
+ std::map<LogString, LogString>::const_iterator it;
+
+ for (it = properties->begin(); it != properties->end(); it++)
{
- std::map<LogString, LogString>::const_iterator it;
- for (it = properties->begin(); it != properties->end(); it++)
- {
- set.push_back(it->first);
- }
+ set.push_back(it->first);
}
+ }
- return set;
+ return set;
}
-const LogString LoggingEvent::getCurrentThreadName() {
+const LogString LoggingEvent::getCurrentThreadName()
+{
#if APR_HAS_THREADS
#if defined(_WIN32)
- char result[20];
- DWORD threadId = GetCurrentThreadId();
- apr_snprintf(result, sizeof(result), LOG4CXX_WIN32_THREAD_FMTSPEC, threadId);
+ char result[20];
+ DWORD threadId = GetCurrentThreadId();
+ apr_snprintf(result, sizeof(result), LOG4CXX_WIN32_THREAD_FMTSPEC, threadId);
#else
- // apr_os_thread_t encoded in HEX takes needs as many characters
- // as two times the size of the type, plus an additional null byte.
- char result[sizeof(apr_os_thread_t) * 3 + 10];
- apr_os_thread_t threadId = apr_os_thread_current();
- apr_snprintf(result, sizeof(result), LOG4CXX_APR_THREAD_FMTSPEC, (void*) &threadId);
+ // apr_os_thread_t encoded in HEX takes needs as many characters
+ // as two times the size of the type, plus an additional null byte.
+ char result[sizeof(apr_os_thread_t) * 3 + 10];
+ apr_os_thread_t threadId = apr_os_thread_current();
+ apr_snprintf(result, sizeof(result), LOG4CXX_APR_THREAD_FMTSPEC, (void*) &threadId);
#endif
- LOG4CXX_DECODE_CHAR(str, (const char*) result);
- return str;
+ LOG4CXX_DECODE_CHAR(str, (const char*) result);
+ return str;
#else
- return LOG4CXX_STR("0x00000000");
+ return LOG4CXX_STR("0x00000000");
#endif
}
void LoggingEvent::setProperty(const LogString& key, const LogString& value)
{
- if (properties == 0)
- {
- properties = new std::map<LogString, LogString>;
- }
+ if (properties == 0)
+ {
+ properties = new std::map<LogString, LogString>;
+ }
- (*properties)[key] = value;
+ (*properties)[key] = value;
}
-void LoggingEvent::writeProlog(ObjectOutputStream& os, Pool& p) {
- unsigned char classDesc[] = {
+void LoggingEvent::writeProlog(ObjectOutputStream& os, Pool& p)
+{
+ unsigned char classDesc[] =
+ {
0x72, 0x00, 0x21,
0x6F, 0x72, 0x67, 0x2E, 0x61, 0x70, 0x61, 0x63,
0x68, 0x65, 0x2E, 0x6C, 0x6F, 0x67, 0x34, 0x6A,
@@ -289,38 +309,49 @@
0x73, 0x70, 0x69, 0x2F, 0x54, 0x68, 0x72, 0x6F,
0x77, 0x61, 0x62, 0x6C, 0x65, 0x49, 0x6E, 0x66,
0x6F, 0x72, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E,
- 0x3B, 0x78, 0x70 };
+ 0x3B, 0x78, 0x70
+ };
- os.writeProlog("org.apache.log4j.spi.LoggingEvent",
- 8, (char*) classDesc, sizeof(classDesc), p);
+ os.writeProlog("org.apache.log4j.spi.LoggingEvent",
+ 8, (char*) classDesc, sizeof(classDesc), p);
}
-void LoggingEvent::write(helpers::ObjectOutputStream& os, Pool& p) const {
- writeProlog(os, p);
- // mdc and ndc lookup required should always be false
- char lookupsRequired[] = { 0, 0 };
- os.writeBytes(lookupsRequired, sizeof(lookupsRequired), p);
- os.writeLong(timeStamp/1000, p);
- os.writeObject(logger, p);
- locationInfo.write(os, p);
- if (mdcCopy == 0 || mdcCopy->size() == 0) {
- os.writeNull(p);
- } else {
- os.writeObject(*mdcCopy, p);
- }
- if (ndc == 0) {
- os.writeNull(p);
- } else {
- os.writeObject(*ndc, p);
- }
- os.writeObject(message, p);
- os.writeObject(threadName, p);
- // throwable
- os.writeNull(p);
- os.writeByte(ObjectOutputStream::TC_BLOCKDATA, p);
- os.writeByte(0x04, p);
- os.writeInt(level->toInt(), p);
- os.writeNull(p);
- os.writeByte(ObjectOutputStream::TC_ENDBLOCKDATA, p);
+void LoggingEvent::write(helpers::ObjectOutputStream& os, Pool& p) const
+{
+ writeProlog(os, p);
+ // mdc and ndc lookup required should always be false
+ char lookupsRequired[] = { 0, 0 };
+ os.writeBytes(lookupsRequired, sizeof(lookupsRequired), p);
+ os.writeLong(timeStamp / 1000, p);
+ os.writeObject(logger, p);
+ locationInfo.write(os, p);
+
+ if (mdcCopy == 0 || mdcCopy->size() == 0)
+ {
+ os.writeNull(p);
+ }
+ else
+ {
+ os.writeObject(*mdcCopy, p);
+ }
+
+ if (ndc == 0)
+ {
+ os.writeNull(p);
+ }
+ else
+ {
+ os.writeObject(*ndc, p);
+ }
+
+ os.writeObject(message, p);
+ os.writeObject(threadName, p);
+ // throwable
+ os.writeNull(p);
+ os.writeByte(ObjectOutputStream::TC_BLOCKDATA, p);
+ os.writeByte(0x04, p);
+ os.writeInt(level->toInt(), p);
+ os.writeNull(p);
+ os.writeByte(ObjectOutputStream::TC_ENDBLOCKDATA, p);
}
diff --git a/src/main/cpp/loggingeventpatternconverter.cpp b/src/main/cpp/loggingeventpatternconverter.cpp
index ce59965..c3ee7f1 100644
--- a/src/main/cpp/loggingeventpatternconverter.cpp
+++ b/src/main/cpp/loggingeventpatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -32,18 +32,23 @@
LoggingEventPatternConverter::LoggingEventPatternConverter(
- const LogString& name1, const LogString& style1) : PatternConverter(name1, style1) {
- }
+ const LogString& name1, const LogString& style1) : PatternConverter(name1, style1)
+{
+}
void LoggingEventPatternConverter::format(const ObjectPtr& obj,
- LogString& output,
- log4cxx::helpers::Pool& p) const {
+ LogString& output,
+ log4cxx::helpers::Pool& p) const
+{
LoggingEventPtr le(obj);
- if (le != NULL) {
- format(le, output, p);
+
+ if (le != NULL)
+ {
+ format(le, output, p);
}
}
-bool LoggingEventPatternConverter::handlesThrowable() const {
+bool LoggingEventPatternConverter::handlesThrowable() const
+{
return false;
}
diff --git a/src/main/cpp/loglog.cpp b/src/main/cpp/loglog.cpp
index dbe5d37..c811bad 100644
--- a/src/main/cpp/loglog.cpp
+++ b/src/main/cpp/loglog.cpp
@@ -20,7 +20,7 @@
#include <log4cxx/helpers/transcoder.h>
#include <iostream>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
#include <log4cxx/helpers/synchronized.h>
@@ -102,7 +102,7 @@
if (!getInstance().quietMode)
{
- emit(msg);
+ emit(msg);
}
}
@@ -132,10 +132,12 @@
if (raw != 0)
{
Transcoder::decode(raw, out);
- } else
+ }
+ else
{
out.append(LOG4CXX_STR("std::exception::what() == null"));
}
+
out.append(1, (logchar) 0x0A);
SystemErrWriter::write(out);
diff --git a/src/main/cpp/logmanager.cpp b/src/main/cpp/logmanager.cpp
index 1af3f43..e75f24d 100644
--- a/src/main/cpp/logmanager.cpp
+++ b/src/main/cpp/logmanager.cpp
@@ -17,7 +17,7 @@
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logmanager.h>
@@ -38,7 +38,7 @@
#include <log4cxx/file.h>
#include <log4cxx/helpers/transcoder.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/helpers/aprinitializer.h>
@@ -48,54 +48,55 @@
IMPLEMENT_LOG4CXX_OBJECT(DefaultRepositorySelector)
-void * LogManager::guard = 0;
+void* LogManager::guard = 0;
-RepositorySelectorPtr& LogManager::getRepositorySelector() {
- //
- // call to initialize APR and trigger "start" of logging clock
- //
- APRInitializer::initialize();
- static spi::RepositorySelectorPtr selector;
- return selector;
+RepositorySelectorPtr& LogManager::getRepositorySelector()
+{
+ //
+ // call to initialize APR and trigger "start" of logging clock
+ //
+ APRInitializer::initialize();
+ static spi::RepositorySelectorPtr selector;
+ return selector;
}
void LogManager::setRepositorySelector(spi::RepositorySelectorPtr selector,
- void * guard1)
+ void* guard1)
{
- if((LogManager::guard != 0) && (LogManager::guard != guard1))
- {
- throw IllegalArgumentException(LOG4CXX_STR("Attempted to reset the LoggerFactory without possessing the guard."));
- }
+ if ((LogManager::guard != 0) && (LogManager::guard != guard1))
+ {
+ throw IllegalArgumentException(LOG4CXX_STR("Attempted to reset the LoggerFactory without possessing the guard."));
+ }
- if(selector == 0)
- {
- throw IllegalArgumentException(LOG4CXX_STR("RepositorySelector must be non-null."));
- }
+ if (selector == 0)
+ {
+ throw IllegalArgumentException(LOG4CXX_STR("RepositorySelector must be non-null."));
+ }
- LogManager::guard = guard1;
- LogManager::getRepositorySelector() = selector;
+ LogManager::guard = guard1;
+ LogManager::getRepositorySelector() = selector;
}
LoggerRepositoryPtr& LogManager::getLoggerRepository()
{
- if (getRepositorySelector() == 0)
- {
- LoggerRepositoryPtr hierarchy(new Hierarchy());
- RepositorySelectorPtr selector(new DefaultRepositorySelector(hierarchy));
- getRepositorySelector() = selector;
- }
+ if (getRepositorySelector() == 0)
+ {
+ LoggerRepositoryPtr hierarchy(new Hierarchy());
+ RepositorySelectorPtr selector(new DefaultRepositorySelector(hierarchy));
+ getRepositorySelector() = selector;
+ }
- return getRepositorySelector()->getLoggerRepository();
+ return getRepositorySelector()->getLoggerRepository();
}
LoggerPtr LogManager::getRootLogger()
{
- // Delegate the actual manufacturing of the logger to the logger repository.
- return getLoggerRepository()->getRootLogger();
+ // Delegate the actual manufacturing of the logger to the logger repository.
+ return getLoggerRepository()->getRootLogger();
}
/**
@@ -103,109 +104,117 @@
*/
LoggerPtr LogManager::getLoggerLS(const LogString& name)
{
- return getLoggerRepository()->getLogger(name);
+ return getLoggerRepository()->getLogger(name);
}
/**
Retrieve the appropriate Logger instance.
*/
LoggerPtr LogManager::getLoggerLS(const LogString& name,
- const spi::LoggerFactoryPtr& factory)
+ const spi::LoggerFactoryPtr& factory)
{
- // Delegate the actual manufacturing of the logger to the logger repository.
- return getLoggerRepository()->getLogger(name, factory);
+ // Delegate the actual manufacturing of the logger to the logger repository.
+ return getLoggerRepository()->getLogger(name, factory);
}
-LoggerPtr LogManager::getLogger(const std::string& name) {
- LOG4CXX_DECODE_CHAR(n, name);
- return getLoggerLS(n);
+LoggerPtr LogManager::getLogger(const std::string& name)
+{
+ LOG4CXX_DECODE_CHAR(n, name);
+ return getLoggerLS(n);
}
LoggerPtr LogManager::getLogger(const std::string& name,
- const spi::LoggerFactoryPtr& factory) {
- LOG4CXX_DECODE_CHAR(n, name);
- return getLoggerLS(n, factory);
+ const spi::LoggerFactoryPtr& factory)
+{
+ LOG4CXX_DECODE_CHAR(n, name);
+ return getLoggerLS(n, factory);
}
LoggerPtr LogManager::exists(const std::string& name)
{
- LOG4CXX_DECODE_CHAR(n, name);
- return existsLS(n);
+ LOG4CXX_DECODE_CHAR(n, name);
+ return existsLS(n);
}
#if LOG4CXX_WCHAR_T_API
-LoggerPtr LogManager::getLogger(const std::wstring& name) {
- LOG4CXX_DECODE_WCHAR(n, name);
- return getLoggerLS(n);
+LoggerPtr LogManager::getLogger(const std::wstring& name)
+{
+ LOG4CXX_DECODE_WCHAR(n, name);
+ return getLoggerLS(n);
}
LoggerPtr LogManager::getLogger(const std::wstring& name,
- const spi::LoggerFactoryPtr& factory) {
- LOG4CXX_DECODE_WCHAR(n, name);
- return getLoggerLS(n, factory);
+ const spi::LoggerFactoryPtr& factory)
+{
+ LOG4CXX_DECODE_WCHAR(n, name);
+ return getLoggerLS(n, factory);
}
LoggerPtr LogManager::exists(const std::wstring& name)
{
- LOG4CXX_DECODE_WCHAR(n, name);
- return existsLS(n);
+ LOG4CXX_DECODE_WCHAR(n, name);
+ return existsLS(n);
}
#endif
#if LOG4CXX_UNICHAR_API
-LoggerPtr LogManager::getLogger(const std::basic_string<UniChar>& name) {
- LOG4CXX_DECODE_UNICHAR(n, name);
- return getLoggerLS(n);
+LoggerPtr LogManager::getLogger(const std::basic_string<UniChar>& name)
+{
+ LOG4CXX_DECODE_UNICHAR(n, name);
+ return getLoggerLS(n);
}
LoggerPtr LogManager::getLogger(const std::basic_string<UniChar>& name,
- const spi::LoggerFactoryPtr& factory) {
- LOG4CXX_DECODE_UNICHAR(n, name);
- return getLoggerLS(n, factory);
+ const spi::LoggerFactoryPtr& factory)
+{
+ LOG4CXX_DECODE_UNICHAR(n, name);
+ return getLoggerLS(n, factory);
}
LoggerPtr LogManager::exists(const std::basic_string<UniChar>& name)
{
- LOG4CXX_DECODE_UNICHAR(n, name);
- return existsLS(n);
+ LOG4CXX_DECODE_UNICHAR(n, name);
+ return existsLS(n);
}
#endif
#if LOG4CXX_CFSTRING_API
-LoggerPtr LogManager::getLogger(const CFStringRef& name) {
- LOG4CXX_DECODE_CFSTRING(n, name);
- return getLoggerLS(n);
+LoggerPtr LogManager::getLogger(const CFStringRef& name)
+{
+ LOG4CXX_DECODE_CFSTRING(n, name);
+ return getLoggerLS(n);
}
LoggerPtr LogManager::getLogger(const CFStringRef& name,
- const spi::LoggerFactoryPtr& factory) {
- LOG4CXX_DECODE_CFSTRING(n, name);
- return getLoggerLS(n, factory);
+ const spi::LoggerFactoryPtr& factory)
+{
+ LOG4CXX_DECODE_CFSTRING(n, name);
+ return getLoggerLS(n, factory);
}
LoggerPtr LogManager::exists(const CFStringRef& name)
{
- LOG4CXX_DECODE_CFSTRING(n, name);
- return existsLS(n);
+ LOG4CXX_DECODE_CFSTRING(n, name);
+ return existsLS(n);
}
#endif
LoggerPtr LogManager::existsLS(const LogString& name)
{
- return getLoggerRepository()->exists(name);
+ return getLoggerRepository()->exists(name);
}
LoggerList LogManager::getCurrentLoggers()
{
- return getLoggerRepository()->getCurrentLoggers();
+ return getLoggerRepository()->getCurrentLoggers();
}
void LogManager::shutdown()
{
- getLoggerRepository()->shutdown();
+ getLoggerRepository()->shutdown();
}
void LogManager::resetConfiguration()
{
- getLoggerRepository()->resetConfiguration();
+ getLoggerRepository()->resetConfiguration();
}
diff --git a/src/main/cpp/logstream.cpp b/src/main/cpp/logstream.cpp
index 74396ed..1470389 100644
--- a/src/main/cpp/logstream.cpp
+++ b/src/main/cpp/logstream.cpp
@@ -19,19 +19,20 @@
#include <log4cxx/stream.h>
#include <log4cxx/helpers/transcoder.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
using namespace log4cxx;
logstream_base::logstream_ios_base::logstream_ios_base(std::ios_base::fmtflags initval,
- int initsize) {
+ int initsize)
+{
#if LOG4CXX_MEMSET_IOS_BASE
- //
- // the destructor for std::ios_base in the MSVC STL
- // releases a pointer that was not initialized in the constructor.
- //
+ //
+ // the destructor for std::ios_base in the MSVC STL
+ // releases a pointer that was not initialized in the constructor.
+ //
memset(this, 0, sizeof(*this));
#endif
flags(initval);
@@ -42,55 +43,70 @@
logstream_base::logstream_base(const LoggerPtr& log,
- const LevelPtr& lvl) : initset((std::ios_base::fmtflags) -1, 1),
- initclear((std::ios_base::fmtflags) 0, 0), fillchar(0), fillset(false), logger(log), level(lvl), location() {
- enabled = logger->isEnabledFor(level);
+ const LevelPtr& lvl) : initset((std::ios_base::fmtflags) - 1, 1),
+ initclear((std::ios_base::fmtflags) 0, 0), fillchar(0), fillset(false), logger(log), level(lvl), location()
+{
+ enabled = logger->isEnabledFor(level);
}
-logstream_base::~logstream_base() {
+logstream_base::~logstream_base()
+{
}
-void logstream_base::insert(std::ios_base& (*manip)(std::ios_base&)) {
+void logstream_base::insert(std::ios_base & (*manip)(std::ios_base&))
+{
get_stream_state(initclear, initset, fillchar, fillset);
(*manip)(initset);
(*manip)(initclear);
refresh_stream_state();
}
-bool logstream_base::set_stream_state(std::ios_base& dest, int& dstchar) {
- std::ios_base::fmtflags setval = initset.flags();
- std::ios_base::fmtflags clrval = initclear.flags();
- std::ios_base::fmtflags mask = setval ^ (~clrval);
- dest.setf(clrval, mask);
- if (initset.precision() == initclear.precision()) {
- dest.precision(initset.precision());
- }
- if (initset.width() == initclear.width()) {
- dest.width(initset.width());
- }
- dstchar = fillchar;
- return fillset;
+bool logstream_base::set_stream_state(std::ios_base& dest, int& dstchar)
+{
+ std::ios_base::fmtflags setval = initset.flags();
+ std::ios_base::fmtflags clrval = initclear.flags();
+ std::ios_base::fmtflags mask = setval ^ (~clrval);
+ dest.setf(clrval, mask);
+
+ if (initset.precision() == initclear.precision())
+ {
+ dest.precision(initset.precision());
+ }
+
+ if (initset.width() == initclear.width())
+ {
+ dest.width(initset.width());
+ }
+
+ dstchar = fillchar;
+ return fillset;
}
-logstream_base& logstream_base::endmsg(logstream_base& stream) {
- stream.end_message();
- return stream;
+logstream_base& logstream_base::endmsg(logstream_base& stream)
+{
+ stream.end_message();
+ return stream;
}
-logstream_base& logstream_base::nop(logstream_base& stream) {
- return stream;
+logstream_base& logstream_base::nop(logstream_base& stream)
+{
+ return stream;
}
-void logstream_base::end_message() {
- if (isEnabled()) {
- log(logger, level, location);
- }
- erase();
+void logstream_base::end_message()
+{
+ if (isEnabled())
+ {
+ log(logger, level, location);
+ }
+
+ erase();
}
-int log4cxx::logstream_base::precision(int p) {
+int log4cxx::logstream_base::precision(int p)
+{
get_stream_state(initclear, initset, fillchar, fillset);
initset.precision(p);
int oldVal = initclear.precision(p);
@@ -98,12 +114,14 @@
return oldVal;
}
-int log4cxx::logstream_base::precision() {
+int log4cxx::logstream_base::precision()
+{
get_stream_state(initclear, initset, fillchar, fillset);
- return initclear.precision();
+ return initclear.precision();
}
-int log4cxx::logstream_base::width(int w) {
+int log4cxx::logstream_base::width(int w)
+{
get_stream_state(initclear, initset, fillchar, fillset);
initset.width(w);
int oldVal = initclear.width(w);
@@ -111,12 +129,14 @@
return oldVal;
}
-int log4cxx::logstream_base::width() {
+int log4cxx::logstream_base::width()
+{
get_stream_state(initclear, initset, fillchar, fillset);
return initclear.width();
}
-int log4cxx::logstream_base::fill(int newfill) {
+int log4cxx::logstream_base::fill(int newfill)
+{
get_stream_state(initclear, initset, fillchar, fillset);
int oldfill = fillchar;
fillchar = newfill;
@@ -125,12 +145,14 @@
return oldfill;
}
-int logstream_base::fill() {
+int logstream_base::fill()
+{
get_stream_state(initclear, initset, fillchar, fillset);
return fillchar;
}
-std::ios_base::fmtflags logstream_base::flags(std::ios_base::fmtflags newflags) {
+std::ios_base::fmtflags logstream_base::flags(std::ios_base::fmtflags newflags)
+{
get_stream_state(initclear, initset, fillchar, fillset);
initset.flags(newflags);
std::ios_base::fmtflags oldVal = initclear.flags(newflags);
@@ -138,7 +160,8 @@
return oldVal;
}
-std::ios_base::fmtflags logstream_base::setf(std::ios_base::fmtflags newflags, std::ios_base::fmtflags mask) {
+std::ios_base::fmtflags logstream_base::setf(std::ios_base::fmtflags newflags, std::ios_base::fmtflags mask)
+{
get_stream_state(initclear, initset, fillchar, fillset);
initset.setf(newflags, mask);
std::ios_base::fmtflags oldVal = initclear.setf(newflags, mask);
@@ -146,7 +169,8 @@
return oldVal;
}
-std::ios_base::fmtflags logstream_base::setf(std::ios_base::fmtflags newflags) {
+std::ios_base::fmtflags logstream_base::setf(std::ios_base::fmtflags newflags)
+{
get_stream_state(initclear, initset, fillchar, fillset);
initset.setf(newflags);
std::ios_base::fmtflags oldVal = initclear.setf(newflags);
@@ -156,248 +180,305 @@
-void logstream_base::setLevel(const ::log4cxx::LevelPtr& newlevel) {
+void logstream_base::setLevel(const ::log4cxx::LevelPtr& newlevel)
+{
level = newlevel;
bool oldLevel = enabled;
enabled = logger->isEnabledFor(level);
- if (oldLevel != enabled) {
+
+ if (oldLevel != enabled)
+ {
erase();
}
}
-bool logstream_base::isEnabledFor(const ::log4cxx::LevelPtr& l) const {
+bool logstream_base::isEnabledFor(const ::log4cxx::LevelPtr& l) const
+{
return logger->isEnabledFor(l);
}
-void logstream_base::setLocation(const log4cxx::spi::LocationInfo& newlocation) {
- if (LOG4CXX_UNLIKELY(enabled)) {
+void logstream_base::setLocation(const log4cxx::spi::LocationInfo& newlocation)
+{
+ if (LOG4CXX_UNLIKELY(enabled))
+ {
location = newlocation;
}
}
logstream::logstream(const log4cxx::LoggerPtr& logger,
- const log4cxx::LevelPtr& level) : logstream_base(logger, level), stream(0) {
+ const log4cxx::LevelPtr& level) : logstream_base(logger, level), stream(0)
+{
}
logstream::logstream(const Ch* loggerName,
- const log4cxx::LevelPtr& level)
- : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0) {
+ const log4cxx::LevelPtr& level)
+ : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0)
+{
}
logstream::logstream(const std::basic_string<Ch>& loggerName,
- const log4cxx::LevelPtr& level) : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0) {
+ const log4cxx::LevelPtr& level) : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0)
+{
}
-logstream::~logstream() {
+logstream::~logstream()
+{
delete stream;
}
-logstream& logstream::operator<<(logstream_base& (*manip)(logstream_base&)) {
+logstream& logstream::operator<<(logstream_base & (*manip)(logstream_base&))
+{
(*manip)(*this);
return *this;
}
-logstream& logstream::operator<<(const LevelPtr& l) {
+logstream& logstream::operator<<(const LevelPtr& l)
+{
setLevel(l);
return *this;
}
-logstream& logstream::operator<<(const log4cxx::spi::LocationInfo& newlocation) {
- setLocation(newlocation);
- return *this;
+logstream& logstream::operator<<(const log4cxx::spi::LocationInfo& newlocation)
+{
+ setLocation(newlocation);
+ return *this;
}
-logstream& logstream::operator>>(const log4cxx::spi::LocationInfo& newlocation) {
- setLocation(newlocation);
- return *this;
+logstream& logstream::operator>>(const log4cxx::spi::LocationInfo& newlocation)
+{
+ setLocation(newlocation);
+ return *this;
}
-logstream& logstream::operator<<(std::ios_base& (*manip)(std::ios_base&)) {
- logstream_base::insert(manip);
- return *this;
+logstream& logstream::operator<<(std::ios_base & (*manip)(std::ios_base&))
+{
+ logstream_base::insert(manip);
+ return *this;
}
-logstream::operator std::basic_ostream<char>&() {
- if (stream == 0) {
- stream = new std::basic_stringstream<Ch>();
- refresh_stream_state();
- }
- return *stream;
+logstream::operator std::basic_ostream<char>& ()
+{
+ if (stream == 0)
+ {
+ stream = new std::basic_stringstream<Ch>();
+ refresh_stream_state();
+ }
+
+ return *stream;
}
void logstream::log(LoggerPtr& log,
- const LevelPtr& lev,
- const log4cxx::spi::LocationInfo& loc) {
- if (stream != 0) {
+ const LevelPtr& lev,
+ const log4cxx::spi::LocationInfo& loc)
+{
+ if (stream != 0)
+ {
std::basic_string<Ch> msg = stream->str();
- if (!msg.empty()) {
+
+ if (!msg.empty())
+ {
log->log(lev, msg, loc);
}
}
}
-void logstream::erase() {
- if (stream != 0) {
- std::basic_string<Ch> emptyStr;
- stream->str(emptyStr);
- }
+void logstream::erase()
+{
+ if (stream != 0)
+ {
+ std::basic_string<Ch> emptyStr;
+ stream->str(emptyStr);
+ }
}
void logstream::get_stream_state(std::ios_base& base,
- std::ios_base& mask,
- int& fill,
- bool& fillSet) const {
- if (stream != 0) {
- std::ios_base::fmtflags flags = stream->flags();
- base.flags(flags);
- mask.flags(flags);
- int width = stream->width();
- base.width(width);
- mask.width(width);
- int precision = stream->precision();
- base.precision(precision);
- mask.precision(precision);
- fill = stream->fill();
- fillSet = true;
- }
+ std::ios_base& mask,
+ int& fill,
+ bool& fillSet) const
+{
+ if (stream != 0)
+ {
+ std::ios_base::fmtflags flags = stream->flags();
+ base.flags(flags);
+ mask.flags(flags);
+ int width = stream->width();
+ base.width(width);
+ mask.width(width);
+ int precision = stream->precision();
+ base.precision(precision);
+ mask.precision(precision);
+ fill = stream->fill();
+ fillSet = true;
+ }
}
-void logstream::refresh_stream_state() {
- if (stream != 0) {
- int ch;
- if(logstream_base::set_stream_state(*stream, ch)) {
- stream->fill(ch);
- }
- }
+void logstream::refresh_stream_state()
+{
+ if (stream != 0)
+ {
+ int ch;
+
+ if (logstream_base::set_stream_state(*stream, ch))
+ {
+ stream->fill(ch);
+ }
+ }
}
#if LOG4CXX_WCHAR_T_API
wlogstream::wlogstream(const log4cxx::LoggerPtr& logger,
- const log4cxx::LevelPtr& level) : logstream_base(logger, level), stream(0) {
+ const log4cxx::LevelPtr& level) : logstream_base(logger, level), stream(0)
+{
}
wlogstream::wlogstream(const Ch* loggerName,
- const log4cxx::LevelPtr& level)
- : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0) {
+ const log4cxx::LevelPtr& level)
+ : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0)
+{
}
wlogstream::wlogstream(const std::basic_string<Ch>& loggerName,
- const log4cxx::LevelPtr& level) : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0) {
+ const log4cxx::LevelPtr& level) : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0)
+{
}
-wlogstream::~wlogstream() {
+wlogstream::~wlogstream()
+{
delete stream;
}
-wlogstream& wlogstream::operator<<(logstream_base& (*manip)(logstream_base&)) {
+wlogstream& wlogstream::operator<<(logstream_base & (*manip)(logstream_base&))
+{
(*manip)(*this);
return *this;
}
-wlogstream& wlogstream::operator<<(const LevelPtr& l) {
+wlogstream& wlogstream::operator<<(const LevelPtr& l)
+{
setLevel(l);
return *this;
}
-wlogstream& wlogstream::operator<<(const log4cxx::spi::LocationInfo& newlocation) {
- setLocation(newlocation);
- return *this;
+wlogstream& wlogstream::operator<<(const log4cxx::spi::LocationInfo& newlocation)
+{
+ setLocation(newlocation);
+ return *this;
}
-wlogstream& wlogstream::operator>>(const log4cxx::spi::LocationInfo& newlocation) {
- setLocation(newlocation);
- return *this;
+wlogstream& wlogstream::operator>>(const log4cxx::spi::LocationInfo& newlocation)
+{
+ setLocation(newlocation);
+ return *this;
}
-wlogstream& wlogstream::operator<<(std::ios_base& (*manip)(std::ios_base&)) {
- logstream_base::insert(manip);
- return *this;
+wlogstream& wlogstream::operator<<(std::ios_base & (*manip)(std::ios_base&))
+{
+ logstream_base::insert(manip);
+ return *this;
}
-wlogstream::operator std::basic_ostream<wchar_t>&() {
- if (stream == 0) {
- stream = new std::basic_stringstream<Ch>();
- refresh_stream_state();
- }
- return *stream;
+wlogstream::operator std::basic_ostream<wchar_t>& ()
+{
+ if (stream == 0)
+ {
+ stream = new std::basic_stringstream<Ch>();
+ refresh_stream_state();
+ }
+
+ return *stream;
}
void wlogstream::log(LoggerPtr& log,
- const LevelPtr& lev,
- const log4cxx::spi::LocationInfo& loc) {
- if (stream != 0) {
+ const LevelPtr& lev,
+ const log4cxx::spi::LocationInfo& loc)
+{
+ if (stream != 0)
+ {
std::basic_string<Ch> msg = stream->str();
- if (!msg.empty()) {
+
+ if (!msg.empty())
+ {
log->log(lev, msg, loc);
}
}
}
-void wlogstream::erase() {
- if (stream != 0) {
- std::basic_string<Ch> emptyStr;
- stream->str(emptyStr);
- }
+void wlogstream::erase()
+{
+ if (stream != 0)
+ {
+ std::basic_string<Ch> emptyStr;
+ stream->str(emptyStr);
+ }
}
void wlogstream::get_stream_state(std::ios_base& base,
- std::ios_base& mask,
- int& fill,
- bool& fillSet) const {
- if (stream != 0) {
- std::ios_base::fmtflags flags = stream->flags();
- base.flags(flags);
- mask.flags(flags);
- int width = stream->width();
- base.width(width);
- mask.width(width);
- int precision = stream->precision();
- base.precision(precision);
- mask.precision(precision);
- fill = stream->fill();
- fillSet = true;
- }
+ std::ios_base& mask,
+ int& fill,
+ bool& fillSet) const
+{
+ if (stream != 0)
+ {
+ std::ios_base::fmtflags flags = stream->flags();
+ base.flags(flags);
+ mask.flags(flags);
+ int width = stream->width();
+ base.width(width);
+ mask.width(width);
+ int precision = stream->precision();
+ base.precision(precision);
+ mask.precision(precision);
+ fill = stream->fill();
+ fillSet = true;
+ }
}
-void wlogstream::refresh_stream_state() {
- if (stream != 0) {
- int ch;
- if(logstream_base::set_stream_state(*stream, ch)) {
- stream->fill(ch);
- }
- }
+void wlogstream::refresh_stream_state()
+{
+ if (stream != 0)
+ {
+ int ch;
+
+ if (logstream_base::set_stream_state(*stream, ch))
+ {
+ stream->fill(ch);
+ }
+ }
}
#endif
#if LOG4CXX_UNICHAR_API
ulogstream::ulogstream(const Ch* loggerName,
- const log4cxx::LevelPtr& level)
- : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0) {
+ const log4cxx::LevelPtr& level)
+ : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0)
+{
}
ulogstream::ulogstream(const std::basic_string<Ch>& loggerName,
- const log4cxx::LevelPtr& level) : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0) {
+ const log4cxx::LevelPtr& level) : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0)
+{
}
#endif
#if LOG4CXX_CFSTRING_API
ulogstream::ulogstream(const CFStringRef& loggerName,
- const log4cxx::LevelPtr& level)
- : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0) {
+ const log4cxx::LevelPtr& level)
+ : logstream_base(log4cxx::Logger::getLogger(loggerName), level), stream(0)
+{
}
#endif
@@ -406,57 +487,71 @@
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
ulogstream::ulogstream(const log4cxx::LoggerPtr& logger,
- const log4cxx::LevelPtr& level) : logstream_base(logger, level), stream(0) {
+ const log4cxx::LevelPtr& level) : logstream_base(logger, level), stream(0)
+{
}
-ulogstream::~ulogstream() {
+ulogstream::~ulogstream()
+{
delete stream;
}
-ulogstream& ulogstream::operator<<(logstream_base& (*manip)(logstream_base&)) {
+ulogstream& ulogstream::operator<<(logstream_base & (*manip)(logstream_base&))
+{
(*manip)(*this);
return *this;
}
-ulogstream& ulogstream::operator<<(const LevelPtr& level) {
+ulogstream& ulogstream::operator<<(const LevelPtr& level)
+{
setLevel(level);
return *this;
}
-ulogstream& ulogstream::operator<<(const log4cxx::spi::LocationInfo& newlocation) {
- setLocation(newlocation);
- return *this;
+ulogstream& ulogstream::operator<<(const log4cxx::spi::LocationInfo& newlocation)
+{
+ setLocation(newlocation);
+ return *this;
}
-ulogstream& ulogstream::operator>>(const log4cxx::spi::LocationInfo& newlocation) {
- setLocation(newlocation);
- return *this;
+ulogstream& ulogstream::operator>>(const log4cxx::spi::LocationInfo& newlocation)
+{
+ setLocation(newlocation);
+ return *this;
}
-ulogstream& ulogstream::operator<<(std::ios_base& (*manip)(std::ios_base&)) {
- logstream_base::insert(manip);
- return *this;
+ulogstream& ulogstream::operator<<(std::ios_base & (*manip)(std::ios_base&))
+{
+ logstream_base::insert(manip);
+ return *this;
}
-ulogstream::operator std::basic_ostream<UniChar>&() {
- if (stream == 0) {
- stream = new std::basic_stringstream<Ch>();
- refresh_stream_state();
- }
- return *stream;
+ulogstream::operator std::basic_ostream<UniChar>& ()
+{
+ if (stream == 0)
+ {
+ stream = new std::basic_stringstream<Ch>();
+ refresh_stream_state();
+ }
+
+ return *stream;
}
void ulogstream::log(LoggerPtr& logger,
- const LevelPtr& level,
- const log4cxx::spi::LocationInfo& location) {
- if (stream != 0) {
+ const LevelPtr& level,
+ const log4cxx::spi::LocationInfo& location)
+{
+ if (stream != 0)
+ {
std::basic_string<Ch> msg = stream->str();
- if (!msg.empty() && logger->isEnabledFor(level)) {
+
+ if (!msg.empty() && logger->isEnabledFor(level))
+ {
LOG4CXX_DECODE_UNICHAR(lsmsg, msg);
logger->forcedLogLS(level, lsmsg, location);
}
@@ -464,40 +559,48 @@
}
-void ulogstream::erase() {
- if (stream != 0) {
- std::basic_string<Ch> emptyStr;
- stream->str(emptyStr);
- }
+void ulogstream::erase()
+{
+ if (stream != 0)
+ {
+ std::basic_string<Ch> emptyStr;
+ stream->str(emptyStr);
+ }
}
void ulogstream::get_stream_state(std::ios_base& base,
- std::ios_base& mask,
- int& fill,
- bool& fillSet) const {
- if (stream != 0) {
- std::ios_base::fmtflags flags = stream->flags();
- base.flags(flags);
- mask.flags(flags);
- int width = stream->width();
- base.width(width);
- mask.width(width);
- int precision = stream->precision();
- base.precision(precision);
- mask.precision(precision);
- fill = stream->fill();
- fillSet = true;
- }
+ std::ios_base& mask,
+ int& fill,
+ bool& fillSet) const
+{
+ if (stream != 0)
+ {
+ std::ios_base::fmtflags flags = stream->flags();
+ base.flags(flags);
+ mask.flags(flags);
+ int width = stream->width();
+ base.width(width);
+ mask.width(width);
+ int precision = stream->precision();
+ base.precision(precision);
+ mask.precision(precision);
+ fill = stream->fill();
+ fillSet = true;
+ }
}
-void ulogstream::refresh_stream_state() {
- if (stream != 0) {
- int fillchar;
- if(logstream_base::set_stream_state(*stream, fillchar)) {
- stream->fill(fillchar);
- }
- }
+void ulogstream::refresh_stream_state()
+{
+ if (stream != 0)
+ {
+ int fillchar;
+
+ if (logstream_base::set_stream_state(*stream, fillchar))
+ {
+ stream->fill(fillchar);
+ }
+ }
}
#endif
diff --git a/src/main/cpp/manualtriggeringpolicy.cpp b/src/main/cpp/manualtriggeringpolicy.cpp
index 5d8958e..b46f64d 100644
--- a/src/main/cpp/manualtriggeringpolicy.cpp
+++ b/src/main/cpp/manualtriggeringpolicy.cpp
@@ -25,18 +25,22 @@
IMPLEMENT_LOG4CXX_OBJECT(ManualTriggeringPolicy)
-ManualTriggeringPolicy::ManualTriggeringPolicy() {
+ManualTriggeringPolicy::ManualTriggeringPolicy()
+{
}
bool ManualTriggeringPolicy::isTriggeringEvent(Appender* /* appender */,
- const log4cxx::spi::LoggingEventPtr& /* event */,
- const LogString& /* file */,
- size_t /* fileLength */ ) {
- return false;
+ const log4cxx::spi::LoggingEventPtr& /* event */,
+ const LogString& /* file */,
+ size_t /* fileLength */ )
+{
+ return false;
}
-void ManualTriggeringPolicy::activateOptions(Pool& /* p */ ) {
+void ManualTriggeringPolicy::activateOptions(Pool& /* p */ )
+{
}
-void ManualTriggeringPolicy::setOption(const LogString& /* option */ , const LogString& /* value */ ) {
+void ManualTriggeringPolicy::setOption(const LogString& /* option */, const LogString& /* value */ )
+{
}
diff --git a/src/main/cpp/mdc.cpp b/src/main/cpp/mdc.cpp
index a91bef6..79b4c9d 100644
--- a/src/main/cpp/mdc.cpp
+++ b/src/main/cpp/mdc.cpp
@@ -20,7 +20,7 @@
#include <log4cxx/helpers/threadspecificdata.h>
#if LOG4CXX_CFSTRING_API
-#include <CoreFoundation/CFString.h>
+ #include <CoreFoundation/CFString.h>
#endif
@@ -29,208 +29,247 @@
MDC::MDC(const std::string& key1, const std::string& value) : key()
{
- Transcoder::decode(key1, key);
- LOG4CXX_DECODE_CHAR(v, value);
- putLS(key, v);
+ Transcoder::decode(key1, key);
+ LOG4CXX_DECODE_CHAR(v, value);
+ putLS(key, v);
}
MDC::~MDC()
{
- LogString prevVal;
- remove(key, prevVal);
+ LogString prevVal;
+ remove(key, prevVal);
}
void MDC::putLS(const LogString& key, const LogString& value)
{
- ThreadSpecificData::put(key, value);
+ ThreadSpecificData::put(key, value);
}
void MDC::put(const std::string& key, const std::string& value)
{
- LOG4CXX_DECODE_CHAR(lkey, key);
- LOG4CXX_DECODE_CHAR(lvalue, value);
- putLS(lkey, lvalue);
+ LOG4CXX_DECODE_CHAR(lkey, key);
+ LOG4CXX_DECODE_CHAR(lvalue, value);
+ putLS(lkey, lvalue);
}
bool MDC::get(const LogString& key, LogString& value)
{
- ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
- Map& map = data->getMap();
+ ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- Map::iterator it = map.find(key);
- if (it != map.end()) {
- value.append(it->second);
- return true;
- }
- data->recycle();
+ if (data != 0)
+ {
+ Map& map = data->getMap();
+
+ Map::iterator it = map.find(key);
+
+ if (it != map.end())
+ {
+ value.append(it->second);
+ return true;
}
- return false;
+
+ data->recycle();
+ }
+
+ return false;
}
std::string MDC::get(const std::string& key)
{
- LOG4CXX_DECODE_CHAR(lkey, key);
- LogString lvalue;
- if (get(lkey, lvalue)) {
- LOG4CXX_ENCODE_CHAR(value, lvalue);
- return value;
- }
- return std::string();
+ LOG4CXX_DECODE_CHAR(lkey, key);
+ LogString lvalue;
+
+ if (get(lkey, lvalue))
+ {
+ LOG4CXX_ENCODE_CHAR(value, lvalue);
+ return value;
+ }
+
+ return std::string();
}
bool MDC::remove(const LogString& key, LogString& value)
{
- ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
- Map& map = data->getMap();
- Map::iterator it;
- if ((it = map.find(key)) != map.end()) {
- value = it->second;
- map.erase(it);
- data->recycle();
- return true;
- }
+ ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
+
+ if (data != 0)
+ {
+ Map& map = data->getMap();
+ Map::iterator it;
+
+ if ((it = map.find(key)) != map.end())
+ {
+ value = it->second;
+ map.erase(it);
+ data->recycle();
+ return true;
}
- return false;
+ }
+
+ return false;
}
std::string MDC::remove(const std::string& key)
{
- LOG4CXX_DECODE_CHAR(lkey, key);
- LogString lvalue;
- if (remove(lkey, lvalue)) {
- LOG4CXX_ENCODE_CHAR(value, lvalue);
- return value;
- }
- return std::string();
+ LOG4CXX_DECODE_CHAR(lkey, key);
+ LogString lvalue;
+
+ if (remove(lkey, lvalue))
+ {
+ LOG4CXX_ENCODE_CHAR(value, lvalue);
+ return value;
+ }
+
+ return std::string();
}
void MDC::clear()
{
- ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
- Map& map = data->getMap();
- map.erase(map.begin(), map.end());
- data->recycle();
- }
+ ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
+
+ if (data != 0)
+ {
+ Map& map = data->getMap();
+ map.erase(map.begin(), map.end());
+ data->recycle();
+ }
}
#if LOG4CXX_WCHAR_T_API
MDC::MDC(const std::wstring& key1, const std::wstring& value) : key()
{
- Transcoder::decode(key1, key);
- LOG4CXX_DECODE_WCHAR(v, value);
- putLS(key, v);
+ Transcoder::decode(key1, key);
+ LOG4CXX_DECODE_WCHAR(v, value);
+ putLS(key, v);
}
std::wstring MDC::get(const std::wstring& key)
{
- LOG4CXX_DECODE_WCHAR(lkey, key);
- LogString lvalue;
- if (get(lkey, lvalue)) {
- LOG4CXX_ENCODE_WCHAR(value, lvalue);
- return value;
- }
- return std::wstring();
+ LOG4CXX_DECODE_WCHAR(lkey, key);
+ LogString lvalue;
+
+ if (get(lkey, lvalue))
+ {
+ LOG4CXX_ENCODE_WCHAR(value, lvalue);
+ return value;
+ }
+
+ return std::wstring();
}
void MDC::put(const std::wstring& key, const std::wstring& value)
{
- LOG4CXX_DECODE_WCHAR(lkey, key);
- LOG4CXX_DECODE_WCHAR(lvalue, value);
- putLS(lkey, lvalue);
+ LOG4CXX_DECODE_WCHAR(lkey, key);
+ LOG4CXX_DECODE_WCHAR(lvalue, value);
+ putLS(lkey, lvalue);
}
std::wstring MDC::remove(const std::wstring& key)
{
- LOG4CXX_DECODE_WCHAR(lkey, key);
- LogString lvalue;
- if (remove(lkey, lvalue)) {
- LOG4CXX_ENCODE_WCHAR(value, lvalue);
- return value;
- }
- return std::wstring();
+ LOG4CXX_DECODE_WCHAR(lkey, key);
+ LogString lvalue;
+
+ if (remove(lkey, lvalue))
+ {
+ LOG4CXX_ENCODE_WCHAR(value, lvalue);
+ return value;
+ }
+
+ return std::wstring();
}
#endif
#if LOG4CXX_UNICHAR_API
-MDC::MDC(const std::basic_string<UniChar>& key1, const std::basic_string<UniChar>& value) {
- Transcoder::decode(key1, key);
- LOG4CXX_DECODE_UNICHAR(v, value);
- putLS(key, v);
+MDC::MDC(const std::basic_string<UniChar>& key1, const std::basic_string<UniChar>& value)
+{
+ Transcoder::decode(key1, key);
+ LOG4CXX_DECODE_UNICHAR(v, value);
+ putLS(key, v);
}
std::basic_string<log4cxx::UniChar> MDC::get(const std::basic_string<log4cxx::UniChar>& key)
{
- LOG4CXX_DECODE_UNICHAR(lkey, key);
- LogString lvalue;
- if (get(lkey, lvalue)) {
- LOG4CXX_ENCODE_UNICHAR(value, lvalue);
- return value;
- }
- return std::basic_string<UniChar>();
+ LOG4CXX_DECODE_UNICHAR(lkey, key);
+ LogString lvalue;
+
+ if (get(lkey, lvalue))
+ {
+ LOG4CXX_ENCODE_UNICHAR(value, lvalue);
+ return value;
+ }
+
+ return std::basic_string<UniChar>();
}
void MDC::put(const std::basic_string<UniChar>& key, const std::basic_string<log4cxx::UniChar>& value)
{
- LOG4CXX_DECODE_UNICHAR(lkey, key);
- LOG4CXX_DECODE_UNICHAR(lvalue, value);
- putLS(lkey, lvalue);
+ LOG4CXX_DECODE_UNICHAR(lkey, key);
+ LOG4CXX_DECODE_UNICHAR(lvalue, value);
+ putLS(lkey, lvalue);
}
std::basic_string<log4cxx::UniChar> MDC::remove(const std::basic_string<log4cxx::UniChar>& key)
{
- LOG4CXX_DECODE_UNICHAR(lkey, key);
- LogString lvalue;
- if (remove(lkey, lvalue)) {
- LOG4CXX_ENCODE_UNICHAR(value, lvalue);
- return value;
- }
- return std::basic_string<UniChar>();
+ LOG4CXX_DECODE_UNICHAR(lkey, key);
+ LogString lvalue;
+
+ if (remove(lkey, lvalue))
+ {
+ LOG4CXX_ENCODE_UNICHAR(value, lvalue);
+ return value;
+ }
+
+ return std::basic_string<UniChar>();
}
#endif
#if LOG4CXX_CFSTRING_API
-MDC::MDC(const CFStringRef& key1, const CFStringRef& value) {
- Transcoder::decode(key1, key);
- LOG4CXX_DECODE_CFSTRING(v, value);
- putLS(key, v);
+MDC::MDC(const CFStringRef& key1, const CFStringRef& value)
+{
+ Transcoder::decode(key1, key);
+ LOG4CXX_DECODE_CFSTRING(v, value);
+ putLS(key, v);
}
CFStringRef MDC::get(const CFStringRef& key)
{
- LOG4CXX_DECODE_CFSTRING(lkey, key);
- LogString lvalue;
- if (get(lkey, lvalue)) {
- LOG4CXX_ENCODE_CFSTRING(value, lvalue);
- return value;
- }
- return CFSTR("");
+ LOG4CXX_DECODE_CFSTRING(lkey, key);
+ LogString lvalue;
+
+ if (get(lkey, lvalue))
+ {
+ LOG4CXX_ENCODE_CFSTRING(value, lvalue);
+ return value;
+ }
+
+ return CFSTR("");
}
void MDC::put(const CFStringRef& key, const CFStringRef& value)
{
- LOG4CXX_DECODE_CFSTRING(lkey, key);
- LOG4CXX_DECODE_CFSTRING(lvalue, value);
- putLS(lkey, lvalue);
+ LOG4CXX_DECODE_CFSTRING(lkey, key);
+ LOG4CXX_DECODE_CFSTRING(lvalue, value);
+ putLS(lkey, lvalue);
}
CFStringRef MDC::remove(const CFStringRef& key)
{
- LOG4CXX_DECODE_CFSTRING(lkey, key);
- LogString lvalue;
- if (remove(lkey, lvalue)) {
- LOG4CXX_ENCODE_CFSTRING(value, lvalue);
- return value;
- }
- return CFSTR("");
+ LOG4CXX_DECODE_CFSTRING(lkey, key);
+ LogString lvalue;
+
+ if (remove(lkey, lvalue))
+ {
+ LOG4CXX_ENCODE_CFSTRING(value, lvalue);
+ return value;
+ }
+
+ return CFSTR("");
}
#endif
diff --git a/src/main/cpp/messagebuffer.cpp b/src/main/cpp/messagebuffer.cpp
index e13d312..9c2b8b1 100644
--- a/src/main/cpp/messagebuffer.cpp
+++ b/src/main/cpp/messagebuffer.cpp
@@ -22,250 +22,384 @@
static bool gMessageBufferUseStaticStream = false;
-namespace log4cxx {
-namespace helpers {
- void MessageBufferUseStaticStream()
- {
- gMessageBufferUseStaticStream = true;
- }
- }
+namespace log4cxx
+{
+namespace helpers
+{
+void MessageBufferUseStaticStream()
+{
+ gMessageBufferUseStaticStream = true;
+}
+}
}
template <typename T>
-void ResetStream(std::basic_ostringstream<T> &stream)
+void ResetStream(std::basic_ostringstream<T>& stream)
{
- stream.seekp(0);
- stream.str(std::basic_string<T>());
- stream.clear();
+ stream.seekp(0);
+ stream.str(std::basic_string<T>());
+ stream.clear();
}
-CharMessageBuffer::CharMessageBuffer() : stream(0) {
+CharMessageBuffer::CharMessageBuffer() : stream(0)
+{
#if defined(STATIC_STRINGSTREAM)
-if (gMessageBufferUseStaticStream)
- {
- thread_local static char ossBuf[8192];
- thread_local static std::basic_ostringstream<char> sStream;
- thread_local static bool inited = false;
- if (!inited)
- {
- inited = true;
- sStream.rdbuf()->pubsetbuf(ossBuf, 8192);
- ResetStream(sStream);
- }
- stream = &sStream;
- }
+ if (gMessageBufferUseStaticStream)
+ {
+ thread_local static char ossBuf[8192];
+ thread_local static std::basic_ostringstream<char> sStream;
+ thread_local static bool inited = false;
+
+ if (!inited)
+ {
+ inited = true;
+ sStream.rdbuf()->pubsetbuf(ossBuf, 8192);
+
+ ResetStream(sStream);
+ }
+
+ stream = &sStream;
+ }
+
#endif
}
-CharMessageBuffer::~CharMessageBuffer() {
- if (!gMessageBufferUseStaticStream) {
- delete stream;
- }
+CharMessageBuffer::~CharMessageBuffer()
+{
+ if (!gMessageBufferUseStaticStream)
+ {
+ delete stream;
+ }
}
-CharMessageBuffer& CharMessageBuffer::operator<<(const std::basic_string<char>& msg) {
- if (stream == 0) {
- buf.append(msg);
- } else {
- *stream << msg;
- }
- return *this;
+CharMessageBuffer& CharMessageBuffer::operator<<(const std::basic_string<char>& msg)
+{
+ if (stream == 0)
+ {
+ buf.append(msg);
+ }
+ else
+ {
+ *stream << msg;
+ }
+
+ return *this;
}
-CharMessageBuffer& CharMessageBuffer::operator<<(const char* msg) {
- const char* actualMsg = msg;
- if (actualMsg == 0) {
- actualMsg = "null";
- }
- if (stream == 0) {
- buf.append(actualMsg);
- } else {
- *stream << actualMsg;
- }
- return *this;
+CharMessageBuffer& CharMessageBuffer::operator<<(const char* msg)
+{
+ const char* actualMsg = msg;
+
+ if (actualMsg == 0)
+ {
+ actualMsg = "null";
+ }
+
+ if (stream == 0)
+ {
+ buf.append(actualMsg);
+ }
+ else
+ {
+ *stream << actualMsg;
+ }
+
+ return *this;
}
-CharMessageBuffer& CharMessageBuffer::operator<<(char* msg) {
- return operator<<((const char*) msg);
+CharMessageBuffer& CharMessageBuffer::operator<<(char* msg)
+{
+ return operator<<((const char*) msg);
}
-CharMessageBuffer& CharMessageBuffer::operator<<(const char msg) {
- if (stream == 0) {
- buf.append(1, msg);
- } else {
- buf.assign(1, msg);
- *stream << buf;
- }
- return *this;
-}
-
-CharMessageBuffer::operator std::basic_ostream<char>&() {
- if (stream == 0) {
- stream = new std::basic_ostringstream<char>();
- if (!buf.empty()) {
+CharMessageBuffer& CharMessageBuffer::operator<<(const char msg)
+{
+ if (stream == 0)
+ {
+ buf.append(1, msg);
+ }
+ else
+ {
+ buf.assign(1, msg);
*stream << buf;
- }
- }
- return *stream;
+ }
+
+ return *this;
}
-const std::basic_string<char>& CharMessageBuffer::str(std::basic_ostream<char>&) {
- buf = stream->str();
+CharMessageBuffer::operator std::basic_ostream<char>& ()
+{
+ if (stream == 0)
+ {
+ stream = new std::basic_ostringstream<char>();
- ResetStream(*stream);
+ if (!buf.empty())
+ {
+ *stream << buf;
+ }
+ }
- return buf;
+ return *stream;
}
-const std::basic_string<char>& CharMessageBuffer::str(CharMessageBuffer&) {
- return buf;
+const std::basic_string<char>& CharMessageBuffer::str(std::basic_ostream<char>&)
+{
+ buf = stream->str();
+
+ ResetStream(*stream);
+
+ return buf;
}
-bool CharMessageBuffer::hasStream() const {
+const std::basic_string<char>& CharMessageBuffer::str(CharMessageBuffer&)
+{
+ return buf;
+}
+
+bool CharMessageBuffer::hasStream() const
+{
return (stream != 0);
}
-std::ostream& CharMessageBuffer::operator<<(ios_base_manip manip) {
- std::ostream& s = *this;
- (*manip)(s);
- return s;
+std::ostream& CharMessageBuffer::operator<<(ios_base_manip manip)
+{
+ std::ostream& s = *this;
+ (*manip)(s);
+ return s;
}
-std::ostream& CharMessageBuffer::operator<<(bool val) { return ((std::ostream&) *this).operator<<(val); }
-std::ostream& CharMessageBuffer::operator<<(short val) { return ((std::ostream&) *this).operator<<(val); }
-std::ostream& CharMessageBuffer::operator<<(int val) { return ((std::ostream&) *this).operator<<(val); }
-std::ostream& CharMessageBuffer::operator<<(unsigned int val) { return ((std::ostream&) *this).operator<<(val); }
-std::ostream& CharMessageBuffer::operator<<(long val) { return ((std::ostream&) *this).operator<<(val); }
-std::ostream& CharMessageBuffer::operator<<(unsigned long val) { return ((std::ostream&) *this).operator<<(val); }
-std::ostream& CharMessageBuffer::operator<<(float val) { return ((std::ostream&) *this).operator<<(val); }
-std::ostream& CharMessageBuffer::operator<<(double val) { return ((std::ostream&) *this).operator<<(val); }
-std::ostream& CharMessageBuffer::operator<<(long double val) { return ((std::ostream&) *this).operator<<(val); }
-std::ostream& CharMessageBuffer::operator<<(void* val) { return ((std::ostream&) *this).operator<<(val); }
+std::ostream& CharMessageBuffer::operator<<(bool val)
+{
+ return ((std::ostream&) * this).operator << (val);
+}
+std::ostream& CharMessageBuffer::operator<<(short val)
+{
+ return ((std::ostream&) * this).operator << (val);
+}
+std::ostream& CharMessageBuffer::operator<<(int val)
+{
+ return ((std::ostream&) * this).operator << (val);
+}
+std::ostream& CharMessageBuffer::operator<<(unsigned int val)
+{
+ return ((std::ostream&) * this).operator << (val);
+}
+std::ostream& CharMessageBuffer::operator<<(long val)
+{
+ return ((std::ostream&) * this).operator << (val);
+}
+std::ostream& CharMessageBuffer::operator<<(unsigned long val)
+{
+ return ((std::ostream&) * this).operator << (val);
+}
+std::ostream& CharMessageBuffer::operator<<(float val)
+{
+ return ((std::ostream&) * this).operator << (val);
+}
+std::ostream& CharMessageBuffer::operator<<(double val)
+{
+ return ((std::ostream&) * this).operator << (val);
+}
+std::ostream& CharMessageBuffer::operator<<(long double val)
+{
+ return ((std::ostream&) * this).operator << (val);
+}
+std::ostream& CharMessageBuffer::operator<<(void* val)
+{
+ return ((std::ostream&) * this).operator << (val);
+}
#if LOG4CXX_WCHAR_T_API
-WideMessageBuffer::WideMessageBuffer() : stream(0) {
+WideMessageBuffer::WideMessageBuffer() : stream(0)
+{
#if defined(STATIC_STRINGSTREAM)
- if (gMessageBufferUseStaticStream)
- {
- thread_local static wchar_t ossBuf[8192];
- thread_local static std::basic_ostringstream<wchar_t> sStream;
- thread_local static bool inited = false;
- if (!inited)
- {
- inited = true;
- sStream.rdbuf()->pubsetbuf(ossBuf, 8192);
- ResetStream(sStream);
- }
- stream = &sStream;
- }
+ if (gMessageBufferUseStaticStream)
+ {
+ thread_local static wchar_t ossBuf[8192];
+ thread_local static std::basic_ostringstream<wchar_t> sStream;
+ thread_local static bool inited = false;
+
+ if (!inited)
+ {
+ inited = true;
+ sStream.rdbuf()->pubsetbuf(ossBuf, 8192);
+
+ ResetStream(sStream);
+ }
+
+ stream = &sStream;
+ }
+
#endif
}
-WideMessageBuffer::~WideMessageBuffer() {
- if (!gMessageBufferUseStaticStream) {
- delete stream;
- }
+WideMessageBuffer::~WideMessageBuffer()
+{
+ if (!gMessageBufferUseStaticStream)
+ {
+ delete stream;
+ }
}
-WideMessageBuffer& WideMessageBuffer::operator<<(const std::basic_string<wchar_t>& msg) {
- if (stream == 0) {
- buf.append(msg);
- } else {
- *stream << msg;
- }
- return *this;
+WideMessageBuffer& WideMessageBuffer::operator<<(const std::basic_string<wchar_t>& msg)
+{
+ if (stream == 0)
+ {
+ buf.append(msg);
+ }
+ else
+ {
+ *stream << msg;
+ }
+
+ return *this;
}
-WideMessageBuffer& WideMessageBuffer::operator<<(const wchar_t* msg) {
- const wchar_t* actualMsg = msg;
- if (actualMsg == 0) {
- actualMsg = L"null";
- }
- if (stream == 0) {
- buf.append(actualMsg);
- } else {
- *stream << actualMsg;
- }
- return *this;
+WideMessageBuffer& WideMessageBuffer::operator<<(const wchar_t* msg)
+{
+ const wchar_t* actualMsg = msg;
+
+ if (actualMsg == 0)
+ {
+ actualMsg = L"null";
+ }
+
+ if (stream == 0)
+ {
+ buf.append(actualMsg);
+ }
+ else
+ {
+ *stream << actualMsg;
+ }
+
+ return *this;
}
-WideMessageBuffer& WideMessageBuffer::operator<<(wchar_t* msg) {
- return operator<<((const wchar_t*) msg);
+WideMessageBuffer& WideMessageBuffer::operator<<(wchar_t* msg)
+{
+ return operator<<((const wchar_t*) msg);
}
-WideMessageBuffer& WideMessageBuffer::operator<<(const wchar_t msg) {
- if (stream == 0) {
- buf.append(1, msg);
- } else {
- buf.assign(1, msg);
- *stream << buf;
- }
- return *this;
-}
-
-WideMessageBuffer::operator std::basic_ostream<wchar_t>&() {
- if (stream == 0) {
- stream = new std::basic_ostringstream<wchar_t>();
- if (!buf.empty()) {
+WideMessageBuffer& WideMessageBuffer::operator<<(const wchar_t msg)
+{
+ if (stream == 0)
+ {
+ buf.append(1, msg);
+ }
+ else
+ {
+ buf.assign(1, msg);
*stream << buf;
- }
- }
- return *stream;
+ }
+
+ return *this;
}
-const std::basic_string<wchar_t>& WideMessageBuffer::str(std::basic_ostream<wchar_t>&) {
- buf = stream->str();
+WideMessageBuffer::operator std::basic_ostream<wchar_t>& ()
+{
+ if (stream == 0)
+ {
+ stream = new std::basic_ostringstream<wchar_t>();
- ResetStream(*stream);
+ if (!buf.empty())
+ {
+ *stream << buf;
+ }
+ }
- return buf;
+ return *stream;
}
-const std::basic_string<wchar_t>& WideMessageBuffer::str(WideMessageBuffer&) {
- return buf;
+const std::basic_string<wchar_t>& WideMessageBuffer::str(std::basic_ostream<wchar_t>&)
+{
+ buf = stream->str();
+
+ ResetStream(*stream);
+
+ return buf;
}
-bool WideMessageBuffer::hasStream() const {
+const std::basic_string<wchar_t>& WideMessageBuffer::str(WideMessageBuffer&)
+{
+ return buf;
+}
+
+bool WideMessageBuffer::hasStream() const
+{
return (stream != 0);
}
-std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(ios_base_manip manip) {
- std::basic_ostream<wchar_t>& s = *this;
- (*manip)(s);
- return s;
+std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(ios_base_manip manip)
+{
+ std::basic_ostream<wchar_t>& s = *this;
+ (*manip)(s);
+ return s;
}
-std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(bool val) { return ((std::basic_ostream<wchar_t>&) *this).operator<<(val); }
-std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(short val) { return ((std::basic_ostream<wchar_t>&) *this).operator<<(val); }
-std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(int val) { return ((std::basic_ostream<wchar_t>&) *this).operator<<(val); }
-std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(unsigned int val) { return ((std::basic_ostream<wchar_t>&) *this).operator<<(val); }
-std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(long val) { return ((std::basic_ostream<wchar_t>&) *this).operator<<(val); }
-std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(unsigned long val) { return ((std::basic_ostream<wchar_t>&) *this).operator<<(val); }
-std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(float val) { return ((std::basic_ostream<wchar_t>&) *this).operator<<(val); }
-std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(double val) { return ((std::basic_ostream<wchar_t>&) *this).operator<<(val); }
-std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(long double val) { return ((std::basic_ostream<wchar_t>&) *this).operator<<(val); }
-std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(void* val) { return ((std::basic_ostream<wchar_t>&) *this).operator<<(val); }
+std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(bool val)
+{
+ return ((std::basic_ostream<wchar_t>&) * this).operator << (val);
+}
+std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(short val)
+{
+ return ((std::basic_ostream<wchar_t>&) * this).operator << (val);
+}
+std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(int val)
+{
+ return ((std::basic_ostream<wchar_t>&) * this).operator << (val);
+}
+std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(unsigned int val)
+{
+ return ((std::basic_ostream<wchar_t>&) * this).operator << (val);
+}
+std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(long val)
+{
+ return ((std::basic_ostream<wchar_t>&) * this).operator << (val);
+}
+std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(unsigned long val)
+{
+ return ((std::basic_ostream<wchar_t>&) * this).operator << (val);
+}
+std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(float val)
+{
+ return ((std::basic_ostream<wchar_t>&) * this).operator << (val);
+}
+std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(double val)
+{
+ return ((std::basic_ostream<wchar_t>&) * this).operator << (val);
+}
+std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(long double val)
+{
+ return ((std::basic_ostream<wchar_t>&) * this).operator << (val);
+}
+std::basic_ostream<wchar_t>& WideMessageBuffer::operator<<(void* val)
+{
+ return ((std::basic_ostream<wchar_t>&) * this).operator << (val);
+}
MessageBuffer::MessageBuffer() : wbuf(0)
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
- , ubuf(0)
+ , ubuf(0)
#endif
{
}
-MessageBuffer::~MessageBuffer() {
+MessageBuffer::~MessageBuffer()
+{
delete wbuf;
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
delete ubuf;
#endif
}
-bool MessageBuffer::hasStream() const {
+bool MessageBuffer::hasStream() const
+{
bool retval = cbuf.hasStream() || (wbuf != 0 && wbuf->hasStream());
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
retval = retval || (ubuf != 0 && ubuf->hasStream());
@@ -273,213 +407,328 @@
return retval;
}
-std::ostream& MessageBuffer::operator<<(ios_base_manip manip) {
- std::ostream& s = *this;
- (*manip)(s);
- return s;
+std::ostream& MessageBuffer::operator<<(ios_base_manip manip)
+{
+ std::ostream& s = *this;
+ (*manip)(s);
+ return s;
}
-MessageBuffer::operator std::ostream&() {
- return (std::ostream&) cbuf;
+MessageBuffer::operator std::ostream& ()
+{
+ return (std::ostream&) cbuf;
}
-CharMessageBuffer& MessageBuffer::operator<<(const std::string& msg) {
- return cbuf.operator<<(msg);
+CharMessageBuffer& MessageBuffer::operator<<(const std::string& msg)
+{
+ return cbuf.operator << (msg);
}
-CharMessageBuffer& MessageBuffer::operator<<(const char* msg) {
- return cbuf.operator<<(msg);
+CharMessageBuffer& MessageBuffer::operator<<(const char* msg)
+{
+ return cbuf.operator << (msg);
}
-CharMessageBuffer& MessageBuffer::operator<<(char* msg) {
- return cbuf.operator<<((const char*) msg);
+CharMessageBuffer& MessageBuffer::operator<<(char* msg)
+{
+ return cbuf.operator << ((const char*) msg);
}
-CharMessageBuffer& MessageBuffer::operator<<(const char msg) {
- return cbuf.operator<<(msg);
+CharMessageBuffer& MessageBuffer::operator<<(const char msg)
+{
+ return cbuf.operator << (msg);
}
-const std::string& MessageBuffer::str(CharMessageBuffer& buf) {
- return cbuf.str(buf);
+const std::string& MessageBuffer::str(CharMessageBuffer& buf)
+{
+ return cbuf.str(buf);
}
-const std::string& MessageBuffer::str(std::ostream& os) {
- return cbuf.str(os);
+const std::string& MessageBuffer::str(std::ostream& os)
+{
+ return cbuf.str(os);
}
-WideMessageBuffer& MessageBuffer::operator<<(const std::wstring& msg) {
- wbuf = new WideMessageBuffer();
- return (*wbuf) << msg;
+WideMessageBuffer& MessageBuffer::operator<<(const std::wstring& msg)
+{
+ wbuf = new WideMessageBuffer();
+ return (*wbuf) << msg;
}
-WideMessageBuffer& MessageBuffer::operator<<(const wchar_t* msg) {
- wbuf = new WideMessageBuffer();
- return (*wbuf) << msg;
+WideMessageBuffer& MessageBuffer::operator<<(const wchar_t* msg)
+{
+ wbuf = new WideMessageBuffer();
+ return (*wbuf) << msg;
}
-WideMessageBuffer& MessageBuffer::operator<<(wchar_t* msg) {
- wbuf = new WideMessageBuffer();
- return (*wbuf) << (const wchar_t*) msg;
+WideMessageBuffer& MessageBuffer::operator<<(wchar_t* msg)
+{
+ wbuf = new WideMessageBuffer();
+ return (*wbuf) << (const wchar_t*) msg;
}
-WideMessageBuffer& MessageBuffer::operator<<(const wchar_t msg) {
- wbuf = new WideMessageBuffer();
- return (*wbuf) << msg;
+WideMessageBuffer& MessageBuffer::operator<<(const wchar_t msg)
+{
+ wbuf = new WideMessageBuffer();
+ return (*wbuf) << msg;
}
-const std::wstring& MessageBuffer::str(WideMessageBuffer& buf) {
- return wbuf->str(buf);
+const std::wstring& MessageBuffer::str(WideMessageBuffer& buf)
+{
+ return wbuf->str(buf);
}
-const std::wstring& MessageBuffer::str(std::basic_ostream<wchar_t>& os) {
- return wbuf->str(os);
+const std::wstring& MessageBuffer::str(std::basic_ostream<wchar_t>& os)
+{
+ return wbuf->str(os);
}
-std::ostream& MessageBuffer::operator<<(bool val) { return cbuf.operator<<(val); }
-std::ostream& MessageBuffer::operator<<(short val) { return cbuf.operator<<(val); }
-std::ostream& MessageBuffer::operator<<(int val) { return cbuf.operator<<(val); }
-std::ostream& MessageBuffer::operator<<(unsigned int val) { return cbuf.operator<<(val); }
-std::ostream& MessageBuffer::operator<<(long val) { return cbuf.operator<<(val); }
-std::ostream& MessageBuffer::operator<<(unsigned long val) { return cbuf.operator<<(val); }
-std::ostream& MessageBuffer::operator<<(float val) { return cbuf.operator<<(val); }
-std::ostream& MessageBuffer::operator<<(double val) { return cbuf.operator<<(val); }
-std::ostream& MessageBuffer::operator<<(long double val) { return cbuf.operator<<(val); }
-std::ostream& MessageBuffer::operator<<(void* val) { return cbuf.operator<<(val); }
+std::ostream& MessageBuffer::operator<<(bool val)
+{
+ return cbuf.operator << (val);
+}
+std::ostream& MessageBuffer::operator<<(short val)
+{
+ return cbuf.operator << (val);
+}
+std::ostream& MessageBuffer::operator<<(int val)
+{
+ return cbuf.operator << (val);
+}
+std::ostream& MessageBuffer::operator<<(unsigned int val)
+{
+ return cbuf.operator << (val);
+}
+std::ostream& MessageBuffer::operator<<(long val)
+{
+ return cbuf.operator << (val);
+}
+std::ostream& MessageBuffer::operator<<(unsigned long val)
+{
+ return cbuf.operator << (val);
+}
+std::ostream& MessageBuffer::operator<<(float val)
+{
+ return cbuf.operator << (val);
+}
+std::ostream& MessageBuffer::operator<<(double val)
+{
+ return cbuf.operator << (val);
+}
+std::ostream& MessageBuffer::operator<<(long double val)
+{
+ return cbuf.operator << (val);
+}
+std::ostream& MessageBuffer::operator<<(void* val)
+{
+ return cbuf.operator << (val);
+}
#endif
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
-UniCharMessageBuffer& MessageBuffer::operator<<(const std::basic_string<log4cxx::UniChar>& msg) {
- ubuf = new UniCharMessageBuffer();
- return (*ubuf) << msg;
+UniCharMessageBuffer& MessageBuffer::operator<<(const std::basic_string<log4cxx::UniChar>& msg)
+{
+ ubuf = new UniCharMessageBuffer();
+ return (*ubuf) << msg;
}
-UniCharMessageBuffer& MessageBuffer::operator<<(const log4cxx::UniChar* msg) {
- ubuf = new UniCharMessageBuffer();
- return (*ubuf) << msg;
+UniCharMessageBuffer& MessageBuffer::operator<<(const log4cxx::UniChar* msg)
+{
+ ubuf = new UniCharMessageBuffer();
+ return (*ubuf) << msg;
}
-UniCharMessageBuffer& MessageBuffer::operator<<(log4cxx::UniChar* msg) {
- ubuf = new UniCharMessageBuffer();
- return (*ubuf) << (const log4cxx::UniChar*) msg;
+UniCharMessageBuffer& MessageBuffer::operator<<(log4cxx::UniChar* msg)
+{
+ ubuf = new UniCharMessageBuffer();
+ return (*ubuf) << (const log4cxx::UniChar*) msg;
}
-UniCharMessageBuffer& MessageBuffer::operator<<(const log4cxx::UniChar msg) {
- ubuf = new UniCharMessageBuffer();
- return (*ubuf) << msg;
+UniCharMessageBuffer& MessageBuffer::operator<<(const log4cxx::UniChar msg)
+{
+ ubuf = new UniCharMessageBuffer();
+ return (*ubuf) << msg;
}
-const std::basic_string<log4cxx::UniChar>& MessageBuffer::str(UniCharMessageBuffer& buf) {
- return ubuf->str(buf);
+const std::basic_string<log4cxx::UniChar>& MessageBuffer::str(UniCharMessageBuffer& buf)
+{
+ return ubuf->str(buf);
}
-const std::basic_string<log4cxx::UniChar>& MessageBuffer::str(std::basic_ostream<log4cxx::UniChar>& os) {
- return ubuf->str(os);
+const std::basic_string<log4cxx::UniChar>& MessageBuffer::str(std::basic_ostream<log4cxx::UniChar>& os)
+{
+ return ubuf->str(os);
}
-UniCharMessageBuffer::UniCharMessageBuffer() : stream(0) {
+UniCharMessageBuffer::UniCharMessageBuffer() : stream(0)
+{
#if defined(STATIC_STRINGSTREAM)
- if (gMessageBufferUseStaticStream)
- {
- thread_local static log4cxx::UniChar ossBuf[8192];
- thread_local static std::basic_ostringstream<log4cxx::UniChar> sStream;
- thread_local static bool inited = false;
- if (!inited)
- {
- inited = true;
- sStream.rdbuf()->pubsetbuf(ossBuf, 8192);
- ResetStream(sStream);
- }
- stream = &sStream;
- }
+ if (gMessageBufferUseStaticStream)
+ {
+ thread_local static log4cxx::UniChar ossBuf[8192];
+ thread_local static std::basic_ostringstream<log4cxx::UniChar> sStream;
+ thread_local static bool inited = false;
+
+ if (!inited)
+ {
+ inited = true;
+ sStream.rdbuf()->pubsetbuf(ossBuf, 8192);
+
+ ResetStream(sStream);
+ }
+
+ stream = &sStream;
+ }
+
#endif
}
-UniCharMessageBuffer::~UniCharMessageBuffer() {
- if (!gMessageBufferUseStaticStream) {
- delete stream;
- }
+UniCharMessageBuffer::~UniCharMessageBuffer()
+{
+ if (!gMessageBufferUseStaticStream)
+ {
+ delete stream;
+ }
}
-UniCharMessageBuffer& UniCharMessageBuffer::operator<<(const std::basic_string<log4cxx::UniChar>& msg) {
- if (stream == 0) {
+UniCharMessageBuffer& UniCharMessageBuffer::operator<<(const std::basic_string<log4cxx::UniChar>& msg)
+{
+ if (stream == 0)
+ {
buf.append(msg);
- } else {
- *stream << buf;
- }
- return *this;
-}
-
-UniCharMessageBuffer& UniCharMessageBuffer::operator<<(const log4cxx::UniChar* msg) {
- const log4cxx::UniChar* actualMsg = msg;
- static log4cxx::UniChar nullLiteral[] = { 0x6E, 0x75, 0x6C, 0x6C, 0};
- if (actualMsg == 0) {
- actualMsg = nullLiteral;
- }
- if (stream == 0) {
- buf.append(actualMsg);
- } else {
- *stream << actualMsg;
- }
- return *this;
-}
-
-UniCharMessageBuffer& UniCharMessageBuffer::operator<<(log4cxx::UniChar* msg) {
- return operator<<((const log4cxx::UniChar*) msg);
-}
-
-UniCharMessageBuffer& UniCharMessageBuffer::operator<<(const log4cxx::UniChar msg) {
- if (stream == 0) {
- buf.append(1, msg);
- } else {
- *stream << msg;
- }
- return *this;
-}
-
-UniCharMessageBuffer::operator UniCharMessageBuffer::uostream&() {
- if (stream == 0) {
- stream = new std::basic_ostringstream<UniChar>();
- if (!buf.empty()) {
+ }
+ else
+ {
*stream << buf;
- }
- }
- return *stream;
+ }
+
+ return *this;
}
-const std::basic_string<log4cxx::UniChar>& UniCharMessageBuffer::str(UniCharMessageBuffer::uostream&) {
- buf = stream->str();
- ResetStream(*stream);
- return buf;
+UniCharMessageBuffer& UniCharMessageBuffer::operator<<(const log4cxx::UniChar* msg)
+{
+ const log4cxx::UniChar* actualMsg = msg;
+ static log4cxx::UniChar nullLiteral[] = { 0x6E, 0x75, 0x6C, 0x6C, 0};
+
+ if (actualMsg == 0)
+ {
+ actualMsg = nullLiteral;
+ }
+
+ if (stream == 0)
+ {
+ buf.append(actualMsg);
+ }
+ else
+ {
+ *stream << actualMsg;
+ }
+
+ return *this;
}
-const std::basic_string<log4cxx::UniChar>& UniCharMessageBuffer::str(UniCharMessageBuffer&) {
- return buf;
+UniCharMessageBuffer& UniCharMessageBuffer::operator<<(log4cxx::UniChar* msg)
+{
+ return operator<<((const log4cxx::UniChar*) msg);
}
-bool UniCharMessageBuffer::hasStream() const {
+UniCharMessageBuffer& UniCharMessageBuffer::operator<<(const log4cxx::UniChar msg)
+{
+ if (stream == 0)
+ {
+ buf.append(1, msg);
+ }
+ else
+ {
+ *stream << msg;
+ }
+
+ return *this;
+}
+
+UniCharMessageBuffer::operator UniCharMessageBuffer::uostream& ()
+{
+ if (stream == 0)
+ {
+ stream = new std::basic_ostringstream<UniChar>();
+
+ if (!buf.empty())
+ {
+ *stream << buf;
+ }
+ }
+
+ return *stream;
+}
+
+const std::basic_string<log4cxx::UniChar>& UniCharMessageBuffer::str(UniCharMessageBuffer::uostream&)
+{
+ buf = stream->str();
+ ResetStream(*stream);
+ return buf;
+}
+
+const std::basic_string<log4cxx::UniChar>& UniCharMessageBuffer::str(UniCharMessageBuffer&)
+{
+ return buf;
+}
+
+bool UniCharMessageBuffer::hasStream() const
+{
return (stream != 0);
}
-UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(ios_base_manip manip) {
- UniCharMessageBuffer::uostream& s = *this;
- (*manip)(s);
- return s;
+UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(ios_base_manip manip)
+{
+ UniCharMessageBuffer::uostream& s = *this;
+ (*manip)(s);
+ return s;
}
-UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(bool val) { return ((UniCharMessageBuffer::uostream&) *this).operator<<(val); }
-UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(short val) { return ((UniCharMessageBuffer::uostream&) *this).operator<<(val); }
-UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(int val) { return ((UniCharMessageBuffer::uostream&) *this).operator<<(val); }
-UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(unsigned int val) { return ((UniCharMessageBuffer::uostream&) *this).operator<<(val); }
-UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(long val) { return ((UniCharMessageBuffer::uostream&) *this).operator<<(val); }
-UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(unsigned long val) { return ((UniCharMessageBuffer::uostream&) *this).operator<<(val); }
-UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(float val) { return ((UniCharMessageBuffer::uostream&) *this).operator<<(val); }
-UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(double val) { return ((UniCharMessageBuffer::uostream&) *this).operator<<(val); }
-UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(long double val) { return ((UniCharMessageBuffer::uostream&) *this).operator<<(val); }
-UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(void* val) { return ((UniCharMessageBuffer::uostream&) *this).operator<<(val); }
+UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(bool val)
+{
+ return ((UniCharMessageBuffer::uostream&) * this).operator << (val);
+}
+UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(short val)
+{
+ return ((UniCharMessageBuffer::uostream&) * this).operator << (val);
+}
+UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(int val)
+{
+ return ((UniCharMessageBuffer::uostream&) * this).operator << (val);
+}
+UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(unsigned int val)
+{
+ return ((UniCharMessageBuffer::uostream&) * this).operator << (val);
+}
+UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(long val)
+{
+ return ((UniCharMessageBuffer::uostream&) * this).operator << (val);
+}
+UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(unsigned long val)
+{
+ return ((UniCharMessageBuffer::uostream&) * this).operator << (val);
+}
+UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(float val)
+{
+ return ((UniCharMessageBuffer::uostream&) * this).operator << (val);
+}
+UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(double val)
+{
+ return ((UniCharMessageBuffer::uostream&) * this).operator << (val);
+}
+UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(long double val)
+{
+ return ((UniCharMessageBuffer::uostream&) * this).operator << (val);
+}
+UniCharMessageBuffer::uostream& UniCharMessageBuffer::operator<<(void* val)
+{
+ return ((UniCharMessageBuffer::uostream&) * this).operator << (val);
+}
@@ -489,28 +738,39 @@
#include <CoreFoundation/CFString.h>
#include <vector>
-UniCharMessageBuffer& UniCharMessageBuffer::operator<<(const CFStringRef& msg) {
+UniCharMessageBuffer& UniCharMessageBuffer::operator<<(const CFStringRef& msg)
+{
const log4cxx::UniChar* chars = CFStringGetCharactersPtr(msg);
- if (chars != 0) {
- return operator<<(chars);
- } else {
- size_t length = CFStringGetLength(msg);
- std::vector<log4cxx::UniChar> tmp(length);
- CFStringGetCharacters(msg, CFRangeMake(0, length), &tmp[0]);
- if (stream) {
+
+ if (chars != 0)
+ {
+ return operator<<(chars);
+ }
+ else
+ {
+ size_t length = CFStringGetLength(msg);
+ std::vector<log4cxx::UniChar> tmp(length);
+ CFStringGetCharacters(msg, CFRangeMake(0, length), &tmp[0]);
+
+ if (stream)
+ {
std::basic_string<UniChar> s(&tmp[0], tmp.size());
*stream << s;
- } else {
+ }
+ else
+ {
buf.append(&tmp[0], tmp.size());
}
}
- return *this;
+
+ return *this;
}
-UniCharMessageBuffer& MessageBuffer::operator<<(const CFStringRef& msg) {
- ubuf = new UniCharMessageBuffer();
- return (*ubuf) << msg;
+UniCharMessageBuffer& MessageBuffer::operator<<(const CFStringRef& msg)
+{
+ ubuf = new UniCharMessageBuffer();
+ return (*ubuf) << msg;
}
#endif
diff --git a/src/main/cpp/messagepatternconverter.cpp b/src/main/cpp/messagepatternconverter.cpp
index 7fe5bf0..238a26f 100644
--- a/src/main/cpp/messagepatternconverter.cpp
+++ b/src/main/cpp/messagepatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -33,20 +33,23 @@
IMPLEMENT_LOG4CXX_OBJECT(MessagePatternConverter)
MessagePatternConverter::MessagePatternConverter() :
- LoggingEventPatternConverter(LOG4CXX_STR("Message"),
- LOG4CXX_STR("message")) {
+ LoggingEventPatternConverter(LOG4CXX_STR("Message"),
+ LOG4CXX_STR("message"))
+{
}
PatternConverterPtr MessagePatternConverter::newInstance(
- const std::vector<LogString>& /* options */) {
- static PatternConverterPtr def(new MessagePatternConverter());
- return def;
+ const std::vector<LogString>& /* options */)
+{
+ static PatternConverterPtr def(new MessagePatternConverter());
+ return def;
}
void MessagePatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- Pool& /* p */) const {
- toAppendTo.append(event->getRenderedMessage());
- }
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ Pool& /* p */) const
+{
+ toAppendTo.append(event->getRenderedMessage());
+}
diff --git a/src/main/cpp/methodlocationpatternconverter.cpp b/src/main/cpp/methodlocationpatternconverter.cpp
index e687112..116b321 100644
--- a/src/main/cpp/methodlocationpatternconverter.cpp
+++ b/src/main/cpp/methodlocationpatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -33,19 +33,22 @@
IMPLEMENT_LOG4CXX_OBJECT(MethodLocationPatternConverter)
MethodLocationPatternConverter::MethodLocationPatternConverter() :
- LoggingEventPatternConverter(LOG4CXX_STR("Method"),
- LOG4CXX_STR("method")) {
+ LoggingEventPatternConverter(LOG4CXX_STR("Method"),
+ LOG4CXX_STR("method"))
+{
}
PatternConverterPtr MethodLocationPatternConverter::newInstance(
- const std::vector<LogString>& /* options */ ) {
- static PatternConverterPtr def(new MethodLocationPatternConverter());
- return def;
+ const std::vector<LogString>& /* options */ )
+{
+ static PatternConverterPtr def(new MethodLocationPatternConverter());
+ return def;
}
void MethodLocationPatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- Pool& /* p */ ) const {
- append(toAppendTo, event->getLocationInformation().getMethodName());
- }
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ Pool& /* p */ ) const
+{
+ append(toAppendTo, event->getLocationInformation().getMethodName());
+}
diff --git a/src/main/cpp/mutex.cpp b/src/main/cpp/mutex.cpp
index d76afca..c3a4d25 100755
--- a/src/main/cpp/mutex.cpp
+++ b/src/main/cpp/mutex.cpp
@@ -23,18 +23,18 @@
#include <apr_thread_rwlock.h>
#include <assert.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #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
+ #if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
+ #include <windows.h>
+ #else
+ // POSIX
+ #include <semaphore.h>
+ #endif
#endif // NON_BLOCKING
@@ -42,119 +42,141 @@
using namespace log4cxx;
-Mutex::Mutex(Pool& p) {
+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);
- }
+ 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) {
+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);
- }
+ apr_status_t stat = apr_thread_mutex_create(&mutex,
+ APR_THREAD_MUTEX_NESTED, p);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw MutexException(stat);
+ }
+
#endif
}
-Mutex::~Mutex() {
+Mutex::~Mutex()
+{
#if APR_HAS_THREADS
- // LOGCXX-322
- if (APRInitializer::isDestructed)
- {
- return;
- }
- apr_thread_mutex_destroy(mutex);
+ // LOGCXX-322
+ if (APRInitializer::isDestructed)
+ {
+ return;
+ }
+
+ apr_thread_mutex_destroy(mutex);
#endif
}
-apr_thread_mutex_t* Mutex::getAPRMutex() const {
+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)
+ : 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);
- }
+ 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)
+ : 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);
- }
+ apr_status_t stat = apr_thread_rwlock_create(&mutex, p);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw MutexException(stat);
+ }
+
#endif
}
-RWMutex::~RWMutex() {
+RWMutex::~RWMutex()
+{
#if APR_HAS_THREADS
- apr_thread_rwlock_destroy(mutex);
+ apr_thread_rwlock_destroy(mutex);
#endif
}
void RWMutex::rdLock() const
{
#if APR_HAS_THREADS
- apr_status_t stat = apr_thread_rwlock_rdlock(mutex);
+ 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);
+ 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;
- }
+ 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
- {
- }
+
+ if (--count == 0)
+ {
+ id = (apr_os_thread_t) -1; // id_ = "not a thread"
+ apr_status_t stat = apr_thread_rwlock_unlock(mutex);
+ }
+ else
+ {
+ }
+
#endif
}
@@ -164,78 +186,94 @@
#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
-namespace log4cxx {
- namespace helpers {
- struct SemaphoreImpl
- {
- HANDLE semaphore;
- };
- }
+namespace log4cxx
+{
+namespace helpers
+{
+struct SemaphoreImpl
+{
+ HANDLE semaphore;
+};
+}
}
static const LONG cMax = 10000; // arbitrary high value
Semaphore::Semaphore(log4cxx::helpers::Pool& p)
- : impl(nullptr)
+ : impl(nullptr)
{
#if APR_HAS_THREADS
- impl = (SemaphoreImpl*)p.palloc(sizeof(SemaphoreImpl));
- if (nullptr == impl) {
- throw MutexException(APR_ENOMEM);
- }
+ impl = (SemaphoreImpl*)p.palloc(sizeof(SemaphoreImpl));
- impl->semaphore = CreateSemaphore(
- NULL, // default security attributes
- 0, // initial count
- cMax, // maximum count
- NULL); // unnamed semaphore
+ if (nullptr == impl)
+ {
+ throw MutexException(APR_ENOMEM);
+ }
- if (impl->semaphore == NULL) {
- throw MutexException(APR_ENOSHMAVAIL);
- }
+ 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);
- }
+
+ 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);
- }
+ 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);
- }
+ BOOL stat = ReleaseSemaphore(impl->semaphore, 1, NULL);
+
+ if (!stat)
+ {
+ throw MutexException(stat);
+ }
+
#endif
}
#else
// POSIX
-namespace log4cxx {
- namespace helpers {
- struct SemaphoreImpl
- {
- sem_t semaphore;
- };
- }
+namespace log4cxx
+{
+namespace helpers
+{
+struct SemaphoreImpl
+{
+ sem_t semaphore;
+};
+}
}
Semaphore::Semaphore(log4cxx::helpers::Pool& p)
@@ -243,24 +281,31 @@
{
#if APR_HAS_THREADS
impl = (SemaphoreImpl*)p.palloc(sizeof(SemaphoreImpl));
- if (nullptr == impl) {
+
+ if (nullptr == impl)
+ {
throw MutexException(APR_ENOMEM);
}
int stat = sem_init(&impl->semaphore, 0, 0);
- if (stat != 0) {
+
+ if (stat != 0)
+ {
throw MutexException(APR_ENOSHMAVAIL);
}
+
#endif
}
Semaphore::~Semaphore()
{
#if APR_HAS_THREADS
+
if (impl)
{
int stat = sem_destroy(&impl->semaphore);
}
+
#endif
}
@@ -268,9 +313,12 @@
{
#if APR_HAS_THREADS
int stat = sem_wait(&impl->semaphore);
- if (stat != 0) {
+
+ if (stat != 0)
+ {
throw MutexException(stat);
}
+
#endif
}
@@ -278,9 +326,12 @@
{
#if APR_HAS_THREADS
int stat = sem_post(&impl->semaphore);
- if (stat != 0) {
+
+ if (stat != 0)
+ {
throw MutexException(stat);
}
+
#endif
}
diff --git a/src/main/cpp/nameabbreviator.cpp b/src/main/cpp/nameabbreviator.cpp
index 90fcc13..182a423 100644
--- a/src/main/cpp/nameabbreviator.cpp
+++ b/src/main/cpp/nameabbreviator.cpp
@@ -27,207 +27,234 @@
IMPLEMENT_LOG4CXX_OBJECT(NameAbbreviator)
-NameAbbreviator::NameAbbreviator() {
+NameAbbreviator::NameAbbreviator()
+{
}
-NameAbbreviator::~NameAbbreviator() {
+NameAbbreviator::~NameAbbreviator()
+{
}
-namespace log4cxx {
- namespace pattern {
- /**
- * Abbreviator that simply appends full name to buffer.
- */
-class NOPAbbreviator : public NameAbbreviator {
-public:
-DECLARE_ABSTRACT_LOG4CXX_OBJECT(NOPAbbreviator)
-BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(NOPAbbreviator)
- LOG4CXX_CAST_ENTRY_CHAIN(NameAbbreviator)
-END_LOG4CXX_CAST_MAP()
+namespace log4cxx
+{
+namespace pattern
+{
+/**
+ * Abbreviator that simply appends full name to buffer.
+ */
+class NOPAbbreviator : public NameAbbreviator
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(NOPAbbreviator)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(NOPAbbreviator)
+ LOG4CXX_CAST_ENTRY_CHAIN(NameAbbreviator)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Constructor.
- */
- NOPAbbreviator() {
- }
+ /**
+ * Constructor.
+ */
+ NOPAbbreviator()
+ {
+ }
- /**
- * {@inheritDoc}
- */
- void abbreviate(LogString::size_type /* nameStart */, LogString& /* buf */) const {
- }
+ /**
+ * {@inheritDoc}
+ */
+ void abbreviate(LogString::size_type /* nameStart */, LogString& /* buf */) const
+ {
+ }
};
- /**
- * Abbreviator that drops starting path elements.
- */
- class MaxElementAbbreviator : public NameAbbreviator {
- /**
- * Maximum number of path elements to output.
- */
- const int count;
+/**
+ * Abbreviator that drops starting path elements.
+ */
+class MaxElementAbbreviator : public NameAbbreviator
+{
+ /**
+ * Maximum number of path elements to output.
+ */
+ const int count;
-public:
-DECLARE_ABSTRACT_LOG4CXX_OBJECT(MaxElementAbbreviator)
-BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(MaxElementAbbreviator)
- LOG4CXX_CAST_ENTRY_CHAIN(NameAbbreviator)
-END_LOG4CXX_CAST_MAP()
- /**
- * Create new instance.
- * @param count maximum number of path elements to output.
- */
- MaxElementAbbreviator(const int count1) : count(count1) {
- }
-
- /**
- * Abbreviate name.
- * @param buf buffer to append abbreviation.
- * @param nameStart start of name to abbreviate.
- */
- void abbreviate(LogString::size_type nameStart, LogString& buf) const {
- // We substract 1 from 'len' when assigning to 'end' to avoid out of
- // bounds exception in return r.substring(end+1, len). This can happen if
- // precision is 1 and the logger name ends with a dot.
- LogString::size_type end = buf.length() - 1;
-
- for (LogString::size_type i = count; i > 0; i--) {
- end = buf.rfind(0x2E /* '.' */, end - 1);
-
- if ((end == LogString::npos) || (end < nameStart)) {
- return;
- }
- }
-
- buf.erase(buf.begin() + nameStart, buf.begin() + (end + 1));
- }
- };
-
- /**
- * Fragment of an pattern abbreviator.
- *
- */
- class PatternAbbreviatorFragment {
- /**
- * Count of initial characters of element to output.
- */
- LogString::size_type charCount;
-
- /**
- * Character used to represent dropped characters.
- * '\0' indicates no representation of dropped characters.
- */
- logchar ellipsis;
-
-public:
- /**
- * Creates a PatternAbbreviatorFragment.
- * @param charCount number of initial characters to preserve.
- * @param ellipsis character to represent elimination of characters,
- * '\0' if no ellipsis is desired.
- */
- PatternAbbreviatorFragment(
- const int charCount1, const logchar ellipsis1)
- : charCount(charCount1), ellipsis(ellipsis1) {
- }
- PatternAbbreviatorFragment() : charCount(0), ellipsis(0) {
- }
-
- PatternAbbreviatorFragment(const PatternAbbreviatorFragment& src)
- : charCount(src.charCount), ellipsis(src.ellipsis) {
- }
-
- PatternAbbreviatorFragment& operator=(const PatternAbbreviatorFragment& src) {
- charCount = src.charCount;
- ellipsis = src.ellipsis;
- return *this;
- }
-
- /**
- * Abbreviate element of name.
- * @param buf buffer to receive element.
- * @param startPos starting index of name element.
- * @return starting index of next element.
- */
- LogString::size_type abbreviate(LogString& buf, LogString::size_type startPos) const {
- LogString::size_type nextDot = buf.find(0x2E /* '.' */, startPos);
-
- if (nextDot != LogString::npos) {
- if ((nextDot - startPos) > charCount) {
- buf.erase(buf.begin() + (startPos + charCount), buf.begin() + nextDot);
- nextDot = startPos + charCount;
-
- if (ellipsis != 0x00) {
- buf.insert(nextDot, 1, ellipsis);
- nextDot++;
- }
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(MaxElementAbbreviator)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(MaxElementAbbreviator)
+ LOG4CXX_CAST_ENTRY_CHAIN(NameAbbreviator)
+ END_LOG4CXX_CAST_MAP()
+ /**
+ * Create new instance.
+ * @param count maximum number of path elements to output.
+ */
+ MaxElementAbbreviator(const int count1) : count(count1)
+ {
}
- nextDot++;
- }
+ /**
+ * Abbreviate name.
+ * @param buf buffer to append abbreviation.
+ * @param nameStart start of name to abbreviate.
+ */
+ void abbreviate(LogString::size_type nameStart, LogString& buf) const
+ {
+ // We substract 1 from 'len' when assigning to 'end' to avoid out of
+ // bounds exception in return r.substring(end+1, len). This can happen if
+ // precision is 1 and the logger name ends with a dot.
+ LogString::size_type end = buf.length() - 1;
- return nextDot;
- }
- };
+ for (LogString::size_type i = count; i > 0; i--)
+ {
+ end = buf.rfind(0x2E /* '.' */, end - 1);
- /**
- * Pattern abbreviator.
- *
- *
- */
- class PatternAbbreviator : public NameAbbreviator {
- /**
- * Element abbreviation patterns.
- */
- std::vector<PatternAbbreviatorFragment> fragments;
+ if ((end == LogString::npos) || (end < nameStart))
+ {
+ return;
+ }
+ }
-public:
-DECLARE_ABSTRACT_LOG4CXX_OBJECT(PatternAbbreviator)
-BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(PatternAbbreviator)
- LOG4CXX_CAST_ENTRY_CHAIN(NameAbbreviator)
-END_LOG4CXX_CAST_MAP()
- /**
- * Create PatternAbbreviator.
- *
- * @param fragments element abbreviation patterns.
- */
- PatternAbbreviator(const std::vector<PatternAbbreviatorFragment>& fragments1) :
- fragments(fragments1) {
- if (fragments1.size() == 0) {
- throw IllegalArgumentException(LOG4CXX_STR("fragments parameter must contain at least one element"));
- }
- }
+ buf.erase(buf.begin() + nameStart, buf.begin() + (end + 1));
+ }
+};
- /**
- * Abbreviate name.
- * @param buf buffer that abbreviated name is appended.
- * @param nameStart start of name.
- */
- void abbreviate(LogString::size_type nameStart, LogString& buf) const {
- //
- // all non-terminal patterns are executed once
- //
- LogString::size_type pos = nameStart;
+/**
+ * Fragment of an pattern abbreviator.
+ *
+ */
+class PatternAbbreviatorFragment
+{
+ /**
+ * Count of initial characters of element to output.
+ */
+ LogString::size_type charCount;
- for (LogString::size_type i = 0; (i < (fragments.size() - 1)) && (pos < buf.length());
- i++) {
- pos = fragments[i].abbreviate(buf, pos);
- }
+ /**
+ * Character used to represent dropped characters.
+ * '\0' indicates no representation of dropped characters.
+ */
+ logchar ellipsis;
- //
- // last pattern in executed repeatedly
- //
- PatternAbbreviatorFragment terminalFragment =
- fragments[fragments.size() - 1];
+ public:
+ /**
+ * Creates a PatternAbbreviatorFragment.
+ * @param charCount number of initial characters to preserve.
+ * @param ellipsis character to represent elimination of characters,
+ * '\0' if no ellipsis is desired.
+ */
+ PatternAbbreviatorFragment(
+ const int charCount1, const logchar ellipsis1)
+ : charCount(charCount1), ellipsis(ellipsis1)
+ {
+ }
+ PatternAbbreviatorFragment() : charCount(0), ellipsis(0)
+ {
+ }
- while (pos < buf.length()) {
- pos = terminalFragment.abbreviate(buf, pos);
- }
- }
- };
+ PatternAbbreviatorFragment(const PatternAbbreviatorFragment& src)
+ : charCount(src.charCount), ellipsis(src.ellipsis)
+ {
+ }
+
+ PatternAbbreviatorFragment& operator=(const PatternAbbreviatorFragment& src)
+ {
+ charCount = src.charCount;
+ ellipsis = src.ellipsis;
+ return *this;
+ }
+
+ /**
+ * Abbreviate element of name.
+ * @param buf buffer to receive element.
+ * @param startPos starting index of name element.
+ * @return starting index of next element.
+ */
+ LogString::size_type abbreviate(LogString& buf, LogString::size_type startPos) const
+ {
+ LogString::size_type nextDot = buf.find(0x2E /* '.' */, startPos);
+
+ if (nextDot != LogString::npos)
+ {
+ if ((nextDot - startPos) > charCount)
+ {
+ buf.erase(buf.begin() + (startPos + charCount), buf.begin() + nextDot);
+ nextDot = startPos + charCount;
+
+ if (ellipsis != 0x00)
+ {
+ buf.insert(nextDot, 1, ellipsis);
+ nextDot++;
+ }
+ }
+
+ nextDot++;
+ }
+
+ return nextDot;
+ }
+};
+
+/**
+ * Pattern abbreviator.
+ *
+ *
+ */
+class PatternAbbreviator : public NameAbbreviator
+{
+ /**
+ * Element abbreviation patterns.
+ */
+ std::vector<PatternAbbreviatorFragment> fragments;
+
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(PatternAbbreviator)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(PatternAbbreviator)
+ LOG4CXX_CAST_ENTRY_CHAIN(NameAbbreviator)
+ END_LOG4CXX_CAST_MAP()
+ /**
+ * Create PatternAbbreviator.
+ *
+ * @param fragments element abbreviation patterns.
+ */
+ PatternAbbreviator(const std::vector<PatternAbbreviatorFragment>& fragments1) :
+ fragments(fragments1)
+ {
+ if (fragments1.size() == 0)
+ {
+ throw IllegalArgumentException(LOG4CXX_STR("fragments parameter must contain at least one element"));
+ }
+ }
+
+ /**
+ * Abbreviate name.
+ * @param buf buffer that abbreviated name is appended.
+ * @param nameStart start of name.
+ */
+ void abbreviate(LogString::size_type nameStart, LogString& buf) const
+ {
+ //
+ // all non-terminal patterns are executed once
+ //
+ LogString::size_type pos = nameStart;
+
+ for (LogString::size_type i = 0; (i < (fragments.size() - 1)) && (pos < buf.length());
+ i++)
+ {
+ pos = fragments[i].abbreviate(buf, pos);
+ }
+
+ //
+ // last pattern in executed repeatedly
+ //
+ PatternAbbreviatorFragment terminalFragment =
+ fragments[fragments.size() - 1];
+
+ while (pos < buf.length())
+ {
+ pos = terminalFragment.abbreviate(buf, pos);
+ }
+ }
+};
}
}
@@ -237,88 +264,104 @@
-NameAbbreviatorPtr NameAbbreviator::getAbbreviator(const LogString& pattern) {
- if (pattern.length() > 0) {
- // if pattern is just spaces and numbers then
- // use MaxElementAbbreviator
- LogString trimmed(StringHelper::trim(pattern));
+NameAbbreviatorPtr NameAbbreviator::getAbbreviator(const LogString& pattern)
+{
+ if (pattern.length() > 0)
+ {
+ // if pattern is just spaces and numbers then
+ // use MaxElementAbbreviator
+ LogString trimmed(StringHelper::trim(pattern));
- if (trimmed.length() == 0) {
- return getDefaultAbbreviator();
- }
-
- LogString::size_type i = 0;
-
- while (
- (i < trimmed.length()) && (trimmed[i] >= 0x30 /* '0' */)
- && (trimmed[i] <= 0x39 /* '9' */)) {
- i++;
- }
-
- //
- // if all blanks and digits
- //
- if (i == trimmed.length()) {
- return new MaxElementAbbreviator(StringHelper::toInt(trimmed));
- }
-
- std::vector<PatternAbbreviatorFragment> fragments;
- logchar ellipsis;
- int charCount;
- LogString::size_type pos = 0;
-
- while (pos < trimmed.length()) {
- LogString::size_type ellipsisPos = pos;
-
- if (trimmed[pos] == 0x2A /* '*' */) {
- charCount = INT_MAX;
- ellipsisPos++;
- } else {
- if ((trimmed[pos] >= 0x30 /* '0' */)
- && (trimmed[pos] <= 0x39 /* '9' */)) {
- charCount = trimmed[pos] - 0x30 /* '0' */;
- ellipsisPos++;
- } else {
- charCount = 0;
- }
+ if (trimmed.length() == 0)
+ {
+ return getDefaultAbbreviator();
}
- ellipsis = 0;
+ LogString::size_type i = 0;
- if (ellipsisPos < trimmed.length()) {
- ellipsis = trimmed[ellipsisPos];
+ while (
+ (i < trimmed.length()) && (trimmed[i] >= 0x30 /* '0' */)
+ && (trimmed[i] <= 0x39 /* '9' */))
+ {
+ i++;
+ }
- if (ellipsis == 0x2E /* '.' */) {
+ //
+ // if all blanks and digits
+ //
+ if (i == trimmed.length())
+ {
+ return new MaxElementAbbreviator(StringHelper::toInt(trimmed));
+ }
+
+ std::vector<PatternAbbreviatorFragment> fragments;
+ logchar ellipsis;
+ int charCount;
+ LogString::size_type pos = 0;
+
+ while (pos < trimmed.length())
+ {
+ LogString::size_type ellipsisPos = pos;
+
+ if (trimmed[pos] == 0x2A /* '*' */)
+ {
+ charCount = INT_MAX;
+ ellipsisPos++;
+ }
+ else
+ {
+ if ((trimmed[pos] >= 0x30 /* '0' */)
+ && (trimmed[pos] <= 0x39 /* '9' */))
+ {
+ charCount = trimmed[pos] - 0x30 /* '0' */;
+ ellipsisPos++;
+ }
+ else
+ {
+ charCount = 0;
+ }
+ }
+
ellipsis = 0;
- }
+
+ if (ellipsisPos < trimmed.length())
+ {
+ ellipsis = trimmed[ellipsisPos];
+
+ if (ellipsis == 0x2E /* '.' */)
+ {
+ ellipsis = 0;
+ }
+ }
+
+ fragments.push_back(PatternAbbreviatorFragment(charCount, ellipsis));
+ pos = trimmed.find(0x2E /* '.' */, pos);
+
+ if (pos == LogString::npos)
+ {
+ break;
+ }
+
+ pos++;
}
- fragments.push_back(PatternAbbreviatorFragment(charCount, ellipsis));
- pos = trimmed.find(0x2E /* '.' */, pos);
-
- if (pos == LogString::npos) {
- break;
- }
-
- pos++;
- }
-
- NameAbbreviatorPtr abbrev(new PatternAbbreviator(fragments));
- return abbrev;
+ NameAbbreviatorPtr abbrev(new PatternAbbreviator(fragments));
+ return abbrev;
}
//
// no matching abbreviation, return defaultAbbreviator
//
return getDefaultAbbreviator();
- }
+}
- /**
- * Gets default abbreviator.
- *
- * @return default abbreviator.
- */
-NameAbbreviatorPtr NameAbbreviator::getDefaultAbbreviator() {
+/**
+ * Gets default abbreviator.
+ *
+ * @return default abbreviator.
+ */
+NameAbbreviatorPtr NameAbbreviator::getDefaultAbbreviator()
+{
static NameAbbreviatorPtr def(new NOPAbbreviator());
return def;
}
diff --git a/src/main/cpp/namepatternconverter.cpp b/src/main/cpp/namepatternconverter.cpp
index 49068dd..11fa630 100644
--- a/src/main/cpp/namepatternconverter.cpp
+++ b/src/main/cpp/namepatternconverter.cpp
@@ -16,7 +16,7 @@
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -35,22 +35,27 @@
const LogString& style1,
const std::vector<LogString>& options) :
LoggingEventPatternConverter(name1, style1),
- abbreviator(getAbbreviator(options)) {
+ abbreviator(getAbbreviator(options))
+{
}
NameAbbreviatorPtr NamePatternConverter::getAbbreviator(
- const std::vector<LogString>& options) {
- if (options.size() > 0) {
- return NameAbbreviator::getAbbreviator(options[0]);
+ const std::vector<LogString>& options)
+{
+ if (options.size() > 0)
+ {
+ return NameAbbreviator::getAbbreviator(options[0]);
}
+
return NameAbbreviator::getDefaultAbbreviator();
}
- /**
- * Abbreviate name in string buffer.
- * @param nameStart starting position of name to abbreviate.
- * @param buf string buffer containing name.
- */
-void NamePatternConverter::abbreviate(int nameStart, LogString& buf) const {
+/**
+ * Abbreviate name in string buffer.
+ * @param nameStart starting position of name to abbreviate.
+ * @param buf string buffer containing name.
+ */
+void NamePatternConverter::abbreviate(int nameStart, LogString& buf) const
+{
abbreviator->abbreviate(nameStart, buf);
}
diff --git a/src/main/cpp/ndc.cpp b/src/main/cpp/ndc.cpp
index 89788c1..1dec630 100644
--- a/src/main/cpp/ndc.cpp
+++ b/src/main/cpp/ndc.cpp
@@ -16,7 +16,7 @@
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -29,31 +29,38 @@
NDC::NDC(const std::string& message)
{
- push(message);
+ push(message);
}
NDC::~NDC()
{
- pop();
+ pop();
}
-LogString& NDC::getMessage(NDC::DiagnosticContext& ctx) {
+LogString& NDC::getMessage(NDC::DiagnosticContext& ctx)
+{
return ctx.first;
}
-LogString& NDC::getFullMessage(NDC::DiagnosticContext& ctx) {
+LogString& NDC::getFullMessage(NDC::DiagnosticContext& ctx)
+{
return ctx.second;
}
void NDC::clear()
{
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- while(!stack.empty()) {
- stack.pop();
+
+ while (!stack.empty())
+ {
+ stack.pop();
}
+
data->recycle();
}
}
@@ -61,17 +68,24 @@
NDC::Stack* NDC::cloneStack()
{
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- if (!stack.empty()) {
+
+ if (!stack.empty())
+ {
return new Stack(stack);
}
}
+
return new Stack();
}
-void NDC::inherit(NDC::Stack * stack) {
- if (stack != NULL) {
+void NDC::inherit(NDC::Stack* stack)
+{
+ if (stack != NULL)
+ {
ThreadSpecificData::inherit(*stack);
delete stack;
}
@@ -81,43 +95,60 @@
bool NDC::get(LogString& dest)
{
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- if(!stack.empty()) {
- dest.append(getFullMessage(stack.top()));
- return true;
+
+ if (!stack.empty())
+ {
+ dest.append(getFullMessage(stack.top()));
+ return true;
}
+
data->recycle();
}
+
return false;
}
-int NDC::getDepth() {
+int NDC::getDepth()
+{
int size = 0;
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
size = data->getStack().size();
- if (size == 0) {
+
+ if (size == 0)
+ {
data->recycle();
}
}
+
return size;
}
LogString NDC::pop()
{
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- if(!stack.empty())
+
+ if (!stack.empty())
{
- LogString value(getMessage(stack.top()));
- stack.pop();
- data->recycle();
- return value;
+ LogString value(getMessage(stack.top()));
+ stack.pop();
+ data->recycle();
+ return value;
}
+
data->recycle();
}
+
return LogString();
}
@@ -125,45 +156,60 @@
{
bool retval = false;
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- if(!stack.empty())
+
+ if (!stack.empty())
{
- Transcoder::encode(getMessage(stack.top()), dst);
- stack.pop();
- retval = true;
+ Transcoder::encode(getMessage(stack.top()), dst);
+ stack.pop();
+ retval = true;
}
+
data->recycle();
}
+
return retval;
}
LogString NDC::peek()
{
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- if(!stack.empty())
+
+ if (!stack.empty())
{
- return getMessage(stack.top());
+ return getMessage(stack.top());
}
+
data->recycle();
}
+
return LogString();
}
bool NDC::peek(std::string& dst)
{
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- if(!stack.empty())
+
+ if (!stack.empty())
{
- Transcoder::encode(getMessage(stack.top()), dst);
- return true;
+ Transcoder::encode(getMessage(stack.top()), dst);
+ return true;
}
+
data->recycle();
}
+
return false;
}
@@ -174,69 +220,85 @@
void NDC::push(const std::string& message)
{
- LOG4CXX_DECODE_CHAR(msg, message);
- pushLS(msg);
+ LOG4CXX_DECODE_CHAR(msg, message);
+ pushLS(msg);
}
void NDC::remove()
{
- clear();
+ clear();
}
-bool NDC::empty() {
+bool NDC::empty()
+{
bool empty = true;
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
empty = stack.empty();
- if (empty) {
+
+ if (empty)
+ {
data->recycle();
}
}
+
return empty;
}
#if LOG4CXX_WCHAR_T_API
NDC::NDC(const std::wstring& message)
{
- push(message);
+ push(message);
}
void NDC::push(const std::wstring& message)
{
- LOG4CXX_DECODE_WCHAR(msg, message);
- pushLS(msg);
+ LOG4CXX_DECODE_WCHAR(msg, message);
+ pushLS(msg);
}
bool NDC::pop(std::wstring& dst)
{
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- if(!stack.empty())
+
+ if (!stack.empty())
{
- Transcoder::encode(getMessage(stack.top()), dst);
- stack.pop();
- data->recycle();
- return true;
+ Transcoder::encode(getMessage(stack.top()), dst);
+ stack.pop();
+ data->recycle();
+ return true;
}
+
data->recycle();
}
+
return false;
}
bool NDC::peek(std::wstring& dst)
{
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- if(!stack.empty())
+
+ if (!stack.empty())
{
- Transcoder::encode(getMessage(stack.top()), dst);
- return true;
+ Transcoder::encode(getMessage(stack.top()), dst);
+ return true;
}
+
data->recycle();
}
+
return false;
}
@@ -246,44 +308,54 @@
#if LOG4CXX_UNICHAR_API
NDC::NDC(const std::basic_string<UniChar>& message)
{
- push(message);
+ push(message);
}
void NDC::push(const std::basic_string<UniChar>& message)
{
- LOG4CXX_DECODE_UNICHAR(msg, message);
- pushLS(msg);
+ LOG4CXX_DECODE_UNICHAR(msg, message);
+ pushLS(msg);
}
bool NDC::pop(std::basic_string<UniChar>& dst)
{
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- if(!stack.empty())
+
+ if (!stack.empty())
{
- Transcoder::encode(stack.top().message, dst);
- stack.pop();
- data->recycle();
- return true;
+ Transcoder::encode(stack.top().message, dst);
+ stack.pop();
+ data->recycle();
+ return true;
}
+
data->recycle();
}
+
return false;
}
bool NDC::peek(std::basic_string<UniChar>& dst)
{
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- if(!stack.empty())
+
+ if (!stack.empty())
{
- Transcoder::encode(stack.top().message, dst);
- return true;
+ Transcoder::encode(stack.top().message, dst);
+ return true;
}
+
data->recycle();
}
+
return false;
}
@@ -293,44 +365,54 @@
#if LOG4CXX_CFSTRING_API
NDC::NDC(const CFStringRef& message)
{
- push(message);
+ push(message);
}
void NDC::push(const CFStringRef& message)
{
- LOG4CXX_DECODE_CFSTRING(msg, message);
- pushLS(msg);
+ LOG4CXX_DECODE_CFSTRING(msg, message);
+ pushLS(msg);
}
bool NDC::pop(CFStringRef& dst)
{
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- if(!stack.empty())
+
+ if (!stack.empty())
{
- dst = Transcoder::encode(getMessage(stack.top()));
- stack.pop();
- data->recycle();
- return true;
+ dst = Transcoder::encode(getMessage(stack.top()));
+ stack.pop();
+ data->recycle();
+ return true;
}
+
data->recycle();
}
+
return false;
}
bool NDC::peek(CFStringRef& dst)
{
ThreadSpecificData* data = ThreadSpecificData::getCurrentData();
- if (data != 0) {
+
+ if (data != 0)
+ {
Stack& stack = data->getStack();
- if(!stack.empty())
+
+ if (!stack.empty())
{
- dst = Transcoder::encode(getMessage(stack.top()));
- return true;
+ dst = Transcoder::encode(getMessage(stack.top()));
+ return true;
}
+
data->recycle();
}
+
return false;
}
diff --git a/src/main/cpp/ndcpatternconverter.cpp b/src/main/cpp/ndcpatternconverter.cpp
index c965541..5057c66 100644
--- a/src/main/cpp/ndcpatternconverter.cpp
+++ b/src/main/cpp/ndcpatternconverter.cpp
@@ -16,7 +16,7 @@
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -34,21 +34,25 @@
IMPLEMENT_LOG4CXX_OBJECT(NDCPatternConverter)
NDCPatternConverter::NDCPatternConverter() :
- LoggingEventPatternConverter(LOG4CXX_STR("NDC"),
- LOG4CXX_STR("ndc")) {
+ LoggingEventPatternConverter(LOG4CXX_STR("NDC"),
+ LOG4CXX_STR("ndc"))
+{
}
PatternConverterPtr NDCPatternConverter::newInstance(
- const std::vector<LogString>& /* options */) {
- static PatternConverterPtr def(new NDCPatternConverter());
- return def;
+ const std::vector<LogString>& /* options */)
+{
+ static PatternConverterPtr def(new NDCPatternConverter());
+ return def;
}
void NDCPatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- Pool& /* p */) const {
- if(!event->getNDC(toAppendTo)) {
- toAppendTo.append(LOG4CXX_STR("null"));
- }
- }
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ Pool& /* p */) const
+{
+ if (!event->getNDC(toAppendTo))
+ {
+ toAppendTo.append(LOG4CXX_STR("null"));
+ }
+}
diff --git a/src/main/cpp/nteventlogappender.cpp b/src/main/cpp/nteventlogappender.cpp
index 07a7866..5bcab69 100644
--- a/src/main/cpp/nteventlogappender.cpp
+++ b/src/main/cpp/nteventlogappender.cpp
@@ -34,56 +34,57 @@
class CCtUserSIDHelper
{
-public:
- static bool FreeSid(SID * pSid)
+ public:
+ static bool FreeSid(SID* pSid)
{
- return ::HeapFree(GetProcessHeap(), 0, (LPVOID)pSid) != 0;
+ return ::HeapFree(GetProcessHeap(), 0, (LPVOID)pSid) != 0;
}
- static bool CopySid(SID * * ppDstSid, SID * pSrcSid)
+ static bool CopySid(SID * * ppDstSid, SID* pSrcSid)
{
- bool bSuccess = false;
+ bool bSuccess = false;
- DWORD dwLength = ::GetLengthSid(pSrcSid);
- *ppDstSid = (SID *) ::HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY, dwLength);
+ DWORD dwLength = ::GetLengthSid(pSrcSid);
+ *ppDstSid = (SID*) ::HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY, dwLength);
- if (::CopySid(dwLength, *ppDstSid, pSrcSid))
- {
- bSuccess = true;
- }
- else
- {
- FreeSid(*ppDstSid);
- }
+ if (::CopySid(dwLength, *ppDstSid, pSrcSid))
+ {
+ bSuccess = true;
+ }
+ else
+ {
+ FreeSid(*ppDstSid);
+ }
- return bSuccess;
+ return bSuccess;
}
static bool GetCurrentUserSID(SID * * ppSid)
{
- bool bSuccess = false;
+ bool bSuccess = false;
- // Pseudohandle so don't need to close it
- HANDLE hProcess = ::GetCurrentProcess();
- HANDLE hToken = NULL;
- if (::OpenProcessToken(hProcess, TOKEN_QUERY, &hToken))
+ // Pseudohandle so don't need to close it
+ HANDLE hProcess = ::GetCurrentProcess();
+ HANDLE hToken = NULL;
+
+ if (::OpenProcessToken(hProcess, TOKEN_QUERY, &hToken))
+ {
+ // Get the required size
+ DWORD tusize = 0;
+ GetTokenInformation(hToken, TokenUser, NULL, 0, &tusize);
+ TOKEN_USER* ptu = (TOKEN_USER*)new BYTE[tusize];
+
+ if (GetTokenInformation(hToken, TokenUser, (LPVOID)ptu, tusize, &tusize))
{
- // Get the required size
- DWORD tusize = 0;
- GetTokenInformation(hToken, TokenUser, NULL, 0, &tusize);
- TOKEN_USER* ptu = (TOKEN_USER*)new BYTE[tusize];
-
- if (GetTokenInformation(hToken, TokenUser, (LPVOID)ptu, tusize, &tusize))
- {
- bSuccess = CopySid(ppSid, (SID *)ptu->User.Sid);
- }
-
- CloseHandle(hToken);
- delete [] ptu;
+ bSuccess = CopySid(ppSid, (SID*)ptu->User.Sid);
}
- return bSuccess;
+ CloseHandle(hToken);
+ delete [] ptu;
+ }
+
+ return bSuccess;
}
};
@@ -94,117 +95,119 @@
}
NTEventLogAppender::NTEventLogAppender(const LogString& server, const LogString& log, const LogString& source, const LayoutPtr& layout)
-: server(server), log(log), source(source), hEventLog(NULL), pCurrentUserSID(NULL)
+ : server(server), log(log), source(source), hEventLog(NULL), pCurrentUserSID(NULL)
{
- this->layout = layout;
- Pool pool;
- activateOptions(pool);
+ this->layout = layout;
+ Pool pool;
+ activateOptions(pool);
}
NTEventLogAppender::~NTEventLogAppender()
{
- finalize();
+ finalize();
}
void NTEventLogAppender::close()
{
- if (hEventLog != NULL)
- {
- ::DeregisterEventSource(hEventLog);
- hEventLog = NULL;
- }
+ if (hEventLog != NULL)
+ {
+ ::DeregisterEventSource(hEventLog);
+ hEventLog = NULL;
+ }
- if (pCurrentUserSID != NULL)
- {
- CCtUserSIDHelper::FreeSid((::SID*) pCurrentUserSID);
- pCurrentUserSID = NULL;
- }
+ if (pCurrentUserSID != NULL)
+ {
+ CCtUserSIDHelper::FreeSid((::SID*) pCurrentUserSID);
+ pCurrentUserSID = NULL;
+ }
}
void NTEventLogAppender::setOption(const LogString& option, const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SERVER"), LOG4CXX_STR("server")))
- {
- server = value;
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOG"), LOG4CXX_STR("log")))
- {
- log = value;
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SOURCE"), LOG4CXX_STR("source")))
- {
- source = value;
- }
- else
- {
- AppenderSkeleton::setOption(option, value);
- }
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SERVER"), LOG4CXX_STR("server")))
+ {
+ server = value;
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOG"), LOG4CXX_STR("log")))
+ {
+ log = value;
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SOURCE"), LOG4CXX_STR("source")))
+ {
+ source = value;
+ }
+ else
+ {
+ AppenderSkeleton::setOption(option, value);
+ }
}
void NTEventLogAppender::activateOptions(Pool&)
{
- if (source.empty())
- {
- LogLog::warn(
- ((LogString) LOG4CXX_STR("Source option not set for appender ["))
- + name + LOG4CXX_STR("]."));
- return;
- }
+ if (source.empty())
+ {
+ LogLog::warn(
+ ((LogString) LOG4CXX_STR("Source option not set for appender ["))
+ + name + LOG4CXX_STR("]."));
+ return;
+ }
- if (log.empty())
- {
- log = LOG4CXX_STR("Application");
- }
+ if (log.empty())
+ {
+ log = LOG4CXX_STR("Application");
+ }
- close();
+ close();
- // current user security identifier
- CCtUserSIDHelper::GetCurrentUserSID((::SID**) &pCurrentUserSID);
+ // current user security identifier
+ CCtUserSIDHelper::GetCurrentUserSID((::SID**) &pCurrentUserSID);
- addRegistryInfo();
+ addRegistryInfo();
- LOG4CXX_ENCODE_WCHAR(wsource, source);
- LOG4CXX_ENCODE_WCHAR(wserver, server);
- hEventLog = ::RegisterEventSourceW(
- wserver.empty() ? NULL : wserver.c_str(),
- wsource.c_str());
- if (hEventLog == NULL) {
- LogString msg(LOG4CXX_STR("Cannot register NT EventLog -- server: '"));
- msg.append(server);
- msg.append(LOG4CXX_STR("' source: '"));
- msg.append(source);
- LogLog::error(msg);
- LogLog::error(getErrorString(LOG4CXX_STR("RegisterEventSource")));
- }
+ LOG4CXX_ENCODE_WCHAR(wsource, source);
+ LOG4CXX_ENCODE_WCHAR(wserver, server);
+ hEventLog = ::RegisterEventSourceW(
+ wserver.empty() ? NULL : wserver.c_str(),
+ wsource.c_str());
+
+ if (hEventLog == NULL)
+ {
+ LogString msg(LOG4CXX_STR("Cannot register NT EventLog -- server: '"));
+ msg.append(server);
+ msg.append(LOG4CXX_STR("' source: '"));
+ msg.append(source);
+ LogLog::error(msg);
+ LogLog::error(getErrorString(LOG4CXX_STR("RegisterEventSource")));
+ }
}
void NTEventLogAppender::append(const LoggingEventPtr& event, Pool& p)
{
- if (hEventLog == NULL)
- {
- LogLog::warn(LOG4CXX_STR("NT EventLog not opened."));
- return;
- }
+ if (hEventLog == NULL)
+ {
+ LogLog::warn(LOG4CXX_STR("NT EventLog not opened."));
+ return;
+ }
- LogString oss;
- layout->format(oss, event, p);
- wchar_t* msgs = Transcoder::wencode(oss, p);
- BOOL bSuccess = ::ReportEventW(
- hEventLog,
- getEventType(event),
- getEventCategory(event),
- 0x1000,
- pCurrentUserSID,
- 1,
- 0,
- (LPCWSTR*) &msgs,
- NULL);
+ LogString oss;
+ layout->format(oss, event, p);
+ wchar_t* msgs = Transcoder::wencode(oss, p);
+ BOOL bSuccess = ::ReportEventW(
+ hEventLog,
+ getEventType(event),
+ getEventCategory(event),
+ 0x1000,
+ pCurrentUserSID,
+ 1,
+ 0,
+ (LPCWSTR*) &msgs,
+ NULL);
- if (!bSuccess)
- {
- LogLog::error(getErrorString(LOG4CXX_STR("ReportEvent")));
- }
+ if (!bSuccess)
+ {
+ LogLog::error(getErrorString(LOG4CXX_STR("ReportEvent")));
+ }
}
/*
@@ -212,79 +215,104 @@
*/
void NTEventLogAppender::addRegistryInfo()
{
- DWORD disposition = 0;
- ::HKEY hkey = 0;
- LogString subkey(LOG4CXX_STR("SYSTEM\\CurrentControlSet\\Services\\EventLog\\"));
- subkey.append(log);
- subkey.append(1, (logchar) 0x5C /* '\\' */);
- subkey.append(source);
- LOG4CXX_ENCODE_WCHAR(wsubkey, subkey);
+ DWORD disposition = 0;
+ ::HKEY hkey = 0;
+ LogString subkey(LOG4CXX_STR("SYSTEM\\CurrentControlSet\\Services\\EventLog\\"));
+ subkey.append(log);
+ subkey.append(1, (logchar) 0x5C /* '\\' */);
+ subkey.append(source);
+ LOG4CXX_ENCODE_WCHAR(wsubkey, subkey);
- long stat = RegCreateKeyExW(HKEY_LOCAL_MACHINE, wsubkey.c_str(), 0, NULL,
- REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL,
- &hkey, &disposition);
- if (stat == ERROR_SUCCESS && disposition == REG_CREATED_NEW_KEY) {
- HMODULE hmodule = GetModuleHandleW(L"log4cxx");
- if (hmodule == NULL) {
- hmodule = GetModuleHandleW(0);
- }
- wchar_t modpath[_MAX_PATH];
- DWORD modlen = GetModuleFileNameW(hmodule, modpath, _MAX_PATH - 1);
- if (modlen > 0) {
- modpath[modlen] = 0;
- RegSetValueExW(hkey, L"EventMessageFile", 0, REG_SZ,
- (LPBYTE) modpath, wcslen(modpath) * sizeof(wchar_t));
- RegSetValueExW(hkey, L"CategoryMessageFile", 0, REG_SZ,
- (LPBYTE) modpath, wcslen(modpath) * sizeof(wchar_t));
- DWORD typesSupported = 7;
- DWORD categoryCount = 6;
- RegSetValueExW(hkey, L"TypesSupported", 0, REG_DWORD,
- (LPBYTE)&typesSupported, sizeof(DWORD));
- RegSetValueExW(hkey, L"CategoryCount", 0, REG_DWORD,
- (LPBYTE)&categoryCount, sizeof(DWORD));
- }
+ long stat = RegCreateKeyExW(HKEY_LOCAL_MACHINE, wsubkey.c_str(), 0, NULL,
+ REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL,
+ &hkey, &disposition);
+
+ if (stat == ERROR_SUCCESS && disposition == REG_CREATED_NEW_KEY)
+ {
+ HMODULE hmodule = GetModuleHandleW(L"log4cxx");
+
+ if (hmodule == NULL)
+ {
+ hmodule = GetModuleHandleW(0);
}
- RegCloseKey(hkey);
- return;
+ wchar_t modpath[_MAX_PATH];
+ DWORD modlen = GetModuleFileNameW(hmodule, modpath, _MAX_PATH - 1);
+
+ if (modlen > 0)
+ {
+ modpath[modlen] = 0;
+ RegSetValueExW(hkey, L"EventMessageFile", 0, REG_SZ,
+ (LPBYTE) modpath, wcslen(modpath) * sizeof(wchar_t));
+ RegSetValueExW(hkey, L"CategoryMessageFile", 0, REG_SZ,
+ (LPBYTE) modpath, wcslen(modpath) * sizeof(wchar_t));
+ DWORD typesSupported = 7;
+ DWORD categoryCount = 6;
+ RegSetValueExW(hkey, L"TypesSupported", 0, REG_DWORD,
+ (LPBYTE)&typesSupported, sizeof(DWORD));
+ RegSetValueExW(hkey, L"CategoryCount", 0, REG_DWORD,
+ (LPBYTE)&categoryCount, sizeof(DWORD));
+ }
+ }
+
+ RegCloseKey(hkey);
+ return;
}
WORD NTEventLogAppender::getEventType(const LoggingEventPtr& event)
{
- int priority = event->getLevel()->toInt();
- WORD type = EVENTLOG_SUCCESS;
- if (priority >= Level::INFO_INT) {
- type = EVENTLOG_INFORMATION_TYPE;
- if (priority >= Level::WARN_INT) {
- type = EVENTLOG_WARNING_TYPE;
- if (priority >= Level::ERROR_INT) {
- type = EVENTLOG_ERROR_TYPE;
- }
- }
- }
- return type;
+ int priority = event->getLevel()->toInt();
+ WORD type = EVENTLOG_SUCCESS;
+
+ if (priority >= Level::INFO_INT)
+ {
+ type = EVENTLOG_INFORMATION_TYPE;
+
+ if (priority >= Level::WARN_INT)
+ {
+ type = EVENTLOG_WARNING_TYPE;
+
+ if (priority >= Level::ERROR_INT)
+ {
+ type = EVENTLOG_ERROR_TYPE;
+ }
+ }
+ }
+
+ return type;
}
WORD NTEventLogAppender::getEventCategory(const LoggingEventPtr& event)
{
- int priority = event->getLevel()->toInt();
- WORD category = 1;
- if (priority >= Level::DEBUG_INT) {
- category = 2;
- if (priority >= Level::INFO_INT) {
- category = 3;
- if (priority >= Level::WARN_INT) {
- category = 4;
- if (priority >= Level::ERROR_INT) {
- category = 5;
- if (priority >= Level::FATAL_INT) {
- category = 6;
+ int priority = event->getLevel()->toInt();
+ WORD category = 1;
+
+ if (priority >= Level::DEBUG_INT)
+ {
+ category = 2;
+
+ if (priority >= Level::INFO_INT)
+ {
+ category = 3;
+
+ if (priority >= Level::WARN_INT)
+ {
+ category = 4;
+
+ if (priority >= Level::ERROR_INT)
+ {
+ category = 5;
+
+ if (priority >= Level::FATAL_INT)
+ {
+ category = 6;
+ }
}
- }
- }
- }
- }
- return category;
+ }
+ }
+ }
+
+ return category;
}
LogString NTEventLogAppender::getErrorString(const LogString& function)
diff --git a/src/main/cpp/objectimpl.cpp b/src/main/cpp/objectimpl.cpp
index db26558..bc2e978 100644
--- a/src/main/cpp/objectimpl.cpp
+++ b/src/main/cpp/objectimpl.cpp
@@ -19,7 +19,7 @@
#include <log4cxx/helpers/objectimpl.h>
#include <apr_atomic.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/helpers/aprinitializer.h>
@@ -27,7 +27,7 @@
ObjectImpl::ObjectImpl() : ref( 0 )
{
- log4cxx::helpers::APRInitializer::initialize();
+ log4cxx::helpers::APRInitializer::initialize();
}
ObjectImpl::~ObjectImpl()
@@ -36,13 +36,13 @@
void ObjectImpl::addRef() const
{
- apr_atomic_inc32( & ref );
+ apr_atomic_inc32( & ref );
}
void ObjectImpl::releaseRef() const
{
- if ( apr_atomic_dec32( & ref ) == 0 )
- {
- delete this;
- }
+ if ( apr_atomic_dec32( & ref ) == 0 )
+ {
+ delete this;
+ }
}
diff --git a/src/main/cpp/objectoutputstream.cpp b/src/main/cpp/objectoutputstream.cpp
index 11c56c7..e119569 100644
--- a/src/main/cpp/objectoutputstream.cpp
+++ b/src/main/cpp/objectoutputstream.cpp
@@ -6,7 +6,7 @@
* (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
+ * 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,
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -31,205 +31,209 @@
IMPLEMENT_LOG4CXX_OBJECT(ObjectOutputStream)
ObjectOutputStream::ObjectOutputStream(OutputStreamPtr outputStream, Pool& p)
- : os(outputStream),
- utf8Encoder(CharsetEncoder::getUTF8Encoder()),
- objectHandleDefault(0x7E0000),
- objectHandle(objectHandleDefault),
- classDescriptions(new ClassDescriptionMap())
+ : os(outputStream),
+ utf8Encoder(CharsetEncoder::getUTF8Encoder()),
+ objectHandleDefault(0x7E0000),
+ objectHandle(objectHandleDefault),
+ classDescriptions(new ClassDescriptionMap())
{
- unsigned char start[] = { 0xAC, 0xED, 0x00, 0x05 };
- ByteBuffer buf((char*) start, sizeof(start));
- os->write(buf, p);
+ unsigned char start[] = { 0xAC, 0xED, 0x00, 0x05 };
+ ByteBuffer buf((char*) start, sizeof(start));
+ os->write(buf, p);
}
ObjectOutputStream::~ObjectOutputStream()
{
- delete classDescriptions;
+ delete classDescriptions;
}
void ObjectOutputStream::close(Pool& p)
{
- os->close(p);
+ os->close(p);
}
void ObjectOutputStream::flush(Pool& p)
{
- os->flush(p);
+ os->flush(p);
}
void ObjectOutputStream::reset(Pool& p)
{
- os->flush(p);
- writeByte(TC_RESET, p);
- os->flush(p);
+ os->flush(p);
+ writeByte(TC_RESET, p);
+ os->flush(p);
- objectHandle = objectHandleDefault;
- classDescriptions->clear();
+ objectHandle = objectHandleDefault;
+ classDescriptions->clear();
}
void ObjectOutputStream::writeObject(const LogString& val, Pool& p)
{
- objectHandle++;
- writeByte(TC_STRING, p);
- char bytes[2];
+ objectHandle++;
+ writeByte(TC_STRING, p);
+ char bytes[2];
#if LOG4CXX_LOGCHAR_IS_UTF8
- size_t len = val.size();
- ByteBuffer dataBuf(const_cast<char*>(val.data()), val.size());
+ size_t len = val.size();
+ ByteBuffer dataBuf(const_cast<char*>(val.data()), val.size());
#else
- size_t maxSize = 6 * val.size();
- char* data = p.pstralloc(maxSize);
- ByteBuffer dataBuf(data, maxSize);
- LogString::const_iterator iter(val.begin());
- utf8Encoder->encode(val, iter, dataBuf);
- dataBuf.flip();
- size_t len = dataBuf.limit();
+ size_t maxSize = 6 * val.size();
+ char* data = p.pstralloc(maxSize);
+ ByteBuffer dataBuf(data, maxSize);
+ LogString::const_iterator iter(val.begin());
+ utf8Encoder->encode(val, iter, dataBuf);
+ dataBuf.flip();
+ size_t len = dataBuf.limit();
#endif
- bytes[1] = (char) (len & 0xFF);
- bytes[0] = (char) ((len >> 8) & 0xFF);
- ByteBuffer lenBuf(bytes, sizeof(bytes));
+ bytes[1] = (char) (len & 0xFF);
+ bytes[0] = (char) ((len >> 8) & 0xFF);
+ ByteBuffer lenBuf(bytes, sizeof(bytes));
- os->write(lenBuf, p);
- os->write(dataBuf, p);
+ os->write(lenBuf, p);
+ os->write(dataBuf, p);
}
void ObjectOutputStream::writeObject(const MDC::Map& val, Pool& p)
{
- //
- // TC_OBJECT and the classDesc for java.util.Hashtable
- //
- unsigned char prolog[] = {
- 0x72, 0x00, 0x13, 0x6A, 0x61, 0x76, 0x61,
- 0x2E, 0x75, 0x74, 0x69, 0x6C, 0x2E, 0x48, 0x61,
- 0x73, 0x68, 0x74, 0x61, 0x62, 0x6C, 0x65, 0x13,
- 0xBB, 0x0F, 0x25, 0x21, 0x4A, 0xE4, 0xB8, 0x03,
- 0x00, 0x02, 0x46, 0x00, 0x0A, 0x6C, 0x6F, 0x61,
- 0x64, 0x46, 0x61, 0x63, 0x74, 0x6F, 0x72, 0x49,
- 0x00, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68,
- 0x6F, 0x6C, 0x64, 0x78, 0x70 };
- writeProlog("java.util.Hashtable", 1, (char*) prolog, sizeof(prolog), p);
+ //
+ // TC_OBJECT and the classDesc for java.util.Hashtable
+ //
+ unsigned char prolog[] =
+ {
+ 0x72, 0x00, 0x13, 0x6A, 0x61, 0x76, 0x61,
+ 0x2E, 0x75, 0x74, 0x69, 0x6C, 0x2E, 0x48, 0x61,
+ 0x73, 0x68, 0x74, 0x61, 0x62, 0x6C, 0x65, 0x13,
+ 0xBB, 0x0F, 0x25, 0x21, 0x4A, 0xE4, 0xB8, 0x03,
+ 0x00, 0x02, 0x46, 0x00, 0x0A, 0x6C, 0x6F, 0x61,
+ 0x64, 0x46, 0x61, 0x63, 0x74, 0x6F, 0x72, 0x49,
+ 0x00, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68,
+ 0x6F, 0x6C, 0x64, 0x78, 0x70
+ };
+ writeProlog("java.util.Hashtable", 1, (char*) prolog, sizeof(prolog), p);
- // loadFactor = 0.75, threshold = 5, blockdata start, buckets.size = 7
- char data[] = { 0x3F, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
- TC_BLOCKDATA, 0x08, 0x00, 0x00, 0x00, 0x07 };
- ByteBuffer dataBuf(data, sizeof(data));
- os->write(dataBuf, p);
+ // loadFactor = 0.75, threshold = 5, blockdata start, buckets.size = 7
+ char data[] = { 0x3F, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
+ TC_BLOCKDATA, 0x08, 0x00, 0x00, 0x00, 0x07
+ };
+ ByteBuffer dataBuf(data, sizeof(data));
+ os->write(dataBuf, p);
- char size[4];
- size_t sz = val.size();
+ char size[4];
+ size_t sz = val.size();
- size[3] = (char) (sz & 0xFF);
- size[2] = (char) ((sz >> 8) & 0xFF);
- size[1] = (char) ((sz >> 16) & 0xFF);
- size[0] = (char) ((sz >> 24) & 0xFF);
+ size[3] = (char) (sz & 0xFF);
+ size[2] = (char) ((sz >> 8) & 0xFF);
+ size[1] = (char) ((sz >> 16) & 0xFF);
+ size[0] = (char) ((sz >> 24) & 0xFF);
- ByteBuffer sizeBuf(size, sizeof(size));
- os->write(sizeBuf, p);
+ ByteBuffer sizeBuf(size, sizeof(size));
+ os->write(sizeBuf, p);
- for (MDC::Map::const_iterator iter = val.begin();
- iter != val.end();
- iter++)
- {
- writeObject(iter->first, p);
- writeObject(iter->second, p);
- }
- writeByte(TC_ENDBLOCKDATA, p);
+ for (MDC::Map::const_iterator iter = val.begin();
+ iter != val.end();
+ iter++)
+ {
+ writeObject(iter->first, p);
+ writeObject(iter->second, p);
+ }
+
+ writeByte(TC_ENDBLOCKDATA, p);
}
void ObjectOutputStream::writeUTFString(const std::string& val, Pool& p)
{
- char bytes[3];
- size_t len = val.size();
- ByteBuffer dataBuf(const_cast<char*>(val.data()), val.size());
- objectHandle++;
+ char bytes[3];
+ size_t len = val.size();
+ ByteBuffer dataBuf(const_cast<char*>(val.data()), val.size());
+ objectHandle++;
- bytes[0] = 0x74;
- bytes[1] = (char) ((len >> 8) & 0xFF);
- bytes[2] = (char) (len & 0xFF);
+ bytes[0] = 0x74;
+ bytes[1] = (char) ((len >> 8) & 0xFF);
+ bytes[2] = (char) (len & 0xFF);
- ByteBuffer lenBuf(bytes, sizeof(bytes));
- os->write(lenBuf, p);
- os->write(dataBuf, p);
+ ByteBuffer lenBuf(bytes, sizeof(bytes));
+ os->write(lenBuf, p);
+ os->write(dataBuf, p);
}
void ObjectOutputStream::writeByte(char val, Pool& p)
{
- ByteBuffer buf(&val, 1);
- os->write(buf, p);
+ ByteBuffer buf(&val, 1);
+ os->write(buf, p);
}
void ObjectOutputStream::writeInt(int val, Pool& p)
{
- char bytes[4];
+ char bytes[4];
- bytes[3] = (char) (val & 0xFF);
- bytes[2] = (char) ((val >> 8) & 0xFF);
- bytes[1] = (char) ((val >> 16) & 0xFF);
- bytes[0] = (char) ((val >> 24) & 0xFF);
+ bytes[3] = (char) (val & 0xFF);
+ bytes[2] = (char) ((val >> 8) & 0xFF);
+ bytes[1] = (char) ((val >> 16) & 0xFF);
+ bytes[0] = (char) ((val >> 24) & 0xFF);
- ByteBuffer buf(bytes, sizeof(bytes));
- os->write(buf, p);
+ ByteBuffer buf(bytes, sizeof(bytes));
+ os->write(buf, p);
}
void ObjectOutputStream::writeLong(log4cxx_time_t val, Pool& p)
{
- char bytes[8];
+ char bytes[8];
- bytes[7] = (char) (val & 0xFF);
- bytes[6] = (char) ((val >> 8) & 0xFF);
- bytes[5] = (char) ((val >> 16) & 0xFF);
- bytes[4] = (char) ((val >> 24) & 0xFF);
- bytes[3] = (char) ((val >> 32) & 0xFF);
- bytes[2] = (char) ((val >> 40) & 0xFF);
- bytes[1] = (char) ((val >> 48) & 0xFF);
- bytes[0] = (char) ((val >> 56) & 0xFF);
+ bytes[7] = (char) (val & 0xFF);
+ bytes[6] = (char) ((val >> 8) & 0xFF);
+ bytes[5] = (char) ((val >> 16) & 0xFF);
+ bytes[4] = (char) ((val >> 24) & 0xFF);
+ bytes[3] = (char) ((val >> 32) & 0xFF);
+ bytes[2] = (char) ((val >> 40) & 0xFF);
+ bytes[1] = (char) ((val >> 48) & 0xFF);
+ bytes[0] = (char) ((val >> 56) & 0xFF);
- ByteBuffer buf(bytes, sizeof(bytes));
- os->write(buf, p);
+ ByteBuffer buf(bytes, sizeof(bytes));
+ os->write(buf, p);
}
void ObjectOutputStream::writeBytes(const char* bytes, size_t len, Pool& p)
{
- ByteBuffer buf(const_cast<char*>(bytes), len);
- os->write(buf, p);
+ ByteBuffer buf(const_cast<char*>(bytes), len);
+ os->write(buf, p);
}
void ObjectOutputStream::writeNull(Pool& p)
{
- writeByte(TC_NULL, p);
+ writeByte(TC_NULL, p);
}
-void ObjectOutputStream::writeProlog(const char* className,
- int classDescIncrement,
- char* classDesc,
- size_t len,
- Pool& p)
+void ObjectOutputStream::writeProlog(const char* className,
+ int classDescIncrement,
+ char* classDesc,
+ size_t len,
+ Pool& p)
{
- ClassDescriptionMap::const_iterator match = classDescriptions->find(className);
+ ClassDescriptionMap::const_iterator match = classDescriptions->find(className);
- if (match != classDescriptions->end())
- {
- char bytes[6];
+ if (match != classDescriptions->end())
+ {
+ char bytes[6];
- bytes[0] = TC_OBJECT;
- bytes[1] = TC_REFERENCE;
- bytes[2] = (char) ((match->second >> 24) & 0xFF);
- bytes[3] = (char) ((match->second >> 16) & 0xFF);
- bytes[4] = (char) ((match->second >> 8) & 0xFF);
- bytes[5] = (char) (match->second & 0xFF);
+ bytes[0] = TC_OBJECT;
+ bytes[1] = TC_REFERENCE;
+ bytes[2] = (char) ((match->second >> 24) & 0xFF);
+ bytes[3] = (char) ((match->second >> 16) & 0xFF);
+ bytes[4] = (char) ((match->second >> 8) & 0xFF);
+ bytes[5] = (char) (match->second & 0xFF);
- ByteBuffer buf(bytes, sizeof(bytes));
- os->write(buf, p);
+ ByteBuffer buf(bytes, sizeof(bytes));
+ os->write(buf, p);
- objectHandle++;
- }
- else
- {
- classDescriptions->insert(ClassDescriptionMap::value_type(className, objectHandle));
- writeByte(TC_OBJECT, p);
+ objectHandle++;
+ }
+ else
+ {
+ classDescriptions->insert(ClassDescriptionMap::value_type(className, objectHandle));
+ writeByte(TC_OBJECT, p);
- ByteBuffer buf(classDesc, len);
- os->write(buf, p);
+ ByteBuffer buf(classDesc, len);
+ os->write(buf, p);
- objectHandle += (classDescIncrement + 1);
- }
+ objectHandle += (classDescIncrement + 1);
+ }
}
diff --git a/src/main/cpp/objectptr.cpp b/src/main/cpp/objectptr.cpp
index 0c4f306..bc3e8b9 100644
--- a/src/main/cpp/objectptr.cpp
+++ b/src/main/cpp/objectptr.cpp
@@ -21,27 +21,32 @@
using namespace log4cxx::helpers;
-ObjectPtrBase::ObjectPtrBase() {
+ObjectPtrBase::ObjectPtrBase()
+{
}
-ObjectPtrBase::~ObjectPtrBase() {
+ObjectPtrBase::~ObjectPtrBase()
+{
}
-void ObjectPtrBase::checkNull(const int& null) {
- if (null != 0) {
- throw IllegalArgumentException(LOG4CXX_STR("Attempt to set pointer to a non-zero numeric value."));
+void ObjectPtrBase::checkNull(const int& null)
+{
+ if (null != 0)
+ {
+ throw IllegalArgumentException(LOG4CXX_STR("Attempt to set pointer to a non-zero numeric value."));
}
}
-void* ObjectPtrBase::exchange(void** destination, void* newValue) {
+void* ObjectPtrBase::exchange(void** destination, void* newValue)
+{
#if _WIN32 && (!defined(_MSC_VER) || _MSC_VER >= 1300)
return InterlockedExchangePointer(destination, newValue);
#elif APR_SIZEOF_VOIDP == 4
- return (void*) apr_atomic_xchg32((volatile apr_uint32_t*) destination,
- (apr_uint32_t) newValue);
+ return (void*) apr_atomic_xchg32((volatile apr_uint32_t*) destination,
+ (apr_uint32_t) newValue);
#else
- void* oldValue = *destination;
- *destination = newValue;
- return oldValue;
+ void* oldValue = *destination;
+ *destination = newValue;
+ return oldValue;
#endif
}
diff --git a/src/main/cpp/obsoleterollingfileappender.cpp b/src/main/cpp/obsoleterollingfileappender.cpp
index 5c6f5d6..2e48008 100644
--- a/src/main/cpp/obsoleterollingfileappender.cpp
+++ b/src/main/cpp/obsoleterollingfileappender.cpp
@@ -29,127 +29,149 @@
using namespace log4cxx::helpers;
using namespace log4cxx::spi;
-namespace log4cxx {
- class ClassRollingFileAppender : public Class
- {
+namespace log4cxx
+{
+class ClassRollingFileAppender : public Class
+{
public:
ClassRollingFileAppender() : helpers::Class() {}
- virtual LogString getName() const {
+ virtual LogString getName() const
+ {
return LOG4CXX_STR("org.apache.log4j.RollingFileAppender");
}
- virtual ObjectPtr newInstance() const {
+ virtual ObjectPtr newInstance() const
+ {
return new RollingFileAppender();
}
- };
+};
}
-const log4cxx::helpers::Class& RollingFileAppender::getClass() const { return getStaticClass(); }
-const log4cxx::helpers::Class& RollingFileAppender::getStaticClass() {
- static ClassRollingFileAppender theClass;
- return theClass;
+const log4cxx::helpers::Class& RollingFileAppender::getClass() const
+{
+ return getStaticClass();
}
-const log4cxx::helpers::ClassRegistration& RollingFileAppender::registerClass() {
+const log4cxx::helpers::Class& RollingFileAppender::getStaticClass()
+{
+ static ClassRollingFileAppender theClass;
+ return theClass;
+}
+const log4cxx::helpers::ClassRegistration& RollingFileAppender::registerClass()
+{
static log4cxx::helpers::ClassRegistration classReg(RollingFileAppender::getStaticClass);
return classReg;
}
-namespace log4cxx { namespace classes {
+namespace log4cxx
+{
+namespace classes
+{
const log4cxx::helpers::ClassRegistration& ObsoleteRollingFileAppenderRegistration =
- RollingFileAppender::registerClass();
-} }
+ RollingFileAppender::registerClass();
+}
+}
RollingFileAppender::RollingFileAppender()
- : maxFileSize(10*1024*1024), maxBackupIndex(1) {
+ : maxFileSize(10 * 1024 * 1024), maxBackupIndex(1)
+{
}
RollingFileAppender::RollingFileAppender(
- const LayoutPtr& newLayout,
- const LogString& filename,
- bool append)
- : maxFileSize(10*1024*1024), maxBackupIndex(1) {
- setLayout(newLayout);
- setFile(filename);
- setAppend(append);
- Pool p;
- activateOptions(p);
+ const LayoutPtr& newLayout,
+ const LogString& filename,
+ bool append)
+ : maxFileSize(10 * 1024 * 1024), maxBackupIndex(1)
+{
+ setLayout(newLayout);
+ setFile(filename);
+ setAppend(append);
+ Pool p;
+ activateOptions(p);
}
RollingFileAppender::RollingFileAppender(const LayoutPtr& newLayout,
- const LogString& filename)
- : maxFileSize(10*1024*1024), maxBackupIndex(1) {
- setLayout(newLayout);
- setFile(filename);
- Pool p;
- activateOptions(p);
+ const LogString& filename)
+ : maxFileSize(10 * 1024 * 1024), maxBackupIndex(1)
+{
+ setLayout(newLayout);
+ setFile(filename);
+ Pool p;
+ activateOptions(p);
}
-RollingFileAppender::~RollingFileAppender() {
+RollingFileAppender::~RollingFileAppender()
+{
}
void RollingFileAppender::setOption(const LogString& option,
- const LogString& value)
+ const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("MAXFILESIZE"), LOG4CXX_STR("maxfilesize"))
- || StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("MAXIMUMFILESIZE"), LOG4CXX_STR("maximumfilesize")))
- {
- setMaxFileSize(value);
- }
- else if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("MAXBACKUPINDEX"), LOG4CXX_STR("maxbackupindex"))
- || StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("MAXIMUMBACKUPINDEX"), LOG4CXX_STR("maximumbackupindex")))
- {
- maxBackupIndex = StringHelper::toInt(value);
- }
- else
- {
- using namespace log4cxx::rolling;
- RollingFileAppenderSkeleton::setOption(option, value);
- }
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("MAXFILESIZE"), LOG4CXX_STR("maxfilesize"))
+ || StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("MAXIMUMFILESIZE"), LOG4CXX_STR("maximumfilesize")))
+ {
+ setMaxFileSize(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("MAXBACKUPINDEX"), LOG4CXX_STR("maxbackupindex"))
+ || StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("MAXIMUMBACKUPINDEX"), LOG4CXX_STR("maximumbackupindex")))
+ {
+ maxBackupIndex = StringHelper::toInt(value);
+ }
+ else
+ {
+ using namespace log4cxx::rolling;
+ RollingFileAppenderSkeleton::setOption(option, value);
+ }
}
-int RollingFileAppender::getMaxBackupIndex() const {
- return maxBackupIndex;
+int RollingFileAppender::getMaxBackupIndex() const
+{
+ return maxBackupIndex;
}
-long RollingFileAppender::getMaximumFileSize() const {
- return maxFileSize;
+long RollingFileAppender::getMaximumFileSize() const
+{
+ return maxFileSize;
}
-void RollingFileAppender::setMaxBackupIndex(int maxBackups) {
- maxBackupIndex = maxBackups;
+void RollingFileAppender::setMaxBackupIndex(int maxBackups)
+{
+ maxBackupIndex = maxBackups;
}
-void RollingFileAppender::setMaximumFileSize(int maxFileSize1) {
- maxFileSize = maxFileSize1;
+void RollingFileAppender::setMaximumFileSize(int maxFileSize1)
+{
+ maxFileSize = maxFileSize1;
}
-void RollingFileAppender::setMaxFileSize(const LogString& value) {
- maxFileSize = OptionConverter::toFileSize(value, maxFileSize + 1);
+void RollingFileAppender::setMaxFileSize(const LogString& value)
+{
+ maxFileSize = OptionConverter::toFileSize(value, maxFileSize + 1);
}
-void RollingFileAppender::activateOptions(Pool& p) {
- log4cxx::rolling::SizeBasedTriggeringPolicyPtr trigger(
- new log4cxx::rolling::SizeBasedTriggeringPolicy());
- trigger->setMaxFileSize(maxFileSize);
- trigger->activateOptions(p);
- setTriggeringPolicy(trigger);
+void RollingFileAppender::activateOptions(Pool& p)
+{
+ log4cxx::rolling::SizeBasedTriggeringPolicyPtr trigger(
+ new log4cxx::rolling::SizeBasedTriggeringPolicy());
+ trigger->setMaxFileSize(maxFileSize);
+ trigger->activateOptions(p);
+ setTriggeringPolicy(trigger);
- log4cxx::rolling::FixedWindowRollingPolicyPtr rolling(
- new log4cxx::rolling::FixedWindowRollingPolicy());
- rolling->setMinIndex(1);
- rolling->setMaxIndex(maxBackupIndex);
- rolling->setFileNamePattern(getFile() + LOG4CXX_STR(".%i"));
- rolling->activateOptions(p);
- setRollingPolicy(rolling);
+ log4cxx::rolling::FixedWindowRollingPolicyPtr rolling(
+ new log4cxx::rolling::FixedWindowRollingPolicy());
+ rolling->setMinIndex(1);
+ rolling->setMaxIndex(maxBackupIndex);
+ rolling->setFileNamePattern(getFile() + LOG4CXX_STR(".%i"));
+ rolling->activateOptions(p);
+ setRollingPolicy(rolling);
- using namespace log4cxx::rolling;
- RollingFileAppenderSkeleton::activateOptions(p);
+ using namespace log4cxx::rolling;
+ RollingFileAppenderSkeleton::activateOptions(p);
}
diff --git a/src/main/cpp/odbcappender.cpp b/src/main/cpp/odbcappender.cpp
index 88876cf..a739d33 100644
--- a/src/main/cpp/odbcappender.cpp
+++ b/src/main/cpp/odbcappender.cpp
@@ -23,14 +23,14 @@
#include <apr_strings.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
#if LOG4CXX_HAVE_ODBC
-#if defined(WIN32) || defined(_WIN32)
-#include <windows.h>
-#endif
-#include <sqlext.h>
+ #if defined(WIN32) || defined(_WIN32)
+ #include <windows.h>
+ #endif
+ #include <sqlext.h>
#endif
@@ -42,43 +42,49 @@
SQLException::SQLException(short fHandleType,
void* hInput, const char* prolog,
log4cxx::helpers::Pool& p)
- : Exception(formatMessage(fHandleType, hInput, prolog, p)) {
+ : Exception(formatMessage(fHandleType, hInput, prolog, p))
+{
}
SQLException::SQLException(const char* msg)
- : Exception(msg) {
+ : Exception(msg)
+{
}
SQLException::SQLException(const SQLException& src)
- : Exception(src) {
+ : Exception(src)
+{
}
const char* SQLException::formatMessage(short fHandleType,
- void* hInput, const char* prolog, log4cxx::helpers::Pool& p) {
- std::string strReturn(prolog);
- strReturn.append(" - ");
+ void* hInput, const char* prolog, log4cxx::helpers::Pool& p)
+{
+ std::string strReturn(prolog);
+ strReturn.append(" - ");
#if LOG4CXX_HAVE_ODBC
- SQLCHAR SqlState[6];
- SQLCHAR Msg[SQL_MAX_MESSAGE_LENGTH];
- SQLINTEGER NativeError;
- SQLSMALLINT i;
- SQLSMALLINT MsgLen;
- SQLRETURN rc2;
+ SQLCHAR SqlState[6];
+ SQLCHAR Msg[SQL_MAX_MESSAGE_LENGTH];
+ SQLINTEGER NativeError;
+ SQLSMALLINT i;
+ SQLSMALLINT MsgLen;
+ SQLRETURN rc2;
- // Get the status records.
- i = 1;
- while ((rc2 = SQLGetDiagRecA(fHandleType, hInput, i, SqlState, &NativeError,
- Msg, sizeof(Msg), &MsgLen)) != SQL_NO_DATA)
- {
- strReturn.append((char*) Msg);
- i++;
- }
+ // Get the status records.
+ i = 1;
+
+ while ((rc2 = SQLGetDiagRecA(fHandleType, hInput, i, SqlState, &NativeError,
+ Msg, sizeof(Msg), &MsgLen)) != SQL_NO_DATA)
+ {
+ strReturn.append((char*) Msg);
+ i++;
+ }
+
#else
- strReturn.append("log4cxx built without ODBC support");
+ strReturn.append("log4cxx built without ODBC support");
#endif
- return apr_pstrdup((apr_pool_t*) p.getAPRPool(), strReturn.c_str());
+ return apr_pstrdup((apr_pool_t*) p.getAPRPool(), strReturn.c_str());
}
@@ -87,46 +93,47 @@
ODBCAppender::ODBCAppender()
-: connection(0), env(0), bufferSize(1)
+ : connection(0), env(0), bufferSize(1)
{
}
ODBCAppender::~ODBCAppender()
{
- finalize();
+ finalize();
}
void ODBCAppender::setOption(const LogString& option, const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFERSIZE"), LOG4CXX_STR("buffersize")))
- {
- setBufferSize((size_t)OptionConverter::toInt(value, 1));
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("PASSWORD"), LOG4CXX_STR("password")))
- {
- setPassword(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SQL"), LOG4CXX_STR("sql")))
- {
- setSql(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("URL"), LOG4CXX_STR("url"))
- || StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("DSN"), LOG4CXX_STR("dsn"))
- || StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("CONNECTIONSTRING"), LOG4CXX_STR("connectionstring")) )
- {
- setURL(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("USER"), LOG4CXX_STR("user")))
- {
- setUser(value);
- }
- else
- {
- AppenderSkeleton::setOption(option, value);
- }
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFERSIZE"), LOG4CXX_STR("buffersize")))
+ {
+ setBufferSize((size_t)OptionConverter::toInt(value, 1));
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("PASSWORD"), LOG4CXX_STR("password")))
+ {
+ setPassword(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SQL"), LOG4CXX_STR("sql")))
+ {
+ setSql(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("URL"), LOG4CXX_STR("url"))
+ || StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("DSN"), LOG4CXX_STR("dsn"))
+ || StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("CONNECTIONSTRING"), LOG4CXX_STR("connectionstring")) )
+ {
+ setURL(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("USER"), LOG4CXX_STR("user")))
+ {
+ setUser(value);
+ }
+ else
+ {
+ AppenderSkeleton::setOption(option, value);
+ }
}
-void ODBCAppender::activateOptions(log4cxx::helpers::Pool&) {
+void ODBCAppender::activateOptions(log4cxx::helpers::Pool&)
+{
#if !LOG4CXX_HAVE_ODBC
LogLog::error(LOG4CXX_STR("Can not activate ODBCAppender unless compiled with ODBC support."));
#endif
@@ -136,57 +143,62 @@
void ODBCAppender::append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p)
{
#if LOG4CXX_HAVE_ODBC
- buffer.push_back(event);
+ buffer.push_back(event);
- if (buffer.size() >= bufferSize)
- flushBuffer(p);
+ if (buffer.size() >= bufferSize)
+ {
+ flushBuffer(p);
+ }
+
#endif
}
LogString ODBCAppender::getLogStatement(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) const
{
- LogString sbuf;
- getLayout()->format(sbuf, event, p);
- return sbuf;
+ LogString sbuf;
+ getLayout()->format(sbuf, event, p);
+ return sbuf;
}
void ODBCAppender::execute(const LogString& sql, log4cxx::helpers::Pool& p)
{
#if LOG4CXX_HAVE_ODBC
- SQLRETURN ret;
- SQLHDBC con = SQL_NULL_HDBC;
- SQLHSTMT stmt = SQL_NULL_HSTMT;
+ SQLRETURN ret;
+ SQLHDBC con = SQL_NULL_HDBC;
+ SQLHSTMT stmt = SQL_NULL_HSTMT;
- try
- {
- con = getConnection(p);
+ try
+ {
+ con = getConnection(p);
- ret = SQLAllocHandle( SQL_HANDLE_STMT, con, &stmt);
- if (ret < 0)
- {
- throw SQLException( SQL_HANDLE_DBC, con, "Failed to allocate sql handle.", p);
- }
+ ret = SQLAllocHandle( SQL_HANDLE_STMT, con, &stmt);
- SQLWCHAR* wsql;
- encode(&wsql, sql, p);
- ret = SQLExecDirectW(stmt, wsql, SQL_NTS);
+ if (ret < 0)
+ {
+ throw SQLException( SQL_HANDLE_DBC, con, "Failed to allocate sql handle.", p);
+ }
- if (ret < 0)
- {
- throw SQLException(SQL_HANDLE_STMT, stmt, "Failed to execute sql statement.", p);
- }
- }
- catch (SQLException& e)
- {
- if (stmt != SQL_NULL_HSTMT)
- {
- SQLFreeHandle(SQL_HANDLE_STMT, stmt);
- }
+ SQLWCHAR* wsql;
+ encode(&wsql, sql, p);
+ ret = SQLExecDirectW(stmt, wsql, SQL_NTS);
- throw;
- }
- SQLFreeHandle(SQL_HANDLE_STMT, stmt);
- closeConnection(con);
+ if (ret < 0)
+ {
+ throw SQLException(SQL_HANDLE_STMT, stmt, "Failed to execute sql statement.", p);
+ }
+ }
+ catch (SQLException& e)
+ {
+ if (stmt != SQL_NULL_HSTMT)
+ {
+ SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+ }
+
+ throw;
+ }
+
+ SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+ closeConnection(con);
#else
throw SQLException("log4cxx build without ODBC support");
#endif
@@ -205,158 +217,179 @@
ODBCAppender::SQLHDBC ODBCAppender::getConnection(log4cxx::helpers::Pool& p)
{
#if LOG4CXX_HAVE_ODBC
- SQLRETURN ret;
+ SQLRETURN ret;
- if (env == SQL_NULL_HENV)
- {
- ret = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
- if (ret < 0)
- {
- SQLException ex(SQL_HANDLE_ENV, env, "Failed to allocate SQL handle.", p);
- env = SQL_NULL_HENV;
- throw ex;
- }
+ if (env == SQL_NULL_HENV)
+ {
+ ret = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
- ret = SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER);
- if (ret < 0)
- {
- SQLException ex(SQL_HANDLE_ENV, env, "Failed to set odbc version.", p);
- SQLFreeHandle(SQL_HANDLE_ENV, env);
- env = SQL_NULL_HENV;
- throw ex;
- }
- }
+ if (ret < 0)
+ {
+ SQLException ex(SQL_HANDLE_ENV, env, "Failed to allocate SQL handle.", p);
+ env = SQL_NULL_HENV;
+ throw ex;
+ }
- if (connection == SQL_NULL_HDBC)
- {
- ret = SQLAllocHandle(SQL_HANDLE_DBC, env, &connection);
- if (ret < 0)
- {
- SQLException ex(SQL_HANDLE_DBC, connection, "Failed to allocate sql handle.", p);
- connection = SQL_NULL_HDBC;
- throw ex;
- }
+ ret = SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER);
+
+ if (ret < 0)
+ {
+ SQLException ex(SQL_HANDLE_ENV, env, "Failed to set odbc version.", p);
+ SQLFreeHandle(SQL_HANDLE_ENV, env);
+ env = SQL_NULL_HENV;
+ throw ex;
+ }
+ }
+
+ if (connection == SQL_NULL_HDBC)
+ {
+ ret = SQLAllocHandle(SQL_HANDLE_DBC, env, &connection);
+
+ if (ret < 0)
+ {
+ SQLException ex(SQL_HANDLE_DBC, connection, "Failed to allocate sql handle.", p);
+ connection = SQL_NULL_HDBC;
+ throw ex;
+ }
- SQLWCHAR *wURL, *wUser, *wPwd;
- encode(&wURL, databaseURL, p);
- encode(&wUser, databaseUser, p);
- encode(&wPwd, databasePassword, p);
+ SQLWCHAR* wURL, *wUser, *wPwd;
+ encode(&wURL, databaseURL, p);
+ encode(&wUser, databaseUser, p);
+ encode(&wPwd, databasePassword, p);
- ret = SQLConnectW( connection,
- wURL, SQL_NTS,
- wUser, SQL_NTS,
- wPwd, SQL_NTS);
+ ret = SQLConnectW( connection,
+ wURL, SQL_NTS,
+ wUser, SQL_NTS,
+ wPwd, SQL_NTS);
- if (ret < 0)
- {
- SQLException ex(SQL_HANDLE_DBC, connection, "Failed to connect to database.", p);
- SQLFreeHandle(SQL_HANDLE_DBC, connection);
- connection = SQL_NULL_HDBC;
- throw ex;
- }
- }
+ if (ret < 0)
+ {
+ SQLException ex(SQL_HANDLE_DBC, connection, "Failed to connect to database.", p);
+ SQLFreeHandle(SQL_HANDLE_DBC, connection);
+ connection = SQL_NULL_HDBC;
+ throw ex;
+ }
+ }
- return connection;
+ return connection;
#else
- return 0;
+ return 0;
#endif
}
void ODBCAppender::close()
{
- if (closed) {
- return;
- }
- Pool p;
- try
- {
- flushBuffer(p);
- }
- catch (SQLException& e)
- {
- errorHandler->error(LOG4CXX_STR("Error closing connection"),
- e, ErrorCode::GENERIC_FAILURE);
- }
-#if LOG4CXX_HAVE_ODBC
- if (connection != SQL_NULL_HDBC)
- {
- SQLDisconnect(connection);
- SQLFreeHandle(SQL_HANDLE_DBC, connection);
- }
+ if (closed)
+ {
+ return;
+ }
- if (env != SQL_NULL_HENV)
- {
- SQLFreeHandle(SQL_HANDLE_ENV, env);
- }
+ Pool p;
+
+ try
+ {
+ flushBuffer(p);
+ }
+ catch (SQLException& e)
+ {
+ errorHandler->error(LOG4CXX_STR("Error closing connection"),
+ e, ErrorCode::GENERIC_FAILURE);
+ }
+
+#if LOG4CXX_HAVE_ODBC
+
+ if (connection != SQL_NULL_HDBC)
+ {
+ SQLDisconnect(connection);
+ SQLFreeHandle(SQL_HANDLE_DBC, connection);
+ }
+
+ if (env != SQL_NULL_HENV)
+ {
+ SQLFreeHandle(SQL_HANDLE_ENV, env);
+ }
+
#endif
- this->closed = true;
+ this->closed = true;
}
void ODBCAppender::flushBuffer(Pool& p)
{
- std::list<spi::LoggingEventPtr>::iterator i;
- for (i = buffer.begin(); i != buffer.end(); i++)
- {
- try
- {
- const LoggingEventPtr& logEvent = *i;
- LogString sql = getLogStatement(logEvent, p);
- execute(sql, p);
- }
- catch (SQLException& e)
- {
- errorHandler->error(LOG4CXX_STR("Failed to execute sql"), e,
- ErrorCode::FLUSH_FAILURE);
- }
- }
+ std::list<spi::LoggingEventPtr>::iterator i;
- // clear the buffer of reported events
- buffer.clear();
+ for (i = buffer.begin(); i != buffer.end(); i++)
+ {
+ try
+ {
+ const LoggingEventPtr& logEvent = *i;
+ LogString sql = getLogStatement(logEvent, p);
+ execute(sql, p);
+ }
+ catch (SQLException& e)
+ {
+ errorHandler->error(LOG4CXX_STR("Failed to execute sql"), e,
+ ErrorCode::FLUSH_FAILURE);
+ }
+ }
+
+ // clear the buffer of reported events
+ buffer.clear();
}
void ODBCAppender::setSql(const LogString& s)
{
- sqlStatement = s;
- if (getLayout() == 0)
- {
- this->setLayout(new PatternLayout(s));
- }
- else
- {
- PatternLayoutPtr patternLayout = this->getLayout();
- if (patternLayout != 0)
- {
- patternLayout->setConversionPattern(s);
- }
- }
+ sqlStatement = s;
+
+ if (getLayout() == 0)
+ {
+ this->setLayout(new PatternLayout(s));
+ }
+ else
+ {
+ PatternLayoutPtr patternLayout = this->getLayout();
+
+ if (patternLayout != 0)
+ {
+ patternLayout->setConversionPattern(s);
+ }
+ }
}
-void ODBCAppender::encode(wchar_t** dest, const LogString& src, Pool& p) {
- *dest = Transcoder::wencode(src, p);
+void ODBCAppender::encode(wchar_t** dest, const LogString& src, Pool& p)
+{
+ *dest = Transcoder::wencode(src, p);
}
void ODBCAppender::encode(unsigned short** dest,
- const LogString& src, Pool& p) {
- // worst case double number of characters from UTF-8 or wchar_t
- *dest = (unsigned short*)
- p.palloc((src.size() + 1) * 2 * sizeof(unsigned short));
- unsigned short* current = *dest;
- for(LogString::const_iterator i = src.begin();
- i != src.end();) {
- unsigned int sv = Transcoder::decode(src, i);
- if (sv < 0x10000) {
- *current++ = (unsigned short) sv;
- } else {
- unsigned char u = (unsigned char) (sv >> 16);
- unsigned char w = (unsigned char) (u - 1);
- unsigned short hs = (0xD800 + ((w & 0xF) << 6) + ((sv & 0xFFFF) >> 10));
- unsigned short ls = (0xDC00 + (sv & 0x3FF));
- *current++ = (unsigned short) hs;
- *current++ = (unsigned short) ls;
- }
- }
- *current = 0;
+ const LogString& src, Pool& p)
+{
+ // worst case double number of characters from UTF-8 or wchar_t
+ *dest = (unsigned short*)
+ p.palloc((src.size() + 1) * 2 * sizeof(unsigned short));
+ unsigned short* current = *dest;
+
+ for (LogString::const_iterator i = src.begin();
+ i != src.end();)
+ {
+ unsigned int sv = Transcoder::decode(src, i);
+
+ if (sv < 0x10000)
+ {
+ *current++ = (unsigned short) sv;
+ }
+ else
+ {
+ unsigned char u = (unsigned char) (sv >> 16);
+ unsigned char w = (unsigned char) (u - 1);
+ unsigned short hs = (0xD800 + ((w & 0xF) << 6) + ((sv & 0xFFFF) >> 10));
+ unsigned short ls = (0xDC00 + (sv & 0x3FF));
+ *current++ = (unsigned short) hs;
+ *current++ = (unsigned short) ls;
+ }
+ }
+
+ *current = 0;
}
diff --git a/src/main/cpp/onlyonceerrorhandler.cpp b/src/main/cpp/onlyonceerrorhandler.cpp
index 49a6963..52dddf2 100644
--- a/src/main/cpp/onlyonceerrorhandler.cpp
+++ b/src/main/cpp/onlyonceerrorhandler.cpp
@@ -27,18 +27,20 @@
IMPLEMENT_LOG4CXX_OBJECT(OnlyOnceErrorHandler)
OnlyOnceErrorHandler::OnlyOnceErrorHandler() :
- WARN_PREFIX(LOG4CXX_STR("log4cxx warning: ")),
-ERROR_PREFIX(LOG4CXX_STR("log4cxx error: ")), firstTime(true)
+ WARN_PREFIX(LOG4CXX_STR("log4cxx warning: ")),
+ ERROR_PREFIX(LOG4CXX_STR("log4cxx error: ")), firstTime(true)
{
}
- void OnlyOnceErrorHandler::addRef() const {
+void OnlyOnceErrorHandler::addRef() const
+{
ObjectImpl::addRef();
- }
+}
- void OnlyOnceErrorHandler::releaseRef() const {
+void OnlyOnceErrorHandler::releaseRef() const
+{
ObjectImpl::releaseRef();
- }
+}
void OnlyOnceErrorHandler::setLogger(const LoggerPtr&)
{
@@ -53,29 +55,29 @@
}
void OnlyOnceErrorHandler::error(const LogString& message, const std::exception& e,
- int) const
+ int) const
{
- if(firstTime)
- {
- LogLog::error(message, e);
- firstTime = false;
- }
+ if (firstTime)
+ {
+ LogLog::error(message, e);
+ firstTime = false;
+ }
}
void OnlyOnceErrorHandler::error(const LogString& message, const std::exception& e,
- int errorCode, const log4cxx::spi::LoggingEventPtr&) const
+ int errorCode, const log4cxx::spi::LoggingEventPtr&) const
{
- error(message, e, errorCode);
+ error(message, e, errorCode);
}
void OnlyOnceErrorHandler::error(const LogString& message) const
{
- if(firstTime)
- {
- LogLog::error(message);
- firstTime = false;
- }
+ if (firstTime)
+ {
+ LogLog::error(message);
+ firstTime = false;
+ }
}
diff --git a/src/main/cpp/optionconverter.cpp b/src/main/cpp/optionconverter.cpp
index 862b547..f2e79fa 100644
--- a/src/main/cpp/optionconverter.cpp
+++ b/src/main/cpp/optionconverter.cpp
@@ -48,334 +48,368 @@
LogString sbuf;
LogString::const_iterator i = s.begin();
- while(i != s.end())
+
+ while (i != s.end())
+ {
+ c = *i++;
+
+ if (c == 0x5C /* '\\' */)
{
- c = *i++;
- if (c == 0x5C /* '\\' */)
- {
- c = *i++;
+ c = *i++;
- switch (c)
- {
- case 0x6E: //'n'
- c = 0x0A;
- break;
+ switch (c)
+ {
+ case 0x6E: //'n'
+ c = 0x0A;
+ break;
- case 0x72: //'r'
- c = 0x0D;
- break;
+ case 0x72: //'r'
+ c = 0x0D;
+ break;
- case 0x74: //'t'
- c = 0x09;
- break;
+ case 0x74: //'t'
+ c = 0x09;
+ break;
- case 0x66: //'f'
- c = 0x0C;
- break;
- default:
- break;
- }
- }
- sbuf.append(1, c);
+ case 0x66: //'f'
+ c = 0x0C;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ sbuf.append(1, c);
}
+
return sbuf;
}
bool OptionConverter::toBoolean(const LogString& value, bool dEfault)
{
- if (value.length() >= 4) {
- if (StringHelper::equalsIgnoreCase(value.substr(0,4),
- LOG4CXX_STR("TRUE"), LOG4CXX_STR("true"))) {
- return true;
- }
+ if (value.length() >= 4)
+ {
+ if (StringHelper::equalsIgnoreCase(value.substr(0, 4),
+ LOG4CXX_STR("TRUE"), LOG4CXX_STR("true")))
+ {
+ return true;
}
+ }
- if (dEfault && value.length() >= 5) {
- if (StringHelper::equalsIgnoreCase(value.substr(0,5),
- LOG4CXX_STR("FALSE"), LOG4CXX_STR("false"))) {
- return false;
- }
+ if (dEfault && value.length() >= 5)
+ {
+ if (StringHelper::equalsIgnoreCase(value.substr(0, 5),
+ LOG4CXX_STR("FALSE"), LOG4CXX_STR("false")))
+ {
+ return false;
}
+ }
- return dEfault;
+ return dEfault;
}
int OptionConverter::toInt(const LogString& value, int dEfault)
{
- LogString trimmed(StringHelper::trim(value));
- if (trimmed.empty())
- {
- return dEfault;
- }
- LOG4CXX_ENCODE_CHAR(cvalue, trimmed);
+ LogString trimmed(StringHelper::trim(value));
- return (int) atol(cvalue.c_str());
+ if (trimmed.empty())
+ {
+ return dEfault;
+ }
+
+ LOG4CXX_ENCODE_CHAR(cvalue, trimmed);
+
+ return (int) atol(cvalue.c_str());
}
long OptionConverter::toFileSize(const LogString& s, long dEfault)
{
- if(s.empty())
+ if (s.empty())
+ {
+ return dEfault;
+ }
+
+ size_t index = s.find_first_of(LOG4CXX_STR("bB"));
+
+ if (index != LogString::npos && index > 0)
+ {
+ long multiplier = 1;
+ index--;
+
+ if (s[index] == 0x6B /* 'k' */ || s[index] == 0x4B /* 'K' */)
{
- return dEfault;
+ multiplier = 1024;
+ }
+ else if (s[index] == 0x6D /* 'm' */ || s[index] == 0x4D /* 'M' */)
+ {
+ multiplier = 1024 * 1024;
+ }
+ else if (s[index] == 0x67 /* 'g'*/ || s[index] == 0x47 /* 'G' */)
+ {
+ multiplier = 1024 * 1024 * 1024;
}
- size_t index = s.find_first_of(LOG4CXX_STR("bB"));
- if (index != LogString::npos && index > 0) {
- long multiplier = 1;
- index--;
- if (s[index] == 0x6B /* 'k' */ || s[index] == 0x4B /* 'K' */) {
- multiplier = 1024;
- } else if(s[index] == 0x6D /* 'm' */ || s[index] == 0x4D /* 'M' */) {
- multiplier = 1024*1024;
- } else if(s[index] == 0x67 /* 'g'*/ || s[index] == 0x47 /* 'G' */) {
- multiplier = 1024*1024*1024;
- }
- return toInt(s.substr(0, index), 1) * multiplier;
- }
+ return toInt(s.substr(0, index), 1) * multiplier;
+ }
- return toInt(s, 1);
+ return toInt(s, 1);
}
LogString OptionConverter::findAndSubst(const LogString& key, Properties& props)
{
- LogString value(props.getProperty(key));
+ LogString value(props.getProperty(key));
- if(value.empty())
- return value;
+ if (value.empty())
+ {
+ return value;
+ }
- try
- {
- return substVars(value, props);
- }
- catch(IllegalArgumentException& e)
- {
- LogLog::error(((LogString) LOG4CXX_STR("Bad option value ["))
- + value + LOG4CXX_STR("]."), e);
- return value;
- }
+ try
+ {
+ return substVars(value, props);
+ }
+ catch (IllegalArgumentException& e)
+ {
+ LogLog::error(((LogString) LOG4CXX_STR("Bad option value ["))
+ + value + LOG4CXX_STR("]."), e);
+ return value;
+ }
}
LogString OptionConverter::substVars(const LogString& val, Properties& props)
{
- LogString sbuf;
- const logchar delimStartArray[] = { 0x24, 0x7B, 0 };
- const LogString delimStart(delimStartArray);
- const logchar delimStop = 0x7D; // '}';
- const size_t DELIM_START_LEN = 2;
- const size_t DELIM_STOP_LEN = 1;
+ LogString sbuf;
+ const logchar delimStartArray[] = { 0x24, 0x7B, 0 };
+ const LogString delimStart(delimStartArray);
+ const logchar delimStop = 0x7D; // '}';
+ const size_t DELIM_START_LEN = 2;
+ const size_t DELIM_STOP_LEN = 1;
- int i = 0;
- int j, k;
+ int i = 0;
+ int j, k;
- while(true)
+ while (true)
+ {
+ j = val.find(delimStart, i);
+
+ if (j == -1)
{
- j = val.find(delimStart, i);
- if(j == -1)
- {
- // no more variables
- if(i==0)
- { // this is a simple string
- return val;
- }
- else
- { // add the tail string which contails no variables and return the result.
- sbuf.append(val.substr(i, val.length() - i));
- return sbuf;
- }
- }
- else
- {
- sbuf.append(val.substr(i, j - i));
- k = val.find(delimStop, j);
- if(k == -1)
- {
- LogString msg(1, (logchar) 0x22 /* '\"' */);
- msg.append(val);
- msg.append(LOG4CXX_STR("\" has no closing brace. Opening brace at position "));
- Pool p;
- StringHelper::toString(j, p, msg);
- msg.append(1, (logchar) 0x2E /* '.' */);
- throw IllegalArgumentException(msg);
- }
- else
- {
- j += DELIM_START_LEN;
- LogString key = val.substr(j, k - j);
- // first try in System properties
- LogString replacement(getSystemProperty(key, LogString()));
- // then try props parameter
- if(replacement.empty())
- {
- replacement = props.getProperty(key);
- }
-
- if(!replacement.empty())
- {
- // Do variable substitution on the replacement string
- // such that we can solve "Hello ${x2}" as "Hello p1"
- // the where the properties are
- // x1=p1
- // x2=${x1}
- LogString recursiveReplacement = substVars(replacement, props);
- sbuf.append(recursiveReplacement);
- }
- i = k + DELIM_STOP_LEN;
- }
- }
+ // no more variables
+ if (i == 0)
+ {
+ // this is a simple string
+ return val;
+ }
+ else
+ {
+ // add the tail string which contails no variables and return the result.
+ sbuf.append(val.substr(i, val.length() - i));
+ return sbuf;
+ }
}
+ else
+ {
+ sbuf.append(val.substr(i, j - i));
+ k = val.find(delimStop, j);
+
+ if (k == -1)
+ {
+ LogString msg(1, (logchar) 0x22 /* '\"' */);
+ msg.append(val);
+ msg.append(LOG4CXX_STR("\" has no closing brace. Opening brace at position "));
+ Pool p;
+ StringHelper::toString(j, p, msg);
+ msg.append(1, (logchar) 0x2E /* '.' */);
+ throw IllegalArgumentException(msg);
+ }
+ else
+ {
+ j += DELIM_START_LEN;
+ LogString key = val.substr(j, k - j);
+ // first try in System properties
+ LogString replacement(getSystemProperty(key, LogString()));
+
+ // then try props parameter
+ if (replacement.empty())
+ {
+ replacement = props.getProperty(key);
+ }
+
+ if (!replacement.empty())
+ {
+ // Do variable substitution on the replacement string
+ // such that we can solve "Hello ${x2}" as "Hello p1"
+ // the where the properties are
+ // x1=p1
+ // x2=${x1}
+ LogString recursiveReplacement = substVars(replacement, props);
+ sbuf.append(recursiveReplacement);
+ }
+
+ i = k + DELIM_STOP_LEN;
+ }
+ }
+ }
}
LogString OptionConverter::getSystemProperty(const LogString& key, const LogString& def)
{
- if (!key.empty())
- {
- LogString value(System::getProperty(key));
+ if (!key.empty())
+ {
+ LogString value(System::getProperty(key));
- if (!value.empty())
- {
- return value;
- }
+ if (!value.empty())
+ {
+ return value;
}
- return def;
+ }
+
+ return def;
}
LevelPtr OptionConverter::toLevel(const LogString& value,
- const LevelPtr& defaultValue)
+ const LevelPtr& defaultValue)
{
size_t hashIndex = value.find(LOG4CXX_STR("#"));
- if (hashIndex == LogString::npos)
+ if (hashIndex == LogString::npos)
+ {
+ if (value.empty())
{
- if (value.empty())
- {
- return defaultValue;
- }
- else
- {
- LogLog::debug(
+ return defaultValue;
+ }
+ else
+ {
+ LogLog::debug(
((LogString) LOG4CXX_STR("OptionConverter::toLevel: no class name specified, level=["))
- + value
- +LOG4CXX_STR("]"));
- // no class name specified : use standard Level class
- return Level::toLevelLS(value, defaultValue);
- }
+ + value
+ + LOG4CXX_STR("]"));
+ // no class name specified : use standard Level class
+ return Level::toLevelLS(value, defaultValue);
}
+ }
- LogString clazz = value.substr(hashIndex + 1);
- LogString levelName = value.substr(0, hashIndex);
- LogLog::debug(((LogString) LOG4CXX_STR("OptionConverter::toLevel: class=["))
- + clazz + LOG4CXX_STR("], level=[") + levelName + LOG4CXX_STR("]"));
+ LogString clazz = value.substr(hashIndex + 1);
+ LogString levelName = value.substr(0, hashIndex);
+ LogLog::debug(((LogString) LOG4CXX_STR("OptionConverter::toLevel: class=["))
+ + clazz + LOG4CXX_STR("], level=[") + levelName + LOG4CXX_STR("]"));
- // This is degenerate case but you never know.
- if (levelName.empty())
- {
- return Level::toLevelLS(value, defaultValue);
- }
+ // This is degenerate case but you never know.
+ if (levelName.empty())
+ {
+ return Level::toLevelLS(value, defaultValue);
+ }
- try
- {
- Level::LevelClass& levelClass =
- (Level::LevelClass&)Loader::loadClass(clazz);
- return levelClass.toLevel(levelName);
- }
- catch (ClassNotFoundException&)
- {
- LogLog::warn(((LogString) LOG4CXX_STR("custom level class ["))
- + clazz + LOG4CXX_STR("] not found."));
- }
- catch(Exception& oops)
- {
- LogLog::warn(
- LOG4CXX_STR("class [") + clazz + LOG4CXX_STR("], level [") + levelName +
- LOG4CXX_STR("] conversion) failed."), oops);
- }
- catch(...)
- {
- LogLog::warn(
- LOG4CXX_STR("class [") + clazz + LOG4CXX_STR("], level [") + levelName +
- LOG4CXX_STR("] conversion) failed."));
- }
+ try
+ {
+ Level::LevelClass& levelClass =
+ (Level::LevelClass&)Loader::loadClass(clazz);
+ return levelClass.toLevel(levelName);
+ }
+ catch (ClassNotFoundException&)
+ {
+ LogLog::warn(((LogString) LOG4CXX_STR("custom level class ["))
+ + clazz + LOG4CXX_STR("] not found."));
+ }
+ catch (Exception& oops)
+ {
+ LogLog::warn(
+ LOG4CXX_STR("class [") + clazz + LOG4CXX_STR("], level [") + levelName +
+ LOG4CXX_STR("] conversion) failed."), oops);
+ }
+ catch (...)
+ {
+ LogLog::warn(
+ LOG4CXX_STR("class [") + clazz + LOG4CXX_STR("], level [") + levelName +
+ LOG4CXX_STR("] conversion) failed."));
+ }
- return defaultValue;
+ return defaultValue;
}
ObjectPtr OptionConverter::instantiateByKey(Properties& props, const LogString& key,
const Class& superClass, const ObjectPtr& defaultValue)
{
- // Get the value of the property in string form
- LogString className(findAndSubst(key, props));
- if(className.empty())
- {
- LogLog::error(
- ((LogString) LOG4CXX_STR("Could not find value for key ")) + key);
- return defaultValue;
- }
+ // Get the value of the property in string form
+ LogString className(findAndSubst(key, props));
- // Trim className to avoid trailing spaces that cause problems.
- return OptionConverter::instantiateByClassName(
- StringHelper::trim(className), superClass, defaultValue);
+ if (className.empty())
+ {
+ LogLog::error(
+ ((LogString) LOG4CXX_STR("Could not find value for key ")) + key);
+ return defaultValue;
+ }
+
+ // Trim className to avoid trailing spaces that cause problems.
+ return OptionConverter::instantiateByClassName(
+ StringHelper::trim(className), superClass, defaultValue);
}
ObjectPtr OptionConverter::instantiateByClassName(const LogString& className,
const Class& superClass, const ObjectPtr& defaultValue)
{
- if(!className.empty())
+ if (!className.empty())
+ {
+ try
{
- try
- {
- const Class& classObj = Loader::loadClass(className);
- ObjectPtr newObject = classObj.newInstance();
- if (!newObject->instanceof(superClass))
- {
- return defaultValue;
- }
+ const Class& classObj = Loader::loadClass(className);
+ ObjectPtr newObject = classObj.newInstance();
- return newObject;
- }
- catch (Exception& e)
- {
- LogLog::error(LOG4CXX_STR("Could not instantiate class [") +
- className + LOG4CXX_STR("]."), e);
- }
+ if (!newObject->instanceof(superClass))
+ {
+ return defaultValue;
+ }
+
+ return newObject;
}
- return defaultValue;
+ catch (Exception& e)
+ {
+ LogLog::error(LOG4CXX_STR("Could not instantiate class [") +
+ className + LOG4CXX_STR("]."), e);
+ }
+ }
+
+ return defaultValue;
}
void OptionConverter::selectAndConfigure(const File& configFileName,
- const LogString& _clazz, spi::LoggerRepositoryPtr& hierarchy)
+ const LogString& _clazz, spi::LoggerRepositoryPtr& hierarchy)
{
- ConfiguratorPtr configurator;
- LogString clazz = _clazz;
+ ConfiguratorPtr configurator;
+ LogString clazz = _clazz;
- LogString filename(configFileName.getPath());
- if(clazz.empty()
- && filename.length() > 4
- && StringHelper::equalsIgnoreCase(
- filename.substr(filename.length() -4),
- LOG4CXX_STR(".XML"), LOG4CXX_STR(".xml")))
- {
- clazz = log4cxx::xml::DOMConfigurator::getStaticClass().toString();
- }
+ LogString filename(configFileName.getPath());
- if(!clazz.empty())
- {
- LogLog::debug(LOG4CXX_STR("Preferred configurator class: ") + clazz);
- configurator = instantiateByClassName(clazz,
- Configurator::getStaticClass(),
- 0);
- if(configurator == 0)
- {
- LogLog::error(LOG4CXX_STR("Could not instantiate configurator [")
- + clazz + LOG4CXX_STR("]."));
- return;
- }
- }
- else
- {
- configurator = new PropertyConfigurator();
- }
+ if (clazz.empty()
+ && filename.length() > 4
+ && StringHelper::equalsIgnoreCase(
+ filename.substr(filename.length() - 4),
+ LOG4CXX_STR(".XML"), LOG4CXX_STR(".xml")))
+ {
+ clazz = log4cxx::xml::DOMConfigurator::getStaticClass().toString();
+ }
- configurator->doConfigure(configFileName, hierarchy);
+ if (!clazz.empty())
+ {
+ LogLog::debug(LOG4CXX_STR("Preferred configurator class: ") + clazz);
+ configurator = instantiateByClassName(clazz,
+ Configurator::getStaticClass(),
+ 0);
+
+ if (configurator == 0)
+ {
+ LogLog::error(LOG4CXX_STR("Could not instantiate configurator [")
+ + clazz + LOG4CXX_STR("]."));
+ return;
+ }
+ }
+ else
+ {
+ configurator = new PropertyConfigurator();
+ }
+
+ configurator->doConfigure(configFileName, hierarchy);
}
diff --git a/src/main/cpp/outputdebugstringappender.cpp b/src/main/cpp/outputdebugstringappender.cpp
index 5e3687f..9e22677 100644
--- a/src/main/cpp/outputdebugstringappender.cpp
+++ b/src/main/cpp/outputdebugstringappender.cpp
@@ -27,19 +27,20 @@
IMPLEMENT_LOG4CXX_OBJECT(OutputDebugStringAppender)
-OutputDebugStringAppender::OutputDebugStringAppender() {
+OutputDebugStringAppender::OutputDebugStringAppender()
+{
}
void OutputDebugStringAppender::append(const spi::LoggingEventPtr& event, Pool& p)
{
- LogString buf;
- layout->format(buf, event, p);
+ LogString buf;
+ layout->format(buf, event, p);
#if LOG4CXX_WCHAR_T_API
- LOG4CXX_ENCODE_WCHAR(wstr, buf);
- ::OutputDebugStringW(wstr.c_str());
+ LOG4CXX_ENCODE_WCHAR(wstr, buf);
+ ::OutputDebugStringW(wstr.c_str());
#else
- LOG4CXX_ENCODE_CHAR(str, buf);
- ::OutputDebugStringA(str.c_str());
+ LOG4CXX_ENCODE_CHAR(str, buf);
+ ::OutputDebugStringA(str.c_str());
#endif
}
diff --git a/src/main/cpp/outputstream.cpp b/src/main/cpp/outputstream.cpp
index 5ebb928..89526d8 100644
--- a/src/main/cpp/outputstream.cpp
+++ b/src/main/cpp/outputstream.cpp
@@ -24,18 +24,22 @@
IMPLEMENT_LOG4CXX_OBJECT(OutputStream)
-OutputStream::OutputStream() {
+OutputStream::OutputStream()
+{
}
-OutputStream::~OutputStream() {
+OutputStream::~OutputStream()
+{
}
#ifdef LOG4CXX_MULTI_PROCESS
-apr_file_t* OutputStream::getFilePtr(){
+apr_file_t* OutputStream::getFilePtr()
+{
throw std::logic_error("getFilePtr must be implemented in the derived class that you are using");
}
-OutputStream& OutputStream::getFileOutPutStreamPtr(){
+OutputStream& OutputStream::getFileOutPutStreamPtr()
+{
throw std::logic_error("getFileOutPutStreamPtr must be implemented in the derived class that you are using");
}
#endif
diff --git a/src/main/cpp/outputstreamwriter.cpp b/src/main/cpp/outputstreamwriter.cpp
index 9b6bf35..88c21c9 100644
--- a/src/main/cpp/outputstreamwriter.cpp
+++ b/src/main/cpp/outputstreamwriter.cpp
@@ -28,61 +28,74 @@
IMPLEMENT_LOG4CXX_OBJECT(OutputStreamWriter)
OutputStreamWriter::OutputStreamWriter(OutputStreamPtr& out1)
- : out(out1), enc(CharsetEncoder::getDefaultEncoder()) {
- if (out1 == 0) {
- throw NullPointerException(LOG4CXX_STR("out parameter may not be null."));
- }
+ : out(out1), enc(CharsetEncoder::getDefaultEncoder())
+{
+ if (out1 == 0)
+ {
+ throw NullPointerException(LOG4CXX_STR("out parameter may not be null."));
+ }
}
OutputStreamWriter::OutputStreamWriter(OutputStreamPtr& out1,
- CharsetEncoderPtr &enc1)
- : out(out1), enc(enc1) {
- if (out1 == 0) {
- throw NullPointerException(LOG4CXX_STR("out parameter may not be null."));
+ CharsetEncoderPtr& enc1)
+ : out(out1), enc(enc1)
+{
+ if (out1 == 0)
+ {
+ throw NullPointerException(LOG4CXX_STR("out parameter may not be null."));
}
- if (enc1 == 0) {
- throw NullPointerException(LOG4CXX_STR("enc parameter may not be null."));
+
+ if (enc1 == 0)
+ {
+ throw NullPointerException(LOG4CXX_STR("enc parameter may not be null."));
}
}
-OutputStreamWriter::~OutputStreamWriter() {
+OutputStreamWriter::~OutputStreamWriter()
+{
}
-void OutputStreamWriter::close(Pool& p) {
- out->close(p);
+void OutputStreamWriter::close(Pool& p)
+{
+ out->close(p);
}
-void OutputStreamWriter::flush(Pool& p) {
- out->flush(p);
+void OutputStreamWriter::flush(Pool& p)
+{
+ out->flush(p);
}
-void OutputStreamWriter::write(const LogString& str, Pool& p) {
- if (str.length() > 0) {
+void OutputStreamWriter::write(const LogString& str, Pool& p)
+{
+ if (str.length() > 0)
+ {
#ifdef LOG4CXX_MULTI_PROCESS
- size_t bufSize = str.length() * 2;
- char *rawbuf = new char[bufSize];
- ByteBuffer buf(rawbuf, (size_t) bufSize);
+ size_t bufSize = str.length() * 2;
+ char* rawbuf = new char[bufSize];
+ ByteBuffer buf(rawbuf, (size_t) bufSize);
#else
- enum { BUFSIZE = 1024 };
- char rawbuf[BUFSIZE];
- ByteBuffer buf(rawbuf, (size_t) BUFSIZE);
+ enum { BUFSIZE = 1024 };
+ char rawbuf[BUFSIZE];
+ ByteBuffer buf(rawbuf, (size_t) BUFSIZE);
#endif
- enc->reset();
- LogString::const_iterator iter = str.begin();
- while(iter != str.end()) {
- CharsetEncoder::encode(enc, str, iter, buf);
- buf.flip();
- out->write(buf, p);
- buf.clear();
- }
+ enc->reset();
+ LogString::const_iterator iter = str.begin();
- CharsetEncoder::encode(enc, str, iter, buf);
- enc->flush(buf);
- buf.flip();
- out->write(buf, p);
+ while (iter != str.end())
+ {
+ CharsetEncoder::encode(enc, str, iter, buf);
+ buf.flip();
+ out->write(buf, p);
+ buf.clear();
+ }
+
+ CharsetEncoder::encode(enc, str, iter, buf);
+ enc->flush(buf);
+ buf.flip();
+ out->write(buf, p);
#ifdef LOG4CXX_MULTI_PROCESS
- delete []rawbuf;
+ delete []rawbuf;
#endif
- }
+ }
}
diff --git a/src/main/cpp/patternconverter.cpp b/src/main/cpp/patternconverter.cpp
index 9b7ab26..c3ee3e9 100644
--- a/src/main/cpp/patternconverter.cpp
+++ b/src/main/cpp/patternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -28,23 +28,28 @@
IMPLEMENT_LOG4CXX_OBJECT(PatternConverter)
PatternConverter::PatternConverter(
- const LogString& name1, const LogString& style1) :
- name(name1), style(style1) {
+ const LogString& name1, const LogString& style1) :
+ name(name1), style(style1)
+{
}
-PatternConverter::~PatternConverter() {
+PatternConverter::~PatternConverter()
+{
}
-LogString PatternConverter::getName() const {
+LogString PatternConverter::getName() const
+{
return name;
}
-LogString PatternConverter::getStyleClass(const log4cxx::helpers::ObjectPtr& /* e */) const {
+LogString PatternConverter::getStyleClass(const log4cxx::helpers::ObjectPtr& /* e */) const
+{
return style;
- }
+}
-void PatternConverter::append(LogString& toAppendTo, const std::string& src) {
- LOG4CXX_DECODE_CHAR(decoded, src);
- toAppendTo.append(decoded);
+void PatternConverter::append(LogString& toAppendTo, const std::string& src)
+{
+ LOG4CXX_DECODE_CHAR(decoded, src);
+ toAppendTo.append(decoded);
}
diff --git a/src/main/cpp/patternlayout.cpp b/src/main/cpp/patternlayout.cpp
index 030262f..8b6de3c 100644
--- a/src/main/cpp/patternlayout.cpp
+++ b/src/main/cpp/patternlayout.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -64,9 +64,10 @@
Constructs a PatternLayout using the supplied conversion pattern.
*/
PatternLayout::PatternLayout(const LogString& pattern)
- : conversionPattern(pattern) {
- Pool pool;
- activateOptions(pool);
+ : conversionPattern(pattern)
+{
+ Pool pool;
+ activateOptions(pool);
}
void PatternLayout::setConversionPattern(const LogString& pattern)
@@ -77,108 +78,117 @@
}
void PatternLayout::format(LogString& output,
- const spi::LoggingEventPtr& event,
- Pool& pool) const
+ const spi::LoggingEventPtr& event,
+ Pool& pool) const
{
- std::vector<FormattingInfoPtr>::const_iterator formatterIter =
- patternFields.begin();
- for(std::vector<LoggingEventPatternConverterPtr>::const_iterator
- converterIter = patternConverters.begin();
- converterIter != patternConverters.end();
- converterIter++, formatterIter++) {
- int startField = output.length();
- (*converterIter)->format(event, output, pool);
- (*formatterIter)->format(startField, output);
- }
+ std::vector<FormattingInfoPtr>::const_iterator formatterIter =
+ patternFields.begin();
+
+ for (std::vector<LoggingEventPatternConverterPtr>::const_iterator
+ converterIter = patternConverters.begin();
+ converterIter != patternConverters.end();
+ converterIter++, formatterIter++)
+ {
+ int startField = output.length();
+ (*converterIter)->format(event, output, pool);
+ (*formatterIter)->format(startField, output);
+ }
}
void PatternLayout::setOption(const LogString& option, const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("CONVERSIONPATTERN"),
- LOG4CXX_STR("conversionpattern")))
- {
- conversionPattern = OptionConverter::convertSpecialChars(value);
- }
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("CONVERSIONPATTERN"),
+ LOG4CXX_STR("conversionpattern")))
+ {
+ conversionPattern = OptionConverter::convertSpecialChars(value);
+ }
}
void PatternLayout::activateOptions(Pool&)
{
- LogString pat(conversionPattern);
- if (pat.empty()) {
- pat = LOG4CXX_STR("%m%n");
- }
- patternConverters.erase(patternConverters.begin(), patternConverters.end());
- patternFields.erase(patternFields.begin(), patternFields.end());
- std::vector<PatternConverterPtr> converters;
- PatternParser::parse(pat,
- converters,
- patternFields,
- getFormatSpecifiers());
+ LogString pat(conversionPattern);
- //
- // strip out any pattern converters that don't handle LoggingEvents
- //
- //
- for(std::vector<PatternConverterPtr>::const_iterator converterIter = converters.begin();
- converterIter != converters.end();
- converterIter++) {
- LoggingEventPatternConverterPtr eventConverter(*converterIter);
- if (eventConverter != NULL) {
- patternConverters.push_back(eventConverter);
- }
- }
+ if (pat.empty())
+ {
+ pat = LOG4CXX_STR("%m%n");
+ }
+
+ patternConverters.erase(patternConverters.begin(), patternConverters.end());
+ patternFields.erase(patternFields.begin(), patternFields.end());
+ std::vector<PatternConverterPtr> converters;
+ PatternParser::parse(pat,
+ converters,
+ patternFields,
+ getFormatSpecifiers());
+
+ //
+ // strip out any pattern converters that don't handle LoggingEvents
+ //
+ //
+ for (std::vector<PatternConverterPtr>::const_iterator converterIter = converters.begin();
+ converterIter != converters.end();
+ converterIter++)
+ {
+ LoggingEventPatternConverterPtr eventConverter(*converterIter);
+
+ if (eventConverter != NULL)
+ {
+ patternConverters.push_back(eventConverter);
+ }
+ }
}
#define RULES_PUT(spec, cls) \
-specs.insert(PatternMap::value_type(LogString(LOG4CXX_STR(spec)), (PatternConstructor) cls ::newInstance))
+ specs.insert(PatternMap::value_type(LogString(LOG4CXX_STR(spec)), (PatternConstructor) cls ::newInstance))
-log4cxx::pattern::PatternMap PatternLayout::getFormatSpecifiers() {
- PatternMap specs;
- RULES_PUT("c", LoggerPatternConverter);
- RULES_PUT("logger", LoggerPatternConverter);
+log4cxx::pattern::PatternMap PatternLayout::getFormatSpecifiers()
+{
+ PatternMap specs;
+ RULES_PUT("c", LoggerPatternConverter);
+ RULES_PUT("logger", LoggerPatternConverter);
- RULES_PUT("C", ClassNamePatternConverter);
- RULES_PUT("class", ClassNamePatternConverter);
+ RULES_PUT("C", ClassNamePatternConverter);
+ RULES_PUT("class", ClassNamePatternConverter);
- RULES_PUT("d", DatePatternConverter);
- RULES_PUT("date", DatePatternConverter);
+ RULES_PUT("d", DatePatternConverter);
+ RULES_PUT("date", DatePatternConverter);
- RULES_PUT("F", FileLocationPatternConverter);
- RULES_PUT("file", FileLocationPatternConverter);
+ RULES_PUT("F", FileLocationPatternConverter);
+ RULES_PUT("file", FileLocationPatternConverter);
- RULES_PUT("l", FullLocationPatternConverter);
+ RULES_PUT("l", FullLocationPatternConverter);
- RULES_PUT("L", LineLocationPatternConverter);
- RULES_PUT("line", LineLocationPatternConverter);
+ RULES_PUT("L", LineLocationPatternConverter);
+ RULES_PUT("line", LineLocationPatternConverter);
- RULES_PUT("m", MessagePatternConverter);
- RULES_PUT("message", MessagePatternConverter);
+ RULES_PUT("m", MessagePatternConverter);
+ RULES_PUT("message", MessagePatternConverter);
- RULES_PUT("n", LineSeparatorPatternConverter);
+ RULES_PUT("n", LineSeparatorPatternConverter);
- RULES_PUT("M", MethodLocationPatternConverter);
- RULES_PUT("method", MethodLocationPatternConverter);
+ RULES_PUT("M", MethodLocationPatternConverter);
+ RULES_PUT("method", MethodLocationPatternConverter);
- RULES_PUT("p", LevelPatternConverter);
- RULES_PUT("level", LevelPatternConverter);
+ RULES_PUT("p", LevelPatternConverter);
+ RULES_PUT("level", LevelPatternConverter);
- RULES_PUT("r", RelativeTimePatternConverter);
- RULES_PUT("relative", RelativeTimePatternConverter);
+ RULES_PUT("r", RelativeTimePatternConverter);
+ RULES_PUT("relative", RelativeTimePatternConverter);
- RULES_PUT("t", ThreadPatternConverter);
- RULES_PUT("thread", ThreadPatternConverter);
+ RULES_PUT("t", ThreadPatternConverter);
+ RULES_PUT("thread", ThreadPatternConverter);
- RULES_PUT("x", NDCPatternConverter);
- RULES_PUT("ndc", NDCPatternConverter);
+ RULES_PUT("x", NDCPatternConverter);
+ RULES_PUT("ndc", NDCPatternConverter);
- RULES_PUT("X", PropertiesPatternConverter);
- RULES_PUT("properties", PropertiesPatternConverter);
+ RULES_PUT("X", PropertiesPatternConverter);
+ RULES_PUT("properties", PropertiesPatternConverter);
- RULES_PUT("throwable", ThrowableInformationPatternConverter);
- return specs;
+ RULES_PUT("throwable", ThrowableInformationPatternConverter);
+ return specs;
}
diff --git a/src/main/cpp/patternparser.cpp b/src/main/cpp/patternparser.cpp
index 7cf7df8..9181dcd 100644
--- a/src/main/cpp/patternparser.cpp
+++ b/src/main/cpp/patternparser.cpp
@@ -30,312 +30,369 @@
/**
* Private constructor.
*/
-PatternParser::PatternParser() {
+PatternParser::PatternParser()
+{
}
-bool PatternParser::isUnicodeIdentifierStart(logchar ch) {
- //
- // greatly simplified version checks if
- // character is USACII alpha or number
- //
- return (ch >= 0x41 /* 'A' */ && ch <= 0x5A /* 'Z' */) ||
- (ch >= 0x61 /* 'a' */ && ch <= 0x7A /* 'z' */) ||
- (ch >= 0x30 /* '0' */ && ch <= 0x39 /* '9' */);
+bool PatternParser::isUnicodeIdentifierStart(logchar ch)
+{
+ //
+ // greatly simplified version checks if
+ // character is USACII alpha or number
+ //
+ return (ch >= 0x41 /* 'A' */ && ch <= 0x5A /* 'Z' */) ||
+ (ch >= 0x61 /* 'a' */ && ch <= 0x7A /* 'z' */) ||
+ (ch >= 0x30 /* '0' */ && ch <= 0x39 /* '9' */);
}
-bool PatternParser::isUnicodeIdentifierPart(logchar ch) {
- //
- // greatly simplified version checks if
- // character is USACII alpha or number
- //
- return isUnicodeIdentifierStart(ch)
- || (ch == 0x5F /* '_' */);
+bool PatternParser::isUnicodeIdentifierPart(logchar ch)
+{
+ //
+ // greatly simplified version checks if
+ // character is USACII alpha or number
+ //
+ return isUnicodeIdentifierStart(ch)
+ || (ch == 0x5F /* '_' */);
}
int PatternParser::extractConverter(
- logchar lastChar, const LogString& pattern,
- LogString::size_type i, LogString& convBuf,
- LogString& currentLiteral) {
- if (!convBuf.empty()) {
- convBuf.erase(convBuf.begin(), convBuf.end());
- }
+ logchar lastChar, const LogString& pattern,
+ LogString::size_type i, LogString& convBuf,
+ LogString& currentLiteral)
+{
+ if (!convBuf.empty())
+ {
+ convBuf.erase(convBuf.begin(), convBuf.end());
+ }
- // When this method is called, lastChar points to the first character of the
- // conversion word. For example:
- // For "%hello" lastChar = 'h'
- // For "%-5hello" lastChar = 'h'
- //System.out.println("lastchar is "+lastChar);
- if (!isUnicodeIdentifierStart(lastChar)) {
+ // When this method is called, lastChar points to the first character of the
+ // conversion word. For example:
+ // For "%hello" lastChar = 'h'
+ // For "%-5hello" lastChar = 'h'
+ //System.out.println("lastchar is "+lastChar);
+ if (!isUnicodeIdentifierStart(lastChar))
+ {
+ return i;
+ }
+
+ convBuf.append(1, lastChar);
+
+ while (
+ (i < pattern.length())
+ && isUnicodeIdentifierPart(pattern[i]))
+ {
+ convBuf.append(1, pattern[i]);
+ currentLiteral.append(1, pattern[i]);
+
+ //System.out.println("conv buffer is now ["+convBuf+"].");
+ i++;
+ }
+
return i;
- }
-
- convBuf.append(1, lastChar);
-
- while (
- (i < pattern.length())
- && isUnicodeIdentifierPart(pattern[i])) {
- convBuf.append(1, pattern[i]);
- currentLiteral.append(1, pattern[i]);
-
- //System.out.println("conv buffer is now ["+convBuf+"].");
- i++;
- }
-
- return i;
}
int PatternParser::extractOptions(const LogString& pattern, LogString::size_type i,
- std::vector<LogString>& options) {
- while ((i < pattern.length()) && (pattern[i] == 0x7B /* '{' */)) {
- int end = pattern.find(0x7D /* '}' */, i);
+ std::vector<LogString>& options)
+{
+ while ((i < pattern.length()) && (pattern[i] == 0x7B /* '{' */))
+ {
+ int end = pattern.find(0x7D /* '}' */, i);
- if (end == -1) {
- break;
+ if (end == -1)
+ {
+ break;
+ }
+
+ LogString r(pattern.substr(i + 1, end - i - 1));
+ options.push_back(r);
+ i = end + 1;
}
- LogString r(pattern.substr(i + 1, end - i - 1));
- options.push_back(r);
- i = end + 1;
- }
-
- return i;
+ return i;
}
void PatternParser::parse(
- const LogString& pattern,
- std::vector<PatternConverterPtr>& patternConverters,
- std::vector<FormattingInfoPtr>& formattingInfos,
- const PatternMap& rules) {
+ const LogString& pattern,
+ std::vector<PatternConverterPtr>& patternConverters,
+ std::vector<FormattingInfoPtr>& formattingInfos,
+ const PatternMap& rules)
+{
- LogString currentLiteral;
+ LogString currentLiteral;
- int patternLength = pattern.length();
- int state = LITERAL_STATE;
- logchar c;
- int i = 0;
- FormattingInfoPtr formattingInfo(FormattingInfo::getDefault());
+ int patternLength = pattern.length();
+ int state = LITERAL_STATE;
+ logchar c;
+ int i = 0;
+ FormattingInfoPtr formattingInfo(FormattingInfo::getDefault());
- while (i < patternLength) {
- c = pattern[i++];
+ while (i < patternLength)
+ {
+ c = pattern[i++];
- switch (state) {
- case LITERAL_STATE:
+ switch (state)
+ {
+ case LITERAL_STATE:
- // In literal state, the last char is always a literal.
- if (i == patternLength) {
- currentLiteral.append(1, c);
+ // In literal state, the last char is always a literal.
+ if (i == patternLength)
+ {
+ currentLiteral.append(1, c);
- continue;
- }
+ continue;
+ }
- if (c == ESCAPE_CHAR) {
- // peek at the next char.
- if(pattern[i] == ESCAPE_CHAR) {
- currentLiteral.append(1, c);
- i++; // move pointer
- } else {
- if (!currentLiteral.empty()) {
- patternConverters.push_back(
- LiteralPatternConverter::newInstance(currentLiteral));
- formattingInfos.push_back(FormattingInfo::getDefault());
- currentLiteral.erase(currentLiteral.begin(), currentLiteral.end());
- }
+ if (c == ESCAPE_CHAR)
+ {
+ // peek at the next char.
+ if (pattern[i] == ESCAPE_CHAR)
+ {
+ currentLiteral.append(1, c);
+ i++; // move pointer
+ }
+ else
+ {
+ if (!currentLiteral.empty())
+ {
+ patternConverters.push_back(
+ LiteralPatternConverter::newInstance(currentLiteral));
+ formattingInfos.push_back(FormattingInfo::getDefault());
+ currentLiteral.erase(currentLiteral.begin(), currentLiteral.end());
+ }
- currentLiteral.append(1, c); // append %
- state = CONVERTER_STATE;
- formattingInfo = FormattingInfo::getDefault();
- }
- } else {
- currentLiteral.append(1, c);
- }
+ currentLiteral.append(1, c); // append %
+ state = CONVERTER_STATE;
+ formattingInfo = FormattingInfo::getDefault();
+ }
+ }
+ else
+ {
+ currentLiteral.append(1, c);
+ }
- break;
+ break;
- case CONVERTER_STATE:
- currentLiteral.append(1, c);
+ case CONVERTER_STATE:
+ currentLiteral.append(1, c);
- switch (c) {
- case 0x2D: // '-'
- formattingInfo =
- new FormattingInfo(
- true, formattingInfo->getMinLength(),
- formattingInfo->getMaxLength());
+ switch (c)
+ {
+ case 0x2D: // '-'
+ formattingInfo =
+ new FormattingInfo(
+ true, formattingInfo->getMinLength(),
+ formattingInfo->getMaxLength());
- break;
+ break;
- case 0x2E: // '.'
- state = DOT_STATE;
+ case 0x2E: // '.'
+ state = DOT_STATE;
- break;
+ break;
- default:
+ default:
- if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) {
- formattingInfo =
- new FormattingInfo(
- formattingInfo->isLeftAligned(), c - 0x30 /* '0' */,
- formattingInfo->getMaxLength());
- state = MIN_STATE;
- } else {
- i = finalizeConverter(
- c, pattern, i, currentLiteral, formattingInfo,
- rules, patternConverters, formattingInfos);
+ if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */))
+ {
+ formattingInfo =
+ new FormattingInfo(
+ formattingInfo->isLeftAligned(), c - 0x30 /* '0' */,
+ formattingInfo->getMaxLength());
+ state = MIN_STATE;
+ }
+ else
+ {
+ i = finalizeConverter(
+ c, pattern, i, currentLiteral, formattingInfo,
+ rules, patternConverters, formattingInfos);
- // Next pattern is assumed to be a literal.
- state = LITERAL_STATE;
- formattingInfo = FormattingInfo::getDefault();
- if (!currentLiteral.empty()) {
- currentLiteral.erase(currentLiteral.begin(), currentLiteral.end());
- }
- }
- } // switch
+ // Next pattern is assumed to be a literal.
+ state = LITERAL_STATE;
+ formattingInfo = FormattingInfo::getDefault();
- break;
+ if (!currentLiteral.empty())
+ {
+ currentLiteral.erase(currentLiteral.begin(), currentLiteral.end());
+ }
+ }
+ } // switch
- case MIN_STATE:
- currentLiteral.append(1, c);
+ break;
- if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) {
- formattingInfo =
- new FormattingInfo(
- formattingInfo->isLeftAligned(),
- (formattingInfo->getMinLength() * 10) + (c - 0x30 /* '0' */),
- formattingInfo->getMaxLength());
- } else if (c == 0x2E /* '.' */) {
- state = DOT_STATE;
- } else {
- i = finalizeConverter(
- c, pattern, i, currentLiteral, formattingInfo,
- rules, patternConverters, formattingInfos);
- state = LITERAL_STATE;
- formattingInfo = FormattingInfo::getDefault();
- if (!currentLiteral.empty()) {
- currentLiteral.erase(currentLiteral.begin(), currentLiteral.end());
- }
- }
+ case MIN_STATE:
+ currentLiteral.append(1, c);
- break;
+ if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */))
+ {
+ formattingInfo =
+ new FormattingInfo(
+ formattingInfo->isLeftAligned(),
+ (formattingInfo->getMinLength() * 10) + (c - 0x30 /* '0' */),
+ formattingInfo->getMaxLength());
+ }
+ else if (c == 0x2E /* '.' */)
+ {
+ state = DOT_STATE;
+ }
+ else
+ {
+ i = finalizeConverter(
+ c, pattern, i, currentLiteral, formattingInfo,
+ rules, patternConverters, formattingInfos);
+ state = LITERAL_STATE;
+ formattingInfo = FormattingInfo::getDefault();
- case DOT_STATE:
- currentLiteral.append(1, c);
+ if (!currentLiteral.empty())
+ {
+ currentLiteral.erase(currentLiteral.begin(), currentLiteral.end());
+ }
+ }
- if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) {
- formattingInfo =
- new FormattingInfo(
- formattingInfo->isLeftAligned(), formattingInfo->getMinLength(),
- c - 0x30 /* '0' */);
- state = MAX_STATE;
- } else {
- LogLog::error(LOG4CXX_STR("Error in pattern, was expecting digit."));
+ break;
- state = LITERAL_STATE;
- }
+ case DOT_STATE:
+ currentLiteral.append(1, c);
- break;
+ if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */))
+ {
+ formattingInfo =
+ new FormattingInfo(
+ formattingInfo->isLeftAligned(), formattingInfo->getMinLength(),
+ c - 0x30 /* '0' */);
+ state = MAX_STATE;
+ }
+ else
+ {
+ LogLog::error(LOG4CXX_STR("Error in pattern, was expecting digit."));
- case MAX_STATE:
- currentLiteral.append(1, c);
+ state = LITERAL_STATE;
+ }
- if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) {
- formattingInfo =
- new FormattingInfo(
- formattingInfo->isLeftAligned(), formattingInfo->getMinLength(),
- (formattingInfo->getMaxLength() * 10) + (c - 0x30 /* '0' */));
- } else {
- i = finalizeConverter(
- c, pattern, i, currentLiteral, formattingInfo,
- rules, patternConverters, formattingInfos);
- state = LITERAL_STATE;
- formattingInfo = FormattingInfo::getDefault();
- if (!currentLiteral.empty()) {
- currentLiteral.erase(currentLiteral.begin(), currentLiteral.end());
- }
- }
+ break;
- break;
- } // switch
- }
+ case MAX_STATE:
+ currentLiteral.append(1, c);
- // while
- if (currentLiteral.length() != 0) {
- patternConverters.push_back(
- LiteralPatternConverter::newInstance(currentLiteral));
- formattingInfos.push_back(FormattingInfo::getDefault());
- }
+ if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */))
+ {
+ formattingInfo =
+ new FormattingInfo(
+ formattingInfo->isLeftAligned(), formattingInfo->getMinLength(),
+ (formattingInfo->getMaxLength() * 10) + (c - 0x30 /* '0' */));
+ }
+ else
+ {
+ i = finalizeConverter(
+ c, pattern, i, currentLiteral, formattingInfo,
+ rules, patternConverters, formattingInfos);
+ state = LITERAL_STATE;
+ formattingInfo = FormattingInfo::getDefault();
+
+ if (!currentLiteral.empty())
+ {
+ currentLiteral.erase(currentLiteral.begin(), currentLiteral.end());
+ }
+ }
+
+ break;
+ } // switch
+ }
+
+ // while
+ if (currentLiteral.length() != 0)
+ {
+ patternConverters.push_back(
+ LiteralPatternConverter::newInstance(currentLiteral));
+ formattingInfos.push_back(FormattingInfo::getDefault());
+ }
}
PatternConverterPtr PatternParser::createConverter(
- const LogString& converterId,
- LogString& currentLiteral,
- const PatternMap& rules,
- std::vector<LogString>& options) {
+ const LogString& converterId,
+ LogString& currentLiteral,
+ const PatternMap& rules,
+ std::vector<LogString>& options)
+{
- LogString converterName(converterId);
+ LogString converterName(converterId);
- for (int i = converterId.length(); i > 0; i--) {
- converterName = converterName.substr(0, i);
- PatternMap::const_iterator iter = rules.find(converterName);
- if (iter != rules.end()) {
- currentLiteral.erase(currentLiteral.begin(),
- currentLiteral.end() - (converterId.length() - i));
- return (iter->second)(options);
+ for (int i = converterId.length(); i > 0; i--)
+ {
+ converterName = converterName.substr(0, i);
+ PatternMap::const_iterator iter = rules.find(converterName);
+
+ if (iter != rules.end())
+ {
+ currentLiteral.erase(currentLiteral.begin(),
+ currentLiteral.end() - (converterId.length() - i));
+ return (iter->second)(options);
+ }
}
- }
- LogLog::error(LogString(LOG4CXX_STR("Unrecognized format specifier ")) + converterId);
- ObjectPtr converterObj;
+ LogLog::error(LogString(LOG4CXX_STR("Unrecognized format specifier ")) + converterId);
+ ObjectPtr converterObj;
- return converterObj;
+ return converterObj;
}
int PatternParser::finalizeConverter(
- logchar c, const LogString& pattern, int i,
- LogString& currentLiteral, const FormattingInfoPtr& formattingInfo,
- const PatternMap& rules,
- std::vector<PatternConverterPtr>& patternConverters,
- std::vector<FormattingInfoPtr>& formattingInfos) {
- LogString convBuf;
- i = extractConverter(c, pattern, i, convBuf, currentLiteral);
- if (convBuf.empty()) {
- LogLog::error(LOG4CXX_STR("Empty conversion specifier"));
- patternConverters.push_back(
- LiteralPatternConverter::newInstance(currentLiteral));
- formattingInfos.push_back(FormattingInfo::getDefault());
- } else {
- LogString converterId(convBuf);
+ logchar c, const LogString& pattern, int i,
+ LogString& currentLiteral, const FormattingInfoPtr& formattingInfo,
+ const PatternMap& rules,
+ std::vector<PatternConverterPtr>& patternConverters,
+ std::vector<FormattingInfoPtr>& formattingInfos)
+{
+ LogString convBuf;
+ i = extractConverter(c, pattern, i, convBuf, currentLiteral);
- std::vector<LogString> options;
- i = extractOptions(pattern, i, options);
-
- PatternConverterPtr pc(
- createConverter(
- converterId, currentLiteral, rules, options));
-
- if (pc == NULL) {
- LogString msg(LOG4CXX_STR("Unrecognized conversion specifier ["));
- msg.append(converterId);
- msg.append(LOG4CXX_STR("] in conversion pattern."));
- LogLog::error(msg);
+ if (convBuf.empty())
+ {
+ LogLog::error(LOG4CXX_STR("Empty conversion specifier"));
patternConverters.push_back(
- LiteralPatternConverter::newInstance(currentLiteral));
+ LiteralPatternConverter::newInstance(currentLiteral));
formattingInfos.push_back(FormattingInfo::getDefault());
- } else {
- patternConverters.push_back(pc);
- formattingInfos.push_back(formattingInfo);
+ }
+ else
+ {
+ LogString converterId(convBuf);
- if (currentLiteral.length() > 0) {
- patternConverters.push_back(
- LiteralPatternConverter::newInstance(currentLiteral));
- formattingInfos.push_back(FormattingInfo::getDefault());
+ std::vector<LogString> options;
+ i = extractOptions(pattern, i, options);
+
+ PatternConverterPtr pc(
+ createConverter(
+ converterId, currentLiteral, rules, options));
+
+ if (pc == NULL)
+ {
+ LogString msg(LOG4CXX_STR("Unrecognized conversion specifier ["));
+ msg.append(converterId);
+ msg.append(LOG4CXX_STR("] in conversion pattern."));
+ LogLog::error(msg);
+ patternConverters.push_back(
+ LiteralPatternConverter::newInstance(currentLiteral));
+ formattingInfos.push_back(FormattingInfo::getDefault());
}
- }
- }
+ else
+ {
+ patternConverters.push_back(pc);
+ formattingInfos.push_back(formattingInfo);
- if (!currentLiteral.empty()) {
- currentLiteral.erase(currentLiteral.begin(), currentLiteral.end());
- }
+ if (currentLiteral.length() > 0)
+ {
+ patternConverters.push_back(
+ LiteralPatternConverter::newInstance(currentLiteral));
+ formattingInfos.push_back(FormattingInfo::getDefault());
+ }
+ }
+ }
- return i;
+ if (!currentLiteral.empty())
+ {
+ currentLiteral.erase(currentLiteral.begin(), currentLiteral.end());
+ }
+
+ return i;
}
diff --git a/src/main/cpp/pool.cpp b/src/main/cpp/pool.cpp
index f2e5615..ea052da 100644
--- a/src/main/cpp/pool.cpp
+++ b/src/main/cpp/pool.cpp
@@ -22,7 +22,7 @@
#include <apr_pools.h>
#include <assert.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/helpers/aprinitializer.h>
@@ -30,57 +30,74 @@
using namespace log4cxx;
-Pool::Pool() : pool(0), release(true) {
+Pool::Pool() : pool(0), release(true)
+{
apr_status_t stat = apr_pool_create(&pool, APRInitializer::getRootPool());
- if (stat != APR_SUCCESS) {
+
+ if (stat != APR_SUCCESS)
+ {
throw PoolException(stat);
}
}
-Pool::Pool(apr_pool_t* p, bool release1) : pool(p), release(release1) {
+Pool::Pool(apr_pool_t* p, bool release1) : pool(p), release(release1)
+{
assert(p != NULL);
}
-Pool::~Pool() {
- if (release) {
- apr_pool_destroy(pool);
+Pool::~Pool()
+{
+ if (release)
+ {
+ apr_pool_destroy(pool);
}
}
-apr_pool_t* Pool::getAPRPool() {
- return pool;
+apr_pool_t* Pool::getAPRPool()
+{
+ return pool;
}
-apr_pool_t* Pool::create() {
+apr_pool_t* Pool::create()
+{
apr_pool_t* child;
apr_status_t stat = apr_pool_create(&child, pool);
- if (stat != APR_SUCCESS) {
+
+ if (stat != APR_SUCCESS)
+ {
throw PoolException(stat);
}
+
return child;
}
-void* Pool::palloc(size_t size) {
- return apr_palloc(pool, size);
+void* Pool::palloc(size_t size)
+{
+ return apr_palloc(pool, size);
}
-char* Pool::pstralloc(size_t size) {
- return (char*) palloc(size);
+char* Pool::pstralloc(size_t size)
+{
+ return (char*) palloc(size);
}
-char* Pool::itoa(int n) {
+char* Pool::itoa(int n)
+{
return apr_itoa(pool, n);
}
-char* Pool::pstrndup(const char* s, size_t len) {
+char* Pool::pstrndup(const char* s, size_t len)
+{
return apr_pstrndup(pool, s, len);
}
-char* Pool::pstrdup(const char* s) {
+char* Pool::pstrdup(const char* s)
+{
return apr_pstrdup(pool, s);
}
-char* Pool::pstrdup(const std::string& s) {
+char* Pool::pstrdup(const std::string& s)
+{
return apr_pstrndup(pool, s.data(), s.length());
}
diff --git a/src/main/cpp/properties.cpp b/src/main/cpp/properties.cpp
index 177699c..c11dbf5 100644
--- a/src/main/cpp/properties.cpp
+++ b/src/main/cpp/properties.cpp
@@ -26,354 +26,431 @@
class PropertyParser
{
-public:
+ public:
void parse(LogString& in, Properties& properties)
{
- LogString key, element;
- LexemType lexemType = BEGIN;
- logchar c;
- bool finished = false;
+ LogString key, element;
+ LexemType lexemType = BEGIN;
+ logchar c;
+ bool finished = false;
- if (!get(in, c))
- {
- return;
- }
+ if (!get(in, c))
+ {
+ return;
+ }
- while (!finished)
+ while (!finished)
+ {
+ switch (lexemType)
{
- switch(lexemType)
+ case BEGIN:
+ switch (c)
{
- case BEGIN:
- switch(c)
- {
- case 0x20: // ' '
- case 0x09: // '\t'
- case 0x0A: // '\n'
- case 0x0D: // '\r'
- if (!get(in, c))
- finished = true;
- break;
-
- case 0x23: // '#'
- case 0x21: // '!'
- lexemType = COMMENT;
- if (!get(in, c))
- finished = true;
- break;
-
- default:
- lexemType = KEY;
- break;
- }
- break;
-
- case KEY:
- switch(c)
- {
- case 0x5C: // '\\'
- lexemType = KEY_ESCAPE;
- if (!get(in, c))
- finished = true;
- break;
-
- case 0x09: // '\t'
- case 0x20: // ' '
- case 0x3A: // ':'
- case 0x3D: // '='
- lexemType = DELIMITER;
- if (!get(in, c))
- finished = true;
- break;
-
- case 0x0A:
- case 0x0D:
- // key associated with an empty string element
- properties.setProperty(key, LogString());
- key.erase(key.begin(), key.end());
- lexemType = BEGIN;
- if (!get(in, c))
- finished = true;
- break;
-
- default:
- key.append(1, c);
- if (!get(in, c))
- finished = true;
- break;
- }
- break;
-
- case KEY_ESCAPE:
- switch(c)
- {
- case 0x74: // 't'
- key.append(1, 0x09);
- lexemType = KEY;
- break;
-
- case 0x6E: // 'n'
- key.append(1, 0x0A);
- lexemType = KEY;
- break;
-
- case 0x72: // 'r'
- key.append(1, 0x0D);
- lexemType = KEY;
- break;
-
- case 0x0A: // '\n'
- lexemType = KEY_CONTINUE;
- break;
-
- case 0x0D: // '\r'
- lexemType = KEY_CONTINUE2;
- break;
-
- default:
- key.append(1, c);
- lexemType = KEY;
- }
- if (!get(in, c)) {
- finished = true;
- }
- break;
-
- case KEY_CONTINUE:
- switch(c)
- {
- case 0x20: // ' '
- case 0x09: // '\t'
- if (!get(in, c))
- finished = true;
- break;
-
- default:
- lexemType = KEY;
- break;
- }
- break;
-
- case KEY_CONTINUE2:
- switch(c)
- {
- case 0x0A: // '\n'
- if (!get(in, c))
- finished = true;
- lexemType = KEY_CONTINUE;
- break;
-
- default:
- lexemType = KEY_CONTINUE;
- break;
- }
- break;
-
- case DELIMITER:
- switch(c)
- {
- case 0x09: // '\t'
- case 0x20: // ' '
- case 0x3A: // ':'
- case 0x3D: // '='
- if (!get(in, c))
- finished = true;
- break;
-
- default:
- lexemType = ELEMENT;
- break;
- }
- break;
-
- case ELEMENT:
- switch(c)
- {
- case 0x5C: // '\\'
- lexemType = ELEMENT_ESCAPE;
- if (!get(in, c))
- finished = true;
- break;
-
- case 0x0A: // '\n'
- case 0x0D: // '\r'
- // key associated with an empty string element
- properties.setProperty(key, element);
- key.erase(key.begin(), key.end());
- element.erase(element.begin(), element.end());
- lexemType = BEGIN;
- if (!get(in, c))
- finished = true;
- break;
-
- default:
- element.append(1, c);
- if (!get(in, c))
- finished = true;
- break;
- }
- break;
-
- case ELEMENT_ESCAPE:
- switch(c)
- {
- case 0x74: // 't'
- element.append(1, 0x09);
- lexemType = ELEMENT;
- break;
-
- case 0x6E: // 'n'
- element.append(1, 0x0A);
- lexemType = ELEMENT;
- break;
-
- case 0x72: // 'r'
- element.append(1, 0x0D);
- lexemType = ELEMENT;
- break;
-
- case 0x0A: // '\n'
- lexemType = ELEMENT_CONTINUE;
- break;
-
- case 0x0D: // '\r'
- lexemType = ELEMENT_CONTINUE2;
- break;
- default:
- element.append(1, c);
- lexemType = ELEMENT;
- break;
- }
- if (!get(in, c)) {
- finished = true;
- }
- break;
-
- case ELEMENT_CONTINUE:
- switch(c)
- {
- case 0x20: // ' '
- case 0x09: // '\t'
- if (!get(in, c))
- finished = true;
- break;
-
- default:
- lexemType = ELEMENT;
- break;
- }
- break;
-
- case ELEMENT_CONTINUE2:
- switch(c)
- {
- case 0x0A: // '\n'
- if (!get(in, c))
- finished = true;
- lexemType = ELEMENT_CONTINUE;
- break;
-
- default:
- lexemType = ELEMENT_CONTINUE;
- break;
- }
- break;
-
- case COMMENT:
- if (c == 0x0A || c == 0x0D)
- {
- lexemType = BEGIN;
- }
+ case 0x20: // ' '
+ case 0x09: // '\t'
+ case 0x0A: // '\n'
+ case 0x0D: // '\r'
if (!get(in, c))
- finished = true;
+ {
+ finished = true;
+ }
+
+ break;
+
+ case 0x23: // '#'
+ case 0x21: // '!'
+ lexemType = COMMENT;
+
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+
+ default:
+ lexemType = KEY;
break;
}
- }
- if (!key.empty())
- {
- properties.setProperty(key, element);
+ break;
+
+ case KEY:
+ switch (c)
+ {
+ case 0x5C: // '\\'
+ lexemType = KEY_ESCAPE;
+
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+
+ case 0x09: // '\t'
+ case 0x20: // ' '
+ case 0x3A: // ':'
+ case 0x3D: // '='
+ lexemType = DELIMITER;
+
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+
+ case 0x0A:
+ case 0x0D:
+ // key associated with an empty string element
+ properties.setProperty(key, LogString());
+ key.erase(key.begin(), key.end());
+ lexemType = BEGIN;
+
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+
+ default:
+ key.append(1, c);
+
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+ }
+
+ break;
+
+ case KEY_ESCAPE:
+ switch (c)
+ {
+ case 0x74: // 't'
+ key.append(1, 0x09);
+ lexemType = KEY;
+ break;
+
+ case 0x6E: // 'n'
+ key.append(1, 0x0A);
+ lexemType = KEY;
+ break;
+
+ case 0x72: // 'r'
+ key.append(1, 0x0D);
+ lexemType = KEY;
+ break;
+
+ case 0x0A: // '\n'
+ lexemType = KEY_CONTINUE;
+ break;
+
+ case 0x0D: // '\r'
+ lexemType = KEY_CONTINUE2;
+ break;
+
+ default:
+ key.append(1, c);
+ lexemType = KEY;
+ }
+
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+
+ case KEY_CONTINUE:
+ switch (c)
+ {
+ case 0x20: // ' '
+ case 0x09: // '\t'
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+
+ default:
+ lexemType = KEY;
+ break;
+ }
+
+ break;
+
+ case KEY_CONTINUE2:
+ switch (c)
+ {
+ case 0x0A: // '\n'
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ lexemType = KEY_CONTINUE;
+ break;
+
+ default:
+ lexemType = KEY_CONTINUE;
+ break;
+ }
+
+ break;
+
+ case DELIMITER:
+ switch (c)
+ {
+ case 0x09: // '\t'
+ case 0x20: // ' '
+ case 0x3A: // ':'
+ case 0x3D: // '='
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+
+ default:
+ lexemType = ELEMENT;
+ break;
+ }
+
+ break;
+
+ case ELEMENT:
+ switch (c)
+ {
+ case 0x5C: // '\\'
+ lexemType = ELEMENT_ESCAPE;
+
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+
+ case 0x0A: // '\n'
+ case 0x0D: // '\r'
+ // key associated with an empty string element
+ properties.setProperty(key, element);
+ key.erase(key.begin(), key.end());
+ element.erase(element.begin(), element.end());
+ lexemType = BEGIN;
+
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+
+ default:
+ element.append(1, c);
+
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+ }
+
+ break;
+
+ case ELEMENT_ESCAPE:
+ switch (c)
+ {
+ case 0x74: // 't'
+ element.append(1, 0x09);
+ lexemType = ELEMENT;
+ break;
+
+ case 0x6E: // 'n'
+ element.append(1, 0x0A);
+ lexemType = ELEMENT;
+ break;
+
+ case 0x72: // 'r'
+ element.append(1, 0x0D);
+ lexemType = ELEMENT;
+ break;
+
+ case 0x0A: // '\n'
+ lexemType = ELEMENT_CONTINUE;
+ break;
+
+ case 0x0D: // '\r'
+ lexemType = ELEMENT_CONTINUE2;
+ break;
+
+ default:
+ element.append(1, c);
+ lexemType = ELEMENT;
+ break;
+ }
+
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+
+ case ELEMENT_CONTINUE:
+ switch (c)
+ {
+ case 0x20: // ' '
+ case 0x09: // '\t'
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
+
+ default:
+ lexemType = ELEMENT;
+ break;
+ }
+
+ break;
+
+ case ELEMENT_CONTINUE2:
+ switch (c)
+ {
+ case 0x0A: // '\n'
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ lexemType = ELEMENT_CONTINUE;
+ break;
+
+ default:
+ lexemType = ELEMENT_CONTINUE;
+ break;
+ }
+
+ break;
+
+ case COMMENT:
+ if (c == 0x0A || c == 0x0D)
+ {
+ lexemType = BEGIN;
+ }
+
+ if (!get(in, c))
+ {
+ finished = true;
+ }
+
+ break;
}
+ }
+
+ if (!key.empty())
+ {
+ properties.setProperty(key, element);
+ }
}
-protected:
+ protected:
static bool get(LogString& in, logchar& c)
{
- if (in.empty()) {
- c = 0;
- return false;
- }
- c = in[0];
- in.erase(in.begin());
- return true;
+ if (in.empty())
+ {
+ c = 0;
+ return false;
+ }
+
+ c = in[0];
+ in.erase(in.begin());
+ return true;
}
typedef enum
{
- BEGIN,
- KEY,
- KEY_ESCAPE,
- KEY_CONTINUE,
- KEY_CONTINUE2,
- DELIMITER,
- ELEMENT,
- ELEMENT_ESCAPE,
- ELEMENT_CONTINUE,
- ELEMENT_CONTINUE2,
- COMMENT
+ BEGIN,
+ KEY,
+ KEY_ESCAPE,
+ KEY_CONTINUE,
+ KEY_CONTINUE2,
+ DELIMITER,
+ ELEMENT,
+ ELEMENT_ESCAPE,
+ ELEMENT_CONTINUE,
+ ELEMENT_CONTINUE2,
+ COMMENT
}
LexemType;
};
-Properties::Properties() : properties(new PropertyMap()) {
+Properties::Properties() : properties(new PropertyMap())
+{
}
-Properties::~Properties() {
+Properties::~Properties()
+{
delete properties;
}
-LogString Properties::setProperty(const LogString& key, const LogString& value) {
+LogString Properties::setProperty(const LogString& key, const LogString& value)
+{
return put(key, value);
}
LogString Properties::put(const LogString& key, const LogString& value)
{
- LogString oldValue((*properties)[key]);
- (*properties)[key] = value;
- return oldValue;
+ LogString oldValue((*properties)[key]);
+ (*properties)[key] = value;
+ return oldValue;
}
-LogString Properties::getProperty(const LogString& key) const {
+LogString Properties::getProperty(const LogString& key) const
+{
return get(key);
}
LogString Properties::get(const LogString& key) const
{
- PropertyMap::const_iterator it = properties->find(key);
- return (it != properties->end()) ? it->second : LogString();
+ PropertyMap::const_iterator it = properties->find(key);
+ return (it != properties->end()) ? it->second : LogString();
}
-void Properties::load(InputStreamPtr inStream) {
- Pool pool;
- InputStreamReaderPtr lineReader(
- new InputStreamReader(inStream, CharsetDecoder::getISOLatinDecoder()));
- LogString contents = lineReader->read(pool);
- properties->clear();
- PropertyParser parser;
- parser.parse(contents, *this);
+void Properties::load(InputStreamPtr inStream)
+{
+ Pool pool;
+ InputStreamReaderPtr lineReader(
+ new InputStreamReader(inStream, CharsetDecoder::getISOLatinDecoder()));
+ LogString contents = lineReader->read(pool);
+ properties->clear();
+ PropertyParser parser;
+ parser.parse(contents, *this);
}
std::vector<LogString> Properties::propertyNames() const
{
- std::vector<LogString> names;
- names.reserve(properties->size());
+ std::vector<LogString> names;
+ names.reserve(properties->size());
- PropertyMap::const_iterator it;
- for (it = properties->begin(); it != properties->end(); it++)
- {
- const LogString& key = it->first;
- names.push_back(key);
- }
+ PropertyMap::const_iterator it;
- return names;
+ for (it = properties->begin(); it != properties->end(); it++)
+ {
+ const LogString& key = it->first;
+ names.push_back(key);
+ }
+
+ return names;
}
diff --git a/src/main/cpp/propertiespatternconverter.cpp b/src/main/cpp/propertiespatternconverter.cpp
index 7b1ba7d..a6d7a84 100644
--- a/src/main/cpp/propertiespatternconverter.cpp
+++ b/src/main/cpp/propertiespatternconverter.cpp
@@ -16,7 +16,7 @@
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -34,49 +34,58 @@
IMPLEMENT_LOG4CXX_OBJECT(PropertiesPatternConverter)
PropertiesPatternConverter::PropertiesPatternConverter(const LogString& name1,
- const LogString& propertyName) :
- LoggingEventPatternConverter(name1,LOG4CXX_STR("property")),
- option(propertyName) {
+ const LogString& propertyName) :
+ LoggingEventPatternConverter(name1, LOG4CXX_STR("property")),
+ option(propertyName)
+{
}
PatternConverterPtr PropertiesPatternConverter::newInstance(
- const std::vector<LogString>& options) {
- if (options.size() == 0) {
- static PatternConverterPtr def(new PropertiesPatternConverter(
- LOG4CXX_STR("Properties"), LOG4CXX_STR("")));
- return def;
- }
- LogString converterName(LOG4CXX_STR("Property{"));
- converterName.append(options[0]);
- converterName.append(LOG4CXX_STR("}"));
- PatternConverterPtr converter(new PropertiesPatternConverter(
- converterName, options[0]));
- return converter;
+ const std::vector<LogString>& options)
+{
+ if (options.size() == 0)
+ {
+ static PatternConverterPtr def(new PropertiesPatternConverter(
+ LOG4CXX_STR("Properties"), LOG4CXX_STR("")));
+ return def;
+ }
+
+ LogString converterName(LOG4CXX_STR("Property{"));
+ converterName.append(options[0]);
+ converterName.append(LOG4CXX_STR("}"));
+ PatternConverterPtr converter(new PropertiesPatternConverter(
+ converterName, options[0]));
+ return converter;
}
void PropertiesPatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- Pool& /* p */) const {
- if (option.length() == 0) {
- toAppendTo.append(1, (logchar) 0x7B /* '{' */);
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ Pool& /* p */) const
+{
+ if (option.length() == 0)
+ {
+ toAppendTo.append(1, (logchar) 0x7B /* '{' */);
- LoggingEvent::KeySet keySet(event->getMDCKeySet());
+ LoggingEvent::KeySet keySet(event->getMDCKeySet());
- for(LoggingEvent::KeySet::const_iterator iter = keySet.begin();
- iter != keySet.end();
- iter++) {
- toAppendTo.append(1, (logchar) 0x7B /* '{' */);
- toAppendTo.append(*iter);
- toAppendTo.append(1, (logchar) 0x2C /* ',' */);
- event->getMDC(*iter, toAppendTo);
- toAppendTo.append(1, (logchar) 0x7D /* '}' */);
- }
+ for (LoggingEvent::KeySet::const_iterator iter = keySet.begin();
+ iter != keySet.end();
+ iter++)
+ {
+ toAppendTo.append(1, (logchar) 0x7B /* '{' */);
+ toAppendTo.append(*iter);
+ toAppendTo.append(1, (logchar) 0x2C /* ',' */);
+ event->getMDC(*iter, toAppendTo);
+ toAppendTo.append(1, (logchar) 0x7D /* '}' */);
+ }
- toAppendTo.append(1, (logchar) 0x7D /* '}' */);
+ toAppendTo.append(1, (logchar) 0x7D /* '}' */);
- } else {
- event->getMDC(option, toAppendTo);
}
- }
+ else
+ {
+ event->getMDC(option, toAppendTo);
+ }
+}
diff --git a/src/main/cpp/propertyconfigurator.cpp b/src/main/cpp/propertyconfigurator.cpp
index e567031..c572c59 100644
--- a/src/main/cpp/propertyconfigurator.cpp
+++ b/src/main/cpp/propertyconfigurator.cpp
@@ -53,80 +53,90 @@
#include <log4cxx/helpers/filewatchdog.h>
namespace log4cxx
{
- class PropertyWatchdog : public FileWatchdog
- {
- public:
- PropertyWatchdog(const File& filename) : FileWatchdog(filename)
- {
- }
+class PropertyWatchdog : public FileWatchdog
+{
+ 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());
+ }
+};
}
-PropertyWatchdog *PropertyConfigurator::pdog = NULL;
+PropertyWatchdog* PropertyConfigurator::pdog = NULL;
#endif
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() {
+PropertyConfigurator::~PropertyConfigurator()
+{
delete registry;
}
-void PropertyConfigurator::addRef() const {
- ObjectImpl::addRef();
+void PropertyConfigurator::addRef() const
+{
+ ObjectImpl::addRef();
}
-void PropertyConfigurator::releaseRef() const {
- ObjectImpl::releaseRef();
+void PropertyConfigurator::releaseRef() const
+{
+ ObjectImpl::releaseRef();
}
void PropertyConfigurator::doConfigure(const File& configFileName,
- spi::LoggerRepositoryPtr& hierarchy)
+ spi::LoggerRepositoryPtr& hierarchy)
{
- hierarchy->setConfigured(true);
+ hierarchy->setConfigured(true);
- Properties props;
- try {
- InputStreamPtr inputStream = new FileInputStream(configFileName);
- props.load(inputStream);
- } catch(const IOException& ie) {
- LogLog::error(((LogString) LOG4CXX_STR("Could not read configuration file ["))
- + configFileName.getPath() + LOG4CXX_STR("]."));
- return;
- }
+ Properties props;
- 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
+ {
+ InputStreamPtr inputStream = new FileInputStream(configFileName);
+ props.load(inputStream);
+ }
+ catch (const IOException& ie)
+ {
+ 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);
+ }
}
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
@@ -138,13 +148,14 @@
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);
@@ -153,318 +164,322 @@
#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));
- if (strstrValue == LOG4CXX_STR("static"))
- {
- MessageBufferUseStaticStream();
- }
+ static const LogString STRINGSTREAM_KEY(LOG4CXX_STR("log4j.stringstream"));
+ LogString strstrValue(properties.getProperty(STRINGSTREAM_KEY));
- configureRootLogger(properties, hierarchy);
- configureLoggerFactory(properties);
- parseCatsAndRenderers(properties, hierarchy);
+ if (strstrValue == LOG4CXX_STR("static"))
+ {
+ MessageBufferUseStaticStream();
+ }
- LogLog::debug(LOG4CXX_STR("Finished configuring."));
+ configureRootLogger(properties, hierarchy);
+ configureLoggerFactory(properties);
+ parseCatsAndRenderers(properties, hierarchy);
- // We don't want to hold references to appenders preventing their
- // destruction.
- registry->clear();
+ LogLog::debug(LOG4CXX_STR("Finished configuring."));
+
+ // 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."));
+ 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);
- }
+ 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);
- }
+ LOCK_W sync(root->getMutex());
+ static const LogString INTERNAL_ROOT_NAME(LOG4CXX_STR("root"));
+ parseLogger(props, root, effectiveFrefix, INTERNAL_ROOT_NAME, value);
+ }
}
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();
- while (it != itEnd)
+ std::vector<LogString>::iterator it = names.begin();
+ std::vector<LogString>::iterator itEnd = names.end();
+
+ while (it != itEnd)
+ {
+ LogString key = *it++;
+
+ if (key.find(CATEGORY_PREFIX) == 0 || key.find(LOGGER_PREFIX) == 0)
{
- LogString key = *it++;
+ 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);
- }
+ LOCK_W sync(logger->getMutex());
+ parseLogger(props, logger, key, loggerName, value);
+ parseAdditivityForLogger(props, logger, loggerName);
}
+ }
}
void 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")));
+ cat->setAdditivity(additivity);
+ }
}
/**
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)
{
- 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()))
+ // 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())
{
- // 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("]."));
-
-
- // 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()));
-
- LogLog::debug((LogString) LOG4CXX_STR("Logger ")
- + loggerName + LOG4CXX_STR(" set to ")
- + logger->getLevel()->toString());
- }
-
+ return;
}
- // Begin by removing all existing appenders.
- logger->removeAllAppenders();
+ LogString levelStr = st.nextToken();
+ LogLog::debug((LogString) LOG4CXX_STR("Level token is [")
+ + levelStr + LOG4CXX_STR("]."));
- AppenderPtr appender;
- LogString appenderName;
- while (st.hasMoreTokens())
+ // 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")))
{
- appenderName = StringHelper::trim(st.nextToken());
+ static const LogString INTERNAL_ROOT_NAME(LOG4CXX_STR("root"));
- if (appenderName.empty() || appenderName == LOG4CXX_STR(","))
- {
- continue;
- }
+ 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(LOG4CXX_STR("Parsing appender named ")
+ 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;
+
+ while (st.hasMoreTokens())
+ {
+ appenderName = StringHelper::trim(st.nextToken());
+
+ if (appenderName.empty() || appenderName == LOG4CXX_STR(","))
+ {
+ continue;
+ }
+
+ LogLog::debug(LOG4CXX_STR("Parsing appender named ")
+ appenderName + LOG4CXX_STR("\"."));
- appender = parseAppender(props, appenderName);
-
- if (appender != 0)
- {
- logger->addAppender(appender);
- }
- }
-}
-
-AppenderPtr PropertyConfigurator::parseAppender(
- helpers::Properties& props, const LogString& appenderName)
-{
- AppenderPtr appender = registryGet(appenderName);
+ appender = parseAppender(props, appenderName);
if (appender != 0)
{
- LogLog::debug((LogString) LOG4CXX_STR("Appender \"")
- + appenderName + LOG4CXX_STR("\" was already parsed."));
-
- return appender;
+ logger->addAppender(appender);
}
+ }
+}
- static const LogString APPENDER_PREFIX(LOG4CXX_STR("log4j.appender."));
+AppenderPtr PropertyConfigurator::parseAppender(
+ helpers::Properties& props, const LogString& appenderName)
+{
+ AppenderPtr appender = registryGet(appenderName);
- // Appender was not previously initialized.
- LogString prefix = APPENDER_PREFIX + appenderName;
- LogString layoutPrefix = prefix + LOG4CXX_STR(".layout");
-
- 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;
- }
-
- appender->setName(appenderName);
-
- if (appender->instanceof(OptionHandler::getStaticClass()))
- {
- Pool p;
- 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("\"."));
-
- //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."));
- }
-
- registryPut(appender);
+ if (appender != 0)
+ {
+ LogLog::debug((LogString) LOG4CXX_STR("Appender \"")
+ + appenderName + LOG4CXX_STR("\" was already parsed."));
return 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 =
+ 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;
+ }
+
+ appender->setName(appenderName);
+
+ if (appender->instanceof(OptionHandler::getStaticClass()))
+ {
+ Pool p;
+
+ 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("\"."));
+
+ //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."));
+ }
+
+ registryPut(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/propertyresourcebundle.cpp b/src/main/cpp/propertyresourcebundle.cpp
index b6e5f64..e99170d 100644
--- a/src/main/cpp/propertyresourcebundle.cpp
+++ b/src/main/cpp/propertyresourcebundle.cpp
@@ -18,7 +18,7 @@
#include <log4cxx/helpers/propertyresourcebundle.h>
#include <log4cxx/helpers/exception.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
@@ -30,28 +30,29 @@
PropertyResourceBundle::PropertyResourceBundle(InputStreamPtr inStream)
{
- properties.load(inStream);
+ properties.load(inStream);
}
LogString PropertyResourceBundle::getString(const LogString& key) const
{
- LogString resource;
- PropertyResourceBundlePtr resourceBundle(const_cast<PropertyResourceBundle*>(this));
+ LogString resource;
+ PropertyResourceBundlePtr resourceBundle(const_cast<PropertyResourceBundle*>(this));
- do
- {
- resource = resourceBundle->properties.getProperty(key);
- if (!resource.empty())
- {
- return resource;
- }
+ do
+ {
+ resource = resourceBundle->properties.getProperty(key);
- resourceBundle = resourceBundle->parent;
- }
- while (resourceBundle != 0);
+ if (!resource.empty())
+ {
+ return resource;
+ }
- throw MissingResourceException(key);
+ resourceBundle = resourceBundle->parent;
+ }
+ while (resourceBundle != 0);
+
+ throw MissingResourceException(key);
#if LOG4CXX_RETURN_AFTER_THROW
- return resource;
+ return resource;
#endif
}
diff --git a/src/main/cpp/propertysetter.cpp b/src/main/cpp/propertysetter.cpp
index 88a6dd7..0efd49e 100644
--- a/src/main/cpp/propertysetter.cpp
+++ b/src/main/cpp/propertysetter.cpp
@@ -36,69 +36,74 @@
}
void PropertySetter::setProperties(const helpers::ObjectPtr& obj,
- helpers::Properties& properties,
- const LogString& prefix,
- Pool& p)
+ helpers::Properties& properties,
+ const LogString& prefix,
+ Pool& p)
{
- PropertySetter(obj).setProperties(properties, prefix, p);
+ PropertySetter(obj).setProperties(properties, prefix, p);
}
void PropertySetter::setProperties(helpers::Properties& properties,
- const LogString& prefix,
- Pool& p)
+ const LogString& prefix,
+ Pool& p)
{
- int len = prefix.length();
+ int len = prefix.length();
- std::vector<LogString> names = properties.propertyNames();
- std::vector<LogString>::iterator it;
+ std::vector<LogString> names = properties.propertyNames();
+ std::vector<LogString>::iterator it;
- for (it = names.begin(); it != names.end(); it++)
+ for (it = names.begin(); it != names.end(); it++)
+ {
+ LogString key = *it;
+
+ // handle only properties that start with the desired frefix.
+ if (key.find(prefix) == 0)
{
- LogString key = *it;
+ // ignore key if it contains dots after the prefix
+ if (key.find(0x2E /* '.' */, len + 1) != LogString::npos)
+ {
+ continue;
+ }
- // handle only properties that start with the desired frefix.
- if (key.find(prefix) == 0)
- {
- // ignore key if it contains dots after the prefix
- if (key.find(0x2E /* '.' */, len + 1) != LogString::npos)
- {
- continue;
- }
+ LogString value = OptionConverter::findAndSubst(key, properties);
+ key = key.substr(len);
- LogString value = OptionConverter::findAndSubst(key, properties);
- key = key.substr(len);
- if (key == LOG4CXX_STR("layout")
- && obj != 0
- && obj->instanceof(Appender::getStaticClass()))
- {
- continue;
- }
- setProperty(key, value, p);
- }
+ if (key == LOG4CXX_STR("layout")
+ && obj != 0
+ && obj->instanceof(Appender::getStaticClass()))
+ {
+ continue;
+ }
+
+ setProperty(key, value, p);
}
- activate(p);
+ }
+
+ activate(p);
}
void PropertySetter::setProperty(const LogString& option,
const LogString& value,
Pool&)
{
- if (value.empty())
- return;
+ if (value.empty())
+ {
+ return;
+ }
- if (obj != 0 && obj->instanceof(OptionHandler::getStaticClass()))
- {
- LogLog::debug(LOG4CXX_STR("Setting option name=[") +
- option + LOG4CXX_STR("], value=[") + value + LOG4CXX_STR("]"));
- OptionHandlerPtr(obj)->setOption(option, value);
- }
+ if (obj != 0 && obj->instanceof(OptionHandler::getStaticClass()))
+ {
+ LogLog::debug(LOG4CXX_STR("Setting option name=[") +
+ option + LOG4CXX_STR("], value=[") + value + LOG4CXX_STR("]"));
+ OptionHandlerPtr(obj)->setOption(option, value);
+ }
}
void PropertySetter::activate(Pool& p)
{
- if (obj != 0 && obj->instanceof(OptionHandler::getStaticClass()))
- {
- OptionHandlerPtr(obj)->activateOptions(p);
- }
+ if (obj != 0 && obj->instanceof(OptionHandler::getStaticClass()))
+ {
+ OptionHandlerPtr(obj)->activateOptions(p);
+ }
}
diff --git a/src/main/cpp/reader.cpp b/src/main/cpp/reader.cpp
index ec53ef7..6effa9a 100644
--- a/src/main/cpp/reader.cpp
+++ b/src/main/cpp/reader.cpp
@@ -22,8 +22,10 @@
IMPLEMENT_LOG4CXX_OBJECT(Reader)
-Reader::Reader() {
+Reader::Reader()
+{
}
-Reader::~Reader() {
+Reader::~Reader()
+{
}
diff --git a/src/main/cpp/relativetimedateformat.cpp b/src/main/cpp/relativetimedateformat.cpp
index 2cce37a..3433d12 100644
--- a/src/main/cpp/relativetimedateformat.cpp
+++ b/src/main/cpp/relativetimedateformat.cpp
@@ -25,14 +25,15 @@
log4cxx::helpers::RelativeTimeDateFormat::RelativeTimeDateFormat()
- : DateFormat(), startTime(log4cxx::spi::LoggingEvent::getStartTime())
+ : DateFormat(), startTime(log4cxx::spi::LoggingEvent::getStartTime())
{
}
void log4cxx::helpers::RelativeTimeDateFormat::format(
- LogString &s,
+ LogString& s,
log4cxx_time_t date,
- Pool& p) const {
+ Pool& p) const
+{
log4cxx_int64_t interval = (date - startTime) / APR_INT64_C(1000);
StringHelper::toString(interval, p, s);
}
diff --git a/src/main/cpp/relativetimepatternconverter.cpp b/src/main/cpp/relativetimepatternconverter.cpp
index db7eaa6..7d96a6a 100644
--- a/src/main/cpp/relativetimepatternconverter.cpp
+++ b/src/main/cpp/relativetimepatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -33,21 +33,24 @@
IMPLEMENT_LOG4CXX_OBJECT(RelativeTimePatternConverter)
RelativeTimePatternConverter::RelativeTimePatternConverter() :
- LoggingEventPatternConverter(LOG4CXX_STR("Time"),
- LOG4CXX_STR("time")) {
+ LoggingEventPatternConverter(LOG4CXX_STR("Time"),
+ LOG4CXX_STR("time"))
+{
}
PatternConverterPtr RelativeTimePatternConverter::newInstance(
- const std::vector<LogString>& /* options */) {
- static PatternConverterPtr def(new RelativeTimePatternConverter());
- return def;
+ const std::vector<LogString>& /* options */)
+{
+ static PatternConverterPtr def(new RelativeTimePatternConverter());
+ return def;
}
void RelativeTimePatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- Pool& p) const {
- log4cxx_time_t delta = (event->getTimeStamp() - LoggingEvent::getStartTime())/1000;
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ Pool& p) const
+{
+ log4cxx_time_t delta = (event->getTimeStamp() - LoggingEvent::getStartTime()) / 1000;
StringHelper::toString(delta, p, toAppendTo);
- }
+}
diff --git a/src/main/cpp/resourcebundle.cpp b/src/main/cpp/resourcebundle.cpp
index 4e8c569..8f3978c 100644
--- a/src/main/cpp/resourcebundle.cpp
+++ b/src/main/cpp/resourcebundle.cpp
@@ -28,95 +28,97 @@
IMPLEMENT_LOG4CXX_OBJECT(ResourceBundle)
ResourceBundlePtr ResourceBundle::getBundle(const LogString& baseName,
- const Locale& locale)
+ const Locale& locale)
{
- LogString bundleName;
- PropertyResourceBundlePtr resourceBundle, previous;
+ LogString bundleName;
+ PropertyResourceBundlePtr resourceBundle, previous;
- std::vector<LogString> bundlesNames;
+ std::vector<LogString> bundlesNames;
- if (!locale.getVariant().empty())
- {
- bundlesNames.push_back(baseName + LOG4CXX_STR("_") +
- locale.getLanguage() + LOG4CXX_STR("_") +
- locale.getCountry() + LOG4CXX_STR("_") +
- locale.getVariant());
- }
+ if (!locale.getVariant().empty())
+ {
+ bundlesNames.push_back(baseName + LOG4CXX_STR("_") +
+ locale.getLanguage() + LOG4CXX_STR("_") +
+ locale.getCountry() + LOG4CXX_STR("_") +
+ locale.getVariant());
+ }
- if (!locale.getCountry().empty())
- {
- bundlesNames.push_back(baseName + LOG4CXX_STR("_") +
- locale.getLanguage() + LOG4CXX_STR("_") +
- locale.getCountry());
- }
+ if (!locale.getCountry().empty())
+ {
+ bundlesNames.push_back(baseName + LOG4CXX_STR("_") +
+ locale.getLanguage() + LOG4CXX_STR("_") +
+ locale.getCountry());
+ }
- if (!locale.getLanguage().empty())
- {
- bundlesNames.push_back(baseName + LOG4CXX_STR("_") +
- locale.getLanguage());
- }
+ if (!locale.getLanguage().empty())
+ {
+ bundlesNames.push_back(baseName + LOG4CXX_STR("_") +
+ locale.getLanguage());
+ }
- bundlesNames.push_back(baseName);
+ bundlesNames.push_back(baseName);
- for (std::vector<LogString>::iterator it = bundlesNames.begin();
- it != bundlesNames.end(); it++)
- {
+ for (std::vector<LogString>::iterator it = bundlesNames.begin();
+ it != bundlesNames.end(); it++)
+ {
- bundleName = *it;
+ bundleName = *it;
- PropertyResourceBundlePtr current;
+ PropertyResourceBundlePtr current;
- // Try loading a class which implements ResourceBundle
- try
- {
- const Class& classObj = Loader::loadClass(bundleName);
- current = classObj.newInstance();
- }
- catch(ClassNotFoundException&)
- {
- current = 0;
- }
-
- // No class found, then try to create a PropertyResourceBundle from a file
- if (current == 0)
- {
- InputStreamPtr bundleStream =
- Loader::getResourceAsStream(
- bundleName + LOG4CXX_STR(".properties"));
- if (bundleStream == 0) {
- continue;
- }
-
+ // Try loading a class which implements ResourceBundle
try
{
- current = new PropertyResourceBundle(bundleStream);
+ const Class& classObj = Loader::loadClass(bundleName);
+ current = classObj.newInstance();
}
- catch(Exception&)
+ catch (ClassNotFoundException&)
{
- throw;
+ current = 0;
}
- }
- // Add the new resource bundle to the hierarchy
- if (resourceBundle == 0)
- {
- resourceBundle = current;
- previous = current;
- }
- else
- {
- previous->setParent(current);
- previous = current;
- }
- }
+ // No class found, then try to create a PropertyResourceBundle from a file
+ if (current == 0)
+ {
+ InputStreamPtr bundleStream =
+ Loader::getResourceAsStream(
+ bundleName + LOG4CXX_STR(".properties"));
- // no resource bundle found at all, then throw exception
- if (resourceBundle == 0)
- {
- throw MissingResourceException(
- ((LogString) LOG4CXX_STR("Missing resource bundle ")) + baseName);
- }
+ if (bundleStream == 0)
+ {
+ continue;
+ }
- return resourceBundle;
+ try
+ {
+ current = new PropertyResourceBundle(bundleStream);
+ }
+ catch (Exception&)
+ {
+ throw;
+ }
+ }
+
+ // Add the new resource bundle to the hierarchy
+ if (resourceBundle == 0)
+ {
+ resourceBundle = current;
+ previous = current;
+ }
+ else
+ {
+ previous->setParent(current);
+ previous = current;
+ }
+ }
+
+ // no resource bundle found at all, then throw exception
+ if (resourceBundle == 0)
+ {
+ throw MissingResourceException(
+ ((LogString) LOG4CXX_STR("Missing resource bundle ")) + baseName);
+ }
+
+ return resourceBundle;
}
diff --git a/src/main/cpp/rollingfileappender.cpp b/src/main/cpp/rollingfileappender.cpp
index 33510de..c0d8783 100644
--- a/src/main/cpp/rollingfileappender.cpp
+++ b/src/main/cpp/rollingfileappender.cpp
@@ -16,20 +16,20 @@
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#ifdef LOG4CXX_MULTI_PROCESS
-#include <apr_portable.h>
-#include <libgen.h>
-#include <apr_file_io.h>
-#include <apr_atomic.h>
-#include <apr_mmap.h>
-#ifndef MAX_FILE_LEN
-#define MAX_FILE_LEN 2048
-#endif
-#include <log4cxx/pattern/filedatepatternconverter.h>
-#include <log4cxx/helpers/date.h>
+ #include <apr_portable.h>
+ #include <libgen.h>
+ #include <apr_file_io.h>
+ #include <apr_atomic.h>
+ #include <apr_mmap.h>
+ #ifndef MAX_FILE_LEN
+ #define MAX_FILE_LEN 2048
+ #endif
+ #include <log4cxx/pattern/filedatepatternconverter.h>
+ #include <log4cxx/helpers/date.h>
#endif
#include <log4cxx/rolling/rollingfileappender.h>
@@ -54,89 +54,112 @@
/**
* Construct a new instance.
*/
-RollingFileAppenderSkeleton::RollingFileAppenderSkeleton() : _event(NULL){
+RollingFileAppenderSkeleton::RollingFileAppenderSkeleton() : _event(NULL)
+{
}
-RollingFileAppender::RollingFileAppender() {
+RollingFileAppender::RollingFileAppender()
+{
}
/**
* Prepare instance of use.
*/
-void RollingFileAppenderSkeleton::activateOptions(Pool &p) {
- if (rollingPolicy == NULL) {
- FixedWindowRollingPolicy* fwrp = new FixedWindowRollingPolicy();
- fwrp->setFileNamePattern(getFile() + LOG4CXX_STR(".%i"));
- rollingPolicy = fwrp;
- }
-
- //
- // if no explicit triggering policy and rolling policy is both.
- //
- if (triggeringPolicy == NULL) {
- TriggeringPolicyPtr trig(rollingPolicy);
- if (trig != NULL) {
- triggeringPolicy = trig;
- }
- }
-
- if (triggeringPolicy == NULL) {
- triggeringPolicy = new ManualTriggeringPolicy();
- }
-
- {
- LOCK_W sync(mutex);
- triggeringPolicy->activateOptions(p);
- rollingPolicy->activateOptions(p);
-
- try {
- RolloverDescriptionPtr rollover1 =
- rollingPolicy->initialize(getFile(), getAppend(), p);
-
- if (rollover1 != NULL) {
- ActionPtr syncAction(rollover1->getSynchronous());
-
- if (syncAction != NULL) {
- syncAction->execute(p);
- }
-
- setFile(rollover1->getActiveFileName());
- setAppend(rollover1->getAppend());
-
- //
- // async action not yet implemented
- //
- ActionPtr asyncAction(rollover1->getAsynchronous());
- if (asyncAction != NULL) {
- asyncAction->execute(p);
- }
- }
-
- File activeFile;
- activeFile.setPath(getFile());
-
- if (getAppend()) {
- fileLength = activeFile.length(p);
- } else {
- fileLength = 0;
- }
-
- FileAppender::activateOptions(p);
- } catch (std::exception& ex) {
- LogLog::warn(
- LogString(LOG4CXX_STR("Exception will initializing RollingFileAppender named "))
- + getName());
+void RollingFileAppenderSkeleton::activateOptions(Pool& p)
+{
+ if (rollingPolicy == NULL)
+ {
+ FixedWindowRollingPolicy* fwrp = new FixedWindowRollingPolicy();
+ fwrp->setFileNamePattern(getFile() + LOG4CXX_STR(".%i"));
+ rollingPolicy = fwrp;
}
- }
+
+ //
+ // if no explicit triggering policy and rolling policy is both.
+ //
+ if (triggeringPolicy == NULL)
+ {
+ TriggeringPolicyPtr trig(rollingPolicy);
+
+ if (trig != NULL)
+ {
+ triggeringPolicy = trig;
+ }
+ }
+
+ if (triggeringPolicy == NULL)
+ {
+ triggeringPolicy = new ManualTriggeringPolicy();
+ }
+
+ {
+ LOCK_W sync(mutex);
+ triggeringPolicy->activateOptions(p);
+ rollingPolicy->activateOptions(p);
+
+ try
+ {
+ RolloverDescriptionPtr rollover1 =
+ rollingPolicy->initialize(getFile(), getAppend(), p);
+
+ if (rollover1 != NULL)
+ {
+ ActionPtr syncAction(rollover1->getSynchronous());
+
+ if (syncAction != NULL)
+ {
+ syncAction->execute(p);
+ }
+
+ setFile(rollover1->getActiveFileName());
+ setAppend(rollover1->getAppend());
+
+ //
+ // async action not yet implemented
+ //
+ ActionPtr asyncAction(rollover1->getAsynchronous());
+
+ if (asyncAction != NULL)
+ {
+ asyncAction->execute(p);
+ }
+ }
+
+ File activeFile;
+ activeFile.setPath(getFile());
+
+ if (getAppend())
+ {
+ fileLength = activeFile.length(p);
+ }
+ else
+ {
+ fileLength = 0;
+ }
+
+ FileAppender::activateOptions(p);
+ }
+ catch (std::exception& ex)
+ {
+ LogLog::warn(
+ LogString(LOG4CXX_STR("Exception will initializing RollingFileAppender named "))
+ + getName());
+ }
+ }
}
#ifdef LOG4CXX_MULTI_PROCESS
-void RollingFileAppenderSkeleton::releaseFileLock(apr_file_t* lock_file){
- if (lock_file){
+void RollingFileAppenderSkeleton::releaseFileLock(apr_file_t* lock_file)
+{
+ if (lock_file)
+ {
apr_status_t stat = apr_file_unlock(lock_file);
- if (stat != APR_SUCCESS){
+
+ if (stat != APR_SUCCESS)
+ {
LogLog::warn(LOG4CXX_STR("flock: unlock failed"));
}
+
apr_file_close(lock_file);
lock_file = NULL;
}
@@ -157,23 +180,28 @@
* @return true if rollover performed.
*/
-bool RollingFileAppenderSkeleton::rollover(Pool& p) {
+bool RollingFileAppenderSkeleton::rollover(Pool& p)
+{
//
// can't roll without a policy
//
- if (rollingPolicy != NULL) {
+ if (rollingPolicy != NULL)
+ {
{
LOCK_W sync(mutex);
#ifdef LOG4CXX_MULTI_PROCESS
std::string fileName(getFile());
- RollingPolicyBase *basePolicy = dynamic_cast<RollingPolicyBase* >(&(*rollingPolicy));
+ RollingPolicyBase* basePolicy = dynamic_cast<RollingPolicyBase* >(&(*rollingPolicy));
apr_time_t n = apr_time_now();
ObjectPtr obj(new Date(n));
LogString fileNamePattern;
- if (basePolicy){
- if (basePolicy->getPatternConverterList().size()){
+
+ if (basePolicy)
+ {
+ if (basePolicy->getPatternConverterList().size())
+ {
(*(basePolicy->getPatternConverterList().begin()))->format(obj, fileNamePattern, p);
fileName = std::string(fileNamePattern);
}
@@ -188,74 +216,105 @@
apr_uid_t uid;
apr_gid_t groupid;
apr_status_t stat = apr_uid_current(&uid, &groupid, pool.getAPRPool());
- if (stat == APR_SUCCESS){
+
+ if (stat == APR_SUCCESS)
+ {
snprintf(szUid, MAX_FILE_LEN, "%u", uid);
}
const std::string lockname = std::string(::dirname(szDirName)) + "/." + ::basename(szBaseName) + szUid + ".lock";
apr_file_t* lock_file;
stat = apr_file_open(&lock_file, lockname.c_str(), APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, p.getAPRPool());
- if (stat != APR_SUCCESS) {
+
+ if (stat != APR_SUCCESS)
+ {
std::string err = "lockfile return error: open lockfile failed. ";
err += (strerror(errno));
LogLog::warn(LOG4CXX_STR(err.c_str()));
bAlreadyRolled = false;
lock_file = NULL;
- }else{
+ }
+ else
+ {
stat = apr_file_lock(lock_file, APR_FLOCK_EXCLUSIVE);
- if (stat != APR_SUCCESS){
+
+ if (stat != APR_SUCCESS)
+ {
std::string err = "apr_file_lock: lock failed. ";
err += (strerror(errno));
LogLog::warn(LOG4CXX_STR(err.c_str()));
bAlreadyRolled = false;
}
- else {
+ else
+ {
if (_event)
+ {
triggeringPolicy->isTriggeringEvent(this, *_event, getFile(), getFileLength());
+ }
}
}
- if (bAlreadyRolled){
+ if (bAlreadyRolled)
+ {
apr_finfo_t finfo1, finfo2;
apr_status_t st1, st2;
apr_file_t* _fd = getWriter()->getOutPutStreamPtr()->getFileOutPutStreamPtr().getFilePtr();
st1 = apr_file_info_get(&finfo1, APR_FINFO_IDENT, _fd);
- if (st1 != APR_SUCCESS){
+
+ if (st1 != APR_SUCCESS)
+ {
LogLog::warn(LOG4CXX_STR("apr_file_info_get failed"));
}
st2 = apr_stat(&finfo2, std::string(getFile()).c_str(), APR_FINFO_IDENT, p.getAPRPool());
- if (st2 != APR_SUCCESS){
+
+ if (st2 != APR_SUCCESS)
+ {
LogLog::warn(LOG4CXX_STR("apr_stat failed."));
}
bAlreadyRolled = ((st1 == APR_SUCCESS) && (st2 == APR_SUCCESS)
- && ((finfo1.device != finfo2.device) || (finfo1.inode != finfo2.inode)));
+ && ((finfo1.device != finfo2.device) || (finfo1.inode != finfo2.inode)));
}
- if (!bAlreadyRolled){
+ if (!bAlreadyRolled)
+ {
#endif
- try {
+
+ try
+ {
RolloverDescriptionPtr rollover1(rollingPolicy->rollover(this->getFile(), this->getAppend(), p));
- if (rollover1 != NULL) {
- if (rollover1->getActiveFileName() == getFile()) {
+
+ if (rollover1 != NULL)
+ {
+ if (rollover1->getActiveFileName() == getFile())
+ {
closeWriter();
bool success = true;
- if (rollover1->getSynchronous() != NULL) {
+
+ if (rollover1->getSynchronous() != NULL)
+ {
success = false;
- try {
+ try
+ {
success = rollover1->getSynchronous()->execute(p);
- } catch (std::exception& ex) {
+ }
+ catch (std::exception& ex)
+ {
LogLog::warn(LOG4CXX_STR("Exception on rollover"));
}
}
- if (success) {
- if (rollover1->getAppend()) {
+ if (success)
+ {
+ if (rollover1->getAppend())
+ {
fileLength = File().setPath(rollover1->getActiveFileName()).length(p);
- } else {
+ }
+ else
+ {
fileLength = 0;
}
@@ -263,20 +322,26 @@
// async action not yet implemented
//
ActionPtr asyncAction(rollover1->getAsynchronous());
- if (asyncAction != NULL) {
+
+ if (asyncAction != NULL)
+ {
asyncAction->execute(p);
}
setFile(
rollover1->getActiveFileName(), rollover1->getAppend(),
bufferedIO, bufferSize, p);
- } else {
+ }
+ else
+ {
setFile(
rollover1->getActiveFileName(), true, bufferedIO, bufferSize, p);
}
- } else {
+ }
+ else
+ {
OutputStreamPtr os(new FileOutputStream(
- rollover1->getActiveFileName(), rollover1->getAppend()));
+ rollover1->getActiveFileName(), rollover1->getAppend()));
WriterPtr newWriter(createWriter(os));
closeWriter();
setFile(rollover1->getActiveFileName());
@@ -284,20 +349,28 @@
bool success = true;
- if (rollover1->getSynchronous() != NULL) {
+ if (rollover1->getSynchronous() != NULL)
+ {
success = false;
- try {
+ try
+ {
success = rollover1->getSynchronous()->execute(p);
- } catch (std::exception& ex) {
+ }
+ catch (std::exception& ex)
+ {
LogLog::warn(LOG4CXX_STR("Exception during rollover"));
}
}
- if (success) {
- if (rollover1->getAppend()) {
+ if (success)
+ {
+ if (rollover1->getAppend())
+ {
fileLength = File().setPath(rollover1->getActiveFileName()).length(p);
- } else {
+ }
+ else
+ {
fileLength = 0;
}
@@ -305,7 +378,9 @@
// async action not yet implemented
//
ActionPtr asyncAction(rollover1->getAsynchronous());
- if (asyncAction != NULL) {
+
+ if (asyncAction != NULL)
+ {
asyncAction->execute(p);
}
}
@@ -318,17 +393,24 @@
#endif
return true;
}
- } catch (std::exception& ex) {
+ }
+ catch (std::exception& ex)
+ {
LogLog::warn(LOG4CXX_STR("Exception during rollover"));
}
+
#ifdef LOG4CXX_MULTI_PROCESS
- }else{
+ }
+ else
+ {
reopenLatestFile(p);
}
+
releaseFileLock(lock_file);
#endif
}
}
+
return false;
}
@@ -336,7 +418,8 @@
/**
* re-open current file when its own handler has been renamed
*/
-void RollingFileAppenderSkeleton::reopenLatestFile(Pool& p){
+void RollingFileAppenderSkeleton::reopenLatestFile(Pool& p)
+{
closeWriter();
OutputStreamPtr os(new FileOutputStream(getFile(), true));
WriterPtr newWriter(createWriter(os));
@@ -351,155 +434,183 @@
/**
* {@inheritDoc}
*/
-void RollingFileAppenderSkeleton::subAppend(const LoggingEventPtr& event, Pool& p) {
- // The rollover check must precede actual writing. This is the
- // only correct behavior for time driven triggers.
- if (
- triggeringPolicy->isTriggeringEvent(
- this, event, getFile(), getFileLength())) {
- //
- // wrap rollover request in try block since
- // rollover may fail in case read access to directory
- // is not provided. However appender should still be in good
- // condition and the append should still happen.
- try {
- _event = &(const_cast<LoggingEventPtr &>(event));
- rollover(p);
- } catch (std::exception& ex) {
- LogLog::warn(LOG4CXX_STR("Exception during rollover attempt."));
+void RollingFileAppenderSkeleton::subAppend(const LoggingEventPtr& event, Pool& p)
+{
+ // The rollover check must precede actual writing. This is the
+ // only correct behavior for time driven triggers.
+ if (
+ triggeringPolicy->isTriggeringEvent(
+ this, event, getFile(), getFileLength()))
+ {
+ //
+ // wrap rollover request in try block since
+ // rollover may fail in case read access to directory
+ // is not provided. However appender should still be in good
+ // condition and the append should still happen.
+ try
+ {
+ _event = &(const_cast<LoggingEventPtr&>(event));
+ rollover(p);
+ }
+ catch (std::exception& ex)
+ {
+ LogLog::warn(LOG4CXX_STR("Exception during rollover attempt."));
+ }
}
- }
#ifdef LOG4CXX_MULTI_PROCESS
- //do re-check before every write
- //
- apr_finfo_t finfo1, finfo2;
- apr_status_t st1, st2;
- apr_file_t* _fd = getWriter()->getOutPutStreamPtr()->getFileOutPutStreamPtr().getFilePtr();
- st1 = apr_file_info_get(&finfo1, APR_FINFO_IDENT, _fd);
- if (st1 != APR_SUCCESS){
- LogLog::warn(LOG4CXX_STR("apr_file_info_get failed"));
- }
+ //do re-check before every write
+ //
+ apr_finfo_t finfo1, finfo2;
+ apr_status_t st1, st2;
+ apr_file_t* _fd = getWriter()->getOutPutStreamPtr()->getFileOutPutStreamPtr().getFilePtr();
+ st1 = apr_file_info_get(&finfo1, APR_FINFO_IDENT, _fd);
- st2 = apr_stat(&finfo2, std::string(getFile()).c_str(), APR_FINFO_IDENT, p.getAPRPool());
- if (st2 != APR_SUCCESS){
- std::string err = "apr_stat failed. file:" + std::string(getFile());
- LogLog::warn(LOG4CXX_STR(err.c_str()));
- }
+ if (st1 != APR_SUCCESS)
+ {
+ LogLog::warn(LOG4CXX_STR("apr_file_info_get failed"));
+ }
- bool bAlreadyRolled = ((st1 == APR_SUCCESS) && (st2 == APR_SUCCESS)
- && ((finfo1.device != finfo2.device) || (finfo1.inode != finfo2.inode)));
+ st2 = apr_stat(&finfo2, std::string(getFile()).c_str(), APR_FINFO_IDENT, p.getAPRPool());
- if (bAlreadyRolled){
- reopenLatestFile(p);
- }
+ if (st2 != APR_SUCCESS)
+ {
+ std::string err = "apr_stat failed. file:" + std::string(getFile());
+ LogLog::warn(LOG4CXX_STR(err.c_str()));
+ }
+
+ bool bAlreadyRolled = ((st1 == APR_SUCCESS) && (st2 == APR_SUCCESS)
+ && ((finfo1.device != finfo2.device) || (finfo1.inode != finfo2.inode)));
+
+ if (bAlreadyRolled)
+ {
+ reopenLatestFile(p);
+ }
+
#endif
- FileAppender::subAppend(event, p);
+ FileAppender::subAppend(event, p);
}
/**
* Get rolling policy.
* @return rolling policy.
*/
-RollingPolicyPtr RollingFileAppenderSkeleton::getRollingPolicy() const {
- return rollingPolicy;
+RollingPolicyPtr RollingFileAppenderSkeleton::getRollingPolicy() const
+{
+ return rollingPolicy;
}
/**
* Get triggering policy.
* @return triggering policy.
*/
-TriggeringPolicyPtr RollingFileAppenderSkeleton::getTriggeringPolicy() const {
- return triggeringPolicy;
+TriggeringPolicyPtr RollingFileAppenderSkeleton::getTriggeringPolicy() const
+{
+ return triggeringPolicy;
}
/**
* Sets the rolling policy.
* @param policy rolling policy.
*/
-void RollingFileAppenderSkeleton::setRollingPolicy(const RollingPolicyPtr& policy) {
- rollingPolicy = policy;
+void RollingFileAppenderSkeleton::setRollingPolicy(const RollingPolicyPtr& policy)
+{
+ rollingPolicy = policy;
}
/**
* Set triggering policy.
* @param policy triggering policy.
*/
-void RollingFileAppenderSkeleton::setTriggeringPolicy(const TriggeringPolicyPtr& policy) {
- triggeringPolicy = policy;
+void RollingFileAppenderSkeleton::setTriggeringPolicy(const TriggeringPolicyPtr& policy)
+{
+ triggeringPolicy = policy;
}
/**
* Close appender. Waits for any asynchronous file compression actions to be completed.
*/
-void RollingFileAppenderSkeleton::close() {
- FileAppender::close();
+void RollingFileAppenderSkeleton::close()
+{
+ FileAppender::close();
}
-namespace log4cxx {
- namespace rolling {
+namespace log4cxx
+{
+namespace rolling
+{
/**
* Wrapper for OutputStream that will report all write
* operations back to this class for file length calculations.
*/
-class CountingOutputStream : public OutputStream {
- /**
- * Wrapped output stream.
- */
- private:
- OutputStreamPtr os;
+class CountingOutputStream : public OutputStream
+{
+ /**
+ * Wrapped output stream.
+ */
+ private:
+ OutputStreamPtr os;
- /**
- * Rolling file appender to inform of stream writes.
- */
- RollingFileAppenderSkeleton* rfa;
+ /**
+ * Rolling file appender to inform of stream writes.
+ */
+ RollingFileAppenderSkeleton* rfa;
- public:
- /**
- * Constructor.
- * @param os output stream to wrap.
- * @param rfa rolling file appender to inform.
- */
- CountingOutputStream(
- OutputStreamPtr& os1, RollingFileAppenderSkeleton* rfa1) :
- os(os1), rfa(rfa1) {
- }
+ public:
+ /**
+ * Constructor.
+ * @param os output stream to wrap.
+ * @param rfa rolling file appender to inform.
+ */
+ CountingOutputStream(
+ OutputStreamPtr& os1, RollingFileAppenderSkeleton* rfa1) :
+ os(os1), rfa(rfa1)
+ {
+ }
- /**
- * {@inheritDoc}
- */
- void close(Pool& p) {
- os->close(p);
- rfa = 0;
- }
+ /**
+ * {@inheritDoc}
+ */
+ void close(Pool& p)
+ {
+ os->close(p);
+ rfa = 0;
+ }
- /**
- * {@inheritDoc}
- */
- void flush(Pool& p) {
- os->flush(p);
- }
+ /**
+ * {@inheritDoc}
+ */
+ void flush(Pool& p)
+ {
+ os->flush(p);
+ }
- /**
- * {@inheritDoc}
- */
- void write(ByteBuffer& buf, Pool& p) {
- os->write(buf, p);
- if (rfa != 0) {
+ /**
+ * {@inheritDoc}
+ */
+ void write(ByteBuffer& buf, Pool& p)
+ {
+ os->write(buf, p);
+
+ if (rfa != 0)
+ {
#ifndef LOG4CXX_MULTI_PROCESS
- rfa->incrementFileLength(buf.limit());
+ rfa->incrementFileLength(buf.limit());
#else
- rfa->setFileLength(File().setPath(rfa->getFile()).length(p));
+ rfa->setFileLength(File().setPath(rfa->getFile()).length(p));
#endif
- }
- }
+ }
+ }
#ifdef LOG4CXX_MULTI_PROCESS
- OutputStream& getFileOutPutStreamPtr() { return *os;}
+ OutputStream& getFileOutPutStreamPtr()
+ {
+ return *os;
+ }
#endif
};
- }
+}
}
/**
@@ -511,21 +622,24 @@
@param os output stream, may not be null.
@return new writer.
*/
-WriterPtr RollingFileAppenderSkeleton::createWriter(OutputStreamPtr& os) {
- OutputStreamPtr cos(new CountingOutputStream(os, this));
- return FileAppender::createWriter(cos);
+WriterPtr RollingFileAppenderSkeleton::createWriter(OutputStreamPtr& os)
+{
+ OutputStreamPtr cos(new CountingOutputStream(os, this));
+ return FileAppender::createWriter(cos);
}
/**
* Get byte length of current active log file.
* @return byte length of current active log file.
*/
-size_t RollingFileAppenderSkeleton::getFileLength() const {
- return fileLength;
+size_t RollingFileAppenderSkeleton::getFileLength() const
+{
+ return fileLength;
}
#ifdef LOG4CXX_MULTI_PROCESS
-void RollingFileAppenderSkeleton::setFileLength(size_t length){
+void RollingFileAppenderSkeleton::setFileLength(size_t length)
+{
fileLength = length;
}
#endif
@@ -534,6 +648,7 @@
* Increments estimated byte length of current active log file.
* @param increment additional bytes written to log file.
*/
-void RollingFileAppenderSkeleton::incrementFileLength(size_t increment) {
- fileLength += increment;
+void RollingFileAppenderSkeleton::incrementFileLength(size_t increment)
+{
+ fileLength += increment;
}
diff --git a/src/main/cpp/rollingpolicy.cpp b/src/main/cpp/rollingpolicy.cpp
index a3f49df..5b9e15c 100644
--- a/src/main/cpp/rollingpolicy.cpp
+++ b/src/main/cpp/rollingpolicy.cpp
@@ -17,8 +17,8 @@
#include <log4cxx/rolling/rollingpolicy.h>
- using namespace log4cxx::rolling;
+using namespace log4cxx::rolling;
- IMPLEMENT_LOG4CXX_OBJECT(RollingPolicy)
+IMPLEMENT_LOG4CXX_OBJECT(RollingPolicy)
diff --git a/src/main/cpp/rollingpolicybase.cpp b/src/main/cpp/rollingpolicybase.cpp
index ee8233c..664c3ed 100644
--- a/src/main/cpp/rollingpolicybase.cpp
+++ b/src/main/cpp/rollingpolicybase.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -36,60 +36,73 @@
IMPLEMENT_LOG4CXX_OBJECT(RollingPolicyBase)
-RollingPolicyBase::RollingPolicyBase() {
+RollingPolicyBase::RollingPolicyBase()
+{
}
-RollingPolicyBase::~RollingPolicyBase() {
+RollingPolicyBase::~RollingPolicyBase()
+{
}
-void RollingPolicyBase::addRef() const {
+void RollingPolicyBase::addRef() const
+{
ObjectImpl::addRef();
}
-void RollingPolicyBase::releaseRef() const {
+void RollingPolicyBase::releaseRef() const
+{
ObjectImpl::releaseRef();
}
-void RollingPolicyBase::activateOptions(log4cxx::helpers::Pool& /* pool */) {
- if (fileNamePatternStr.length() > 0) {
- parseFileNamePattern();
- } else {
- LogString msg(LOG4CXX_STR("The FileNamePattern option must be set before using FixedWindowRollingPolicy."));
- LogString ref1(LOG4CXX_STR("See also http://logging.apache.org/log4j/codes.html#tbr_fnp_not_set"));
- LogLog::warn(msg);
- LogLog::warn(ref1);
- throw IllegalStateException();
- }
+void RollingPolicyBase::activateOptions(log4cxx::helpers::Pool& /* pool */)
+{
+ if (fileNamePatternStr.length() > 0)
+ {
+ parseFileNamePattern();
+ }
+ else
+ {
+ LogString msg(LOG4CXX_STR("The FileNamePattern option must be set before using FixedWindowRollingPolicy."));
+ LogString ref1(LOG4CXX_STR("See also http://logging.apache.org/log4j/codes.html#tbr_fnp_not_set"));
+ LogLog::warn(msg);
+ LogLog::warn(ref1);
+ throw IllegalStateException();
+ }
}
-void RollingPolicyBase::setOption(const LogString& option, const LogString& value) {
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("FILENAMEPATTERN"),
- LOG4CXX_STR("filenamepattern"))) {
- fileNamePatternStr = value;
- }
+void RollingPolicyBase::setOption(const LogString& option, const LogString& value)
+{
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("FILENAMEPATTERN"),
+ LOG4CXX_STR("filenamepattern")))
+ {
+ fileNamePatternStr = value;
+ }
}
-void RollingPolicyBase::setFileNamePattern(const LogString& fnp) {
- fileNamePatternStr = fnp;
+void RollingPolicyBase::setFileNamePattern(const LogString& fnp)
+{
+ fileNamePatternStr = fnp;
}
-LogString RollingPolicyBase::getFileNamePattern() const {
- return fileNamePatternStr;
+LogString RollingPolicyBase::getFileNamePattern() const
+{
+ return fileNamePatternStr;
}
/**
* Parse file name pattern.
*/
-void RollingPolicyBase::parseFileNamePattern() {
- patternConverters.erase(patternConverters.begin(), patternConverters.end());
- patternFields.erase(patternFields.begin(), patternFields.end());
- PatternParser::parse(fileNamePatternStr,
- patternConverters,
- patternFields,
- getFormatSpecifiers());
+void RollingPolicyBase::parseFileNamePattern()
+{
+ patternConverters.erase(patternConverters.begin(), patternConverters.end());
+ patternFields.erase(patternFields.begin(), patternFields.end());
+ PatternParser::parse(fileNamePatternStr,
+ patternConverters,
+ patternFields,
+ getFormatSpecifiers());
}
/**
@@ -99,15 +112,18 @@
* @param buf string buffer to which formatted file name is appended, may not be null.
*/
void RollingPolicyBase::formatFileName(
- ObjectPtr& obj,
- LogString& toAppendTo,
- Pool& pool) const {
+ ObjectPtr& obj,
+ LogString& toAppendTo,
+ Pool& pool) const
+{
std::vector<FormattingInfoPtr>::const_iterator formatterIter =
- patternFields.begin();
- for(std::vector<PatternConverterPtr>::const_iterator
- converterIter = patternConverters.begin();
- converterIter != patternConverters.end();
- converterIter++, formatterIter++) {
+ patternFields.begin();
+
+ for (std::vector<PatternConverterPtr>::const_iterator
+ converterIter = patternConverters.begin();
+ converterIter != patternConverters.end();
+ converterIter++, formatterIter++)
+ {
int startField = toAppendTo.length();
(*converterIter)->format(obj, toAppendTo, pool);
(*formatterIter)->format(startField, toAppendTo);
@@ -115,32 +131,42 @@
}
-PatternConverterPtr RollingPolicyBase::getIntegerPatternConverter() const {
- for(std::vector<PatternConverterPtr>::const_iterator
- converterIter = patternConverters.begin();
- converterIter != patternConverters.end();
- converterIter++) {
- IntegerPatternConverterPtr intPattern(*converterIter);
- if (intPattern != NULL) {
- return *converterIter;
- }
- }
- PatternConverterPtr noMatch;
- return noMatch;
+PatternConverterPtr RollingPolicyBase::getIntegerPatternConverter() const
+{
+ for (std::vector<PatternConverterPtr>::const_iterator
+ converterIter = patternConverters.begin();
+ converterIter != patternConverters.end();
+ converterIter++)
+ {
+ IntegerPatternConverterPtr intPattern(*converterIter);
+
+ if (intPattern != NULL)
+ {
+ return *converterIter;
+ }
+ }
+
+ PatternConverterPtr noMatch;
+ return noMatch;
}
-PatternConverterPtr RollingPolicyBase::getDatePatternConverter() const {
- for(std::vector<PatternConverterPtr>::const_iterator
- converterIter = patternConverters.begin();
- converterIter != patternConverters.end();
- converterIter++) {
- DatePatternConverterPtr datePattern(*converterIter);
- if (datePattern != NULL) {
- return *converterIter;
- }
- }
- PatternConverterPtr noMatch;
- return noMatch;
+PatternConverterPtr RollingPolicyBase::getDatePatternConverter() const
+{
+ for (std::vector<PatternConverterPtr>::const_iterator
+ converterIter = patternConverters.begin();
+ converterIter != patternConverters.end();
+ converterIter++)
+ {
+ DatePatternConverterPtr datePattern(*converterIter);
+
+ if (datePattern != NULL)
+ {
+ return *converterIter;
+ }
+ }
+
+ PatternConverterPtr noMatch;
+ return noMatch;
}
diff --git a/src/main/cpp/rolloverdescription.cpp b/src/main/cpp/rolloverdescription.cpp
index eef7fe5..fbd9242 100644
--- a/src/main/cpp/rolloverdescription.cpp
+++ b/src/main/cpp/rolloverdescription.cpp
@@ -25,7 +25,8 @@
IMPLEMENT_LOG4CXX_OBJECT(RolloverDescription)
-RolloverDescription::RolloverDescription() {
+RolloverDescription::RolloverDescription()
+{
}
RolloverDescription::RolloverDescription(
@@ -33,30 +34,35 @@
const bool append1,
const ActionPtr& synchronous1,
const ActionPtr& asynchronous1)
- : activeFileName(activeFileName1),
- append(append1),
- synchronous(synchronous1),
- asynchronous(asynchronous1) {
+ : activeFileName(activeFileName1),
+ append(append1),
+ synchronous(synchronous1),
+ asynchronous(asynchronous1)
+{
}
-LogString RolloverDescription::getActiveFileName() const {
+LogString RolloverDescription::getActiveFileName() const
+{
return activeFileName;
}
-bool RolloverDescription::getAppend() const {
+bool RolloverDescription::getAppend() const
+{
return append;
}
-ActionPtr RolloverDescription::getSynchronous() const {
+ActionPtr RolloverDescription::getSynchronous() const
+{
return synchronous;
}
- /**
- * Action to be completed after close of current active log file
- * and before next rollover attempt, may be executed asynchronously.
- *
- * @return action, may be null.
- */
-ActionPtr RolloverDescription::getAsynchronous() const {
+/**
+ * Action to be completed after close of current active log file
+ * and before next rollover attempt, may be executed asynchronously.
+ *
+ * @return action, may be null.
+ */
+ActionPtr RolloverDescription::getAsynchronous() const
+{
return asynchronous;
}
diff --git a/src/main/cpp/rootlogger.cpp b/src/main/cpp/rootlogger.cpp
index e08f41b..0d89e50 100644
--- a/src/main/cpp/rootlogger.cpp
+++ b/src/main/cpp/rootlogger.cpp
@@ -27,25 +27,25 @@
RootLogger::RootLogger(Pool& pool, const LevelPtr& level1) :
Logger(pool, LOG4CXX_STR("root"))
{
- setLevel(level1);
+ setLevel(level1);
}
const LevelPtr& RootLogger::getEffectiveLevel() const
{
- return level;
+ return level;
}
void RootLogger::setLevel(const LevelPtr& level1)
{
- if(level1 == 0)
- {
- LogLog::error(LOG4CXX_STR("You have tried to set a null level to root."));
- }
- else
- {
+ if (level1 == 0)
+ {
+ LogLog::error(LOG4CXX_STR("You have tried to set a null level to root."));
+ }
+ else
+ {
- this->level = level1;
- }
+ this->level = level1;
+ }
}
diff --git a/src/main/cpp/serversocket.cpp b/src/main/cpp/serversocket.cpp
index 0669a43..33565b1 100644
--- a/src/main/cpp/serversocket.cpp
+++ b/src/main/cpp/serversocket.cpp
@@ -27,38 +27,48 @@
*/
ServerSocket::ServerSocket(int port) : pool(), mutex(pool), socket(0), timeout(0)
{
- apr_status_t status =
- apr_socket_create(&socket, APR_INET, SOCK_STREAM,
- APR_PROTO_TCP, pool.getAPRPool());
- if (status != APR_SUCCESS) {
- throw SocketException(status);
- }
+ apr_status_t status =
+ apr_socket_create(&socket, APR_INET, SOCK_STREAM,
+ APR_PROTO_TCP, pool.getAPRPool());
- status = apr_socket_opt_set(socket, APR_SO_NONBLOCK, 1);
- if (status != APR_SUCCESS) {
- throw SocketException(status);
- }
+ if (status != APR_SUCCESS)
+ {
+ throw SocketException(status);
+ }
- // Create server socket address (including port number)
- apr_sockaddr_t *server_addr;
- status =
- apr_sockaddr_info_get(&server_addr, NULL, APR_INET,
- port, 0, pool.getAPRPool());
- if (status != APR_SUCCESS) {
- throw ConnectException(status);
- }
+ status = apr_socket_opt_set(socket, APR_SO_NONBLOCK, 1);
- // bind the socket to the address
- status = apr_socket_bind(socket, server_addr);
- if (status != APR_SUCCESS) {
- throw BindException(status);
- }
+ if (status != APR_SUCCESS)
+ {
+ throw SocketException(status);
+ }
+
+ // Create server socket address (including port number)
+ apr_sockaddr_t* server_addr;
+ status =
+ apr_sockaddr_info_get(&server_addr, NULL, APR_INET,
+ port, 0, pool.getAPRPool());
+
+ if (status != APR_SUCCESS)
+ {
+ throw ConnectException(status);
+ }
+
+ // bind the socket to the address
+ status = apr_socket_bind(socket, server_addr);
+
+ if (status != APR_SUCCESS)
+ {
+ throw BindException(status);
+ }
- status = apr_socket_listen(socket, 50);
- if (status != APR_SUCCESS) {
- throw SocketException(status);
- }
+ status = apr_socket_listen(socket, 50);
+
+ if (status != APR_SUCCESS)
+ {
+ throw SocketException(status);
+ }
}
@@ -66,13 +76,19 @@
{
}
-void ServerSocket::close() {
+void ServerSocket::close()
+{
synchronized sync(mutex);
- if (socket != 0) {
+
+ if (socket != 0)
+ {
apr_status_t status = apr_socket_close(socket);
- if (status != APR_SUCCESS) {
+
+ if (status != APR_SUCCESS)
+ {
throw SocketException(status);
}
+
socket = 0;
}
}
@@ -80,9 +96,12 @@
/** Listens for a connection to be made to this socket and
accepts it
*/
-SocketPtr ServerSocket::accept() {
+SocketPtr ServerSocket::accept()
+{
synchronized sync(mutex);
- if (socket == 0) {
+
+ if (socket == 0)
+ {
throw IOException();
}
@@ -98,26 +117,36 @@
apr_interval_time_t to = timeout * 1000;
apr_status_t status = apr_poll(&poll, 1, &signaled, to);
- if (APR_STATUS_IS_TIMEUP(status)) {
+ if (APR_STATUS_IS_TIMEUP(status))
+ {
throw SocketTimeoutException();
- } else if (status != APR_SUCCESS) {
+ }
+ else if (status != APR_SUCCESS)
+ {
throw SocketException(status);
}
apr_pool_t* newPool;
status = apr_pool_create(&newPool, 0);
- if (status != APR_SUCCESS) {
+
+ if (status != APR_SUCCESS)
+ {
throw PoolException(status);
}
+
apr_socket_t* newSocket;
status = apr_socket_accept(&newSocket, socket, newPool);
- if (status != APR_SUCCESS) {
+
+ if (status != APR_SUCCESS)
+ {
apr_pool_destroy(newPool);
throw SocketException(status);
}
status = apr_socket_opt_set(newSocket, APR_SO_NONBLOCK, 0);
- if (status != APR_SUCCESS) {
+
+ if (status != APR_SUCCESS)
+ {
apr_pool_destroy(newPool);
throw SocketException(status);
}
@@ -129,12 +158,12 @@
*/
int ServerSocket::getSoTimeout() const
{
- return timeout;
+ return timeout;
}
/** Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
*/
void ServerSocket::setSoTimeout(int newVal)
{
- timeout = newVal;
+ timeout = newVal;
}
diff --git a/src/main/cpp/simpledateformat.cpp b/src/main/cpp/simpledateformat.cpp
index 3ddb05c..6c51d78 100644
--- a/src/main/cpp/simpledateformat.cpp
+++ b/src/main/cpp/simpledateformat.cpp
@@ -24,7 +24,7 @@
#include <log4cxx/helpers/stringhelper.h>
#include <assert.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
#include <log4cxx/helpers/pool.h>
@@ -35,363 +35,391 @@
using namespace std;
#if LOG4CXX_HAS_STD_LOCALE
-#include <locale>
+ #include <locale>
#endif
#if defined(_MSC_VER) && _MSC_VER < 1300
-#define HAS_FACET(locale, type) _HAS(locale, type)
-#define USE_FACET(locale, type) _USE(locale, type)
-#define PUT_FACET(facet, os, time, spec) facet.put(os, os, time, spec)
+ #define HAS_FACET(locale, type) _HAS(locale, type)
+ #define USE_FACET(locale, type) _USE(locale, type)
+ #define PUT_FACET(facet, os, time, spec) facet.put(os, os, time, spec)
#else
-#if defined(_RWSTD_NO_TEMPLATE_ON_RETURN_TYPE)
-#define HAS_FACET(locale, type) std::has_facet(locale, (type*) 0)
-#define USE_FACET(locale, type) std::use_facet(locale, (type*) 0)
-#else
-#define HAS_FACET(locale, type) std::has_facet < type >(locale)
-#define USE_FACET(locale, type) std::use_facet < type >(locale)
-#endif
-#define PUT_FACET(facet, os, time, spec) facet.put(os, os, os.fill(), time, spec)
+ #if defined(_RWSTD_NO_TEMPLATE_ON_RETURN_TYPE)
+ #define HAS_FACET(locale, type) std::has_facet(locale, (type*) 0)
+ #define USE_FACET(locale, type) std::use_facet(locale, (type*) 0)
+ #else
+ #define HAS_FACET(locale, type) std::has_facet < type >(locale)
+ #define USE_FACET(locale, type) std::use_facet < type >(locale)
+ #endif
+ #define PUT_FACET(facet, os, time, spec) facet.put(os, os, os.fill(), time, spec)
#endif
namespace log4cxx
{
- namespace helpers
- {
- namespace SimpleDateFormatImpl
- {
- typedef void (*incrementFunction)(tm& time, apr_time_exp_t& apr_time);
+namespace helpers
+{
+namespace SimpleDateFormatImpl
+{
+typedef void (*incrementFunction)(tm& time, apr_time_exp_t& apr_time);
- /**
- * Abstract inner class representing one format token
- * (one or more instances of a character).
- */
- class PatternToken {
+/**
+ * Abstract inner class representing one format token
+ * (one or more instances of a character).
+ */
+class PatternToken
+{
public:
- PatternToken() {
- }
+ PatternToken()
+ {
+ }
- virtual ~PatternToken() {
- }
+ virtual ~PatternToken()
+ {
+ }
- /**
- * Sets the time zone.
- * @param zone new time zone.
- */
- virtual void setTimeZone(const TimeZonePtr& zone) {
- }
+ /**
+ * Sets the time zone.
+ * @param zone new time zone.
+ */
+ virtual void setTimeZone(const TimeZonePtr& zone)
+ {
+ }
- /**
- * Appends the formatted content to the string.
- * @param s string to which format contribution is appended.
- * @param date exploded date/time.
- * @param p memory pool.
- */
- virtual void format(LogString& s,
- const apr_time_exp_t& date,
- log4cxx::helpers::Pool& p) const = 0;
+ /**
+ * Appends the formatted content to the string.
+ * @param s string to which format contribution is appended.
+ * @param date exploded date/time.
+ * @param p memory pool.
+ */
+ virtual void format(LogString& s,
+ const apr_time_exp_t& date,
+ log4cxx::helpers::Pool& p) const = 0;
protected:
- static void incrementMonth(tm& time, apr_time_exp_t& aprtime) {
- time.tm_mon++;
- aprtime.tm_mon++;
- }
+ static void incrementMonth(tm& time, apr_time_exp_t& aprtime)
+ {
+ time.tm_mon++;
+ aprtime.tm_mon++;
+ }
- static void incrementDay(tm& time, apr_time_exp_t& aprtime) {
- time.tm_wday++;
- aprtime.tm_wday++;
- }
+ static void incrementDay(tm& time, apr_time_exp_t& aprtime)
+ {
+ time.tm_wday++;
+ aprtime.tm_wday++;
+ }
- static void incrementHalfDay(tm& time, apr_time_exp_t& aprtime) {
- time.tm_hour += 12;
- aprtime.tm_hour += 12;
- }
+ static void incrementHalfDay(tm& time, apr_time_exp_t& aprtime)
+ {
+ time.tm_hour += 12;
+ aprtime.tm_hour += 12;
+ }
- static void renderFacet(const std::locale* locale,
- incrementFunction inc,
- char spec,
- unsigned int wspec,
- const char* aprspec,
- std::vector<LogString>& values) {
- std::vector<LogString>::iterator valueIter = values.begin();
- tm time;
- memset(&time, 0, sizeof(time));
- apr_time_exp_t aprtime;
- memset(&aprtime, 0, sizeof(aprtime));
+ static void renderFacet(const std::locale* locale,
+ incrementFunction inc,
+ char spec,
+ unsigned int wspec,
+ const char* aprspec,
+ std::vector<LogString>& values)
+ {
+ std::vector<LogString>::iterator valueIter = values.begin();
+ tm time;
+ memset(&time, 0, sizeof(time));
+ apr_time_exp_t aprtime;
+ memset(&aprtime, 0, sizeof(aprtime));
#if LOG4CXX_HAS_STD_LOCALE
- if (locale != NULL) {
+
+ if (locale != NULL)
+ {
#if LOG4CXX_WCHAR_T_API
- if (HAS_FACET(*locale, std::time_put<wchar_t>)) {
- const std::time_put<wchar_t>& facet = USE_FACET(*locale, std::time_put<wchar_t>);
- size_t start = 0;
- std::basic_ostringstream<wchar_t> os;
- for(; valueIter != values.end(); valueIter++) {
- PUT_FACET(facet, os, &time, (wchar_t) wspec);
- Transcoder::decode(os.str().substr(start), *valueIter);
- start = os.str().length();
- (*inc)(time, aprtime);
- }
- } else
+
+ if (HAS_FACET(*locale, std::time_put<wchar_t>))
+ {
+ const std::time_put<wchar_t>& facet = USE_FACET(*locale, std::time_put<wchar_t>);
+ size_t start = 0;
+ std::basic_ostringstream<wchar_t> os;
+
+ for (; valueIter != values.end(); valueIter++)
+ {
+ PUT_FACET(facet, os, &time, (wchar_t) wspec);
+ Transcoder::decode(os.str().substr(start), *valueIter);
+ start = os.str().length();
+ (*inc)(time, aprtime);
+ }
+ }
+ else
#endif
- if (HAS_FACET(*locale, std::time_put<char>)) {
+ if (HAS_FACET(*locale, std::time_put<char>))
+ {
const std::time_put<char>& facet = USE_FACET(*locale, std::time_put<char> );
size_t start = 0;
std::ostringstream os;
- for(; valueIter != values.end(); valueIter++) {
+
+ for (; valueIter != values.end(); valueIter++)
+ {
PUT_FACET(facet, os, &time, spec);
Transcoder::decode(os.str().substr(start), *valueIter);
start = os.str().length();
(*inc)(time, aprtime);
}
}
- }
-#endif
- const size_t BUFSIZE = 256;
- char buf[BUFSIZE];
- memset(buf, 0, BUFSIZE);
- apr_size_t retsize = 0;
- for(; valueIter != values.end(); valueIter++) {
- apr_status_t stat = apr_strftime(buf, &retsize, BUFSIZE, aprspec, &aprtime);
- (*inc)(time, aprtime);
- if (stat == APR_SUCCESS) {
- Transcoder::decode(std::string(buf, retsize), *valueIter);
- } else {
- valueIter->append(1, (logchar) 0x3F);
- }
- }
}
- private:
- /**
- * Private copy constructor.
- */
- PatternToken(const PatternToken&);
+#endif
+ const size_t BUFSIZE = 256;
+ char buf[BUFSIZE];
+ memset(buf, 0, BUFSIZE);
+ apr_size_t retsize = 0;
- /**
- * Private assignment operator.
- */
- PatternToken& operator=(const PatternToken&);
- };
+ for (; valueIter != values.end(); valueIter++)
+ {
+ apr_status_t stat = apr_strftime(buf, &retsize, BUFSIZE, aprspec, &aprtime);
+ (*inc)(time, aprtime);
+
+ if (stat == APR_SUCCESS)
+ {
+ Transcoder::decode(std::string(buf, retsize), *valueIter);
+ }
+ else
+ {
+ valueIter->append(1, (logchar) 0x3F);
+ }
+ }
+ }
+
+ private:
+ /**
+ * Private copy constructor.
+ */
+ PatternToken(const PatternToken&);
+
+ /**
+ * Private assignment operator.
+ */
+ PatternToken& operator=(const PatternToken&);
+};
class LiteralToken : public PatternToken
{
-public:
- LiteralToken( logchar ch1, int count1 ) : ch( ch1 ), count( count1 )
- {
- }
+ public:
+ LiteralToken( logchar ch1, int count1 ) : ch( ch1 ), count( count1 )
+ {
+ }
- void format( LogString& s, const apr_time_exp_t & , Pool & /* p */ ) const
- {
- s.append( count, ch );
- }
+ void format( LogString& s, const apr_time_exp_t&, Pool& /* p */ ) const
+ {
+ s.append( count, ch );
+ }
-private:
- logchar ch;
- int count;
+ private:
+ logchar ch;
+ int count;
};
class EraToken : public PatternToken
{
-public:
- EraToken( int /* count */ , const std::locale * /* locale */ )
- {
- }
+ public:
+ EraToken( int /* count */, const std::locale* /* locale */ )
+ {
+ }
- void format(LogString& s, const apr_time_exp_t & /* tm */, Pool & /* p */ ) const
- {
- s.append(1, (logchar) 0x41 /* 'A' */);
- s.append(1, (logchar) 0x44 /* 'D' */);
- }
+ void format(LogString& s, const apr_time_exp_t& /* tm */, Pool& /* p */ ) const
+ {
+ s.append(1, (logchar) 0x41 /* 'A' */);
+ s.append(1, (logchar) 0x44 /* 'D' */);
+ }
};
class NumericToken : public PatternToken
{
-public:
- NumericToken( size_t width1 ) : width( width1 )
- {
- }
+ public:
+ NumericToken( size_t width1 ) : width( width1 )
+ {
+ }
- virtual int getField( const apr_time_exp_t & tm ) const = 0;
+ virtual int getField( const apr_time_exp_t& tm ) const = 0;
- void format( LogString& s, const apr_time_exp_t & tm, Pool & p ) const
- {
- size_t initialLength = s.length();
+ void format( LogString& s, const apr_time_exp_t& tm, Pool& p ) const
+ {
+ size_t initialLength = s.length();
- StringHelper::toString( getField( tm ), p, s );
- size_t finalLength = s.length();
- if ( initialLength + width > finalLength )
- {
- s.insert( initialLength, ( initialLength + width ) - finalLength, (logchar) 0x30 /* '0' */);
- }
- }
+ StringHelper::toString( getField( tm ), p, s );
+ size_t finalLength = s.length();
-private:
- size_t width;
+ if ( initialLength + width > finalLength )
+ {
+ s.insert( initialLength, ( initialLength + width ) - finalLength, (logchar) 0x30 /* '0' */);
+ }
+ }
+
+ private:
+ size_t width;
};
class YearToken : public NumericToken
{
-public:
- YearToken( int width1 ) : NumericToken( width1 )
- {
- }
+ public:
+ YearToken( int width1 ) : NumericToken( width1 )
+ {
+ }
- int getField( const apr_time_exp_t & tm ) const
- {
- return 1900 + tm.tm_year;
- }
+ int getField( const apr_time_exp_t& tm ) const
+ {
+ return 1900 + tm.tm_year;
+ }
};
class MonthToken : public NumericToken
{
-public:
- MonthToken( int width1 ) : NumericToken( width1 )
- {
- }
+ public:
+ MonthToken( int width1 ) : NumericToken( width1 )
+ {
+ }
- int getField( const apr_time_exp_t & tm ) const
- {
- return tm.tm_mon + 1;
- }
+ int getField( const apr_time_exp_t& tm ) const
+ {
+ return tm.tm_mon + 1;
+ }
};
class AbbreviatedMonthNameToken : public PatternToken
{
-public:
- AbbreviatedMonthNameToken(int, const std::locale *locale) : names( 12 ) {
- renderFacet(locale, PatternToken::incrementMonth, 'b', 0x62, "%b", names);
- }
+ public:
+ AbbreviatedMonthNameToken(int, const std::locale* locale) : names( 12 )
+ {
+ renderFacet(locale, PatternToken::incrementMonth, 'b', 0x62, "%b", names);
+ }
- void format(LogString& s, const apr_time_exp_t & tm, Pool & /* p */ ) const
- {
- s.append( names[tm.tm_mon] );
- }
+ void format(LogString& s, const apr_time_exp_t& tm, Pool& /* p */ ) const
+ {
+ s.append( names[tm.tm_mon] );
+ }
-private:
- std::vector < LogString > names;
+ private:
+ std::vector < LogString > names;
};
class FullMonthNameToken : public PatternToken
{
-public:
- FullMonthNameToken( int width, const std::locale *locale) : names( 12 )
- {
- renderFacet(locale, PatternToken::incrementMonth, 'B', 0x42, "%B", names);
- }
+ public:
+ FullMonthNameToken( int width, const std::locale* locale) : names( 12 )
+ {
+ renderFacet(locale, PatternToken::incrementMonth, 'B', 0x42, "%B", names);
+ }
- void format( LogString& s, const apr_time_exp_t & tm, Pool & /* p */ ) const
- {
- s.append( names[tm.tm_mon] );
- }
+ void format( LogString& s, const apr_time_exp_t& tm, Pool& /* p */ ) const
+ {
+ s.append( names[tm.tm_mon] );
+ }
-private:
- std::vector < LogString > names;
+ private:
+ std::vector < LogString > names;
};
class WeekInYearToken : public NumericToken
{
-public:
- WeekInYearToken( int width1 ) : NumericToken( width1 )
- {
- }
+ public:
+ WeekInYearToken( int width1 ) : NumericToken( width1 )
+ {
+ }
- int getField( const apr_time_exp_t & tm ) const
- {
- return tm.tm_yday / 7;
- }
+ int getField( const apr_time_exp_t& tm ) const
+ {
+ return tm.tm_yday / 7;
+ }
};
class WeekInMonthToken : public NumericToken
{
-public:
- WeekInMonthToken( int width1 ) : NumericToken( width1 )
- {
- }
+ public:
+ WeekInMonthToken( int width1 ) : NumericToken( width1 )
+ {
+ }
- int getField( const apr_time_exp_t & tm ) const
- {
- return tm.tm_mday / 7;
- }
+ int getField( const apr_time_exp_t& tm ) const
+ {
+ return tm.tm_mday / 7;
+ }
};
class DayInMonthToken : public NumericToken
{
-public:
- DayInMonthToken( int width1 ) : NumericToken( width1 )
- {
- }
+ public:
+ DayInMonthToken( int width1 ) : NumericToken( width1 )
+ {
+ }
- int getField( const apr_time_exp_t & tm ) const
- {
- return tm.tm_mday;
- }
+ int getField( const apr_time_exp_t& tm ) const
+ {
+ return tm.tm_mday;
+ }
};
class DayInYearToken : public NumericToken
{
-public:
- DayInYearToken( int width1 ) : NumericToken( width1 )
- {
- }
+ public:
+ DayInYearToken( int width1 ) : NumericToken( width1 )
+ {
+ }
- int getField( const apr_time_exp_t & tm ) const
- {
- return tm.tm_yday;
- }
+ int getField( const apr_time_exp_t& tm ) const
+ {
+ return tm.tm_yday;
+ }
};
class DayOfWeekInMonthToken : public NumericToken
{
-public:
- DayOfWeekInMonthToken( int width1 ) : NumericToken( width1 )
- {
- }
+ public:
+ DayOfWeekInMonthToken( int width1 ) : NumericToken( width1 )
+ {
+ }
- int getField( const apr_time_exp_t & /* tm */ ) const
- {
- return -1;
- }
+ int getField( const apr_time_exp_t& /* tm */ ) const
+ {
+ return -1;
+ }
};
class AbbreviatedDayNameToken : public PatternToken
{
-public:
- AbbreviatedDayNameToken( int width, const std::locale *locale) : names( 7 ) {
- renderFacet(locale, PatternToken::incrementDay, 'a', 0x61, "%a", names);
- }
+ public:
+ AbbreviatedDayNameToken( int width, const std::locale* locale) : names( 7 )
+ {
+ renderFacet(locale, PatternToken::incrementDay, 'a', 0x61, "%a", names);
+ }
- void format( LogString& s, const apr_time_exp_t & tm, Pool & /* p */ ) const
- {
- s.append( names[tm.tm_wday] );
- }
+ void format( LogString& s, const apr_time_exp_t& tm, Pool& /* p */ ) const
+ {
+ s.append( names[tm.tm_wday] );
+ }
-private:
- std::vector < LogString > names;
+ private:
+ std::vector < LogString > names;
};
@@ -399,18 +427,19 @@
class FullDayNameToken : public PatternToken
{
-public:
- FullDayNameToken( int width, const std::locale *locale) : names( 7 ) {
- renderFacet(locale, PatternToken::incrementDay, 'A', 0x41, "%A", names);
- }
+ public:
+ FullDayNameToken( int width, const std::locale* locale) : names( 7 )
+ {
+ renderFacet(locale, PatternToken::incrementDay, 'A', 0x41, "%A", names);
+ }
- void format( LogString& s, const apr_time_exp_t & tm, Pool & /* p */ ) const
- {
- s.append( names[tm.tm_wday] );
- }
+ void format( LogString& s, const apr_time_exp_t& tm, Pool& /* p */ ) const
+ {
+ s.append( names[tm.tm_wday] );
+ }
-private:
- std::vector < LogString > names;
+ private:
+ std::vector < LogString > names;
};
@@ -418,388 +447,405 @@
class MilitaryHourToken : public NumericToken
{
-public:
- MilitaryHourToken( int width1, int offset1 ) : NumericToken( width1 ), offset( offset1 )
- {
- }
+ public:
+ MilitaryHourToken( int width1, int offset1 ) : NumericToken( width1 ), offset( offset1 )
+ {
+ }
- int getField( const apr_time_exp_t & tm ) const
- {
- return tm.tm_hour + offset;
- }
+ int getField( const apr_time_exp_t& tm ) const
+ {
+ return tm.tm_hour + offset;
+ }
-private:
- int offset;
+ private:
+ int offset;
};
class HourToken : public NumericToken
{
-public:
- HourToken( int width1, int /* offset1 */ ) : NumericToken( width1 ), offset( 0 )
- {
- }
+ public:
+ HourToken( int width1, int /* offset1 */ ) : NumericToken( width1 ), offset( 0 )
+ {
+ }
- int getField( const apr_time_exp_t & tm ) const
- {
- return ( ( tm.tm_hour + 12 - offset ) % 12 ) + offset;
- }
+ int getField( const apr_time_exp_t& tm ) const
+ {
+ return ( ( tm.tm_hour + 12 - offset ) % 12 ) + offset;
+ }
-private:
- int offset;
+ private:
+ int offset;
};
class MinuteToken : public NumericToken
{
-public:
- MinuteToken( int width1 ) : NumericToken( width1 )
- {
- }
+ public:
+ MinuteToken( int width1 ) : NumericToken( width1 )
+ {
+ }
- int getField( const apr_time_exp_t & tm ) const
- {
- return tm.tm_min;
- }
+ int getField( const apr_time_exp_t& tm ) const
+ {
+ return tm.tm_min;
+ }
};
class SecondToken : public NumericToken
{
-public:
- SecondToken( int width1 ) : NumericToken( width1 )
- {
- }
+ public:
+ SecondToken( int width1 ) : NumericToken( width1 )
+ {
+ }
- int getField( const apr_time_exp_t & tm ) const
- {
- return tm.tm_sec;
- }
+ int getField( const apr_time_exp_t& tm ) const
+ {
+ return tm.tm_sec;
+ }
};
class MillisecondToken : public NumericToken
{
-public:
- MillisecondToken( int width1 ) : NumericToken( width1 )
- {
- }
+ public:
+ MillisecondToken( int width1 ) : NumericToken( width1 )
+ {
+ }
- int getField( const apr_time_exp_t & tm ) const
- {
- return tm.tm_usec / 1000;
- }
+ int getField( const apr_time_exp_t& tm ) const
+ {
+ return tm.tm_usec / 1000;
+ }
};
class MicrosecondToken : public NumericToken
{
-public:
- MicrosecondToken( int width1 ) : NumericToken( width1 )
- {
- }
+ public:
+ MicrosecondToken( int width1 ) : NumericToken( width1 )
+ {
+ }
- int getField( const apr_time_exp_t & tm ) const
- {
- return tm.tm_usec;
- }
+ int getField( const apr_time_exp_t& tm ) const
+ {
+ return tm.tm_usec;
+ }
};
class AMPMToken : public PatternToken
{
-public:
- AMPMToken( int width, const std::locale *locale) : names( 2 ) {
- renderFacet(locale, PatternToken::incrementHalfDay, 'p', 0x70, "%p", names);
- }
+ public:
+ AMPMToken( int width, const std::locale* locale) : names( 2 )
+ {
+ renderFacet(locale, PatternToken::incrementHalfDay, 'p', 0x70, "%p", names);
+ }
- void format( LogString& s, const apr_time_exp_t & tm, Pool & /* p */ ) const
- {
- s.append( names[tm.tm_hour / 12] );
- }
+ void format( LogString& s, const apr_time_exp_t& tm, Pool& /* p */ ) const
+ {
+ s.append( names[tm.tm_hour / 12] );
+ }
-private:
- std::vector < LogString > names;
+ private:
+ std::vector < LogString > names;
};
class GeneralTimeZoneToken : public PatternToken
{
-public:
- GeneralTimeZoneToken( int /* width */ )
- {
- }
+ public:
+ GeneralTimeZoneToken( int /* width */ )
+ {
+ }
- void format( LogString& s, const apr_time_exp_t & , Pool & /* p */ ) const {
- s.append(timeZone->getID());
- }
+ void format( LogString& s, const apr_time_exp_t&, Pool& /* p */ ) const
+ {
+ s.append(timeZone->getID());
+ }
- void setTimeZone( const TimeZonePtr & zone )
- {
- timeZone = zone;
- }
+ void setTimeZone( const TimeZonePtr& zone )
+ {
+ timeZone = zone;
+ }
-private:
- TimeZonePtr timeZone;
+ private:
+ TimeZonePtr timeZone;
};
class RFC822TimeZoneToken : public PatternToken
{
-public:
- RFC822TimeZoneToken( int /* width */ )
- {
- }
+ public:
+ RFC822TimeZoneToken( int /* width */ )
+ {
+ }
- void format( LogString& s, const apr_time_exp_t & tm, Pool & p ) const
- {
- if ( tm.tm_gmtoff == 0 )
- {
- s.append( 1, (logchar) 0x5A /* 'Z' */ );
- }
- else
- {
- apr_int32_t off = tm.tm_gmtoff;
- size_t basePos = s.length();
- s.append( LOG4CXX_STR( "+0000" ) );
- if ( off < 0 )
- {
- s[basePos] = 0x2D; // '-'
- off = -off;
- }
- LogString hours;
- StringHelper::toString( off / 3600, p, hours );
- size_t hourPos = basePos + 2;
- //
- // assumes that point values for 0-9 are same between char and wchar_t
- //
- for ( size_t i = hours.length(); i-- > 0; )
- {
- s[hourPos--] = hours[i];
- }
- LogString min;
- StringHelper::toString( ( off % 3600 ) / 60, p, min );
- size_t minPos = basePos + 4;
- //
- // assumes that point values for 0-9 are same between char and wchar_t
- //
- for ( size_t j = min.length(); j-- > 0; )
- {
- s[minPos--] = min[j];
- }
- }
- }
+ void format( LogString& s, const apr_time_exp_t& tm, Pool& p ) const
+ {
+ if ( tm.tm_gmtoff == 0 )
+ {
+ s.append( 1, (logchar) 0x5A /* 'Z' */ );
+ }
+ else
+ {
+ apr_int32_t off = tm.tm_gmtoff;
+ size_t basePos = s.length();
+ s.append( LOG4CXX_STR( "+0000" ) );
+
+ if ( off < 0 )
+ {
+ s[basePos] = 0x2D; // '-'
+ off = -off;
+ }
+
+ LogString hours;
+ StringHelper::toString( off / 3600, p, hours );
+ size_t hourPos = basePos + 2;
+
+ //
+ // assumes that point values for 0-9 are same between char and wchar_t
+ //
+ for ( size_t i = hours.length(); i-- > 0; )
+ {
+ s[hourPos--] = hours[i];
+ }
+
+ LogString min;
+ StringHelper::toString( ( off % 3600 ) / 60, p, min );
+ size_t minPos = basePos + 4;
+
+ //
+ // assumes that point values for 0-9 are same between char and wchar_t
+ //
+ for ( size_t j = min.length(); j-- > 0; )
+ {
+ s[minPos--] = min[j];
+ }
+ }
+ }
};
- }
+}
}
}
using namespace log4cxx::helpers::SimpleDateFormatImpl;
-void SimpleDateFormat::addToken(const logchar spec, const int repeat, const std::locale * locale,
- std::vector < PatternToken * > & pattern )
- {
- PatternToken * token = NULL;
- switch ( spec )
- {
- case 0x47: // 'G'
- token = ( new EraToken( repeat, locale ) );
- break;
-
- case 0x79: // 'y'
- token = ( new YearToken( repeat ) );
- break;
-
- case 0x4D: // 'M'
- if ( repeat <= 2 )
- {
- token = ( new MonthToken( repeat ) );
- }
- else if ( repeat <= 3 )
- {
- token = ( new AbbreviatedMonthNameToken( repeat, locale ) );
- }
- else
- {
- token = ( new FullMonthNameToken( repeat, locale ) );
- }
- break;
-
- case 0x77: // 'w'
- token = ( new WeekInYearToken( repeat ) );
- break;
-
- case 0x57: // 'W'
- token = ( new WeekInMonthToken( repeat ) );
- break;
-
- case 0x44: // 'D'
- token = ( new DayInYearToken( repeat ) );
- break;
-
- case 0x64: // 'd'
- token = ( new DayInMonthToken( repeat ) );
- break;
-
- case 0x46: // 'F'
- token = ( new DayOfWeekInMonthToken( repeat ) );
- break;
-
- case 0x45: // 'E'
- if ( repeat <= 3 )
- {
- token = ( new AbbreviatedDayNameToken( repeat, locale ) );
- }
- else
- {
- token = ( new FullDayNameToken( repeat, locale ) );
- }
- break;
-
- case 0x61: // 'a'
- token = ( new AMPMToken( repeat, locale ) );
- break;
-
- case 0x48: // 'H'
- token = ( new MilitaryHourToken( repeat, 0 ) );
- break;
-
- case 0x6B: // 'k'
- token = ( new MilitaryHourToken( repeat, 1 ) );
- break;
-
- case 0x4B: // 'K'
- token = ( new HourToken( repeat, 0 ) );
- break;
-
- case 0x68: // 'h'
- token = ( new HourToken( repeat, 1 ) );
- break;
-
- case 0x6D: // 'm'
- token = ( new MinuteToken( repeat ) );
- break;
-
- case 0x73: // 's'
- token = ( new SecondToken( repeat ) );
- break;
-
- case 0x53: // 'S'
- if ( repeat == 6 )
- {
- token = ( new MicrosecondToken( repeat ) );
- }
- else
- {
- // It would be nice to support patterns with arbitrary
- // subsecond precision (like "s.S" or "s.SSSS"), but we
- // don't; so this is a back-compatible default.
- token = ( new MillisecondToken( repeat ) );
- }
- break;
-
- case 0x7A: // 'z'
- token = ( new GeneralTimeZoneToken( repeat ) );
- break;
-
- case 0x5A: // 'Z'
- token = ( new RFC822TimeZoneToken( repeat ) );
- break;
-
- default:
- token = ( new LiteralToken( spec, repeat ) );
- }
- assert( token != NULL );
- pattern.push_back( token );
-}
-
-
-void SimpleDateFormat::parsePattern( const LogString & fmt, const std::locale * locale,
- std::vector < PatternToken * > & pattern )
+void SimpleDateFormat::addToken(const logchar spec, const int repeat, const std::locale* locale,
+ std::vector < PatternToken* >& pattern )
{
- if ( !fmt.empty() )
- {
- LogString::const_iterator iter = fmt.begin();
- int repeat = 1;
- logchar prevChar = * iter;
- for ( iter++; iter != fmt.end(); iter++ )
- {
- if ( * iter == prevChar )
- {
- repeat++;
- }
- else
- {
- addToken( prevChar, repeat, locale, pattern );
- prevChar = * iter;
- repeat = 1;
- }
- }
- addToken( prevChar, repeat, locale, pattern );
- }
+ PatternToken* token = NULL;
+
+ switch ( spec )
+ {
+ case 0x47: // 'G'
+ token = ( new EraToken( repeat, locale ) );
+ break;
+
+ case 0x79: // 'y'
+ token = ( new YearToken( repeat ) );
+ break;
+
+ case 0x4D: // 'M'
+ if ( repeat <= 2 )
+ {
+ token = ( new MonthToken( repeat ) );
+ }
+ else if ( repeat <= 3 )
+ {
+ token = ( new AbbreviatedMonthNameToken( repeat, locale ) );
+ }
+ else
+ {
+ token = ( new FullMonthNameToken( repeat, locale ) );
+ }
+
+ break;
+
+ case 0x77: // 'w'
+ token = ( new WeekInYearToken( repeat ) );
+ break;
+
+ case 0x57: // 'W'
+ token = ( new WeekInMonthToken( repeat ) );
+ break;
+
+ case 0x44: // 'D'
+ token = ( new DayInYearToken( repeat ) );
+ break;
+
+ case 0x64: // 'd'
+ token = ( new DayInMonthToken( repeat ) );
+ break;
+
+ case 0x46: // 'F'
+ token = ( new DayOfWeekInMonthToken( repeat ) );
+ break;
+
+ case 0x45: // 'E'
+ if ( repeat <= 3 )
+ {
+ token = ( new AbbreviatedDayNameToken( repeat, locale ) );
+ }
+ else
+ {
+ token = ( new FullDayNameToken( repeat, locale ) );
+ }
+
+ break;
+
+ case 0x61: // 'a'
+ token = ( new AMPMToken( repeat, locale ) );
+ break;
+
+ case 0x48: // 'H'
+ token = ( new MilitaryHourToken( repeat, 0 ) );
+ break;
+
+ case 0x6B: // 'k'
+ token = ( new MilitaryHourToken( repeat, 1 ) );
+ break;
+
+ case 0x4B: // 'K'
+ token = ( new HourToken( repeat, 0 ) );
+ break;
+
+ case 0x68: // 'h'
+ token = ( new HourToken( repeat, 1 ) );
+ break;
+
+ case 0x6D: // 'm'
+ token = ( new MinuteToken( repeat ) );
+ break;
+
+ case 0x73: // 's'
+ token = ( new SecondToken( repeat ) );
+ break;
+
+ case 0x53: // 'S'
+ if ( repeat == 6 )
+ {
+ token = ( new MicrosecondToken( repeat ) );
+ }
+ else
+ {
+ // It would be nice to support patterns with arbitrary
+ // subsecond precision (like "s.S" or "s.SSSS"), but we
+ // don't; so this is a back-compatible default.
+ token = ( new MillisecondToken( repeat ) );
+ }
+
+ break;
+
+ case 0x7A: // 'z'
+ token = ( new GeneralTimeZoneToken( repeat ) );
+ break;
+
+ case 0x5A: // 'Z'
+ token = ( new RFC822TimeZoneToken( repeat ) );
+ break;
+
+ default:
+ token = ( new LiteralToken( spec, repeat ) );
+ }
+
+ assert( token != NULL );
+ pattern.push_back( token );
}
-SimpleDateFormat::SimpleDateFormat( const LogString & fmt ) : timeZone( TimeZone::getDefault() )
+void SimpleDateFormat::parsePattern( const LogString& fmt, const std::locale* locale,
+ std::vector < PatternToken* >& pattern )
+{
+ if ( !fmt.empty() )
+ {
+ LogString::const_iterator iter = fmt.begin();
+ int repeat = 1;
+ logchar prevChar = * iter;
+
+ for ( iter++; iter != fmt.end(); iter++ )
+ {
+ if ( * iter == prevChar )
+ {
+ repeat++;
+ }
+ else
+ {
+ addToken( prevChar, repeat, locale, pattern );
+ prevChar = * iter;
+ repeat = 1;
+ }
+ }
+
+ addToken( prevChar, repeat, locale, pattern );
+ }
+}
+
+
+SimpleDateFormat::SimpleDateFormat( const LogString& fmt ) : timeZone( TimeZone::getDefault() )
{
#if LOG4CXX_HAS_STD_LOCALE
- std::locale defaultLocale;
- parsePattern( fmt, & defaultLocale, pattern );
+ std::locale defaultLocale;
+ parsePattern( fmt, & defaultLocale, pattern );
#else
- parsePattern( fmt, NULL, pattern );
+ parsePattern( fmt, NULL, pattern );
#endif
- for ( PatternTokenList::iterator iter = pattern.begin(); iter != pattern.end(); iter++ )
- {
- ( * iter )->setTimeZone( timeZone );
- }
+
+ for ( PatternTokenList::iterator iter = pattern.begin(); iter != pattern.end(); iter++ )
+ {
+ ( * iter )->setTimeZone( timeZone );
+ }
}
-SimpleDateFormat::SimpleDateFormat( const LogString & fmt, const std::locale * locale ) : timeZone( TimeZone::getDefault() )
+SimpleDateFormat::SimpleDateFormat( const LogString& fmt, const std::locale* locale ) : timeZone( TimeZone::getDefault() )
{
- parsePattern( fmt, locale, pattern );
- for ( PatternTokenList::iterator iter = pattern.begin(); iter != pattern.end(); iter++ )
- {
- ( * iter )->setTimeZone( timeZone );
- }
+ parsePattern( fmt, locale, pattern );
+
+ for ( PatternTokenList::iterator iter = pattern.begin(); iter != pattern.end(); iter++ )
+ {
+ ( * iter )->setTimeZone( timeZone );
+ }
}
SimpleDateFormat::~SimpleDateFormat()
{
- for ( PatternTokenList::iterator iter = pattern.begin(); iter != pattern.end(); iter++ )
- {
- delete * iter;
- }
-}
-
-
-void SimpleDateFormat::format( LogString & s, log4cxx_time_t time, Pool & p ) const
-{
- apr_time_exp_t exploded;
- apr_status_t stat = timeZone->explode( & exploded, time );
- if ( stat == APR_SUCCESS )
- {
- for ( PatternTokenList::const_iterator iter = pattern.begin(); iter != pattern.end(); iter++ )
+ for ( PatternTokenList::iterator iter = pattern.begin(); iter != pattern.end(); iter++ )
{
- ( * iter )->format( s, exploded, p );
+ delete * iter;
}
- }
}
-void SimpleDateFormat::setTimeZone( const TimeZonePtr & zone )
+
+void SimpleDateFormat::format( LogString& s, log4cxx_time_t time, Pool& p ) const
{
- timeZone = zone;
+ apr_time_exp_t exploded;
+ apr_status_t stat = timeZone->explode( & exploded, time );
+
+ if ( stat == APR_SUCCESS )
+ {
+ for ( PatternTokenList::const_iterator iter = pattern.begin(); iter != pattern.end(); iter++ )
+ {
+ ( * iter )->format( s, exploded, p );
+ }
+ }
+}
+
+void SimpleDateFormat::setTimeZone( const TimeZonePtr& zone )
+{
+ timeZone = zone;
}
diff --git a/src/main/cpp/simplelayout.cpp b/src/main/cpp/simplelayout.cpp
index 6addedf..2134d9e 100644
--- a/src/main/cpp/simplelayout.cpp
+++ b/src/main/cpp/simplelayout.cpp
@@ -27,11 +27,11 @@
void SimpleLayout::format(LogString& output,
- const spi::LoggingEventPtr& event,
- log4cxx::helpers::Pool&) const
+ const spi::LoggingEventPtr& event,
+ log4cxx::helpers::Pool&) const
{
- output.append(event->getLevel()->toString());
- output.append(LOG4CXX_STR(" - "));
- output.append(event->getRenderedMessage());
- output.append(LOG4CXX_EOL);
+ output.append(event->getLevel()->toString());
+ output.append(LOG4CXX_STR(" - "));
+ output.append(event->getRenderedMessage());
+ output.append(LOG4CXX_EOL);
}
diff --git a/src/main/cpp/sizebasedtriggeringpolicy.cpp b/src/main/cpp/sizebasedtriggeringpolicy.cpp
index 7105e91..f843a19 100644
--- a/src/main/cpp/sizebasedtriggeringpolicy.cpp
+++ b/src/main/cpp/sizebasedtriggeringpolicy.cpp
@@ -26,31 +26,38 @@
IMPLEMENT_LOG4CXX_OBJECT(SizeBasedTriggeringPolicy)
SizeBasedTriggeringPolicy::SizeBasedTriggeringPolicy()
- : maxFileSize(10 * 1024 * 1024) {
+ : maxFileSize(10 * 1024 * 1024)
+{
}
bool SizeBasedTriggeringPolicy::isTriggeringEvent(Appender* /* appender */,
- const log4cxx::spi::LoggingEventPtr& /* event */,
- const LogString& /* file */,
- size_t fileLength) {
- return (fileLength >= maxFileSize);
+ const log4cxx::spi::LoggingEventPtr& /* event */,
+ const LogString& /* file */,
+ size_t fileLength)
+{
+ return (fileLength >= maxFileSize);
}
-size_t SizeBasedTriggeringPolicy::getMaxFileSize() {
- return maxFileSize;
+size_t SizeBasedTriggeringPolicy::getMaxFileSize()
+{
+ return maxFileSize;
}
-void SizeBasedTriggeringPolicy::setMaxFileSize(size_t l) {
- maxFileSize = l;
+void SizeBasedTriggeringPolicy::setMaxFileSize(size_t l)
+{
+ maxFileSize = l;
}
-void SizeBasedTriggeringPolicy::activateOptions(Pool& /* p */) {
+void SizeBasedTriggeringPolicy::activateOptions(Pool& /* p */)
+{
}
-void SizeBasedTriggeringPolicy::setOption(const LogString& option, const LogString& value) {
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("MAXFILESIZE"),
- LOG4CXX_STR("maxfilesize"))) {
- maxFileSize = OptionConverter::toFileSize(value, 10*1024*1024);
- }
+void SizeBasedTriggeringPolicy::setOption(const LogString& option, const LogString& value)
+{
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("MAXFILESIZE"),
+ LOG4CXX_STR("maxfilesize")))
+ {
+ maxFileSize = OptionConverter::toFileSize(value, 10 * 1024 * 1024);
+ }
}
diff --git a/src/main/cpp/smtpappender.cpp b/src/main/cpp/smtpappender.cpp
index 3439588..8972676 100644
--- a/src/main/cpp/smtpappender.cpp
+++ b/src/main/cpp/smtpappender.cpp
@@ -24,7 +24,7 @@
#include <log4cxx/helpers/transcoder.h>
#include <log4cxx/helpers/synchronized.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
@@ -39,290 +39,356 @@
using namespace log4cxx::spi;
#if LOG4CXX_HAVE_LIBESMTP
-#include <auth-client.h>
-#include <libesmtp.h>
+ #include <auth-client.h>
+ #include <libesmtp.h>
#endif
-namespace log4cxx {
- namespace net {
- //
- // The following two classes implement an C++ SMTP wrapper over libesmtp.
- // The same signatures could be implemented over different SMTP implementations
- // or libesmtp could be combined with libgmime to enable support for non-ASCII
- // content.
+namespace log4cxx
+{
+namespace net
+{
+//
+// The following two classes implement an C++ SMTP wrapper over libesmtp.
+// The same signatures could be implemented over different SMTP implementations
+// or libesmtp could be combined with libgmime to enable support for non-ASCII
+// content.
#if LOG4CXX_HAVE_LIBESMTP
+/**
+ * SMTP Session.
+ */
+class SMTPSession
+{
+ public:
/**
- * SMTP Session.
- */
- class SMTPSession {
- public:
- /**
- * Create new instance.
- */
- SMTPSession(const LogString& smtpHost,
- int smtpPort,
- const LogString& smtpUsername,
- const LogString& smtpPassword,
- Pool& p) : session(0), authctx(0),
- user(toAscii(smtpUsername, p)),
- pwd(toAscii(smtpPassword, p)) {
- auth_client_init();
- session = smtp_create_session();
- if (session == 0) {
- throw Exception("Could not initialize session.");
- }
- std::string host(toAscii(smtpHost, p));
- host.append(1, ':');
- host.append(p.itoa(smtpPort));
- smtp_set_server(session, host.c_str());
+ * Create new instance.
+ */
+ SMTPSession(const LogString& smtpHost,
+ int smtpPort,
+ const LogString& smtpUsername,
+ const LogString& smtpPassword,
+ Pool& p) : session(0), authctx(0),
+ user(toAscii(smtpUsername, p)),
+ pwd(toAscii(smtpPassword, p))
+ {
+ auth_client_init();
+ session = smtp_create_session();
- authctx = auth_create_context();
- auth_set_mechanism_flags(authctx, AUTH_PLUGIN_PLAIN, 0);
- auth_set_interact_cb(authctx, authinteract, (void*) this);
-
- if (*user || *pwd) {
- smtp_auth_set_context(session, authctx);
- }
+ if (session == 0)
+ {
+ throw Exception("Could not initialize session.");
}
- ~SMTPSession() {
- smtp_destroy_session(session);
- auth_destroy_context(authctx);
- }
+ std::string host(toAscii(smtpHost, p));
+ host.append(1, ':');
+ host.append(p.itoa(smtpPort));
+ smtp_set_server(session, host.c_str());
- void send(Pool& p) {
- int status = smtp_start_session(session);
- if (!status) {
- size_t bufSize = 128;
- char* buf = p.pstralloc(bufSize);
- smtp_strerror(smtp_errno(), buf, bufSize);
- throw Exception(buf);
- }
- }
+ authctx = auth_create_context();
+ auth_set_mechanism_flags(authctx, AUTH_PLUGIN_PLAIN, 0);
+ auth_set_interact_cb(authctx, authinteract, (void*) this);
- operator smtp_session_t() {
- return session;
+ if (*user || *pwd)
+ {
+ smtp_auth_set_context(session, authctx);
}
+ }
- static char* toAscii(const LogString& str, Pool& p) {
- char* buf = p.pstralloc(str.length() + 1);
- char* current = buf;
- for(LogString::const_iterator iter = str.begin();
+ ~SMTPSession()
+ {
+ smtp_destroy_session(session);
+ auth_destroy_context(authctx);
+ }
+
+ void send(Pool& p)
+ {
+ int status = smtp_start_session(session);
+
+ if (!status)
+ {
+ size_t bufSize = 128;
+ char* buf = p.pstralloc(bufSize);
+ smtp_strerror(smtp_errno(), buf, bufSize);
+ throw Exception(buf);
+ }
+ }
+
+ operator smtp_session_t()
+ {
+ return session;
+ }
+
+ static char* toAscii(const LogString& str, Pool& p)
+ {
+ char* buf = p.pstralloc(str.length() + 1);
+ char* current = buf;
+
+ for (LogString::const_iterator iter = str.begin();
iter != str.end();
- iter++) {
- unsigned int c = *iter;
- if (c > 0x7F) {
- c = '?';
- }
- *current++ = c;
+ iter++)
+ {
+ unsigned int c = *iter;
+
+ if (c > 0x7F)
+ {
+ c = '?';
}
- *current = 0;
- return buf;
+
+ *current++ = c;
}
- private:
- SMTPSession(SMTPSession&);
- SMTPSession& operator=(SMTPSession&);
- smtp_session_t session;
- auth_context_t authctx;
- char* user;
- char* pwd;
+ *current = 0;
+ return buf;
+ }
- /**
- * This method is called if the SMTP server requests authentication.
- */
- static int authinteract(auth_client_request_t request, char **result, int fields,
- void *arg) {
- SMTPSession* pThis = (SMTPSession*) arg;
- for (int i = 0; i < fields; i++) {
- int flag = request[i].flags & 0x07;
- if (flag == AUTH_USER) {
- result[i] = pThis->user;
- } else if(flag == AUTH_PASS) {
- result[i] = pThis->pwd;
- }
- }
- return 1;
- }
-
-
- };
+ private:
+ SMTPSession(SMTPSession&);
+ SMTPSession& operator=(SMTPSession&);
+ smtp_session_t session;
+ auth_context_t authctx;
+ char* user;
+ char* pwd;
/**
- * A message in an SMTP session.
+ * This method is called if the SMTP server requests authentication.
*/
- class SMTPMessage {
- public:
- SMTPMessage(SMTPSession& session,
- const LogString& from,
- const LogString& to,
- const LogString& cc,
- const LogString& bcc,
- const LogString& subject,
- const LogString msg, Pool& p) {
- message = smtp_add_message(session);
- body = current = toMessage(msg, p);
- messagecbState = 0;
- smtp_set_reverse_path(message, toAscii(from, p));
- addRecipients(to, "To", p);
- addRecipients(cc, "Cc", p);
- addRecipients(bcc, "Bcc", p);
- if (!subject.empty()) {
- smtp_set_header(message, "Subject", toAscii(subject, p));
- }
- smtp_set_messagecb(message, messagecb, this);
- }
- ~SMTPMessage() {
+ static int authinteract(auth_client_request_t request, char** result, int fields,
+ void* arg)
+ {
+ SMTPSession* pThis = (SMTPSession*) arg;
+
+ for (int i = 0; i < fields; i++)
+ {
+ int flag = request[i].flags & 0x07;
+
+ if (flag == AUTH_USER)
+ {
+ result[i] = pThis->user;
+ }
+ else if (flag == AUTH_PASS)
+ {
+ result[i] = pThis->pwd;
+ }
}
- private:
- SMTPMessage(const SMTPMessage&);
- SMTPMessage& operator=(const SMTPMessage&);
- smtp_message_t message;
- const char* body;
- const char* current;
- int messagecbState;
- void addRecipients(const LogString& addresses, const char* field, Pool& p) {
- if (!addresses.empty()) {
+ return 1;
+ }
+
+
+};
+
+/**
+ * A message in an SMTP session.
+ */
+class SMTPMessage
+{
+ public:
+ SMTPMessage(SMTPSession& session,
+ const LogString& from,
+ const LogString& to,
+ const LogString& cc,
+ const LogString& bcc,
+ const LogString& subject,
+ const LogString msg, Pool& p)
+ {
+ message = smtp_add_message(session);
+ body = current = toMessage(msg, p);
+ messagecbState = 0;
+ smtp_set_reverse_path(message, toAscii(from, p));
+ addRecipients(to, "To", p);
+ addRecipients(cc, "Cc", p);
+ addRecipients(bcc, "Bcc", p);
+
+ if (!subject.empty())
+ {
+ smtp_set_header(message, "Subject", toAscii(subject, p));
+ }
+
+ smtp_set_messagecb(message, messagecb, this);
+ }
+ ~SMTPMessage()
+ {
+ }
+
+ private:
+ SMTPMessage(const SMTPMessage&);
+ SMTPMessage& operator=(const SMTPMessage&);
+ smtp_message_t message;
+ const char* body;
+ const char* current;
+ int messagecbState;
+ void addRecipients(const LogString& addresses, const char* field, Pool& p)
+ {
+ if (!addresses.empty())
+ {
char* str = p.pstrdup(toAscii(addresses, p));;
smtp_set_header(message, field, NULL, str);
char* last;
- for(char* next = apr_strtok(str, ",", &last);
- next;
- next = apr_strtok(NULL, ",", &last)) {
+
+ for (char* next = apr_strtok(str, ",", &last);
+ next;
+ next = apr_strtok(NULL, ",", &last))
+ {
smtp_add_recipient(message, next);
}
- }
- }
- static const char* toAscii(const LogString& str, Pool& p) {
- return SMTPSession::toAscii(str, p);
- }
+ }
+ }
+ static const char* toAscii(const LogString& str, Pool& p)
+ {
+ return SMTPSession::toAscii(str, p);
+ }
- /**
- * Message bodies can only contain US-ASCII characters and
- * CR and LFs can only occur together.
- */
- static const char* toMessage(const LogString& str, Pool& p) {
- //
- // count the number of carriage returns and line feeds
- //
- int feedCount = 0;
- for(size_t pos = str.find_first_of(LOG4CXX_STR("\n\r"));
- pos != LogString::npos;
- pos = str.find_first_of(LOG4CXX_STR("\n\r"), ++pos)) {
- feedCount++;
- }
- //
- // allocate sufficient space for the modified message
- char* retval = p.pstralloc(str.length() + feedCount + 1);
- char* current = retval;
- char* startOfLine = current;
- //
- // iterator through message
- //
- for(LogString::const_iterator iter = str.begin();
- iter != str.end();
- iter++) {
- unsigned int c = *iter;
- //
- // replace non-ASCII characters with '?'
- //
- if (c > 0x7F) {
- *current++ = 0x3F; // '?'
- } else if (c == 0x0A || c == 0x0D) {
- //
- // replace any stray CR or LF with CRLF
- // reset start of line
- *current++ = 0x0D;
- *current++ = 0x0A;
- startOfLine = current;
- LogString::const_iterator next = iter + 1;
- if (next != str.end() && (*next == 0x0A || *next == 0x0D)) {
- iter++;
- }
- } else {
- //
- // truncate any lines to 1000 characters (including CRLF)
- // as required by RFC.
- if (current < startOfLine + 998) {
+ /**
+ * Message bodies can only contain US-ASCII characters and
+ * CR and LFs can only occur together.
+ */
+ static const char* toMessage(const LogString& str, Pool& p)
+ {
+ //
+ // count the number of carriage returns and line feeds
+ //
+ int feedCount = 0;
+
+ for (size_t pos = str.find_first_of(LOG4CXX_STR("\n\r"));
+ pos != LogString::npos;
+ pos = str.find_first_of(LOG4CXX_STR("\n\r"), ++pos))
+ {
+ feedCount++;
+ }
+
+ //
+ // allocate sufficient space for the modified message
+ char* retval = p.pstralloc(str.length() + feedCount + 1);
+ char* current = retval;
+ char* startOfLine = current;
+
+ //
+ // iterator through message
+ //
+ for (LogString::const_iterator iter = str.begin();
+ iter != str.end();
+ iter++)
+ {
+ unsigned int c = *iter;
+
+ //
+ // replace non-ASCII characters with '?'
+ //
+ if (c > 0x7F)
+ {
+ *current++ = 0x3F; // '?'
+ }
+ else if (c == 0x0A || c == 0x0D)
+ {
+ //
+ // replace any stray CR or LF with CRLF
+ // reset start of line
+ *current++ = 0x0D;
+ *current++ = 0x0A;
+ startOfLine = current;
+ LogString::const_iterator next = iter + 1;
+
+ if (next != str.end() && (*next == 0x0A || *next == 0x0D))
+ {
+ iter++;
+ }
+ }
+ else
+ {
+ //
+ // truncate any lines to 1000 characters (including CRLF)
+ // as required by RFC.
+ if (current < startOfLine + 998)
+ {
*current++ = (char) c;
- }
- }
- }
- *current = 0;
- return retval;
- }
+ }
+ }
+ }
- /**
- * Callback for message.
- */
- static const char* messagecb(void** ctx, int* len, void* arg) {
- *ctx = 0;
- const char* retval = 0;
- SMTPMessage* pThis = (SMTPMessage*) arg;
- // rewind message
- if (len == NULL) {
- pThis->current = pThis->body;
- } else {
- // we are asked for headers, but we don't have any
- if ((pThis->messagecbState)++ == 0) {
+ *current = 0;
+ return retval;
+ }
+
+ /**
+ * Callback for message.
+ */
+ static const char* messagecb(void** ctx, int* len, void* arg)
+ {
+ *ctx = 0;
+ const char* retval = 0;
+ SMTPMessage* pThis = (SMTPMessage*) arg;
+
+ // rewind message
+ if (len == NULL)
+ {
+ pThis->current = pThis->body;
+ }
+ else
+ {
+ // we are asked for headers, but we don't have any
+ if ((pThis->messagecbState)++ == 0)
+ {
return NULL;
- }
- if (pThis->current) {
- *len = strlen(pThis->current);
- }
- retval = pThis->current;
- pThis->current = 0;
- }
- return retval;
- }
+ }
- };
+ if (pThis->current)
+ {
+ *len = strlen(pThis->current);
+ }
+
+ retval = pThis->current;
+ pThis->current = 0;
+ }
+
+ return retval;
+ }
+
+};
#endif
- class LOG4CXX_EXPORT DefaultEvaluator :
- public virtual spi::TriggeringEventEvaluator,
- public virtual helpers::ObjectImpl
- {
- public:
- DECLARE_LOG4CXX_OBJECT(DefaultEvaluator)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(DefaultEvaluator)
- LOG4CXX_CAST_ENTRY(spi::TriggeringEventEvaluator)
- END_LOG4CXX_CAST_MAP()
+class LOG4CXX_EXPORT DefaultEvaluator :
+ public virtual spi::TriggeringEventEvaluator,
+ public virtual helpers::ObjectImpl
+{
+ public:
+ DECLARE_LOG4CXX_OBJECT(DefaultEvaluator)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(DefaultEvaluator)
+ LOG4CXX_CAST_ENTRY(spi::TriggeringEventEvaluator)
+ END_LOG4CXX_CAST_MAP()
- DefaultEvaluator();
+ DefaultEvaluator();
- /**
- Is this <code>event</code> the e-mail triggering event?
- <p>This method returns <code>true</code>, if the event level
- has ERROR level or higher. Otherwise it returns
- <code>false</code>.
- */
- virtual bool isTriggeringEvent(const spi::LoggingEventPtr& event);
- private:
- DefaultEvaluator(const DefaultEvaluator&);
- DefaultEvaluator& operator=(const DefaultEvaluator&);
- }; // class DefaultEvaluator
+ /**
+ Is this <code>event</code> the e-mail triggering event?
+ <p>This method returns <code>true</code>, if the event level
+ has ERROR level or higher. Otherwise it returns
+ <code>false</code>.
+ */
+ virtual bool isTriggeringEvent(const spi::LoggingEventPtr& event);
+ private:
+ DefaultEvaluator(const DefaultEvaluator&);
+ DefaultEvaluator& operator=(const DefaultEvaluator&);
+}; // class DefaultEvaluator
- }
+}
}
IMPLEMENT_LOG4CXX_OBJECT(DefaultEvaluator)
IMPLEMENT_LOG4CXX_OBJECT(SMTPAppender)
-DefaultEvaluator::DefaultEvaluator() {
+DefaultEvaluator::DefaultEvaluator()
+{
}
bool DefaultEvaluator::isTriggeringEvent(const spi::LoggingEventPtr& event)
{
- return event->getLevel()->isGreaterOrEqual(Level::getError());
+ return event->getLevel()->isGreaterOrEqual(Level::getError());
}
SMTPAppender::SMTPAppender()
-: smtpPort(25), bufferSize(512), locationInfo(false), cb(bufferSize),
-evaluator(new DefaultEvaluator())
+ : smtpPort(25), bufferSize(512), locationInfo(false), cb(bufferSize),
+ evaluator(new DefaultEvaluator())
{
}
@@ -330,75 +396,90 @@
Use <code>evaluator</code> passed as parameter as the
TriggeringEventEvaluator for this SMTPAppender. */
SMTPAppender::SMTPAppender(spi::TriggeringEventEvaluatorPtr evaluator)
-: smtpPort(25), bufferSize(512), locationInfo(false), cb(bufferSize),
-evaluator(evaluator)
+ : smtpPort(25), bufferSize(512), locationInfo(false), cb(bufferSize),
+ evaluator(evaluator)
{
}
SMTPAppender::~SMTPAppender()
{
- finalize();
+ finalize();
}
-bool SMTPAppender::requiresLayout() const {
+bool SMTPAppender::requiresLayout() const
+{
return true;
}
-LogString SMTPAppender::getFrom() const {
+LogString SMTPAppender::getFrom() const
+{
return from;
}
-void SMTPAppender::setFrom(const LogString& newVal) {
+void SMTPAppender::setFrom(const LogString& newVal)
+{
from = newVal;
}
-LogString SMTPAppender::getSubject() const {
+LogString SMTPAppender::getSubject() const
+{
return subject;
}
-void SMTPAppender::setSubject(const LogString& newVal) {
+void SMTPAppender::setSubject(const LogString& newVal)
+{
subject = newVal;
}
-LogString SMTPAppender::getSMTPHost() const {
+LogString SMTPAppender::getSMTPHost() const
+{
return smtpHost;
}
-void SMTPAppender::setSMTPHost(const LogString& newVal) {
+void SMTPAppender::setSMTPHost(const LogString& newVal)
+{
smtpHost = newVal;
}
-int SMTPAppender::getSMTPPort() const {
+int SMTPAppender::getSMTPPort() const
+{
return smtpPort;
}
-void SMTPAppender::setSMTPPort(int newVal) {
+void SMTPAppender::setSMTPPort(int newVal)
+{
smtpPort = newVal;
}
-bool SMTPAppender::getLocationInfo() const {
- return locationInfo;
+bool SMTPAppender::getLocationInfo() const
+{
+ return locationInfo;
}
-void SMTPAppender::setLocationInfo(bool newVal) {
+void SMTPAppender::setLocationInfo(bool newVal)
+{
locationInfo = newVal;
}
-LogString SMTPAppender::getSMTPUsername() const {
+LogString SMTPAppender::getSMTPUsername() const
+{
return smtpUsername;
}
-void SMTPAppender::setSMTPUsername(const LogString& newVal) {
+void SMTPAppender::setSMTPUsername(const LogString& newVal)
+{
smtpUsername = newVal;
}
-LogString SMTPAppender::getSMTPPassword() const {
+LogString SMTPAppender::getSMTPPassword() const
+{
return smtpPassword;
}
-void SMTPAppender::setSMTPPassword(const LogString& newVal) {
+void SMTPAppender::setSMTPPassword(const LogString& newVal)
+{
smtpPassword = newVal;
}
@@ -407,69 +488,73 @@
void SMTPAppender::setOption(const LogString& option,
- const LogString& value)
+ const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFERSIZE"), LOG4CXX_STR("buffersize")))
- {
- setBufferSize(OptionConverter::toInt(value, 512));
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("EVALUATORCLASS"), LOG4CXX_STR("evaluatorclass")))
- {
- setEvaluatorClass(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("FROM"), LOG4CXX_STR("from")))
- {
- setFrom(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SMTPHOST"), LOG4CXX_STR("smtphost")))
- {
- setSMTPHost(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SMTPUSERNAME"), LOG4CXX_STR("smtpusername")))
- {
- setSMTPUsername(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SMTPPASSWORD"), LOG4CXX_STR("smtppassword")))
- {
- setSMTPPassword(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SUBJECT"), LOG4CXX_STR("subject")))
- {
- setSubject(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("TO"), LOG4CXX_STR("to")))
- {
- setTo(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("CC"), LOG4CXX_STR("cc")))
- {
- setCc(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BCC"), LOG4CXX_STR("bcc")))
- {
- setBcc(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SMTPPORT"), LOG4CXX_STR("smtpport")))
- {
- setSMTPPort(OptionConverter::toInt(value, 25));
- }
- else
- {
- AppenderSkeleton::setOption(option, value);
- }
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BUFFERSIZE"), LOG4CXX_STR("buffersize")))
+ {
+ setBufferSize(OptionConverter::toInt(value, 512));
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("EVALUATORCLASS"), LOG4CXX_STR("evaluatorclass")))
+ {
+ setEvaluatorClass(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("FROM"), LOG4CXX_STR("from")))
+ {
+ setFrom(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SMTPHOST"), LOG4CXX_STR("smtphost")))
+ {
+ setSMTPHost(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SMTPUSERNAME"), LOG4CXX_STR("smtpusername")))
+ {
+ setSMTPUsername(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SMTPPASSWORD"), LOG4CXX_STR("smtppassword")))
+ {
+ setSMTPPassword(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SUBJECT"), LOG4CXX_STR("subject")))
+ {
+ setSubject(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("TO"), LOG4CXX_STR("to")))
+ {
+ setTo(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("CC"), LOG4CXX_STR("cc")))
+ {
+ setCc(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("BCC"), LOG4CXX_STR("bcc")))
+ {
+ setBcc(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SMTPPORT"), LOG4CXX_STR("smtpport")))
+ {
+ setSMTPPort(OptionConverter::toInt(value, 25));
+ }
+ else
+ {
+ AppenderSkeleton::setOption(option, value);
+ }
}
-bool SMTPAppender::asciiCheck(const LogString& value, const LogString& field) {
- for(LogString::const_iterator iter = value.begin();
- iter != value.end();
- iter++) {
- if (0x7F < (unsigned int) *iter) {
+bool SMTPAppender::asciiCheck(const LogString& value, const LogString& field)
+{
+ for (LogString::const_iterator iter = value.begin();
+ iter != value.end();
+ iter++)
+ {
+ if (0x7F < (unsigned int) *iter)
+ {
LogLog::warn(field + LOG4CXX_STR(" contains non-ASCII character"));
return false;
- }
- }
- return true;
+ }
+ }
+
+ return true;
}
/**
@@ -477,38 +562,49 @@
recipient, from, etc. */
void SMTPAppender::activateOptions(Pool& p)
{
- bool activate = true;
- if (layout == 0) {
- errorHandler->error(LOG4CXX_STR("No layout set for appender named [") +name+ LOG4CXX_STR("]."));
- activate = false;
- }
- if(evaluator == 0) {
- errorHandler->error(LOG4CXX_STR("No TriggeringEventEvaluator is set for appender [")+
- name+LOG4CXX_STR("]."));
- activate = false;
- }
- if(smtpHost.empty()) {
- errorHandler->error(LOG4CXX_STR("No smtpHost is set for appender [")+
- name+LOG4CXX_STR("]."));
- activate = false;
- }
- if(to.empty() && cc.empty() && bcc.empty()) {
- errorHandler->error(LOG4CXX_STR("No recipient address is set for appender [")+
- name+LOG4CXX_STR("]."));
- activate = false;
- }
- activate &= asciiCheck(to, LOG4CXX_STR("to"));
- activate &= asciiCheck(cc, LOG4CXX_STR("cc"));
- activate &= asciiCheck(bcc, LOG4CXX_STR("bcc"));
- activate &= asciiCheck(from, LOG4CXX_STR("from"));
+ bool activate = true;
+
+ if (layout == 0)
+ {
+ errorHandler->error(LOG4CXX_STR("No layout set for appender named [") + name + LOG4CXX_STR("]."));
+ activate = false;
+ }
+
+ if (evaluator == 0)
+ {
+ errorHandler->error(LOG4CXX_STR("No TriggeringEventEvaluator is set for appender [") +
+ name + LOG4CXX_STR("]."));
+ activate = false;
+ }
+
+ if (smtpHost.empty())
+ {
+ errorHandler->error(LOG4CXX_STR("No smtpHost is set for appender [") +
+ name + LOG4CXX_STR("]."));
+ activate = false;
+ }
+
+ if (to.empty() && cc.empty() && bcc.empty())
+ {
+ errorHandler->error(LOG4CXX_STR("No recipient address is set for appender [") +
+ name + LOG4CXX_STR("]."));
+ activate = false;
+ }
+
+ activate &= asciiCheck(to, LOG4CXX_STR("to"));
+ activate &= asciiCheck(cc, LOG4CXX_STR("cc"));
+ activate &= asciiCheck(bcc, LOG4CXX_STR("bcc"));
+ activate &= asciiCheck(from, LOG4CXX_STR("from"));
#if !LOG4CXX_HAVE_LIBESMTP
- errorHandler->error(LOG4CXX_STR("log4cxx built without SMTP support."));
- activate = false;
+ errorHandler->error(LOG4CXX_STR("log4cxx built without SMTP support."));
+ activate = false;
#endif
- if (activate) {
+
+ if (activate)
+ {
AppenderSkeleton::activateOptions(p);
- }
+ }
}
/**
@@ -517,23 +613,23 @@
an e-mail to be sent. */
void SMTPAppender::append(const spi::LoggingEventPtr& event, Pool& p)
{
- if(!checkEntryConditions())
- {
- return;
- }
+ if (!checkEntryConditions())
+ {
+ return;
+ }
- LogString ndc;
- event->getNDC(ndc);
- event->getThreadName();
- // Get a copy of this thread's MDC.
- event->getMDCCopy();
+ LogString ndc;
+ event->getNDC(ndc);
+ event->getThreadName();
+ // Get a copy of this thread's MDC.
+ event->getMDCCopy();
- cb.add(event);
+ cb.add(event);
- if(evaluator->isTriggeringEvent(event))
- {
- sendBuffer(p);
- }
+ if (evaluator->isTriggeringEvent(event))
+ {
+ sendBuffer(p);
+ }
}
/**
@@ -544,59 +640,68 @@
bool SMTPAppender::checkEntryConditions()
{
#if LOG4CXX_HAVE_LIBESMTP
- if((to.empty() && cc.empty() && bcc.empty()) || from.empty() || smtpHost.empty())
- {
- errorHandler->error(LOG4CXX_STR("Message not configured."));
- return false;
- }
- if(evaluator == 0)
- {
- errorHandler->error(LOG4CXX_STR("No TriggeringEventEvaluator is set for appender [")+
- name+ LOG4CXX_STR("]."));
- return false;
- }
+ if ((to.empty() && cc.empty() && bcc.empty()) || from.empty() || smtpHost.empty())
+ {
+ errorHandler->error(LOG4CXX_STR("Message not configured."));
+ return false;
+ }
+
+ if (evaluator == 0)
+ {
+ errorHandler->error(LOG4CXX_STR("No TriggeringEventEvaluator is set for appender [") +
+ name + LOG4CXX_STR("]."));
+ return false;
+ }
- if(layout == 0)
- {
- errorHandler->error(LOG4CXX_STR("No layout set for appender named [")+name+LOG4CXX_STR("]."));
- return false;
- }
- return true;
+ if (layout == 0)
+ {
+ errorHandler->error(LOG4CXX_STR("No layout set for appender named [") + name + LOG4CXX_STR("]."));
+ return false;
+ }
+
+ return true;
#else
- return false;
+ return false;
#endif
}
-void SMTPAppender::close() {
- this->closed = true;
+void SMTPAppender::close()
+{
+ this->closed = true;
}
-LogString SMTPAppender::getTo() const{
- return to;
+LogString SMTPAppender::getTo() const
+{
+ return to;
}
-void SMTPAppender::setTo(const LogString& addressStr) {
- to = addressStr;
+void SMTPAppender::setTo(const LogString& addressStr)
+{
+ to = addressStr;
}
-LogString SMTPAppender::getCc() const{
- return cc;
+LogString SMTPAppender::getCc() const
+{
+ return cc;
}
-void SMTPAppender::setCc(const LogString& addressStr) {
- cc = addressStr;
+void SMTPAppender::setCc(const LogString& addressStr)
+{
+ cc = addressStr;
}
-LogString SMTPAppender::getBcc() const{
- return bcc;
+LogString SMTPAppender::getBcc() const
+{
+ return bcc;
}
-void SMTPAppender::setBcc(const LogString& addressStr) {
- bcc = addressStr;
+void SMTPAppender::setBcc(const LogString& addressStr)
+{
+ bcc = addressStr;
}
/**
@@ -605,34 +710,37 @@
void SMTPAppender::sendBuffer(Pool& p)
{
#if LOG4CXX_HAVE_LIBESMTP
- // Note: this code already owns the monitor for this
- // appender. This frees us from needing to synchronize on 'cb'.
- try
- {
- LogString sbuf;
- layout->appendHeader(sbuf, p);
- int len = cb.length();
- for(int i = 0; i < len; i++)
- {
- LoggingEventPtr event = cb.get();
- layout->format(sbuf, event, p);
- }
+ // Note: this code already owns the monitor for this
+ // appender. This frees us from needing to synchronize on 'cb'.
+ try
+ {
+ LogString sbuf;
+ layout->appendHeader(sbuf, p);
- layout->appendFooter(sbuf, p);
+ int len = cb.length();
- SMTPSession session(smtpHost, smtpPort, smtpUsername, smtpPassword, p);
+ for (int i = 0; i < len; i++)
+ {
+ LoggingEventPtr event = cb.get();
+ layout->format(sbuf, event, p);
+ }
- SMTPMessage message(session, from, to, cc,
- bcc, subject, sbuf, p);
+ layout->appendFooter(sbuf, p);
- session.send(p);
+ SMTPSession session(smtpHost, smtpPort, smtpUsername, smtpPassword, p);
- }
- catch(std::exception& e)
- {
- LogLog::error(LOG4CXX_STR("Error occured while sending e-mail notification."), e);
- }
+ SMTPMessage message(session, from, to, cc,
+ bcc, subject, sbuf, p);
+
+ session.send(p);
+
+ }
+ catch (std::exception& e)
+ {
+ LogLog::error(LOG4CXX_STR("Error occured while sending e-mail notification."), e);
+ }
+
#endif
}
@@ -641,14 +749,16 @@
*/
LogString SMTPAppender::getEvaluatorClass()
{
- return evaluator == 0 ? LogString() : evaluator->getClass().getName();
+ return evaluator == 0 ? LogString() : evaluator->getClass().getName();
}
-log4cxx::spi::TriggeringEventEvaluatorPtr SMTPAppender::getEvaluator() const {
- return evaluator;
+log4cxx::spi::TriggeringEventEvaluatorPtr SMTPAppender::getEvaluator() const
+{
+ return evaluator;
}
-void SMTPAppender::setEvaluator(log4cxx::spi::TriggeringEventEvaluatorPtr& trigger) {
+void SMTPAppender::setEvaluator(log4cxx::spi::TriggeringEventEvaluatorPtr& trigger)
+{
evaluator = trigger;
}
@@ -661,8 +771,8 @@
*/
void SMTPAppender::setBufferSize(int sz)
{
- this->bufferSize = sz;
- cb.resize(sz);
+ this->bufferSize = sz;
+ cb.resize(sz);
}
/**
@@ -674,7 +784,7 @@
*/
void SMTPAppender::setEvaluatorClass(const LogString& value)
{
- evaluator = OptionConverter::instantiateByClassName(value,
- TriggeringEventEvaluator::getStaticClass(), evaluator);
+ evaluator = OptionConverter::instantiateByClassName(value,
+ TriggeringEventEvaluator::getStaticClass(), evaluator);
}
diff --git a/src/main/cpp/socket.cpp b/src/main/cpp/socket.cpp
index 0d876ed..bf683a0 100644
--- a/src/main/cpp/socket.cpp
+++ b/src/main/cpp/socket.cpp
@@ -31,60 +31,81 @@
*/
Socket::Socket(InetAddressPtr& addr, int prt) : pool(), socket(0), address(addr), port(prt)
{
- apr_status_t status =
- apr_socket_create(&socket, APR_INET, SOCK_STREAM,
- APR_PROTO_TCP, pool.getAPRPool());
- if (status != APR_SUCCESS) {
- throw SocketException(status);
- }
+ apr_status_t status =
+ apr_socket_create(&socket, APR_INET, SOCK_STREAM,
+ APR_PROTO_TCP, pool.getAPRPool());
- LOG4CXX_ENCODE_CHAR(host, addr->getHostAddress());
+ if (status != APR_SUCCESS)
+ {
+ throw SocketException(status);
+ }
- // create socket address (including port)
- apr_sockaddr_t *client_addr;
- status =
- apr_sockaddr_info_get(&client_addr, host.c_str(), APR_INET,
- prt, 0, pool.getAPRPool());
- if (status != APR_SUCCESS) {
- throw ConnectException(status);
- }
+ LOG4CXX_ENCODE_CHAR(host, addr->getHostAddress());
- // connect the socket
- status = apr_socket_connect(socket, client_addr);
- if (status != APR_SUCCESS) {
- throw ConnectException(status);
- }
+ // create socket address (including port)
+ apr_sockaddr_t* client_addr;
+ status =
+ apr_sockaddr_info_get(&client_addr, host.c_str(), APR_INET,
+ prt, 0, pool.getAPRPool());
+
+ if (status != APR_SUCCESS)
+ {
+ throw ConnectException(status);
+ }
+
+ // connect the socket
+ status = apr_socket_connect(socket, client_addr);
+
+ if (status != APR_SUCCESS)
+ {
+ throw ConnectException(status);
+ }
}
Socket::Socket(apr_socket_t* s, apr_pool_t* p) :
- pool(p, true), socket(s) {
+ pool(p, true), socket(s)
+{
apr_sockaddr_t* sa;
apr_status_t status = apr_socket_addr_get(&sa, APR_REMOTE, s);
- if (status == APR_SUCCESS) {
+
+ if (status == APR_SUCCESS)
+ {
port = sa->port;
LogString remotename;
LogString remoteip;
- if (sa->hostname != NULL) {
+
+ if (sa->hostname != NULL)
+ {
Transcoder::decode(sa->hostname, remotename);
}
+
char* buf = 0;
status = apr_sockaddr_ip_get(&buf, sa);
- if (status == APR_SUCCESS) {
+
+ if (status == APR_SUCCESS)
+ {
Transcoder::decode(buf, remoteip);
}
+
address = new InetAddress(remotename, remoteip);
}
}
-Socket::~Socket() {
+Socket::~Socket()
+{
}
-size_t Socket::write(ByteBuffer& buf) {
- if (socket == 0) {
- throw ClosedChannelException();
+size_t Socket::write(ByteBuffer& buf)
+{
+ if (socket == 0)
+ {
+ throw ClosedChannelException();
}
+
int totalWritten = 0;
- while(buf.remaining() > 0) {
+
+ while (buf.remaining() > 0)
+ {
apr_size_t written = buf.remaining();
// while writing to the socket, we need to ignore the SIGPIPE
@@ -101,29 +122,39 @@
buf.position(buf.position() + written);
totalWritten += written;
- if (status != APR_SUCCESS) {
+
+ if (status != APR_SUCCESS)
+ {
throw SocketException(status);
}
}
+
return totalWritten;
}
-void Socket::close() {
- if (socket != 0) {
+void Socket::close()
+{
+ if (socket != 0)
+ {
apr_status_t status = apr_socket_close(socket);
- if (status != APR_SUCCESS) {
+
+ if (status != APR_SUCCESS)
+ {
throw SocketException(status);
}
+
socket = 0;
}
}
-InetAddressPtr Socket::getInetAddress() const {
+InetAddressPtr Socket::getInetAddress() const
+{
return address;
}
-int Socket::getPort() const {
+int Socket::getPort() const
+{
return port;
}
diff --git a/src/main/cpp/socketappender.cpp b/src/main/cpp/socketappender.cpp
index 70826c3..7af0287 100644
--- a/src/main/cpp/socketappender.cpp
+++ b/src/main/cpp/socketappender.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/net/socketappender.h>
@@ -38,93 +38,93 @@
// The default port number of remote logging server (4560)
-int SocketAppender::DEFAULT_PORT = 4560;
+int SocketAppender::DEFAULT_PORT = 4560;
// The default reconnection delay (30000 milliseconds or 30 seconds).
-int SocketAppender::DEFAULT_RECONNECTION_DELAY = 30000;
+int SocketAppender::DEFAULT_RECONNECTION_DELAY = 30000;
SocketAppender::SocketAppender()
-: SocketAppenderSkeleton(DEFAULT_PORT, DEFAULT_RECONNECTION_DELAY)
+ : SocketAppenderSkeleton(DEFAULT_PORT, DEFAULT_RECONNECTION_DELAY)
{
}
SocketAppender::SocketAppender(InetAddressPtr& address1, int port1)
-: SocketAppenderSkeleton(address1, port1, DEFAULT_RECONNECTION_DELAY)
+ : SocketAppenderSkeleton(address1, port1, DEFAULT_RECONNECTION_DELAY)
{
- Pool p;
- activateOptions(p);
+ Pool p;
+ activateOptions(p);
}
SocketAppender::SocketAppender(const LogString& host, int port1)
-: SocketAppenderSkeleton(host, port1, DEFAULT_RECONNECTION_DELAY)
+ : SocketAppenderSkeleton(host, port1, DEFAULT_RECONNECTION_DELAY)
{
- Pool p;
- activateOptions(p);
+ Pool p;
+ activateOptions(p);
}
SocketAppender::~SocketAppender()
{
- finalize();
+ finalize();
}
int SocketAppender::getDefaultDelay() const
{
- return DEFAULT_RECONNECTION_DELAY;
+ return DEFAULT_RECONNECTION_DELAY;
}
int SocketAppender::getDefaultPort() const
{
- return DEFAULT_PORT;
+ return DEFAULT_PORT;
}
void SocketAppender::setSocket(log4cxx::helpers::SocketPtr& socket, Pool& p)
{
- LOCK_W sync(mutex);
+ LOCK_W sync(mutex);
- oos = new ObjectOutputStream(new SocketOutputStream(socket), p);
+ oos = new ObjectOutputStream(new SocketOutputStream(socket), p);
}
void SocketAppender::cleanUp(Pool& p)
{
- if (oos == 0)
- {
- return;
- }
+ if (oos == 0)
+ {
+ return;
+ }
- try
- {
- oos->close(p);
- oos = 0;
- }
- catch(std::exception& e)
- {}
+ try
+ {
+ oos->close(p);
+ oos = 0;
+ }
+ catch (std::exception& e)
+ {}
}
void SocketAppender::append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p)
{
- if (oos == 0)
- {
- return;
- }
+ if (oos == 0)
+ {
+ return;
+ }
- LogString ndcVal;
- event->getNDC(ndcVal);
- event->getThreadName();
- event->getMDCCopy();
+ LogString ndcVal;
+ event->getNDC(ndcVal);
+ event->getThreadName();
+ event->getMDCCopy();
- try
- {
- event->write(*oos, p);
- oos->reset(p);
- }
- catch(std::exception& e)
- {
- oos = 0;
- LogLog::warn(LOG4CXX_STR("Detected problem with connection: "), e);
+ try
+ {
+ event->write(*oos, p);
+ oos->reset(p);
+ }
+ catch (std::exception& e)
+ {
+ oos = 0;
+ LogLog::warn(LOG4CXX_STR("Detected problem with connection: "), e);
- if (getReconnectionDelay() > 0)
- {
- fireConnector();
- }
- }
+ if (getReconnectionDelay() > 0)
+ {
+ fireConnector();
+ }
+ }
}
diff --git a/src/main/cpp/socketappenderskeleton.cpp b/src/main/cpp/socketappenderskeleton.cpp
index 3010590..dcad50c 100755
--- a/src/main/cpp/socketappenderskeleton.cpp
+++ b/src/main/cpp/socketappenderskeleton.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#define __STDC_CONSTANT_MACROS
@@ -33,159 +33,195 @@
using namespace log4cxx::net;
SocketAppenderSkeleton::SocketAppenderSkeleton(int defaultPort, int reconnectionDelay1)
-: remoteHost(),
- address(),
- port(defaultPort),
- reconnectionDelay(reconnectionDelay1),
- locationInfo(false),
- thread() {
+ : remoteHost(),
+ address(),
+ port(defaultPort),
+ reconnectionDelay(reconnectionDelay1),
+ locationInfo(false),
+ thread()
+{
}
SocketAppenderSkeleton::SocketAppenderSkeleton(InetAddressPtr address1, int port1, int delay)
-:
- remoteHost(),
- address(address1),
- port(port1),
- reconnectionDelay(delay),
- locationInfo(false),
- thread() {
+ :
+ remoteHost(),
+ address(address1),
+ port(port1),
+ reconnectionDelay(delay),
+ locationInfo(false),
+ thread()
+{
remoteHost = this->address->getHostName();
}
SocketAppenderSkeleton::SocketAppenderSkeleton(const LogString& host, int port1, int delay)
-: remoteHost(host),
- address(InetAddress::getByName(host)),
- port(port1),
- reconnectionDelay(delay),
- locationInfo(false),
- thread() {
+ : remoteHost(host),
+ address(InetAddress::getByName(host)),
+ port(port1),
+ reconnectionDelay(delay),
+ locationInfo(false),
+ thread()
+{
}
SocketAppenderSkeleton::~SocketAppenderSkeleton()
{
- finalize();
- try {
- thread.join();
- } catch(ThreadException& ex) {
- LogLog::error(LOG4CXX_STR("Error closing socket appender connection thread"), ex);
- }
+ finalize();
+
+ try
+ {
+ thread.join();
+ }
+ catch (ThreadException& ex)
+ {
+ LogLog::error(LOG4CXX_STR("Error closing socket appender connection thread"), ex);
+ }
}
void SocketAppenderSkeleton::activateOptions(Pool& p)
{
- AppenderSkeleton::activateOptions(p);
- connect(p);
+ AppenderSkeleton::activateOptions(p);
+ connect(p);
}
-void SocketAppenderSkeleton::close() {
+void SocketAppenderSkeleton::close()
+{
LOCK_W sync(mutex);
- if (closed) return;
+
+ if (closed)
+ {
+ return;
+ }
+
closed = true;
cleanUp(pool);
thread.interrupt();
}
-void SocketAppenderSkeleton::connect(Pool& p) {
- if (address == 0) {
+void SocketAppenderSkeleton::connect(Pool& p)
+{
+ if (address == 0)
+ {
LogLog::error(LogString(LOG4CXX_STR("No remote host is set for Appender named \"")) +
- name + LOG4CXX_STR("\"."));
- } else {
+ name + LOG4CXX_STR("\"."));
+ }
+ else
+ {
cleanUp(p);
- try {
+
+ try
+ {
SocketPtr socket(new Socket(address, port));
setSocket(socket, p);
- } catch(SocketException& e) {
- LogString msg = LOG4CXX_STR("Could not connect to remote log4cxx server at [")
- +address->getHostName()+LOG4CXX_STR("].");
- if(reconnectionDelay > 0)
- {
- msg += LOG4CXX_STR(" We will try again later. ");
- }
- fireConnector(); // fire the connector thread
- LogLog::error(msg, e);
+ }
+ catch (SocketException& e)
+ {
+ LogString msg = LOG4CXX_STR("Could not connect to remote log4cxx server at [")
+ + address->getHostName() + LOG4CXX_STR("].");
+
+ if (reconnectionDelay > 0)
+ {
+ msg += LOG4CXX_STR(" We will try again later. ");
+ }
+
+ fireConnector(); // fire the connector thread
+ LogLog::error(msg, e);
}
}
}
void SocketAppenderSkeleton::setOption(const LogString& option, const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("REMOTEHOST"), LOG4CXX_STR("remotehost")))
- {
- setRemoteHost(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("PORT"), LOG4CXX_STR("port")))
- {
- setPort(OptionConverter::toInt(value, getDefaultPort()));
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo")))
- {
- setLocationInfo(OptionConverter::toBoolean(value, false));
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("RECONNECTIONDELAY"), LOG4CXX_STR("reconnectiondelay")))
- {
- setReconnectionDelay(OptionConverter::toInt(value, getDefaultDelay()));
- }
- else
- {
- AppenderSkeleton::setOption(option, value);
- }
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("REMOTEHOST"), LOG4CXX_STR("remotehost")))
+ {
+ setRemoteHost(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("PORT"), LOG4CXX_STR("port")))
+ {
+ setPort(OptionConverter::toInt(value, getDefaultPort()));
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo")))
+ {
+ setLocationInfo(OptionConverter::toBoolean(value, false));
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("RECONNECTIONDELAY"), LOG4CXX_STR("reconnectiondelay")))
+ {
+ setReconnectionDelay(OptionConverter::toInt(value, getDefaultDelay()));
+ }
+ else
+ {
+ AppenderSkeleton::setOption(option, value);
+ }
}
void SocketAppenderSkeleton::fireConnector()
{
- LOCK_W sync(mutex);
- if ( !thread.isAlive() ) {
- 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);
- }
+ LOCK_W sync(mutex);
+
+ if ( !thread.isAlive() )
+ {
+ 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);
+ }
+ }
}
-void* LOG4CXX_THREAD_FUNC SocketAppenderSkeleton::monitor(apr_thread_t* /* thread */, void* data) {
- SocketAppenderSkeleton* socketAppender = (SocketAppenderSkeleton*) data;
- SocketPtr socket;
- bool isClosed = socketAppender->closed;
- while(!isClosed)
- {
- try
- {
- Thread::sleep(socketAppender->reconnectionDelay);
- if(!socketAppender->closed) {
- LogLog::debug(LogString(LOG4CXX_STR("Attempting connection to "))
- + socketAppender->address->getHostName());
- socket = new Socket(socketAppender->address, socketAppender->port);
- Pool p;
- socketAppender->setSocket(socket, p);
- LogLog::debug(LOG4CXX_STR("Connection established. Exiting connector thread."));
- }
- return NULL;
- }
- catch(InterruptedException&) {
- LogLog::debug(LOG4CXX_STR("Connector interrupted. Leaving loop."));
- return NULL;
- }
- catch(ConnectException&)
- {
- LogLog::debug(LOG4CXX_STR("Remote host ")
- +socketAppender->address->getHostName()
- +LOG4CXX_STR(" refused connection."));
- }
- catch(IOException& e)
- {
- LogString exmsg;
- log4cxx::helpers::Transcoder::decode(e.what(), exmsg);
+void* LOG4CXX_THREAD_FUNC SocketAppenderSkeleton::monitor(apr_thread_t* /* thread */, void* data)
+{
+ SocketAppenderSkeleton* socketAppender = (SocketAppenderSkeleton*) data;
+ SocketPtr socket;
+ bool isClosed = socketAppender->closed;
- LogLog::debug(((LogString) LOG4CXX_STR("Could not connect to "))
- + socketAppender->address->getHostName()
- + LOG4CXX_STR(". Exception is ")
- + exmsg);
- }
- isClosed = socketAppender->closed;
+ while (!isClosed)
+ {
+ try
+ {
+ Thread::sleep(socketAppender->reconnectionDelay);
+
+ if (!socketAppender->closed)
+ {
+ LogLog::debug(LogString(LOG4CXX_STR("Attempting connection to "))
+ + socketAppender->address->getHostName());
+ socket = new Socket(socketAppender->address, socketAppender->port);
+ Pool p;
+ socketAppender->setSocket(socket, p);
+ LogLog::debug(LOG4CXX_STR("Connection established. Exiting connector thread."));
+ }
+
+ return NULL;
+ }
+ catch (InterruptedException&)
+ {
+ LogLog::debug(LOG4CXX_STR("Connector interrupted. Leaving loop."));
+ return NULL;
+ }
+ catch (ConnectException&)
+ {
+ LogLog::debug(LOG4CXX_STR("Remote host ")
+ + socketAppender->address->getHostName()
+ + LOG4CXX_STR(" refused connection."));
+ }
+ catch (IOException& e)
+ {
+ LogString exmsg;
+ log4cxx::helpers::Transcoder::decode(e.what(), exmsg);
+
+ LogLog::debug(((LogString) LOG4CXX_STR("Could not connect to "))
+ + socketAppender->address->getHostName()
+ + LOG4CXX_STR(". Exception is ")
+ + exmsg);
}
- LogLog::debug(LOG4CXX_STR("Exiting Connector.run() method."));
- return NULL;
+ isClosed = socketAppender->closed;
+ }
+
+ LogLog::debug(LOG4CXX_STR("Exiting Connector.run() method."));
+ return NULL;
}
diff --git a/src/main/cpp/sockethubappender.cpp b/src/main/cpp/sockethubappender.cpp
index b519fb0..1c7d3c6 100644
--- a/src/main/cpp/sockethubappender.cpp
+++ b/src/main/cpp/sockethubappender.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/net/sockethubappender.h>
@@ -45,195 +45,211 @@
SocketHubAppender::~SocketHubAppender()
{
- finalize();
+ finalize();
}
SocketHubAppender::SocketHubAppender()
- : port(DEFAULT_PORT), streams(), locationInfo(false), thread()
+ : port(DEFAULT_PORT), streams(), locationInfo(false), thread()
{
}
SocketHubAppender::SocketHubAppender(int port1)
- : port(port1), streams(), locationInfo(false), thread()
+ : port(port1), streams(), locationInfo(false), thread()
{
- startServer();
+ startServer();
}
void SocketHubAppender::activateOptions(Pool& /* p */ )
{
- startServer();
+ startServer();
}
void SocketHubAppender::setOption(const LogString& option,
- const LogString& value)
+ const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("PORT"), LOG4CXX_STR("port")))
- {
- setPort(OptionConverter::toInt(value, DEFAULT_PORT));
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo")))
- {
- setLocationInfo(OptionConverter::toBoolean(value, true));
- }
- else
- {
- AppenderSkeleton::setOption(option, value);
- }
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("PORT"), LOG4CXX_STR("port")))
+ {
+ setPort(OptionConverter::toInt(value, DEFAULT_PORT));
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo")))
+ {
+ setLocationInfo(OptionConverter::toBoolean(value, true));
+ }
+ else
+ {
+ AppenderSkeleton::setOption(option, value);
+ }
}
void SocketHubAppender::close()
{
+ {
+ LOCK_W sync(mutex);
+
+ if (closed)
{
- LOCK_W sync(mutex);
- if (closed) {
- return;
- }
- closed = true;
+ return;
}
- LogLog::debug(LOG4CXX_STR("closing SocketHubAppender ") + getName());
- //
- // wait until the server thread completes
- //
- thread.join();
+ closed = true;
+ }
- LOCK_W sync(mutex);
- // close all of the connections
- LogLog::debug(LOG4CXX_STR("closing client connections"));
- for (std::vector<helpers::ObjectOutputStreamPtr>::iterator iter = streams.begin();
- iter != streams.end();
- iter++) {
- if ( (*iter) != NULL) {
- try {
- (*iter)->close(pool);
- } catch(SocketException& e) {
- LogLog::error(LOG4CXX_STR("could not close socket: "), e);
- }
- }
- }
- streams.erase(streams.begin(), streams.end());
+ LogLog::debug(LOG4CXX_STR("closing SocketHubAppender ") + getName());
+ //
+ // wait until the server thread completes
+ //
+ thread.join();
+
+ LOCK_W sync(mutex);
+ // close all of the connections
+ LogLog::debug(LOG4CXX_STR("closing client connections"));
+
+ for (std::vector<helpers::ObjectOutputStreamPtr>::iterator iter = streams.begin();
+ iter != streams.end();
+ iter++)
+ {
+ if ( (*iter) != NULL)
+ {
+ try
+ {
+ (*iter)->close(pool);
+ }
+ catch (SocketException& e)
+ {
+ LogLog::error(LOG4CXX_STR("could not close socket: "), e);
+ }
+ }
+ }
+
+ streams.erase(streams.begin(), streams.end());
- LogLog::debug(LOG4CXX_STR("SocketHubAppender ")
- + getName() + LOG4CXX_STR(" closed"));
+ LogLog::debug(LOG4CXX_STR("SocketHubAppender ")
+ + getName() + LOG4CXX_STR(" closed"));
}
void SocketHubAppender::append(const spi::LoggingEventPtr& event, Pool& p)
{
- // if no open connections, exit now
- if(streams.empty())
+ // if no open connections, exit now
+ if (streams.empty())
+ {
+ return;
+ }
+
+ LogString ndcVal;
+ event->getNDC(ndcVal);
+ event->getThreadName();
+ // Get a copy of this thread's MDC.
+ event->getMDCCopy();
+
+
+ // loop through the current set of open connections, appending the event to each
+ std::vector<ObjectOutputStreamPtr>::iterator it = streams.begin();
+ std::vector<ObjectOutputStreamPtr>::iterator itEnd = streams.end();
+
+ while (it != itEnd)
+ {
+ // list size changed unexpectedly? Just exit the append.
+ if (*it == 0)
{
- return;
+ break;
}
- LogString ndcVal;
- event->getNDC(ndcVal);
- event->getThreadName();
- // Get a copy of this thread's MDC.
- event->getMDCCopy();
-
-
- // loop through the current set of open connections, appending the event to each
- std::vector<ObjectOutputStreamPtr>::iterator it = streams.begin();
- std::vector<ObjectOutputStreamPtr>::iterator itEnd = streams.end();
- while(it != itEnd)
+ try
{
- // list size changed unexpectedly? Just exit the append.
- if (*it == 0)
- {
- break;
- }
-
- try
- {
- event->write(**it, p);
- (*it)->flush(p);
- it++;
- }
- catch(std::exception& e)
- {
- // there was an io exception so just drop the connection
- it = streams.erase(it);
- itEnd = streams.end();
- LogLog::debug(LOG4CXX_STR("dropped connection"), e);
- }
+ event->write(**it, p);
+ (*it)->flush(p);
+ it++;
}
+ catch (std::exception& e)
+ {
+ // there was an io exception so just drop the connection
+ it = streams.erase(it);
+ itEnd = streams.end();
+ LogLog::debug(LOG4CXX_STR("dropped connection"), e);
+ }
+ }
}
void SocketHubAppender::startServer()
{
- thread.run(monitor, this);
+ thread.run(monitor, this);
}
-void* APR_THREAD_FUNC SocketHubAppender::monitor(apr_thread_t* /* thread */, void* data) {
- SocketHubAppender* pThis = (SocketHubAppender*) data;
+void* APR_THREAD_FUNC SocketHubAppender::monitor(apr_thread_t* /* thread */, void* data)
+{
+ SocketHubAppender* pThis = (SocketHubAppender*) data;
- ServerSocket* serverSocket = 0;
+ ServerSocket* serverSocket = 0;
+
+ try
+ {
+ serverSocket = new ServerSocket(pThis->port);
+ serverSocket->setSoTimeout(1000);
+ }
+ catch (SocketException& e)
+ {
+ LogLog::error(LOG4CXX_STR("exception setting timeout, shutting down server socket."), e);
+ delete serverSocket;
+ return NULL;
+ }
+
+ bool stopRunning = pThis->closed;
+
+ while (!stopRunning)
+ {
+ SocketPtr socket;
try
{
- serverSocket = new ServerSocket(pThis->port);
- serverSocket->setSoTimeout(1000);
+ socket = serverSocket->accept();
+ }
+ catch (InterruptedIOException&)
+ {
+ // timeout occurred, so just loop
}
catch (SocketException& e)
{
- LogLog::error(LOG4CXX_STR("exception setting timeout, shutting down server socket."), e);
- delete serverSocket;
- return NULL;
+ LogLog::error(LOG4CXX_STR("exception accepting socket, shutting down server socket."), e);
+ stopRunning = true;
}
-
- bool stopRunning = pThis->closed;
- while (!stopRunning)
+ catch (IOException& e)
{
- SocketPtr socket;
- try
- {
- socket = serverSocket->accept();
- }
- catch (InterruptedIOException&)
- {
- // timeout occurred, so just loop
- }
- catch (SocketException& e)
- {
- LogLog::error(LOG4CXX_STR("exception accepting socket, shutting down server socket."), e);
- stopRunning = true;
- }
- catch (IOException& e)
- {
- LogLog::error(LOG4CXX_STR("exception accepting socket."), e);
- }
-
- // if there was a socket accepted
- if (socket != 0)
- {
- try
- {
- InetAddressPtr remoteAddress = socket->getInetAddress();
- LogLog::debug(LOG4CXX_STR("accepting connection from ")
- + remoteAddress->getHostName()
- + LOG4CXX_STR(" (")
- + remoteAddress->getHostAddress()
- + LOG4CXX_STR(")"));
-
- // add it to the oosList.
- LOCK_W sync(pThis->mutex);
- OutputStreamPtr os(new SocketOutputStream(socket));
- Pool p;
- ObjectOutputStreamPtr oos(new ObjectOutputStream(os, p));
- pThis->streams.push_back(oos);
- }
- catch (IOException& e)
- {
- LogLog::error(LOG4CXX_STR("exception creating output stream on socket."), e);
- }
- }
- stopRunning = (stopRunning || pThis->closed);
+ LogLog::error(LOG4CXX_STR("exception accepting socket."), e);
}
- delete serverSocket;
- return NULL;
+
+ // if there was a socket accepted
+ if (socket != 0)
+ {
+ try
+ {
+ InetAddressPtr remoteAddress = socket->getInetAddress();
+ LogLog::debug(LOG4CXX_STR("accepting connection from ")
+ + remoteAddress->getHostName()
+ + LOG4CXX_STR(" (")
+ + remoteAddress->getHostAddress()
+ + LOG4CXX_STR(")"));
+
+ // add it to the oosList.
+ LOCK_W sync(pThis->mutex);
+ OutputStreamPtr os(new SocketOutputStream(socket));
+ Pool p;
+ ObjectOutputStreamPtr oos(new ObjectOutputStream(os, p));
+ pThis->streams.push_back(oos);
+ }
+ catch (IOException& e)
+ {
+ LogLog::error(LOG4CXX_STR("exception creating output stream on socket."), e);
+ }
+ }
+
+ stopRunning = (stopRunning || pThis->closed);
+ }
+
+ delete serverSocket;
+ return NULL;
}
#endif
diff --git a/src/main/cpp/socketoutputstream.cpp b/src/main/cpp/socketoutputstream.cpp
index 7c1e449..bf19ebe 100644
--- a/src/main/cpp/socketoutputstream.cpp
+++ b/src/main/cpp/socketoutputstream.cpp
@@ -29,32 +29,39 @@
IMPLEMENT_LOG4CXX_OBJECT(SocketOutputStream)
SocketOutputStream::SocketOutputStream(const SocketPtr& socket1)
-: socket(socket1) {
+ : socket(socket1)
+{
}
-SocketOutputStream::~SocketOutputStream() {
+SocketOutputStream::~SocketOutputStream()
+{
}
-void SocketOutputStream::close(Pool& p) {
+void SocketOutputStream::close(Pool& p)
+{
flush(p);
socket->close();
}
-void SocketOutputStream::flush(Pool& /* p */) {
- if (array.size() > 0) {
- ByteBuffer buf((char*) &array[0], array.size());
- socket->write(buf);
- array.resize(0);
- }
+void SocketOutputStream::flush(Pool& /* p */)
+{
+ if (array.size() > 0)
+ {
+ ByteBuffer buf((char*) &array[0], array.size());
+ socket->write(buf);
+ array.resize(0);
+ }
}
-void SocketOutputStream::write(ByteBuffer& buf, Pool& /* p */ ) {
- if (buf.remaining() > 0) {
- size_t sz = array.size();
- array.resize(sz + buf.remaining());
- memcpy(&array[sz], buf.current(), buf.remaining());
- buf.position(buf.limit());
- }
+void SocketOutputStream::write(ByteBuffer& buf, Pool& /* p */ )
+{
+ if (buf.remaining() > 0)
+ {
+ size_t sz = array.size();
+ array.resize(sz + buf.remaining());
+ memcpy(&array[sz], buf.current(), buf.remaining());
+ buf.position(buf.limit());
+ }
}
diff --git a/src/main/cpp/strftimedateformat.cpp b/src/main/cpp/strftimedateformat.cpp
index 120f60b..a8bf3c0 100644
--- a/src/main/cpp/strftimedateformat.cpp
+++ b/src/main/cpp/strftimedateformat.cpp
@@ -26,30 +26,38 @@
StrftimeDateFormat::StrftimeDateFormat(const LogString& fmt)
- : timeZone(TimeZone::getDefault()) {
+ : timeZone(TimeZone::getDefault())
+{
log4cxx::helpers::Transcoder::encode(fmt, pattern);
}
-StrftimeDateFormat::~StrftimeDateFormat() {
+StrftimeDateFormat::~StrftimeDateFormat()
+{
}
-void StrftimeDateFormat::format(LogString& s, log4cxx_time_t time, Pool& /* p */ ) const {
- apr_time_exp_t exploded;
- apr_status_t stat = timeZone->explode(&exploded, time);
- if (stat == APR_SUCCESS) {
- const apr_size_t bufSize = 255;
- char buf[bufSize];
- apr_size_t bufLen;
- stat = apr_strftime(buf, &bufLen, bufSize, pattern.c_str(), &exploded);
- if (stat == APR_SUCCESS) {
- log4cxx::helpers::Transcoder::decode(std::string(buf, bufLen), s);
+void StrftimeDateFormat::format(LogString& s, log4cxx_time_t time, Pool& /* p */ ) const
+{
+ apr_time_exp_t exploded;
+ apr_status_t stat = timeZone->explode(&exploded, time);
+
+ if (stat == APR_SUCCESS)
+ {
+ const apr_size_t bufSize = 255;
+ char buf[bufSize];
+ apr_size_t bufLen;
+ stat = apr_strftime(buf, &bufLen, bufSize, pattern.c_str(), &exploded);
+
+ if (stat == APR_SUCCESS)
+ {
+ log4cxx::helpers::Transcoder::decode(std::string(buf, bufLen), s);
+ }
}
- }
}
-void StrftimeDateFormat::setTimeZone(const TimeZonePtr& zone) {
- timeZone = zone;
+void StrftimeDateFormat::setTimeZone(const TimeZonePtr& zone)
+{
+ timeZone = zone;
}
diff --git a/src/main/cpp/stringhelper.cpp b/src/main/cpp/stringhelper.cpp
index bbd5fe2..4964d32 100644
--- a/src/main/cpp/stringhelper.cpp
+++ b/src/main/cpp/stringhelper.cpp
@@ -24,7 +24,7 @@
#include <apr_strings.h>
#include <log4cxx/helpers/pool.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
#include <cctype>
@@ -32,61 +32,75 @@
#include <apr.h>
//LOG4CXX-417: need stdlib.h for atoi on some systems.
#ifdef APR_HAVE_STDLIB_H
-#include <stdlib.h>
+ #include <stdlib.h>
#endif
using namespace log4cxx;
using namespace log4cxx::helpers;
-bool StringHelper::equalsIgnoreCase(const LogString& s1, const logchar* upper, const logchar* lower) {
- for (LogString::const_iterator iter = s1.begin();
- iter != s1.end();
- iter++, upper++, lower++) {
- if (*iter != *upper && *iter != * lower) return false;
- }
- return (*upper == 0);
+bool StringHelper::equalsIgnoreCase(const LogString& s1, const logchar* upper, const logchar* lower)
+{
+ for (LogString::const_iterator iter = s1.begin();
+ iter != s1.end();
+ iter++, upper++, lower++)
+ {
+ if (*iter != *upper && *iter != * lower)
+ {
+ return false;
+ }
+ }
+
+ return (*upper == 0);
}
-bool StringHelper::equalsIgnoreCase(const LogString& s1, const LogString& upper, const LogString& lower) {
- LogString::const_iterator u = upper.begin();
- LogString::const_iterator l = lower.begin();
- LogString::const_iterator iter = s1.begin();
- for (;
- iter != s1.end() && u != upper.end() && l != lower.end();
- iter++, u++, l++) {
- if (*iter != *u && *iter != *l) return false;
- }
- return u == upper.end() && iter == s1.end();
+bool StringHelper::equalsIgnoreCase(const LogString& s1, const LogString& upper, const LogString& lower)
+{
+ LogString::const_iterator u = upper.begin();
+ LogString::const_iterator l = lower.begin();
+ LogString::const_iterator iter = s1.begin();
+
+ for (;
+ iter != s1.end() && u != upper.end() && l != lower.end();
+ iter++, u++, l++)
+ {
+ if (*iter != *u && *iter != *l)
+ {
+ return false;
+ }
+ }
+
+ return u == upper.end() && iter == s1.end();
}
LogString StringHelper::toLowerCase(const LogString& s)
{
- LogString d;
- std::transform(s.begin(), s.end(),
- std::insert_iterator<LogString>(d, d.begin()), tolower);
- return d;
+ LogString d;
+ std::transform(s.begin(), s.end(),
+ std::insert_iterator<LogString>(d, d.begin()), tolower);
+ return d;
}
LogString StringHelper::trim(const LogString& s)
{
- LogString::size_type pos = s.find_first_not_of(' ');
- if (pos == std::string::npos)
- {
- return LogString();
- }
+ LogString::size_type pos = s.find_first_not_of(' ');
- LogString::size_type n = s.find_last_not_of(' ') - pos + 1;
- return s.substr(pos, n);
+ if (pos == std::string::npos)
+ {
+ return LogString();
+ }
+
+ LogString::size_type n = s.find_last_not_of(' ') - pos + 1;
+ return s.substr(pos, n);
}
bool StringHelper::startsWith(const LogString& s, const LogString& prefix)
{
if (s.length() < prefix.length())
{
- return false;
+ return false;
}
return s.compare(0, prefix.length(), prefix) == 0;
@@ -94,76 +108,101 @@
bool StringHelper::endsWith(const LogString& s, const LogString& suffix)
{
- if (suffix.length() <= s.length()) {
- return s.compare(s.length() - suffix.length(), suffix.length(), suffix) == 0;
+ if (suffix.length() <= s.length())
+ {
+ return s.compare(s.length() - suffix.length(), suffix.length(), suffix) == 0;
}
+
return false;
}
-int StringHelper::toInt(const LogString& s) {
+int StringHelper::toInt(const LogString& s)
+{
std::string as;
Transcoder::encode(s, as);
return atoi(as.c_str());
}
-log4cxx_int64_t StringHelper::toInt64(const LogString& s) {
+log4cxx_int64_t StringHelper::toInt64(const LogString& s)
+{
std::string as;
Transcoder::encode(s, as);
return apr_atoi64(as.c_str());
}
-void StringHelper::toString(int n, Pool& pool, LogString& s) {
- char* fmt = pool.itoa(n);
- Transcoder::decode(fmt, s);
+void StringHelper::toString(int n, Pool& pool, LogString& s)
+{
+ char* fmt = pool.itoa(n);
+ Transcoder::decode(fmt, s);
}
-void StringHelper::toString(bool val, LogString& dst) {
- if (val) {
- dst.append(LOG4CXX_STR("true"));
- } else {
- dst.append(LOG4CXX_STR("false"));
- }
-}
-
-
-void StringHelper::toString(log4cxx_int64_t n, Pool& pool, LogString& dst) {
- if (n >= INT_MIN && n <= INT_MAX) {
- toString((int) n, pool, dst);
- } else {
- const log4cxx_int64_t BILLION = APR_INT64_C(1000000000);
- int billions = (int) (n / BILLION);
- char* upper = pool.itoa(billions);
- int remain = (int) (n - billions * BILLION);
- if (remain < 0) remain *= -1;
- char* lower = pool.itoa(remain);
- Transcoder::decode(upper, dst);
- dst.append(9 - strlen(lower), 0x30 /* '0' */);
- Transcoder::decode(lower, dst);
- }
-}
-
-
-void StringHelper::toString(size_t n, Pool& pool, LogString& s) {
- toString((log4cxx_int64_t) n, pool, s);
-}
-
-LogString StringHelper::format(const LogString& pattern, const std::vector<LogString>& params) {
-
- LogString result;
- int i = 0;
- while(pattern[i] != 0) {
- if (pattern[i] == 0x7B /* '{' */ && pattern[i + 1] >= 0x30 /* '0' */ &&
- pattern[i + 1] <= 0x39 /* '9' */ && pattern[i + 2] == 0x7D /* '}' */) {
- int arg = pattern[i + 1] - 0x30 /* '0' */;
- result = result + params[arg];
- i += 3;
- } else {
- result = result + pattern[i];
- i++;
+void StringHelper::toString(bool val, LogString& dst)
+{
+ if (val)
+ {
+ dst.append(LOG4CXX_STR("true"));
}
- }
+ else
+ {
+ dst.append(LOG4CXX_STR("false"));
+ }
+}
- return result;
+
+void StringHelper::toString(log4cxx_int64_t n, Pool& pool, LogString& dst)
+{
+ if (n >= INT_MIN && n <= INT_MAX)
+ {
+ toString((int) n, pool, dst);
+ }
+ else
+ {
+ const log4cxx_int64_t BILLION = APR_INT64_C(1000000000);
+ int billions = (int) (n / BILLION);
+ char* upper = pool.itoa(billions);
+ int remain = (int) (n - billions * BILLION);
+
+ if (remain < 0)
+ {
+ remain *= -1;
+ }
+
+ char* lower = pool.itoa(remain);
+ Transcoder::decode(upper, dst);
+ dst.append(9 - strlen(lower), 0x30 /* '0' */);
+ Transcoder::decode(lower, dst);
+ }
+}
+
+
+void StringHelper::toString(size_t n, Pool& pool, LogString& s)
+{
+ toString((log4cxx_int64_t) n, pool, s);
+}
+
+LogString StringHelper::format(const LogString& pattern, const std::vector<LogString>& params)
+{
+
+ LogString result;
+ int i = 0;
+
+ while (pattern[i] != 0)
+ {
+ if (pattern[i] == 0x7B /* '{' */ && pattern[i + 1] >= 0x30 /* '0' */ &&
+ pattern[i + 1] <= 0x39 /* '9' */ && pattern[i + 2] == 0x7D /* '}' */)
+ {
+ int arg = pattern[i + 1] - 0x30 /* '0' */;
+ result = result + params[arg];
+ i += 3;
+ }
+ else
+ {
+ result = result + pattern[i];
+ i++;
+ }
+ }
+
+ return result;
}
diff --git a/src/main/cpp/stringmatchfilter.cpp b/src/main/cpp/stringmatchfilter.cpp
index 96f1d9b..de8c006 100644
--- a/src/main/cpp/stringmatchfilter.cpp
+++ b/src/main/cpp/stringmatchfilter.cpp
@@ -29,52 +29,53 @@
IMPLEMENT_LOG4CXX_OBJECT(StringMatchFilter)
StringMatchFilter::StringMatchFilter() :
- acceptOnMatch(true),
- stringToMatch()
+ acceptOnMatch(true),
+ stringToMatch()
{
}
void StringMatchFilter::setOption(const LogString& option,
- const LogString& value)
+ const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("STRINGTOMATCH"), LOG4CXX_STR("stringtomatch")))
- {
- stringToMatch = value;
- }
- else if (StringHelper::equalsIgnoreCase(option,
- LOG4CXX_STR("ACCEPTONMATCH"), LOG4CXX_STR("acceptonmatch")))
- {
- acceptOnMatch = OptionConverter::toBoolean(value, acceptOnMatch);
- }
+ if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("STRINGTOMATCH"), LOG4CXX_STR("stringtomatch")))
+ {
+ stringToMatch = value;
+ }
+ else if (StringHelper::equalsIgnoreCase(option,
+ LOG4CXX_STR("ACCEPTONMATCH"), LOG4CXX_STR("acceptonmatch")))
+ {
+ acceptOnMatch = OptionConverter::toBoolean(value, acceptOnMatch);
+ }
}
Filter::FilterDecision StringMatchFilter::decide(
- const log4cxx::spi::LoggingEventPtr& event) const
+ const log4cxx::spi::LoggingEventPtr& event) const
{
- const LogString& msg = event->getRenderedMessage();
+ const LogString& msg = event->getRenderedMessage();
- if(msg.empty() || stringToMatch.empty())
- {
- return Filter::NEUTRAL;
- }
+ if (msg.empty() || stringToMatch.empty())
+ {
+ return Filter::NEUTRAL;
+ }
- if( msg.find(stringToMatch) == LogString::npos )
- {
- return Filter::NEUTRAL;
- }
- else
- { // we've got a match
- if(acceptOnMatch)
- {
- return Filter::ACCEPT;
- }
- else
- {
- return Filter::DENY;
- }
- }
+ if ( msg.find(stringToMatch) == LogString::npos )
+ {
+ return Filter::NEUTRAL;
+ }
+ else
+ {
+ // we've got a match
+ if (acceptOnMatch)
+ {
+ return Filter::ACCEPT;
+ }
+ else
+ {
+ return Filter::DENY;
+ }
+ }
}
diff --git a/src/main/cpp/stringtokenizer.cpp b/src/main/cpp/stringtokenizer.cpp
index 3f015e5..18880cb 100644
--- a/src/main/cpp/stringtokenizer.cpp
+++ b/src/main/cpp/stringtokenizer.cpp
@@ -19,7 +19,7 @@
#include <log4cxx/helpers/stringtokenizer.h>
#include <log4cxx/helpers/exception.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
@@ -27,7 +27,7 @@
using namespace log4cxx::helpers;
StringTokenizer::StringTokenizer(const LogString& str, const LogString& delim1)
-: src(str), delim(delim1), pos(0)
+ : src(str), delim(delim1), pos(0)
{
}
@@ -37,24 +37,31 @@
bool StringTokenizer::hasMoreTokens() const
{
- return (pos != LogString::npos
+ return (pos != LogString::npos
&& src.find_first_not_of(delim, pos) != LogString::npos);
}
LogString StringTokenizer::nextToken()
{
- if (pos != LogString::npos) {
- size_t nextPos = src.find_first_not_of(delim, pos);
- if (nextPos != LogString::npos) {
- pos = src.find_first_of(delim, nextPos);
- if (pos == LogString::npos) {
- return src.substr(nextPos);
- }
- return src.substr(nextPos, pos - nextPos);
+ if (pos != LogString::npos)
+ {
+ size_t nextPos = src.find_first_not_of(delim, pos);
+
+ if (nextPos != LogString::npos)
+ {
+ pos = src.find_first_of(delim, nextPos);
+
+ if (pos == LogString::npos)
+ {
+ return src.substr(nextPos);
}
+
+ return src.substr(nextPos, pos - nextPos);
}
- throw NoSuchElementException();
+ }
+
+ throw NoSuchElementException();
#if LOG4CXX_RETURN_AFTER_THROW
- return LogString();
+ return LogString();
#endif
}
diff --git a/src/main/cpp/synchronized.cpp b/src/main/cpp/synchronized.cpp
index a732c7f..7939c9c 100644
--- a/src/main/cpp/synchronized.cpp
+++ b/src/main/cpp/synchronized.cpp
@@ -26,62 +26,71 @@
using namespace log4cxx;
synchronized::synchronized(const Mutex& mutex1)
-: mutex(mutex1.getAPRMutex())
+ : 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);
- }
+ 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)
+ : 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);
- }
+ 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);
- }
+ 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(mutex1)
{
- mutex.rdLock();
+ mutex.rdLock();
}
synchronized_read::~synchronized_read()
{
- mutex.rdUnlock();
+ mutex.rdUnlock();
}
synchronized_write::synchronized_write(const RWMutex& mutex1)
- : mutex(mutex1)
+ : mutex(mutex1)
{
- mutex.wrLock();
+ mutex.wrLock();
}
synchronized_write::~synchronized_write()
{
- mutex.wrUnlock();
+ mutex.wrUnlock();
}
#endif // RW_MUTEX
diff --git a/src/main/cpp/syslogappender.cpp b/src/main/cpp/syslogappender.cpp
index a50f6c5..abf7998 100644
--- a/src/main/cpp/syslogappender.cpp
+++ b/src/main/cpp/syslogappender.cpp
@@ -23,36 +23,36 @@
#include <log4cxx/level.h>
#include <log4cxx/helpers/transcoder.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
#if LOG4CXX_HAVE_SYSLOG
-#include <syslog.h>
+ #include <syslog.h>
#else
- /* facility codes */
- #define LOG_KERN (0<<3) /* kernel messages */
- #define LOG_USER (1<<3) /* random user-level messages */
- #define LOG_MAIL (2<<3) /* mail system */
- #define LOG_DAEMON (3<<3) /* system daemons */
- #define LOG_AUTH (4<<3) /* security/authorization messages */
- #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
- #define LOG_LPR (6<<3) /* line printer subsystem */
- #define LOG_NEWS (7<<3) /* network news subsystem */
- #define LOG_UUCP (8<<3) /* UUCP subsystem */
- #define LOG_CRON (9<<3) /* clock daemon */
- #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
- #define LOG_FTP (11<<3) /* ftp daemon */
+ /* facility codes */
+ #define LOG_KERN (0<<3) /* kernel messages */
+ #define LOG_USER (1<<3) /* random user-level messages */
+ #define LOG_MAIL (2<<3) /* mail system */
+ #define LOG_DAEMON (3<<3) /* system daemons */
+ #define LOG_AUTH (4<<3) /* security/authorization messages */
+ #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
+ #define LOG_LPR (6<<3) /* line printer subsystem */
+ #define LOG_NEWS (7<<3) /* network news subsystem */
+ #define LOG_UUCP (8<<3) /* UUCP subsystem */
+ #define LOG_CRON (9<<3) /* clock daemon */
+ #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
+ #define LOG_FTP (11<<3) /* ftp daemon */
- /* other codes through 15 reserved for system use */
- #define LOG_LOCAL0 (16<<3) /* reserved for local use */
- #define LOG_LOCAL1 (17<<3) /* reserved for local use */
- #define LOG_LOCAL2 (18<<3) /* reserved for local use */
- #define LOG_LOCAL3 (19<<3) /* reserved for local use */
- #define LOG_LOCAL4 (20<<3) /* reserved for local use */
- #define LOG_LOCAL5 (21<<3) /* reserved for local use */
- #define LOG_LOCAL6 (22<<3) /* reserved for local use */
- #define LOG_LOCAL7 (23<<3) /* reserved for local use */
+ /* other codes through 15 reserved for system use */
+ #define LOG_LOCAL0 (16<<3) /* reserved for local use */
+ #define LOG_LOCAL1 (17<<3) /* reserved for local use */
+ #define LOG_LOCAL2 (18<<3) /* reserved for local use */
+ #define LOG_LOCAL3 (19<<3) /* reserved for local use */
+ #define LOG_LOCAL4 (20<<3) /* reserved for local use */
+ #define LOG_LOCAL5 (21<<3) /* reserved for local use */
+ #define LOG_LOCAL6 (22<<3) /* reserved for local use */
+ #define LOG_LOCAL7 (23<<3) /* reserved for local use */
#endif
#define LOG_UNDEF -1
@@ -64,63 +64,64 @@
IMPLEMENT_LOG4CXX_OBJECT(SyslogAppender)
SyslogAppender::SyslogAppender()
-: syslogFacility(LOG_USER), facilityPrinting(false), sw(0)
+ : syslogFacility(LOG_USER), facilityPrinting(false), sw(0)
{
- this->initSyslogFacilityStr();
+ this->initSyslogFacilityStr();
}
SyslogAppender::SyslogAppender(const LayoutPtr& layout1,
- int syslogFacility1)
-: syslogFacility(syslogFacility1), facilityPrinting(false), sw(0)
+ int syslogFacility1)
+ : syslogFacility(syslogFacility1), facilityPrinting(false), sw(0)
{
- this->layout = layout1;
- this->initSyslogFacilityStr();
+ this->layout = layout1;
+ this->initSyslogFacilityStr();
}
SyslogAppender::SyslogAppender(const LayoutPtr& layout1,
- const LogString& syslogHost1, int syslogFacility1)
-: syslogFacility(syslogFacility1), facilityPrinting(false), sw(0)
+ const LogString& syslogHost1, int syslogFacility1)
+ : syslogFacility(syslogFacility1), facilityPrinting(false), sw(0)
{
- this->layout = layout1;
- this->initSyslogFacilityStr();
- setSyslogHost(syslogHost1);
+ this->layout = layout1;
+ this->initSyslogFacilityStr();
+ setSyslogHost(syslogHost1);
}
SyslogAppender::~SyslogAppender()
{
- finalize();
+ finalize();
}
/** Release any resources held by this SyslogAppender.*/
void SyslogAppender::close()
{
- closed = true;
- if (sw != 0)
- {
- delete sw;
- sw = 0;
- }
+ closed = true;
+
+ if (sw != 0)
+ {
+ delete sw;
+ sw = 0;
+ }
}
void SyslogAppender::initSyslogFacilityStr()
{
- facilityStr = getFacilityString(this->syslogFacility);
+ facilityStr = getFacilityString(this->syslogFacility);
- if (facilityStr.empty())
- {
- Pool p;
- LogString msg(LOG4CXX_STR("\""));
- StringHelper::toString(syslogFacility, p, msg);
- msg.append(LOG4CXX_STR("\" is an unknown syslog facility. Defaulting to \"USER\"."));
- LogLog::error(msg);
- this->syslogFacility = LOG_USER;
- facilityStr = LOG4CXX_STR("user:");
- }
- else
- {
- facilityStr += LOG4CXX_STR(":");
- }
+ if (facilityStr.empty())
+ {
+ Pool p;
+ LogString msg(LOG4CXX_STR("\""));
+ StringHelper::toString(syslogFacility, p, msg);
+ msg.append(LOG4CXX_STR("\" is an unknown syslog facility. Defaulting to \"USER\"."));
+ LogLog::error(msg);
+ this->syslogFacility = LOG_USER;
+ facilityStr = LOG4CXX_STR("user:");
+ }
+ else
+ {
+ facilityStr += LOG4CXX_STR(":");
+ }
}
/**
@@ -128,172 +129,222 @@
e.g. "kern", "user", etc.
*/
LogString SyslogAppender::getFacilityString(
- int syslogFacility)
+ int syslogFacility)
{
- switch(syslogFacility)
- {
- case LOG_KERN: return LOG4CXX_STR("kern");
- case LOG_USER: return LOG4CXX_STR("user");
- case LOG_MAIL: return LOG4CXX_STR("mail");
- case LOG_DAEMON: return LOG4CXX_STR("daemon");
- case LOG_AUTH: return LOG4CXX_STR("auth");
- case LOG_SYSLOG: return LOG4CXX_STR("syslog");
- case LOG_LPR: return LOG4CXX_STR("lpr");
- case LOG_NEWS: return LOG4CXX_STR("news");
- case LOG_UUCP: return LOG4CXX_STR("uucp");
- case LOG_CRON: return LOG4CXX_STR("cron");
+ switch (syslogFacility)
+ {
+ case LOG_KERN:
+ return LOG4CXX_STR("kern");
+
+ case LOG_USER:
+ return LOG4CXX_STR("user");
+
+ case LOG_MAIL:
+ return LOG4CXX_STR("mail");
+
+ case LOG_DAEMON:
+ return LOG4CXX_STR("daemon");
+
+ case LOG_AUTH:
+ return LOG4CXX_STR("auth");
+
+ case LOG_SYSLOG:
+ return LOG4CXX_STR("syslog");
+
+ case LOG_LPR:
+ return LOG4CXX_STR("lpr");
+
+ case LOG_NEWS:
+ return LOG4CXX_STR("news");
+
+ case LOG_UUCP:
+ return LOG4CXX_STR("uucp");
+
+ case LOG_CRON:
+ return LOG4CXX_STR("cron");
#ifdef LOG_AUTHPRIV
- case LOG_AUTHPRIV: return LOG4CXX_STR("authpriv");
+
+ case LOG_AUTHPRIV:
+ return LOG4CXX_STR("authpriv");
#endif
#ifdef LOG_FTP
- case LOG_FTP: return LOG4CXX_STR("ftp");
+
+ case LOG_FTP:
+ return LOG4CXX_STR("ftp");
#endif
- case LOG_LOCAL0: return LOG4CXX_STR("local0");
- case LOG_LOCAL1: return LOG4CXX_STR("local1");
- case LOG_LOCAL2: return LOG4CXX_STR("local2");
- case LOG_LOCAL3: return LOG4CXX_STR("local3");
- case LOG_LOCAL4: return LOG4CXX_STR("local4");
- case LOG_LOCAL5: return LOG4CXX_STR("local5");
- case LOG_LOCAL6: return LOG4CXX_STR("local6");
- case LOG_LOCAL7: return LOG4CXX_STR("local7");
- default: return LogString();
- }
+
+ case LOG_LOCAL0:
+ return LOG4CXX_STR("local0");
+
+ case LOG_LOCAL1:
+ return LOG4CXX_STR("local1");
+
+ case LOG_LOCAL2:
+ return LOG4CXX_STR("local2");
+
+ case LOG_LOCAL3:
+ return LOG4CXX_STR("local3");
+
+ case LOG_LOCAL4:
+ return LOG4CXX_STR("local4");
+
+ case LOG_LOCAL5:
+ return LOG4CXX_STR("local5");
+
+ case LOG_LOCAL6:
+ return LOG4CXX_STR("local6");
+
+ case LOG_LOCAL7:
+ return LOG4CXX_STR("local7");
+
+ default:
+ return LogString();
+ }
}
int SyslogAppender::getFacility(
- const LogString& s)
+ const LogString& s)
{
- if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("KERN"), LOG4CXX_STR("kern")))
- {
- return LOG_KERN;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("USER"), LOG4CXX_STR("user")))
- {
- return LOG_USER;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("MAIL"), LOG4CXX_STR("mail")))
- {
- return LOG_MAIL;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("DAEMON"), LOG4CXX_STR("daemon")))
- {
- return LOG_DAEMON;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("AUTH"), LOG4CXX_STR("auth")))
- {
- return LOG_AUTH;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("SYSLOG"), LOG4CXX_STR("syslog")))
- {
- return LOG_SYSLOG;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LPR"), LOG4CXX_STR("lpr")))
- {
- return LOG_LPR;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("NEWS"), LOG4CXX_STR("news")))
- {
- return LOG_NEWS;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("UUCP"), LOG4CXX_STR("uucp")))
- {
- return LOG_UUCP;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("CRON"), LOG4CXX_STR("cron")))
- {
- return LOG_CRON;
- }
+ if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("KERN"), LOG4CXX_STR("kern")))
+ {
+ return LOG_KERN;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("USER"), LOG4CXX_STR("user")))
+ {
+ return LOG_USER;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("MAIL"), LOG4CXX_STR("mail")))
+ {
+ return LOG_MAIL;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("DAEMON"), LOG4CXX_STR("daemon")))
+ {
+ return LOG_DAEMON;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("AUTH"), LOG4CXX_STR("auth")))
+ {
+ return LOG_AUTH;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("SYSLOG"), LOG4CXX_STR("syslog")))
+ {
+ return LOG_SYSLOG;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LPR"), LOG4CXX_STR("lpr")))
+ {
+ return LOG_LPR;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("NEWS"), LOG4CXX_STR("news")))
+ {
+ return LOG_NEWS;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("UUCP"), LOG4CXX_STR("uucp")))
+ {
+ return LOG_UUCP;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("CRON"), LOG4CXX_STR("cron")))
+ {
+ return LOG_CRON;
+ }
+
#ifdef LOG_AUTHPRIV
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("AUTHPRIV"), LOG4CXX_STR("authpriv")))
- {
- return LOG_AUTHPRIV;
- }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("AUTHPRIV"), LOG4CXX_STR("authpriv")))
+ {
+ return LOG_AUTHPRIV;
+ }
+
#endif
#ifdef LOG_FTP
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("FTP"), LOG4CXX_STR("ftp")))
- {
- return LOG_FTP;
- }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("FTP"), LOG4CXX_STR("ftp")))
+ {
+ return LOG_FTP;
+ }
+
#endif
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL0"), LOG4CXX_STR("local0")))
- {
- return LOG_LOCAL0;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL1"), LOG4CXX_STR("local1")))
- {
- return LOG_LOCAL1;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL2"), LOG4CXX_STR("local2")))
- {
- return LOG_LOCAL2;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL3"), LOG4CXX_STR("local3")))
- {
- return LOG_LOCAL3;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL4"), LOG4CXX_STR("local4")))
- {
- return LOG_LOCAL4;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL5"), LOG4CXX_STR("local5")))
- {
- return LOG_LOCAL5;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL6"), LOG4CXX_STR("local6")))
- {
- return LOG_LOCAL6;
- }
- else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL7"), LOG4CXX_STR("local7")))
- {
- return LOG_LOCAL7;
- }
- else
- {
- return LOG_UNDEF;
- }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL0"), LOG4CXX_STR("local0")))
+ {
+ return LOG_LOCAL0;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL1"), LOG4CXX_STR("local1")))
+ {
+ return LOG_LOCAL1;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL2"), LOG4CXX_STR("local2")))
+ {
+ return LOG_LOCAL2;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL3"), LOG4CXX_STR("local3")))
+ {
+ return LOG_LOCAL3;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL4"), LOG4CXX_STR("local4")))
+ {
+ return LOG_LOCAL4;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL5"), LOG4CXX_STR("local5")))
+ {
+ return LOG_LOCAL5;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL6"), LOG4CXX_STR("local6")))
+ {
+ return LOG_LOCAL6;
+ }
+ else if (StringHelper::equalsIgnoreCase(s, LOG4CXX_STR("LOCAL7"), LOG4CXX_STR("local7")))
+ {
+ return LOG_LOCAL7;
+ }
+ else
+ {
+ return LOG_UNDEF;
+ }
}
void SyslogAppender::append(const spi::LoggingEventPtr& event, Pool& p)
{
- if (!isAsSevereAsThreshold(event->getLevel()))
- return;
+ if (!isAsSevereAsThreshold(event->getLevel()))
+ {
+ return;
+ }
- LogString msg;
- layout->format(msg, event, p);
+ LogString msg;
+ layout->format(msg, event, p);
-// On the local host, we can directly use the system function 'syslog'
-// if it is available
+ // On the local host, we can directly use the system function 'syslog'
+ // if it is available
#if LOG4CXX_HAVE_SYSLOG
- if (sw == 0)
- {
- std::string sbuf;
- Transcoder::encode(msg, sbuf);
- // use of "%s" to avoid a security hole
- ::syslog(syslogFacility | event->getLevel()->getSyslogEquivalent(),
- "%s", sbuf.c_str());
+ if (sw == 0)
+ {
+ std::string sbuf;
+ Transcoder::encode(msg, sbuf);
- return;
- }
+ // use of "%s" to avoid a security hole
+ ::syslog(syslogFacility | event->getLevel()->getSyslogEquivalent(),
+ "%s", sbuf.c_str());
+
+ return;
+ }
+
#endif
- // We must not attempt to append if sw is null.
- if(sw == 0)
- {
- errorHandler->error(LOG4CXX_STR("No syslog host is set for SyslogAppedender named \"")+
- this->name+LOG4CXX_STR("\"."));
- return;
- }
+ // We must not attempt to append if sw is null.
+ if (sw == 0)
+ {
+ errorHandler->error(LOG4CXX_STR("No syslog host is set for SyslogAppedender named \"") +
+ this->name + LOG4CXX_STR("\"."));
+ return;
+ }
- LogString sbuf(1, 0x3C /* '<' */);
- StringHelper::toString((syslogFacility | event->getLevel()->getSyslogEquivalent()), p, sbuf);
- sbuf.append(1, (logchar) 0x3E /* '>' */);
- if (facilityPrinting)
- {
- sbuf.append(facilityStr);
- }
- sbuf.append(msg);
- sw->write(sbuf);
+ LogString sbuf(1, 0x3C /* '<' */);
+ StringHelper::toString((syslogFacility | event->getLevel()->getSyslogEquivalent()), p, sbuf);
+ sbuf.append(1, (logchar) 0x3E /* '>' */);
+
+ if (facilityPrinting)
+ {
+ sbuf.append(facilityStr);
+ }
+
+ sbuf.append(msg);
+ sw->write(sbuf);
}
void SyslogAppender::activateOptions(Pool&)
@@ -302,68 +353,78 @@
void SyslogAppender::setOption(const LogString& option, const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SYSLOGHOST"), LOG4CXX_STR("sysloghost")))
- {
- setSyslogHost(value);
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("FACILITY"), LOG4CXX_STR("facility")))
- {
- setFacility(value);
- }
- else
- {
- AppenderSkeleton::setOption(option, value);
- }
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("SYSLOGHOST"), LOG4CXX_STR("sysloghost")))
+ {
+ setSyslogHost(value);
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("FACILITY"), LOG4CXX_STR("facility")))
+ {
+ setFacility(value);
+ }
+ else
+ {
+ AppenderSkeleton::setOption(option, value);
+ }
}
void SyslogAppender::setSyslogHost(const LogString& syslogHost1)
{
- if (this->sw != 0)
- {
- delete this->sw;
- this->sw = 0;
- }
- LogString slHost = syslogHost1;
- int slHostPort = -1;
+ if (this->sw != 0)
+ {
+ delete this->sw;
+ this->sw = 0;
+ }
- LogString::size_type colonPos = 0;
- colonPos = slHost.rfind(':');
- if (colonPos != LogString::npos)
- {
- slHostPort = StringHelper::toInt(slHost.substr(colonPos+1));
- // Erase the :port part of the host name
- slHost.erase( colonPos );
- }
+ LogString slHost = syslogHost1;
+ int slHostPort = -1;
-// On the local host, we can directly use the system function 'syslog'
-// if it is available (cf. append)
+ LogString::size_type colonPos = 0;
+ colonPos = slHost.rfind(':');
+
+ if (colonPos != LogString::npos)
+ {
+ slHostPort = StringHelper::toInt(slHost.substr(colonPos + 1));
+ // Erase the :port part of the host name
+ slHost.erase( colonPos );
+ }
+
+ // On the local host, we can directly use the system function 'syslog'
+ // if it is available (cf. append)
#if LOG4CXX_HAVE_SYSLOG
- if (syslogHost1 != LOG4CXX_STR("localhost") && syslogHost1 != LOG4CXX_STR("127.0.0.1")
- && !syslogHost1.empty())
-#endif
- if (slHostPort >= 0) this->sw = new SyslogWriter(slHost, slHostPort);
- else this->sw = new SyslogWriter(slHost);
- this->syslogHost = slHost;
- this->syslogHostPort = slHostPort;
+ if (syslogHost1 != LOG4CXX_STR("localhost") && syslogHost1 != LOG4CXX_STR("127.0.0.1")
+ && !syslogHost1.empty())
+#endif
+ if (slHostPort >= 0)
+ {
+ this->sw = new SyslogWriter(slHost, slHostPort);
+ }
+ else
+ {
+ this->sw = new SyslogWriter(slHost);
+ }
+
+ this->syslogHost = slHost;
+ this->syslogHostPort = slHostPort;
}
void SyslogAppender::setFacility(const LogString& facilityName)
{
- if (facilityName.empty())
- {
- return;
- }
+ if (facilityName.empty())
+ {
+ return;
+ }
- syslogFacility = getFacility(facilityName);
- if (syslogFacility == LOG_UNDEF)
- {
- LogLog::error(LOG4CXX_STR("[")+facilityName +
- LOG4CXX_STR("] is an unknown syslog facility. Defaulting to [USER]."));
- syslogFacility = LOG_USER;
- }
+ syslogFacility = getFacility(facilityName);
- this->initSyslogFacilityStr();
+ if (syslogFacility == LOG_UNDEF)
+ {
+ LogLog::error(LOG4CXX_STR("[") + facilityName +
+ LOG4CXX_STR("] is an unknown syslog facility. Defaulting to [USER]."));
+ syslogFacility = LOG_USER;
+ }
+
+ this->initSyslogFacilityStr();
}
diff --git a/src/main/cpp/syslogwriter.cpp b/src/main/cpp/syslogwriter.cpp
index 676a924..a92d1fb 100644
--- a/src/main/cpp/syslogwriter.cpp
+++ b/src/main/cpp/syslogwriter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -30,37 +30,39 @@
using namespace log4cxx::helpers;
SyslogWriter::SyslogWriter(const LogString& syslogHost1, int syslogHostPort1)
-: syslogHost(syslogHost1), syslogHostPort(syslogHostPort1)
+ : syslogHost(syslogHost1), syslogHostPort(syslogHostPort1)
{
- try
- {
- this->address = InetAddress::getByName(syslogHost1);
- }
- catch(UnknownHostException& e)
- {
- LogLog::error(((LogString) LOG4CXX_STR("Could not find ")) + syslogHost1 +
- LOG4CXX_STR(". All logging will FAIL."), e);
- }
+ try
+ {
+ this->address = InetAddress::getByName(syslogHost1);
+ }
+ catch (UnknownHostException& e)
+ {
+ LogLog::error(((LogString) LOG4CXX_STR("Could not find ")) + syslogHost1 +
+ LOG4CXX_STR(". All logging will FAIL."), e);
+ }
- try
- {
- this->ds = new DatagramSocket();
- }
- catch (SocketException& e)
- {
- LogLog::error(((LogString) LOG4CXX_STR("Could not instantiate DatagramSocket to ")) + syslogHost1 +
- LOG4CXX_STR(". All logging will FAIL."), e);
- }
+ try
+ {
+ this->ds = new DatagramSocket();
+ }
+ catch (SocketException& e)
+ {
+ LogLog::error(((LogString) LOG4CXX_STR("Could not instantiate DatagramSocket to ")) + syslogHost1 +
+ LOG4CXX_STR(". All logging will FAIL."), e);
+ }
}
-void SyslogWriter::write(const LogString& source) {
- if (this->ds != 0 && this->address != 0) {
- LOG4CXX_ENCODE_CHAR(data, source);
+void SyslogWriter::write(const LogString& source)
+{
+ if (this->ds != 0 && this->address != 0)
+ {
+ LOG4CXX_ENCODE_CHAR(data, source);
- DatagramPacketPtr packet(
- new DatagramPacket((void*) data.data(), data.length(),
- address, syslogHostPort));
+ DatagramPacketPtr packet(
+ new DatagramPacket((void*) data.data(), data.length(),
+ address, syslogHostPort));
- ds->send(packet);
- }
+ ds->send(packet);
+ }
}
diff --git a/src/main/cpp/system.cpp b/src/main/cpp/system.cpp
index 7047aa4..6bbe057 100644
--- a/src/main/cpp/system.cpp
+++ b/src/main/cpp/system.cpp
@@ -31,66 +31,92 @@
LogString System::getProperty(const LogString& lkey)
{
- if (lkey.empty())
+ if (lkey.empty())
+ {
+ throw IllegalArgumentException(LOG4CXX_STR("key is empty"));
+ }
+
+ LogString rv;
+
+ if (lkey == LOG4CXX_STR("java.io.tmpdir"))
+ {
+ Pool p;
+ const char* dir = NULL;
+ apr_status_t stat = apr_temp_dir_get(&dir, p.getAPRPool());
+
+ if (stat == APR_SUCCESS)
{
- throw IllegalArgumentException(LOG4CXX_STR("key is empty"));
+ Transcoder::decode(dir, rv);
}
- LogString rv;
- if (lkey == LOG4CXX_STR("java.io.tmpdir")) {
- Pool p;
- const char* dir = NULL;
- apr_status_t stat = apr_temp_dir_get(&dir, p.getAPRPool());
- if (stat == APR_SUCCESS) {
+ return rv;
+ }
+
+ if (lkey == LOG4CXX_STR("user.dir"))
+ {
+ Pool p;
+ char* dir = NULL;
+ apr_status_t stat = apr_filepath_get(&dir, APR_FILEPATH_NATIVE,
+ p.getAPRPool());
+
+ if (stat == APR_SUCCESS)
+ {
Transcoder::decode(dir, rv);
- }
- return rv;
}
- if (lkey == LOG4CXX_STR("user.dir")) {
- Pool p;
- char* dir = NULL;
- apr_status_t stat = apr_filepath_get(&dir, APR_FILEPATH_NATIVE,
- p.getAPRPool());
- if (stat == APR_SUCCESS) {
- Transcoder::decode(dir, rv);
- }
- return rv;
- }
+ return rv;
+ }
+
#if APR_HAS_USER
- if (lkey == LOG4CXX_STR("user.home") || lkey == LOG4CXX_STR("user.name")) {
- Pool pool;
- apr_uid_t userid;
- apr_gid_t groupid;
- apr_pool_t* p = pool.getAPRPool();
- apr_status_t stat = apr_uid_current(&userid, &groupid, p);
- if (stat == APR_SUCCESS) {
+
+ if (lkey == LOG4CXX_STR("user.home") || lkey == LOG4CXX_STR("user.name"))
+ {
+ Pool pool;
+ apr_uid_t userid;
+ apr_gid_t groupid;
+ apr_pool_t* p = pool.getAPRPool();
+ apr_status_t stat = apr_uid_current(&userid, &groupid, p);
+
+ if (stat == APR_SUCCESS)
+ {
char* username = NULL;
stat = apr_uid_name_get(&username, userid, p);
- if (stat == APR_SUCCESS) {
- if (lkey == LOG4CXX_STR("user.name")) {
- Transcoder::decode(username, rv);
- } else {
- char* dirname = NULL;
- stat = apr_uid_homepath_get(&dirname, username, p);
- if (stat == APR_SUCCESS) {
- Transcoder::decode(dirname, rv);
+
+ if (stat == APR_SUCCESS)
+ {
+ if (lkey == LOG4CXX_STR("user.name"))
+ {
+ Transcoder::decode(username, rv);
}
- }
+ else
+ {
+ char* dirname = NULL;
+ stat = apr_uid_homepath_get(&dirname, username, p);
+
+ if (stat == APR_SUCCESS)
+ {
+ Transcoder::decode(dirname, rv);
+ }
+ }
}
- }
- return rv;
}
+
+ return rv;
+ }
+
#endif
- LOG4CXX_ENCODE_CHAR(key, lkey);
- Pool p;
- char* value = NULL;
- apr_status_t stat = apr_env_get(&value, key.c_str(),
- p.getAPRPool());
- if (stat == APR_SUCCESS) {
- Transcoder::decode((const char*) value, rv);
- }
- return rv;
+ LOG4CXX_ENCODE_CHAR(key, lkey);
+ Pool p;
+ char* value = NULL;
+ apr_status_t stat = apr_env_get(&value, key.c_str(),
+ p.getAPRPool());
+
+ if (stat == APR_SUCCESS)
+ {
+ Transcoder::decode((const char*) value, rv);
+ }
+
+ return rv;
}
diff --git a/src/main/cpp/systemerrwriter.cpp b/src/main/cpp/systemerrwriter.cpp
index 01b5ba3..cce411a 100644
--- a/src/main/cpp/systemerrwriter.cpp
+++ b/src/main/cpp/systemerrwriter.cpp
@@ -20,7 +20,7 @@
#include <log4cxx/helpers/transcoder.h>
#include <stdio.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
@@ -29,45 +29,56 @@
IMPLEMENT_LOG4CXX_OBJECT(SystemErrWriter)
-SystemErrWriter::SystemErrWriter() {
+SystemErrWriter::SystemErrWriter()
+{
}
-SystemErrWriter::~SystemErrWriter() {
+SystemErrWriter::~SystemErrWriter()
+{
}
-void SystemErrWriter::close(Pool& /* p */) {
+void SystemErrWriter::close(Pool& /* p */)
+{
}
-void SystemErrWriter::flush(Pool& /* p */) {
+void SystemErrWriter::flush(Pool& /* p */)
+{
flush();
}
-void SystemErrWriter::write(const LogString& str, Pool& /* p */) {
- write(str);
+void SystemErrWriter::write(const LogString& str, Pool& /* p */)
+{
+ write(str);
}
-bool SystemErrWriter::isWide() {
+bool SystemErrWriter::isWide()
+{
#if LOG4CXX_FORCE_WIDE_CONSOLE
- return true;
+ return true;
#elif LOG4CXX_FORCE_BYTE_CONSOLE || !LOG4CXX_HAS_FWIDE
- return false;
+ return false;
#else
- return fwide(stderr, 0) > 0;
+ return fwide(stderr, 0) > 0;
#endif
}
-void SystemErrWriter::write(const LogString& str) {
+void SystemErrWriter::write(const LogString& str)
+{
#if LOG4CXX_WCHAR_T_API
- if (isWide()) {
- LOG4CXX_ENCODE_WCHAR(msg, str);
+
+ if (isWide())
+ {
+ LOG4CXX_ENCODE_WCHAR(msg, str);
fputws(msg.c_str(), stderr);
- return;
+ return;
}
+
#endif
LOG4CXX_ENCODE_CHAR(msg, str);
fputs(msg.c_str(), stderr);
}
-void SystemErrWriter::flush() {
+void SystemErrWriter::flush()
+{
fflush(stderr);
}
diff --git a/src/main/cpp/systemoutwriter.cpp b/src/main/cpp/systemoutwriter.cpp
index 4296f77..83e0ae8 100644
--- a/src/main/cpp/systemoutwriter.cpp
+++ b/src/main/cpp/systemoutwriter.cpp
@@ -20,7 +20,7 @@
#include <log4cxx/helpers/transcoder.h>
#include <stdio.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
@@ -29,45 +29,56 @@
IMPLEMENT_LOG4CXX_OBJECT(SystemOutWriter)
-SystemOutWriter::SystemOutWriter() {
+SystemOutWriter::SystemOutWriter()
+{
}
-SystemOutWriter::~SystemOutWriter() {
+SystemOutWriter::~SystemOutWriter()
+{
}
-void SystemOutWriter::close(Pool& /* p */ ) {
+void SystemOutWriter::close(Pool& /* p */ )
+{
}
-void SystemOutWriter::flush(Pool& /* p */ ) {
+void SystemOutWriter::flush(Pool& /* p */ )
+{
flush();
}
-void SystemOutWriter::write(const LogString& str, Pool& /* p */ ) {
+void SystemOutWriter::write(const LogString& str, Pool& /* p */ )
+{
write(str);
}
-bool SystemOutWriter::isWide() {
+bool SystemOutWriter::isWide()
+{
#if LOG4CXX_FORCE_WIDE_CONSOLE
- return true;
+ return true;
#elif LOG4CXX_FORCE_BYTE_CONSOLE || !LOG4CXX_HAS_FWIDE
- return false;
+ return false;
#else
- return fwide(stdout, 0) > 0;
+ return fwide(stdout, 0) > 0;
#endif
}
-void SystemOutWriter::write(const LogString& str) {
+void SystemOutWriter::write(const LogString& str)
+{
#if LOG4CXX_WCHAR_T_API
- if (isWide()) {
- LOG4CXX_ENCODE_WCHAR(msg, str);
+
+ if (isWide())
+ {
+ LOG4CXX_ENCODE_WCHAR(msg, str);
fputws(msg.c_str(), stdout);
- return;
+ return;
}
+
#endif
LOG4CXX_ENCODE_CHAR(msg, str);
fputs(msg.c_str(), stdout);
}
-void SystemOutWriter::flush() {
+void SystemOutWriter::flush()
+{
fflush(stdout);
}
diff --git a/src/main/cpp/telnetappender.cpp b/src/main/cpp/telnetappender.cpp
index ff38ee3..81aaaf9 100644
--- a/src/main/cpp/telnetappender.cpp
+++ b/src/main/cpp/telnetappender.cpp
@@ -41,53 +41,57 @@
const int TelnetAppender::MAX_CONNECTIONS = 20;
TelnetAppender::TelnetAppender()
- : port(DEFAULT_PORT), connections(MAX_CONNECTIONS),
- encoding(LOG4CXX_STR("UTF-8")),
- encoder(CharsetEncoder::getUTF8Encoder()),
- serverSocket(NULL), sh()
+ : port(DEFAULT_PORT), connections(MAX_CONNECTIONS),
+ encoding(LOG4CXX_STR("UTF-8")),
+ encoder(CharsetEncoder::getUTF8Encoder()),
+ serverSocket(NULL), sh()
{
- LOCK_W sync(mutex);
- activeConnections = 0;
+ LOCK_W sync(mutex);
+ activeConnections = 0;
}
TelnetAppender::~TelnetAppender()
{
- finalize();
- delete serverSocket;
+ finalize();
+ delete serverSocket;
}
void TelnetAppender::activateOptions(Pool& /* p */)
{
- if (serverSocket == NULL) {
- serverSocket = new ServerSocket(port);
- serverSocket->setSoTimeout(1000);
- }
- sh.run(acceptConnections, this);
+ if (serverSocket == NULL)
+ {
+ serverSocket = new ServerSocket(port);
+ serverSocket->setSoTimeout(1000);
+ }
+
+ sh.run(acceptConnections, this);
}
void TelnetAppender::setOption(const LogString& option,
- const LogString& value)
+ const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("PORT"), LOG4CXX_STR("port")))
- {
- setPort(OptionConverter::toInt(value, DEFAULT_PORT));
- }
- else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("ENCODING"), LOG4CXX_STR("encoding")))
- {
- setEncoding(value);
- }
- else
- {
- AppenderSkeleton::setOption(option, value);
- }
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("PORT"), LOG4CXX_STR("port")))
+ {
+ setPort(OptionConverter::toInt(value, DEFAULT_PORT));
+ }
+ else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("ENCODING"), LOG4CXX_STR("encoding")))
+ {
+ setEncoding(value);
+ }
+ else
+ {
+ AppenderSkeleton::setOption(option, value);
+ }
}
-LogString TelnetAppender::getEncoding() const {
+LogString TelnetAppender::getEncoding() const
+{
LOCK_W sync(mutex);
return encoding;
}
-void TelnetAppender::setEncoding(const LogString& value) {
+void TelnetAppender::setEncoding(const LogString& value)
+{
LOCK_W sync(mutex);
encoder = CharsetEncoder::getEncoder(value);
encoding = value;
@@ -96,155 +100,202 @@
void TelnetAppender::close()
{
- LOCK_W sync(mutex);
- if (closed) return;
- closed = true;
+ LOCK_W sync(mutex);
- SocketPtr nullSocket;
- for(ConnectionList::iterator iter = connections.begin();
+ if (closed)
+ {
+ return;
+ }
+
+ closed = true;
+
+ SocketPtr nullSocket;
+
+ for (ConnectionList::iterator iter = connections.begin();
iter != connections.end();
- iter++) {
- if (*iter != 0) {
- (*iter)->close();
- *iter = nullSocket;
- }
+ iter++)
+ {
+ if (*iter != 0)
+ {
+ (*iter)->close();
+ *iter = nullSocket;
}
+ }
- if (serverSocket != NULL) {
- try {
- serverSocket->close();
- } catch(Exception&) {
- }
+ if (serverSocket != NULL)
+ {
+ try
+ {
+ serverSocket->close();
}
-
- try {
- sh.join();
- } catch(Exception& ex) {
+ catch (Exception&)
+ {
}
+ }
- activeConnections = 0;
+ try
+ {
+ sh.join();
+ }
+ catch (Exception& ex)
+ {
+ }
+
+ activeConnections = 0;
}
-void TelnetAppender::write(ByteBuffer& buf) {
- for (ConnectionList::iterator iter = connections.begin();
- iter != connections.end();
- iter++) {
- if (*iter != 0) {
- try {
- ByteBuffer b(buf.current(), buf.remaining());
- (*iter)->write(b);
- } catch(Exception& ex) {
- // The client has closed the connection, remove it from our list:
- *iter = 0;
- activeConnections--;
- }
+void TelnetAppender::write(ByteBuffer& buf)
+{
+ for (ConnectionList::iterator iter = connections.begin();
+ iter != connections.end();
+ iter++)
+ {
+ if (*iter != 0)
+ {
+ try
+ {
+ ByteBuffer b(buf.current(), buf.remaining());
+ (*iter)->write(b);
+ }
+ catch (Exception& ex)
+ {
+ // The client has closed the connection, remove it from our list:
+ *iter = 0;
+ activeConnections--;
}
}
+ }
}
-void TelnetAppender::writeStatus(const SocketPtr& socket, const LogString& msg, Pool& p) {
+void TelnetAppender::writeStatus(const SocketPtr& socket, const LogString& msg, Pool& p)
+{
+ size_t bytesSize = msg.size() * 2;
+ char* bytes = p.pstralloc(bytesSize);
+
+ LogString::const_iterator msgIter(msg.begin());
+ ByteBuffer buf(bytes, bytesSize);
+
+ while (msgIter != msg.end())
+ {
+ encoder->encode(msg, msgIter, buf);
+ buf.flip();
+ socket->write(buf);
+ buf.clear();
+ }
+}
+
+void TelnetAppender::append(const spi::LoggingEventPtr& event, Pool& p)
+{
+ size_t count = activeConnections;
+
+ if (count > 0)
+ {
+ LogString msg;
+ this->layout->format(msg, event, pool);
+ msg.append(LOG4CXX_STR("\r\n"));
size_t bytesSize = msg.size() * 2;
char* bytes = p.pstralloc(bytesSize);
LogString::const_iterator msgIter(msg.begin());
ByteBuffer buf(bytes, bytesSize);
- while(msgIter != msg.end()) {
- encoder->encode(msg, msgIter, buf);
+ LOCK_W sync(this->mutex);
+
+ while (msgIter != msg.end())
+ {
+ log4cxx_status_t stat = encoder->encode(msg, msgIter, buf);
buf.flip();
- socket->write(buf);
+ write(buf);
buf.clear();
+
+ if (CharsetEncoder::isError(stat))
+ {
+ LogString unrepresented(1, 0x3F /* '?' */);
+ LogString::const_iterator unrepresentedIter(unrepresented.begin());
+ stat = encoder->encode(unrepresented, unrepresentedIter, buf);
+ buf.flip();
+ write(buf);
+ buf.clear();
+ msgIter++;
+ }
}
+ }
}
-void TelnetAppender::append(const spi::LoggingEventPtr& event, Pool& p)
+void* APR_THREAD_FUNC TelnetAppender::acceptConnections(apr_thread_t* /* thread */, void* data)
{
- size_t count = activeConnections;
- if (count > 0) {
- LogString msg;
- this->layout->format(msg, event, pool);
- msg.append(LOG4CXX_STR("\r\n"));
- size_t bytesSize = msg.size() * 2;
- char* bytes = p.pstralloc(bytesSize);
-
- LogString::const_iterator msgIter(msg.begin());
- ByteBuffer buf(bytes, bytesSize);
-
- LOCK_W sync(this->mutex);
- while(msgIter != msg.end()) {
- log4cxx_status_t stat = encoder->encode(msg, msgIter, buf);
- buf.flip();
- write(buf);
- buf.clear();
- if (CharsetEncoder::isError(stat)) {
- LogString unrepresented(1, 0x3F /* '?' */);
- LogString::const_iterator unrepresentedIter(unrepresented.begin());
- stat = encoder->encode(unrepresented, unrepresentedIter, buf);
- buf.flip();
- write(buf);
- buf.clear();
- msgIter++;
- }
- }
- }
-}
-
-void* APR_THREAD_FUNC TelnetAppender::acceptConnections(apr_thread_t* /* thread */, void* data) {
TelnetAppender* pThis = (TelnetAppender*) data;
// main loop; is left when This->closed is != 0 after an accept()
- while(true)
+ while (true)
{
try
{
- SocketPtr newClient = pThis->serverSocket->accept();
- bool done = pThis->closed;
- if (done) {
- Pool p;
- pThis->writeStatus(newClient, LOG4CXX_STR("Log closed.\r\n"), p);
- newClient->close();
+ SocketPtr newClient = pThis->serverSocket->accept();
+ bool done = pThis->closed;
+
+ if (done)
+ {
+ Pool p;
+ pThis->writeStatus(newClient, LOG4CXX_STR("Log closed.\r\n"), p);
+ newClient->close();
+
+ break;
+ }
+
+ size_t count = pThis->activeConnections;
+
+ if (count >= pThis->connections.size())
+ {
+ Pool p;
+ pThis->writeStatus(newClient, LOG4CXX_STR("Too many connections.\r\n"), p);
+ newClient->close();
+ }
+ else
+ {
+ //
+ // find unoccupied connection
+ //
+ LOCK_W sync(pThis->mutex);
+
+ for (ConnectionList::iterator iter = pThis->connections.begin();
+ iter != pThis->connections.end();
+ iter++)
+ {
+ if (*iter == NULL)
+ {
+ *iter = newClient;
+ pThis->activeConnections++;
break;
+ }
}
- size_t count = pThis->activeConnections;
- if (count >= pThis->connections.size()) {
- Pool p;
- pThis->writeStatus(newClient, LOG4CXX_STR("Too many connections.\r\n"), p);
- newClient->close();
- } else {
- //
- // find unoccupied connection
- //
- LOCK_W sync(pThis->mutex);
- for(ConnectionList::iterator iter = pThis->connections.begin();
- iter != pThis->connections.end();
- iter++) {
- if (*iter == NULL) {
- *iter = newClient;
- pThis->activeConnections++;
-
- break;
- }
- }
-
- Pool p;
- 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);
- }
- } catch(InterruptedIOException &e) {
- if (pThis->closed) {
- break;
- }
- } catch(Exception& e) {
- if (!pThis->closed) {
- LogLog::error(LOG4CXX_STR("Encountered error while in SocketHandler loop."), e);
- } else {
- break;
- }
+ Pool p;
+ 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);
+ }
+ }
+ catch (InterruptedIOException& e)
+ {
+ if (pThis->closed)
+ {
+ break;
+ }
+ }
+ catch (Exception& e)
+ {
+ if (!pThis->closed)
+ {
+ LogLog::error(LOG4CXX_STR("Encountered error while in SocketHandler loop."), e);
+ }
+ else
+ {
+ break;
+ }
}
}
diff --git a/src/main/cpp/threadcxx.cpp b/src/main/cpp/threadcxx.cpp
index 05450fd..9977135 100644
--- a/src/main/cpp/threadcxx.cpp
+++ b/src/main/cpp/threadcxx.cpp
@@ -29,108 +29,121 @@
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;
- }
+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;
- };
+ /**
+ * 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);
- }
+/**
+ * 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;
- };
+ 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;
- }
+/**
+ * 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());
+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();
+ (package->getRunnable())(thread, package->getData());
+ package->getThread()->ending();
}
apr_thread_exit(thread, 0); // this function never returns !
return 0;
@@ -138,104 +151,145 @@
#endif
Thread::Thread() : thread(NULL), alive(0), interruptedStatus(0),
- interruptedMutex(NULL), interruptedCondition(NULL) {
+ interruptedMutex(NULL), interruptedCondition(NULL)
+{
}
-Thread::~Thread() {
+Thread::~Thread()
+{
join();
}
-void Thread::run(Runnable start, void* data) {
+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);
- }
+ // Try to join first if previous instance did exit
+ if ( isActive() && !isAlive() )
+ {
+ join();
+ }
- // 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);
+ // 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"));
+ throw ThreadException(LOG4CXX_STR("APR_HAS_THREADS is not true"));
#endif
}
-void Thread::join() {
+void Thread::join()
+{
#if APR_HAS_THREADS
- if (thread != NULL) {
+
+ if (thread != NULL)
+ {
apr_status_t startStat;
apr_status_t stat = apr_thread_join(&startStat, thread);
thread = NULL;
- if (stat != APR_SUCCESS) {
+
+ if (stat != APR_SUCCESS)
+ {
throw ThreadException(stat);
}
}
+
#endif
}
-void Thread::currentThreadInterrupt() {
+void Thread::currentThreadInterrupt()
+{
#if APR_HAS_THREADS
- void* tls = getThreadLocal().get();
- if (tls != 0) {
- ((Thread*) tls)->interrupt();
- }
+ void* tls = getThreadLocal().get();
+
+ if (tls != 0)
+ {
+ ((Thread*) tls)->interrupt();
+ }
+
#endif
}
-void Thread::interrupt() {
+void Thread::interrupt()
+{
apr_atomic_set32(&interruptedStatus, 0xFFFFFFFF);
#if APR_HAS_THREADS
- if (interruptedMutex != NULL) {
+
+ if (interruptedMutex != NULL)
+ {
synchronized sync(interruptedMutex);
apr_status_t stat = apr_thread_cond_signal(interruptedCondition);
- if (stat != APR_SUCCESS) throw ThreadException(stat);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw ThreadException(stat);
+ }
}
+
#endif
}
-bool Thread::interrupted() {
+bool Thread::interrupted()
+{
#if APR_HAS_THREADS
- void* tls = getThreadLocal().get();
- if (tls != 0) {
- return apr_atomic_xchg32(&(((Thread*) tls)->interruptedStatus), 0) != 0;
- }
+ void* tls = getThreadLocal().get();
+
+ if (tls != 0)
+ {
+ return apr_atomic_xchg32(&(((Thread*) tls)->interruptedStatus), 0) != 0;
+ }
+
#endif
- return false;
+ return false;
}
-bool Thread::isCurrentThread() const {
+bool Thread::isCurrentThread() const
+{
#if APR_HAS_THREADS
const void* tls = getThreadLocal().get();
return (tls == this);
@@ -244,39 +298,58 @@
#endif
}
-bool Thread::isAlive() {
+bool Thread::isAlive()
+{
return apr_atomic_read32(&alive) != 0;
}
-void Thread::ending() {
+void Thread::ending()
+{
apr_atomic_set32(&alive, 0);
}
-void Thread::sleep(int duration) {
+void Thread::sleep(int duration)
+{
#if APR_HAS_THREADS
- if(interrupted()) {
- throw InterruptedException();
+
+ if (interrupted())
+ {
+ throw InterruptedException();
}
- if (duration > 0) {
+
+ if (duration > 0)
+ {
Thread* pThis = (Thread*) getThreadLocal().get();
- if (pThis == NULL) {
- apr_sleep(duration*1000);
- } else {
+
+ 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)) {
+ pThis->interruptedMutex, duration * 1000);
+
+ if (stat != APR_SUCCESS && !APR_STATUS_IS_TIMEUP(stat))
+ {
throw ThreadException(stat);
}
- if (interrupted()) {
+
+ if (interrupted())
+ {
throw InterruptedException();
}
}
}
+
#else
- if (duration > 0) {
- apr_sleep(duration*1000);
+
+ if (duration > 0)
+ {
+ apr_sleep(duration * 1000);
}
+
#endif
}
diff --git a/src/main/cpp/threadlocal.cpp b/src/main/cpp/threadlocal.cpp
index 313ecfc..87ae0d8 100644
--- a/src/main/cpp/threadlocal.cpp
+++ b/src/main/cpp/threadlocal.cpp
@@ -22,39 +22,53 @@
using namespace log4cxx::helpers;
using namespace log4cxx;
-apr_threadkey_t* ThreadLocal::create(Pool& p) {
+apr_threadkey_t* ThreadLocal::create(Pool& p)
+{
apr_threadkey_t* key = 0;
#if APR_HAS_THREADS
apr_status_t stat = apr_threadkey_private_create(&key, 0, p.getAPRPool());
- if (stat != APR_SUCCESS) {
- throw RuntimeException(stat);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw RuntimeException(stat);
}
+
#endif
return key;
}
-ThreadLocal::ThreadLocal() : p(), key(create(p)) {
+ThreadLocal::ThreadLocal() : p(), key(create(p))
+{
}
-ThreadLocal::~ThreadLocal() {
+ThreadLocal::~ThreadLocal()
+{
}
-void ThreadLocal::set(void* priv) {
+void ThreadLocal::set(void* priv)
+{
#if APR_HAS_THREADS
apr_status_t stat = apr_threadkey_private_set(priv, key);
- if (stat != APR_SUCCESS) {
+
+ if (stat != APR_SUCCESS)
+ {
throw RuntimeException(stat);
}
+
#endif
}
-void* ThreadLocal::get() {
+void* ThreadLocal::get()
+{
void* retval = 0;
#if APR_HAS_THREADS
apr_status_t stat = apr_threadkey_private_get(&retval, key);
- if (stat != APR_SUCCESS) {
+
+ if (stat != APR_SUCCESS)
+ {
throw RuntimeException(stat);
}
+
#endif
return retval;
}
diff --git a/src/main/cpp/threadpatternconverter.cpp b/src/main/cpp/threadpatternconverter.cpp
index c725079..085f924 100644
--- a/src/main/cpp/threadpatternconverter.cpp
+++ b/src/main/cpp/threadpatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#include <log4cxx/logstring.h>
@@ -23,28 +23,31 @@
#include <log4cxx/spi/loggingevent.h>
#include <log4cxx/spi/location/locationinfo.h>
- using namespace log4cxx;
- using namespace log4cxx::pattern;
- using namespace log4cxx::spi;
- using namespace log4cxx::helpers;
+using namespace log4cxx;
+using namespace log4cxx::pattern;
+using namespace log4cxx::spi;
+using namespace log4cxx::helpers;
- IMPLEMENT_LOG4CXX_OBJECT(ThreadPatternConverter)
+IMPLEMENT_LOG4CXX_OBJECT(ThreadPatternConverter)
- ThreadPatternConverter::ThreadPatternConverter() :
+ThreadPatternConverter::ThreadPatternConverter() :
LoggingEventPatternConverter(LOG4CXX_STR("Thread"),
- LOG4CXX_STR("Thread")) {
- }
+ LOG4CXX_STR("Thread"))
+{
+}
- PatternConverterPtr ThreadPatternConverter::newInstance(
- const std::vector<LogString>& /* options */) {
- static PatternConverterPtr def(new ThreadPatternConverter());
- return def;
- }
+PatternConverterPtr ThreadPatternConverter::newInstance(
+ const std::vector<LogString>& /* options */)
+{
+ static PatternConverterPtr def(new ThreadPatternConverter());
+ return def;
+}
- void ThreadPatternConverter::format(
- const LoggingEventPtr& event,
- LogString& toAppendTo,
- Pool& /* p */) const {
+void ThreadPatternConverter::format(
+ const LoggingEventPtr& event,
+ LogString& toAppendTo,
+ Pool& /* p */) const
+{
toAppendTo.append(event->getThreadName());
- }
+}
diff --git a/src/main/cpp/threadspecificdata.cpp b/src/main/cpp/threadspecificdata.cpp
index 0968526..b165509 100644
--- a/src/main/cpp/threadspecificdata.cpp
+++ b/src/main/cpp/threadspecificdata.cpp
@@ -20,7 +20,7 @@
#include <log4cxx/helpers/exception.h>
#include <apr_thread_proc.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/helpers/aprinitializer.h>
@@ -29,57 +29,76 @@
ThreadSpecificData::ThreadSpecificData()
- : ndcStack(), mdcMap() {
+ : ndcStack(), mdcMap()
+{
}
-ThreadSpecificData::~ThreadSpecificData() {
+ThreadSpecificData::~ThreadSpecificData()
+{
}
-log4cxx::NDC::Stack& ThreadSpecificData::getStack() {
- return ndcStack;
+log4cxx::NDC::Stack& ThreadSpecificData::getStack()
+{
+ return ndcStack;
}
-log4cxx::MDC::Map& ThreadSpecificData::getMap() {
- return mdcMap;
+log4cxx::MDC::Map& ThreadSpecificData::getMap()
+{
+ return mdcMap;
}
-ThreadSpecificData& ThreadSpecificData::getDataNoThreads() {
+ThreadSpecificData& ThreadSpecificData::getDataNoThreads()
+{
static ThreadSpecificData noThreadData;
return noThreadData;
}
-ThreadSpecificData* ThreadSpecificData::getCurrentData() {
+ThreadSpecificData* ThreadSpecificData::getCurrentData()
+{
#if APR_HAS_THREADS
- void* pData = NULL;
- apr_threadkey_private_get(&pData, APRInitializer::getTlsKey());
- return (ThreadSpecificData*) pData;
+ void* pData = NULL;
+ apr_threadkey_private_get(&pData, APRInitializer::getTlsKey());
+ return (ThreadSpecificData*) pData;
#else
- return &getDataNoThreads();
+ return &getDataNoThreads();
#endif
}
-void ThreadSpecificData::recycle() {
+void ThreadSpecificData::recycle()
+{
#if APR_HAS_THREADS
- if(ndcStack.empty() && mdcMap.empty()) {
+
+ if (ndcStack.empty() && mdcMap.empty())
+ {
void* pData = NULL;
apr_status_t stat = apr_threadkey_private_get(&pData, APRInitializer::getTlsKey());
- if (stat == APR_SUCCESS && pData == this) {
+
+ if (stat == APR_SUCCESS && pData == this)
+ {
stat = apr_threadkey_private_set(0, APRInitializer::getTlsKey());
- if (stat == APR_SUCCESS) {
+
+ if (stat == APR_SUCCESS)
+ {
delete this;
}
}
}
+
#endif
}
-void ThreadSpecificData::put(const LogString& key, const LogString& val) {
+void ThreadSpecificData::put(const LogString& key, const LogString& val)
+{
ThreadSpecificData* data = getCurrentData();
- if (data == 0) {
+
+ if (data == 0)
+ {
data = createCurrentData();
}
- if (data != 0) {
+
+ if (data != 0)
+ {
data->getMap()[key] = val;
}
}
@@ -87,16 +106,25 @@
-void ThreadSpecificData::push(const LogString& val) {
+void ThreadSpecificData::push(const LogString& val)
+{
ThreadSpecificData* data = getCurrentData();
- if (data == 0) {
+
+ if (data == 0)
+ {
data = createCurrentData();
}
- if (data != 0) {
+
+ if (data != 0)
+ {
NDC::Stack& stack = data->getStack();
- if(stack.empty()) {
+
+ if (stack.empty())
+ {
stack.push(NDC::DiagnosticContext(val, val));
- } else {
+ }
+ else
+ {
LogString fullMessage(stack.top().second);
fullMessage.append(1, (logchar) 0x20);
fullMessage.append(val);
@@ -105,26 +133,35 @@
}
}
-void ThreadSpecificData::inherit(const NDC::Stack& src) {
+void ThreadSpecificData::inherit(const NDC::Stack& src)
+{
ThreadSpecificData* data = getCurrentData();
- if (data == 0) {
+
+ if (data == 0)
+ {
data = createCurrentData();
}
- if (data != 0) {
+
+ if (data != 0)
+ {
data->getStack() = src;
}
}
-ThreadSpecificData* ThreadSpecificData::createCurrentData() {
+ThreadSpecificData* ThreadSpecificData::createCurrentData()
+{
#if APR_HAS_THREADS
ThreadSpecificData* newData = new ThreadSpecificData();
apr_status_t stat = apr_threadkey_private_set(newData, APRInitializer::getTlsKey());
- if (stat != APR_SUCCESS) {
- delete newData;
- newData = NULL;
+
+ if (stat != APR_SUCCESS)
+ {
+ delete newData;
+ newData = NULL;
}
+
return newData;
#else
return 0;
diff --git a/src/main/cpp/throwableinformationpatternconverter.cpp b/src/main/cpp/throwableinformationpatternconverter.cpp
index bba9d5c..81a1cc2 100644
--- a/src/main/cpp/throwableinformationpatternconverter.cpp
+++ b/src/main/cpp/throwableinformationpatternconverter.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -34,31 +34,37 @@
IMPLEMENT_LOG4CXX_OBJECT(ThrowableInformationPatternConverter)
ThrowableInformationPatternConverter::ThrowableInformationPatternConverter(bool shortReport1) :
- LoggingEventPatternConverter(LOG4CXX_STR("Throwable"),
- LOG4CXX_STR("throwable")),
- shortReport(shortReport1) {
+ LoggingEventPatternConverter(LOG4CXX_STR("Throwable"),
+ LOG4CXX_STR("throwable")),
+ shortReport(shortReport1)
+{
}
PatternConverterPtr ThrowableInformationPatternConverter::newInstance(
- const std::vector<LogString>& options) {
- if (options.size() > 0 && options[0].compare(LOG4CXX_STR("short")) == 0) {
- static PatternConverterPtr shortConverter(new ThrowableInformationPatternConverter(true));
- return shortConverter;
- }
- static PatternConverterPtr converter(new ThrowableInformationPatternConverter(false));
- return converter;
+ const std::vector<LogString>& options)
+{
+ if (options.size() > 0 && options[0].compare(LOG4CXX_STR("short")) == 0)
+ {
+ static PatternConverterPtr shortConverter(new ThrowableInformationPatternConverter(true));
+ return shortConverter;
+ }
+
+ static PatternConverterPtr converter(new ThrowableInformationPatternConverter(false));
+ return converter;
}
void ThrowableInformationPatternConverter::format(
- const LoggingEventPtr& /* event */,
- LogString& /* toAppendTo */,
- Pool& /* p */) const {
+ const LoggingEventPtr& /* event */,
+ LogString& /* toAppendTo */,
+ Pool& /* p */) const
+{
}
- /**
- * This converter obviously handles throwables.
- * @return true.
- */
-bool ThrowableInformationPatternConverter::handlesThrowable() const {
+/**
+ * This converter obviously handles throwables.
+ * @return true.
+ */
+bool ThrowableInformationPatternConverter::handlesThrowable() const
+{
return true;
}
diff --git a/src/main/cpp/timebasedrollingpolicy.cpp b/src/main/cpp/timebasedrollingpolicy.cpp
index 0f786ec..1fe8a20 100644
--- a/src/main/cpp/timebasedrollingpolicy.cpp
+++ b/src/main/cpp/timebasedrollingpolicy.cpp
@@ -15,11 +15,11 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#ifdef LOG4CXX_MULTI_PROCESS
-#include <libgen.h>
+ #include <libgen.h>
#endif
#include <log4cxx/logstring.h>
@@ -35,7 +35,7 @@
#include<iostream>
#ifndef INT64_C
-#define INT64_C(x) x ## LL
+ #define INT64_C(x) x ## LL
#endif
#include <apr_time.h>
@@ -52,23 +52,35 @@
#define LOCK_FILE_SUFFIX ".maplck"
#define MAX_FILE_LEN 2048
-bool TimeBasedRollingPolicy::isMapFileEmpty(log4cxx::helpers::Pool& pool){
+bool TimeBasedRollingPolicy::isMapFileEmpty(log4cxx::helpers::Pool& pool)
+{
apr_finfo_t finfo;
apr_status_t st = apr_stat(&finfo, _mapFileName.c_str(), APR_FINFO_SIZE, pool.getAPRPool());
- if (st != APR_SUCCESS){
+
+ if (st != APR_SUCCESS)
+ {
LogLog::warn(LOG4CXX_STR("apr_stat failed."));
}
+
if (st == APR_SUCCESS && !finfo.size)
+ {
return true;
+ }
+
return false;
}
-void TimeBasedRollingPolicy::initMMapFile(const LogString& lastFileName, log4cxx::helpers::Pool& pool){
+void TimeBasedRollingPolicy::initMMapFile(const LogString& lastFileName, log4cxx::helpers::Pool& pool)
+{
int iRet = 0;
- if (!_mmap){
+
+ if (!_mmap)
+ {
iRet = createMMapFile(std::string(_fileNamePattern), pool);
}
- if (!iRet && isMapFileEmpty(pool)) {
+
+ if (!iRet && isMapFileEmpty(pool))
+ {
lockMMapFile(APR_FLOCK_EXCLUSIVE);
memset(_mmap->mm, 0, MAX_FILE_LEN);
memcpy(_mmap->mm, std::string(lastFileName).c_str(), std::string(lastFileName).size());
@@ -76,62 +88,78 @@
}
}
-const std::string TimeBasedRollingPolicy::createFile(const std::string& fileName, const std::string& suffix, log4cxx::helpers::Pool& pool) {
- char szUid[MAX_FILE_LEN] = {'\0'};
- char szBaseName[MAX_FILE_LEN] = {'\0'};
- char szDirName[MAX_FILE_LEN] = {'\0'};
- memcpy(szDirName, fileName.c_str(), fileName.size() > MAX_FILE_LEN ? MAX_FILE_LEN : fileName.size());
- memcpy(szBaseName, fileName.c_str(), fileName.size() > MAX_FILE_LEN ? MAX_FILE_LEN : fileName.size());
+const std::string TimeBasedRollingPolicy::createFile(const std::string& fileName, const std::string& suffix, log4cxx::helpers::Pool& pool)
+{
+ char szUid[MAX_FILE_LEN] = {'\0'};
+ char szBaseName[MAX_FILE_LEN] = {'\0'};
+ char szDirName[MAX_FILE_LEN] = {'\0'};
+ memcpy(szDirName, fileName.c_str(), fileName.size() > MAX_FILE_LEN ? MAX_FILE_LEN : fileName.size());
+ memcpy(szBaseName, fileName.c_str(), fileName.size() > MAX_FILE_LEN ? MAX_FILE_LEN : fileName.size());
- apr_uid_t uid;
- apr_gid_t groupid;
- apr_status_t stat = apr_uid_current(&uid, &groupid, pool.getAPRPool());
- if (stat == APR_SUCCESS){
- snprintf(szUid, MAX_FILE_LEN, "%u", uid);
- }
- return std::string(::dirname(szDirName)) + "/." + ::basename(szBaseName) + szUid + suffix;
+ apr_uid_t uid;
+ apr_gid_t groupid;
+ apr_status_t stat = apr_uid_current(&uid, &groupid, pool.getAPRPool());
+
+ if (stat == APR_SUCCESS)
+ {
+ snprintf(szUid, MAX_FILE_LEN, "%u", uid);
+ }
+
+ return std::string(::dirname(szDirName)) + "/." + ::basename(szBaseName) + szUid + suffix;
}
-int TimeBasedRollingPolicy::createMMapFile(const std::string& fileName, log4cxx::helpers::Pool& pool){
- _mapFileName = createFile(fileName, MMAP_FILE_SUFFIX, pool);
+int TimeBasedRollingPolicy::createMMapFile(const std::string& fileName, log4cxx::helpers::Pool& pool)
+{
+ _mapFileName = createFile(fileName, MMAP_FILE_SUFFIX, pool);
- apr_status_t stat = apr_file_open(&_file_map, _mapFileName.c_str(), APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, _mmapPool->getAPRPool());
- if (stat != APR_SUCCESS){
+ apr_status_t stat = apr_file_open(&_file_map, _mapFileName.c_str(), APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, _mmapPool->getAPRPool());
+
+ if (stat != APR_SUCCESS)
+ {
std::string err(std::string("open mmap file failed. ") + std::string(strerror(errno)) + ". Check the privilege or try to remove " + _mapFileName + " if exist.");
LogLog::warn(LOG4CXX_STR(err.c_str()));
return -1;
- }
+ }
- if (isMapFileEmpty(pool)){
- stat = apr_file_trunc(_file_map, MAX_FILE_LEN + 1);
- if (stat != APR_SUCCESS){
- LogLog::warn(LOG4CXX_STR("apr_file_trunc failed."));
- apr_file_close(_file_map);
- return -1;
- }
- }
+ if (isMapFileEmpty(pool))
+ {
+ stat = apr_file_trunc(_file_map, MAX_FILE_LEN + 1);
- stat = apr_mmap_create(&_mmap, _file_map, 0, MAX_FILE_LEN, APR_MMAP_WRITE | APR_MMAP_READ, _mmapPool->getAPRPool());
- if (stat != APR_SUCCESS){
- LogLog::warn(LOG4CXX_STR("mmap failed."));
- apr_file_close(_file_map);
- return -1;
- }
+ if (stat != APR_SUCCESS)
+ {
+ LogLog::warn(LOG4CXX_STR("apr_file_trunc failed."));
+ apr_file_close(_file_map);
+ return -1;
+ }
+ }
- return 0;
+ stat = apr_mmap_create(&_mmap, _file_map, 0, MAX_FILE_LEN, APR_MMAP_WRITE | APR_MMAP_READ, _mmapPool->getAPRPool());
+
+ if (stat != APR_SUCCESS)
+ {
+ LogLog::warn(LOG4CXX_STR("mmap failed."));
+ apr_file_close(_file_map);
+ return -1;
+ }
+
+ return 0;
}
int TimeBasedRollingPolicy::lockMMapFile(int type)
{
apr_status_t stat = apr_file_lock(_lock_file, type);
- if (stat != APR_SUCCESS) {
+
+ if (stat != APR_SUCCESS)
+ {
LogLog::warn(LOG4CXX_STR("apr_file_lock for mmap failed."));
}
}
int TimeBasedRollingPolicy::unLockMMapFile()
{
apr_status_t stat = apr_file_unlock(_lock_file);
- if (stat != APR_SUCCESS) {
+
+ if (stat != APR_SUCCESS)
+ {
LogLog::warn(LOG4CXX_STR("apr_file_unlock for mmap failed."));
}
}
@@ -140,40 +168,48 @@
TimeBasedRollingPolicy::TimeBasedRollingPolicy()
#ifdef LOG4CXX_MULTI_PROCESS
- :_mmap(NULL), _file_map(NULL), bAlreadyInitialized(false), _mmapPool(new Pool()), _lock_file(NULL), bRefreshCurFile(false)
+ : _mmap(NULL), _file_map(NULL), bAlreadyInitialized(false), _mmapPool(new Pool()), _lock_file(NULL), bRefreshCurFile(false)
#endif
{
}
#ifdef LOG4CXX_MULTI_PROCESS
-TimeBasedRollingPolicy::~TimeBasedRollingPolicy() {
+TimeBasedRollingPolicy::~TimeBasedRollingPolicy()
+{
//no-need to delete mmap
delete _mmapPool;
}
#endif
-void TimeBasedRollingPolicy::addRef() const {
+void TimeBasedRollingPolicy::addRef() const
+{
TriggeringPolicy::addRef();
}
-void TimeBasedRollingPolicy::releaseRef() const {
+void TimeBasedRollingPolicy::releaseRef() const
+{
TriggeringPolicy::releaseRef();
}
-void TimeBasedRollingPolicy::activateOptions(log4cxx::helpers::Pool& pool) {
+void TimeBasedRollingPolicy::activateOptions(log4cxx::helpers::Pool& pool)
+{
// find out period from the filename pattern
- if (getFileNamePattern().length() > 0) {
- parseFileNamePattern();
- } else {
- LogLog::warn(
- LOG4CXX_STR("The FileNamePattern option must be set before using TimeBasedRollingPolicy. "));
- throw IllegalStateException();
+ if (getFileNamePattern().length() > 0)
+ {
+ parseFileNamePattern();
+ }
+ else
+ {
+ LogLog::warn(
+ LOG4CXX_STR("The FileNamePattern option must be set before using TimeBasedRollingPolicy. "));
+ throw IllegalStateException();
}
PatternConverterPtr dtc(getDatePatternConverter());
- if (dtc == NULL) {
- throw IllegalStateException();
+ if (dtc == NULL)
+ {
+ throw IllegalStateException();
}
apr_time_t n = apr_time_now();
@@ -183,16 +219,23 @@
lastFileName = buf;
#ifdef LOG4CXX_MULTI_PROCESS
- if (getPatternConverterList().size()){
+
+ if (getPatternConverterList().size())
+ {
(*(getPatternConverterList().begin()))->format(obj, _fileNamePattern, pool);
- }else{
+ }
+ else
+ {
_fileNamePattern = lastFileName;
}
- if (!_lock_file) {
+ if (!_lock_file)
+ {
const std::string lockname = createFile(std::string(_fileNamePattern), LOCK_FILE_SUFFIX, *_mmapPool);
apr_status_t stat = apr_file_open(&_lock_file, lockname.c_str(), APR_CREATE | APR_READ | APR_WRITE, APR_OS_DEFAULT, (*_mmapPool).getAPRPool());
- if (stat != APR_SUCCESS) {
+
+ if (stat != APR_SUCCESS)
+ {
LogLog::warn(LOG4CXX_STR("open lock file failed."));
}
}
@@ -202,154 +245,182 @@
suffixLength = 0;
- if (lastFileName.length() >= 3) {
- if (lastFileName.compare(lastFileName.length() - 3, 3, LOG4CXX_STR(".gz")) == 0) {
- suffixLength = 3;
- } else if (lastFileName.length() >= 4 && lastFileName.compare(lastFileName.length() - 4, 4, LOG4CXX_STR(".zip")) == 0) {
- suffixLength = 4;
- }
+ if (lastFileName.length() >= 3)
+ {
+ if (lastFileName.compare(lastFileName.length() - 3, 3, LOG4CXX_STR(".gz")) == 0)
+ {
+ suffixLength = 3;
+ }
+ else if (lastFileName.length() >= 4 && lastFileName.compare(lastFileName.length() - 4, 4, LOG4CXX_STR(".zip")) == 0)
+ {
+ suffixLength = 4;
+ }
}
}
#define RULES_PUT(spec, cls) \
-specs.insert(PatternMap::value_type(LogString(LOG4CXX_STR(spec)), (PatternConstructor) cls ::newInstance))
+ specs.insert(PatternMap::value_type(LogString(LOG4CXX_STR(spec)), (PatternConstructor) cls ::newInstance))
-log4cxx::pattern::PatternMap TimeBasedRollingPolicy::getFormatSpecifiers() const {
- PatternMap specs;
- RULES_PUT("d", FileDatePatternConverter);
- RULES_PUT("date", FileDatePatternConverter);
- return specs;
+log4cxx::pattern::PatternMap TimeBasedRollingPolicy::getFormatSpecifiers() const
+{
+ PatternMap specs;
+ RULES_PUT("d", FileDatePatternConverter);
+ RULES_PUT("date", FileDatePatternConverter);
+ return specs;
}
/**
* {@inheritDoc}
*/
RolloverDescriptionPtr TimeBasedRollingPolicy::initialize(
- const LogString& currentActiveFile,
- const bool append,
- Pool& pool)
+ const LogString& currentActiveFile,
+ const bool append,
+ Pool& pool)
{
- apr_time_t n = apr_time_now();
- nextCheck = ((n / APR_USEC_PER_SEC) + 1) * APR_USEC_PER_SEC;
+ apr_time_t n = apr_time_now();
+ nextCheck = ((n / APR_USEC_PER_SEC) + 1) * APR_USEC_PER_SEC;
- File currentFile(currentActiveFile);
+ File currentFile(currentActiveFile);
- LogString buf;
- ObjectPtr obj(new Date(currentFile.exists(pool) ? currentFile.lastModified(pool) : n));
- formatFileName(obj, buf, pool);
- lastFileName = buf;
+ LogString buf;
+ ObjectPtr obj(new Date(currentFile.exists(pool) ? currentFile.lastModified(pool) : n));
+ formatFileName(obj, buf, pool);
+ lastFileName = buf;
- ActionPtr noAction;
+ ActionPtr noAction;
- if (currentActiveFile.length() > 0) {
- return new RolloverDescription(
- currentActiveFile, append, noAction, noAction);
- } else {
- bRefreshCurFile = true;
- return new RolloverDescription(
- lastFileName.substr(0, lastFileName.length() - suffixLength), append,
- noAction, noAction);
- }
+ if (currentActiveFile.length() > 0)
+ {
+ return new RolloverDescription(
+ currentActiveFile, append, noAction, noAction);
+ }
+ else
+ {
+ bRefreshCurFile = true;
+ return new RolloverDescription(
+ lastFileName.substr(0, lastFileName.length() - suffixLength), append,
+ noAction, noAction);
+ }
}
RolloverDescriptionPtr TimeBasedRollingPolicy::rollover(
- const LogString& currentActiveFile,
- const bool append,
- Pool& pool)
+ const LogString& currentActiveFile,
+ const bool append,
+ Pool& pool)
{
- apr_time_t n = apr_time_now();
- nextCheck = ((n / APR_USEC_PER_SEC) + 1) * APR_USEC_PER_SEC;
+ apr_time_t n = apr_time_now();
+ nextCheck = ((n / APR_USEC_PER_SEC) + 1) * APR_USEC_PER_SEC;
- LogString buf;
- ObjectPtr obj(new Date(n));
- formatFileName(obj, buf, pool);
+ LogString buf;
+ ObjectPtr obj(new Date(n));
+ formatFileName(obj, buf, pool);
- LogString newFileName(buf);
+ LogString newFileName(buf);
#ifdef LOG4CXX_MULTI_PROCESS
- bAlreadyInitialized = true;
- if (_mmap && !isMapFileEmpty(*_mmapPool)){
- lockMMapFile(APR_FLOCK_SHARED);
- LogString mapLastFile((char *)_mmap->mm);
- lastFileName = mapLastFile;
- unLockMMapFile();
- }else{
- _mmap = NULL;
- initMMapFile(lastFileName, *_mmapPool);
- }
+ bAlreadyInitialized = true;
+
+ if (_mmap && !isMapFileEmpty(*_mmapPool))
+ {
+ lockMMapFile(APR_FLOCK_SHARED);
+ LogString mapLastFile((char*)_mmap->mm);
+ lastFileName = mapLastFile;
+ unLockMMapFile();
+ }
+ else
+ {
+ _mmap = NULL;
+ initMMapFile(lastFileName, *_mmapPool);
+ }
+
#endif
- //
- // if file names haven't changed, no rollover
- //
- if (newFileName == lastFileName) {
- RolloverDescriptionPtr desc;
- return desc;
- }
+ //
+ // if file names haven't changed, no rollover
+ //
+ if (newFileName == lastFileName)
+ {
+ RolloverDescriptionPtr desc;
+ return desc;
+ }
- ActionPtr renameAction;
- ActionPtr compressAction;
- LogString lastBaseName(
- lastFileName.substr(0, lastFileName.length() - suffixLength));
- LogString nextActiveFile(
- newFileName.substr(0, newFileName.length() - suffixLength));
+ ActionPtr renameAction;
+ ActionPtr compressAction;
+ LogString lastBaseName(
+ lastFileName.substr(0, lastFileName.length() - suffixLength));
+ LogString nextActiveFile(
+ newFileName.substr(0, newFileName.length() - suffixLength));
- //
- // if currentActiveFile is not lastBaseName then
- // active file name is not following file pattern
- // and requires a rename plus maintaining the same name
- if (currentActiveFile != lastBaseName) {
- renameAction =
- new FileRenameAction(
- File().setPath(currentActiveFile), File().setPath(lastBaseName), true);
- nextActiveFile = currentActiveFile;
- }
+ //
+ // if currentActiveFile is not lastBaseName then
+ // active file name is not following file pattern
+ // and requires a rename plus maintaining the same name
+ if (currentActiveFile != lastBaseName)
+ {
+ renameAction =
+ new FileRenameAction(
+ File().setPath(currentActiveFile), File().setPath(lastBaseName), true);
+ nextActiveFile = currentActiveFile;
+ }
- if (suffixLength == 3) {
- compressAction =
- new GZCompressAction(
- File().setPath(lastBaseName), File().setPath(lastFileName), true);
- }
+ if (suffixLength == 3)
+ {
+ compressAction =
+ new GZCompressAction(
+ File().setPath(lastBaseName), File().setPath(lastFileName), true);
+ }
- if (suffixLength == 4) {
- compressAction =
- new ZipCompressAction(
- File().setPath(lastBaseName), File().setPath(lastFileName), true);
- }
+ if (suffixLength == 4)
+ {
+ compressAction =
+ new ZipCompressAction(
+ File().setPath(lastBaseName), File().setPath(lastFileName), true);
+ }
#ifdef LOG4CXX_MULTI_PROCESS
- if (_mmap && !isMapFileEmpty(*_mmapPool)){
- lockMMapFile(APR_FLOCK_EXCLUSIVE);
- memset(_mmap->mm, 0, MAX_FILE_LEN);
- memcpy(_mmap->mm, std::string(newFileName).c_str(), std::string(newFileName).size());
- unLockMMapFile();
- }else{
- _mmap = NULL;
- initMMapFile(newFileName, *_mmapPool);
- }
+
+ if (_mmap && !isMapFileEmpty(*_mmapPool))
+ {
+ lockMMapFile(APR_FLOCK_EXCLUSIVE);
+ memset(_mmap->mm, 0, MAX_FILE_LEN);
+ memcpy(_mmap->mm, std::string(newFileName).c_str(), std::string(newFileName).size());
+ unLockMMapFile();
+ }
+ else
+ {
+ _mmap = NULL;
+ initMMapFile(newFileName, *_mmapPool);
+ }
+
#else
- lastFileName = newFileName;
+ lastFileName = newFileName;
#endif
- return new RolloverDescription(nextActiveFile, append, renameAction, compressAction);
+ return new RolloverDescription(nextActiveFile, append, renameAction, compressAction);
}
bool TimeBasedRollingPolicy::isTriggeringEvent(
- Appender* appender,
- const log4cxx::spi::LoggingEventPtr& /* event */,
- const LogString& filename ,
- size_t /* fileLength */) {
+ Appender* appender,
+ const log4cxx::spi::LoggingEventPtr& /* event */,
+ const LogString& filename,
+ size_t /* fileLength */)
+{
#ifdef LOG4CXX_MULTI_PROCESS
- if (bRefreshCurFile && _mmap && !isMapFileEmpty(*_mmapPool)) {
+
+ if (bRefreshCurFile && _mmap && !isMapFileEmpty(*_mmapPool))
+ {
lockMMapFile(APR_FLOCK_SHARED);
- LogString mapCurrent((char *)_mmap->mm);
+ LogString mapCurrent((char*)_mmap->mm);
unLockMMapFile();
LogString mapCurrentBase(mapCurrent.substr(0, mapCurrent.length() - suffixLength));
- if (!mapCurrentBase.empty() && mapCurrentBase != filename) {
- dynamic_cast<FileAppender *>(appender)->setFile(mapCurrentBase);
+
+ if (!mapCurrentBase.empty() && mapCurrentBase != filename)
+ {
+ dynamic_cast<FileAppender*>(appender)->setFile(mapCurrentBase);
}
}
+
return ((apr_time_now()) > nextCheck) || (!bAlreadyInitialized);
#else
return apr_time_now() > nextCheck;
diff --git a/src/main/cpp/timezone.cpp b/src/main/cpp/timezone.cpp
index a14aebd..822bbbe 100644
--- a/src/main/cpp/timezone.cpp
+++ b/src/main/cpp/timezone.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
#if defined(_MSC_VER)
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
@@ -39,135 +39,153 @@
namespace log4cxx
{
- namespace helpers
- {
- namespace TimeZoneImpl
- {
- /** Time zone object that represents GMT. */
- class GMTTimeZone : public TimeZone
- {
- public:
+namespace helpers
+{
+namespace TimeZoneImpl
+{
+/** Time zone object that represents GMT. */
+class GMTTimeZone : public TimeZone
+{
+ public:
/** Class factory. */
- static const TimeZonePtr & getInstance()
+ static const TimeZonePtr& getInstance()
{
- static TimeZonePtr tz( new GMTTimeZone() );
- return tz;
+ static TimeZonePtr tz( new GMTTimeZone() );
+ return tz;
}
/** Explode time to human readable form. */
- log4cxx_status_t explode( apr_time_exp_t * result, log4cxx_time_t input ) const
+ log4cxx_status_t explode( apr_time_exp_t* result, log4cxx_time_t input ) const
{
- apr_status_t stat;
- // APR 1.1 and early mishandles microseconds on dates
- // before 1970, APR bug 32520
- if (LOG4CXX_UNLIKELY(input < 0 && apr_time_usec(input) < 0)) {
- apr_time_t floorTime = (apr_time_sec(input) -1) * APR_USEC_PER_SEC;
- stat = apr_time_exp_gmt(result, floorTime);
- result->tm_usec = (int) (input - floorTime);
- } else {
- stat = apr_time_exp_gmt( result, input );
- }
- return stat;
+ apr_status_t stat;
+
+ // APR 1.1 and early mishandles microseconds on dates
+ // before 1970, APR bug 32520
+ if (LOG4CXX_UNLIKELY(input < 0 && apr_time_usec(input) < 0))
+ {
+ apr_time_t floorTime = (apr_time_sec(input) - 1) * APR_USEC_PER_SEC;
+ stat = apr_time_exp_gmt(result, floorTime);
+ result->tm_usec = (int) (input - floorTime);
+ }
+ else
+ {
+ stat = apr_time_exp_gmt( result, input );
+ }
+
+ return stat;
}
- private:
+ private:
GMTTimeZone() : TimeZone( LOG4CXX_STR("GMT") )
{
}
- };
+};
- /** Time zone object that represents GMT. */
- class LocalTimeZone : public TimeZone
- {
- public:
+/** Time zone object that represents GMT. */
+class LocalTimeZone : public TimeZone
+{
+ public:
/** Class factory. */
- static const TimeZonePtr & getInstance()
+ static const TimeZonePtr& getInstance()
{
- static TimeZonePtr tz( new LocalTimeZone() );
- return tz;
+ static TimeZonePtr tz( new LocalTimeZone() );
+ return tz;
}
/** Explode time to human readable form. */
- log4cxx_status_t explode( apr_time_exp_t * result, log4cxx_time_t input ) const
+ log4cxx_status_t explode( apr_time_exp_t* result, log4cxx_time_t input ) const
{
- apr_status_t stat;
- // APR 1.1 and early mishandles microseconds on dates
- // before 1970, APR bug 32520
- if (LOG4CXX_UNLIKELY(input < 0 && apr_time_usec(input) < 0)) {
- apr_time_t floorTime = (apr_time_sec(input) -1) * APR_USEC_PER_SEC;
- stat = apr_time_exp_lt(result, floorTime);
- result->tm_usec = (int) (input - floorTime);
- } else {
- stat = apr_time_exp_lt( result, input );
- }
- return stat;
+ apr_status_t stat;
+
+ // APR 1.1 and early mishandles microseconds on dates
+ // before 1970, APR bug 32520
+ if (LOG4CXX_UNLIKELY(input < 0 && apr_time_usec(input) < 0))
+ {
+ apr_time_t floorTime = (apr_time_sec(input) - 1) * APR_USEC_PER_SEC;
+ stat = apr_time_exp_lt(result, floorTime);
+ result->tm_usec = (int) (input - floorTime);
+ }
+ else
+ {
+ stat = apr_time_exp_lt( result, input );
+ }
+
+ return stat;
}
- private:
+ private:
LocalTimeZone() : TimeZone( getTimeZoneName() )
{
}
static const LogString getTimeZoneName()
{
- const int MAX_TZ_LENGTH = 255;
- char tzName[MAX_TZ_LENGTH];
- apr_size_t tzLength;
- apr_time_exp_t tm;
- apr_time_exp_lt(&tm, 0);
- apr_strftime(tzName, &tzLength, MAX_TZ_LENGTH, "%Z", &tm);
- if (tzLength == 0) {
- apr_strftime(tzName, &tzLength, MAX_TZ_LENGTH, "%z", &tm);
- }
- tzName[tzLength] = 0;
- LogString retval;
- log4cxx::helpers::Transcoder::decode(tzName, retval);
- return retval;
+ const int MAX_TZ_LENGTH = 255;
+ char tzName[MAX_TZ_LENGTH];
+ apr_size_t tzLength;
+ apr_time_exp_t tm;
+ apr_time_exp_lt(&tm, 0);
+ apr_strftime(tzName, &tzLength, MAX_TZ_LENGTH, "%Z", &tm);
+
+ if (tzLength == 0)
+ {
+ apr_strftime(tzName, &tzLength, MAX_TZ_LENGTH, "%z", &tm);
+ }
+
+ tzName[tzLength] = 0;
+ LogString retval;
+ log4cxx::helpers::Transcoder::decode(tzName, retval);
+ return retval;
}
- };
+};
- /** Time zone object that represents a fixed offset from GMT. */
- class FixedTimeZone : public TimeZone
- {
- public:
- FixedTimeZone( const LogString & name, apr_int32_t offset1 ) : TimeZone( name ), offset( offset1 )
+/** Time zone object that represents a fixed offset from GMT. */
+class FixedTimeZone : public TimeZone
+{
+ public:
+ FixedTimeZone( const LogString& name, apr_int32_t offset1 ) : TimeZone( name ), offset( offset1 )
{
}
/** Explode time to human readable form. */
- log4cxx_status_t explode( apr_time_exp_t * result, log4cxx_time_t input ) const
+ log4cxx_status_t explode( apr_time_exp_t* result, log4cxx_time_t input ) const
{
- apr_status_t stat;
- // APR 1.1 and early mishandles microseconds on dates
- // before 1970, APR bug 32520
- if (LOG4CXX_UNLIKELY(input < 0 && apr_time_usec(input) < 0)) {
- apr_time_t floorTime = (apr_time_sec(input) -1) * APR_USEC_PER_SEC;
- stat = apr_time_exp_tz(result, floorTime, offset);
- result->tm_usec = (int) (input - floorTime);
- } else {
- stat = apr_time_exp_tz( result, input, offset );
- }
- return stat;
+ apr_status_t stat;
+
+ // APR 1.1 and early mishandles microseconds on dates
+ // before 1970, APR bug 32520
+ if (LOG4CXX_UNLIKELY(input < 0 && apr_time_usec(input) < 0))
+ {
+ apr_time_t floorTime = (apr_time_sec(input) - 1) * APR_USEC_PER_SEC;
+ stat = apr_time_exp_tz(result, floorTime, offset);
+ result->tm_usec = (int) (input - floorTime);
+ }
+ else
+ {
+ stat = apr_time_exp_tz( result, input, offset );
+ }
+
+ return stat;
}
- private:
+ private:
const apr_int32_t offset;
- };
+};
- }
- }
+}
+}
}
-TimeZone::TimeZone( const LogString & id1 ) : id( id1 )
+TimeZone::TimeZone( const LogString& id1 ) : id( id1 )
{
}
@@ -175,76 +193,99 @@
{
}
-const TimeZonePtr & TimeZone::getDefault()
+const TimeZonePtr& TimeZone::getDefault()
{
- return log4cxx::helpers::TimeZoneImpl::LocalTimeZone::getInstance();
+ return log4cxx::helpers::TimeZoneImpl::LocalTimeZone::getInstance();
}
-const TimeZonePtr & TimeZone::getGMT()
+const TimeZonePtr& TimeZone::getGMT()
{
- return log4cxx::helpers::TimeZoneImpl::GMTTimeZone::getInstance();
-}
-
-const TimeZonePtr TimeZone::getTimeZone( const LogString & id )
-{
- const logchar gmt[] = { 0x47, 0x4D, 0x54, 0 };
- if ( id == gmt )
- {
return log4cxx::helpers::TimeZoneImpl::GMTTimeZone::getInstance();
- }
- if ( id.length() >= 5 && id.substr( 0, 3 ) == gmt )
- {
- int hours = 0;
- int minutes = 0;
- int sign = 1;
- if (id[3] == 0x2D /* '-' */) {
- sign = -1;
- }
- LogString off( id.substr( 4 ) );
- if ( id.length() >= 7 )
+}
+
+const TimeZonePtr TimeZone::getTimeZone( const LogString& id )
+{
+ const logchar gmt[] = { 0x47, 0x4D, 0x54, 0 };
+
+ if ( id == gmt )
{
- size_t colonPos = off.find( 0x3A /* ':' */);
- if ( colonPos == LogString::npos )
- {
- minutes = StringHelper::toInt(off.substr(off.length() - 2));
- hours = StringHelper::toInt(off.substr(0, off.length() - 2));
- }
- else
- {
- minutes = StringHelper::toInt(off.substr(colonPos + 1));
- hours = StringHelper::toInt(off.substr(0, colonPos));
- }
- } else {
- hours = StringHelper::toInt(off);
+ return log4cxx::helpers::TimeZoneImpl::GMTTimeZone::getInstance();
}
- LogString s(gmt);
- Pool p;
- LogString hh;
- StringHelper::toString(hours, p, hh);
- if (sign > 0) {
- s.append(1, (logchar) 0x2B /* '+' */);
- } else {
- s.append(1, (logchar) 0x2D /* '-' */);
+
+ if ( id.length() >= 5 && id.substr( 0, 3 ) == gmt )
+ {
+ int hours = 0;
+ int minutes = 0;
+ int sign = 1;
+
+ if (id[3] == 0x2D /* '-' */)
+ {
+ sign = -1;
+ }
+
+ LogString off( id.substr( 4 ) );
+
+ if ( id.length() >= 7 )
+ {
+ size_t colonPos = off.find( 0x3A /* ':' */);
+
+ if ( colonPos == LogString::npos )
+ {
+ minutes = StringHelper::toInt(off.substr(off.length() - 2));
+ hours = StringHelper::toInt(off.substr(0, off.length() - 2));
+ }
+ else
+ {
+ minutes = StringHelper::toInt(off.substr(colonPos + 1));
+ hours = StringHelper::toInt(off.substr(0, colonPos));
+ }
+ }
+ else
+ {
+ hours = StringHelper::toInt(off);
+ }
+
+ LogString s(gmt);
+ Pool p;
+ LogString hh;
+ StringHelper::toString(hours, p, hh);
+
+ if (sign > 0)
+ {
+ s.append(1, (logchar) 0x2B /* '+' */);
+ }
+ else
+ {
+ s.append(1, (logchar) 0x2D /* '-' */);
+ }
+
+ if (hh.length() == 1)
+ {
+ s.append(1, (logchar) 0x30 /* '0' */);
+ }
+
+ s.append(hh);
+ s.append(1, (logchar) 0x3A /*' :' */);
+ LogString mm;
+ StringHelper::toString(minutes, p, mm);
+
+ if (mm.length() == 1)
+ {
+ s.append(1, (logchar) 0x30 /* '0' */);
+ }
+
+ s.append(mm);
+ apr_int32_t offset = sign * (hours * 3600 + minutes * 60);
+ return new log4cxx::helpers::TimeZoneImpl::FixedTimeZone( s, offset );
}
- if (hh.length() == 1) {
- s.append(1, (logchar) 0x30 /* '0' */);
+
+ const TimeZonePtr& ltz = getDefault();
+
+ if ( ltz->getID() == id )
+ {
+ return ltz;
}
- s.append(hh);
- s.append(1, (logchar) 0x3A /*' :' */);
- LogString mm;
- StringHelper::toString(minutes, p, mm);
- if (mm.length() == 1) {
- s.append(1, (logchar) 0x30 /* '0' */);
- }
- s.append(mm);
- apr_int32_t offset = sign * (hours * 3600 + minutes * 60);
- return new log4cxx::helpers::TimeZoneImpl::FixedTimeZone( s, offset );
- }
- const TimeZonePtr & ltz = getDefault();
- if ( ltz->getID() == id )
- {
- return ltz;
- }
- return getGMT();
+
+ return getGMT();
}
diff --git a/src/main/cpp/transcoder.cpp b/src/main/cpp/transcoder.cpp
index c3e6f62..ac58d3f 100644
--- a/src/main/cpp/transcoder.cpp
+++ b/src/main/cpp/transcoder.cpp
@@ -27,85 +27,112 @@
#include <apr.h>
#include <apr_strings.h>
#if !defined(LOG4CXX)
-#define LOG4CXX 1
+ #define LOG4CXX 1
#endif
#include <log4cxx/private/log4cxx_private.h>
#if LOG4CXX_LOGCHAR_IS_UNICHAR || LOG4CXX_CFSTRING_API || LOG4CXX_UNICHAR_API
-#include <CoreFoundation/CFString.h>
+ #include <CoreFoundation/CFString.h>
#endif
using namespace log4cxx;
using namespace log4cxx::helpers;
-void Transcoder::decodeUTF8(const std::string& src, LogString& dst) {
- std::string::const_iterator iter = src.begin();
- while(iter != src.end()) {
- unsigned int sv = decode(src, iter);
- if(sv != 0xFFFF) {
+void Transcoder::decodeUTF8(const std::string& src, LogString& dst)
+{
+ std::string::const_iterator iter = src.begin();
+
+ while (iter != src.end())
+ {
+ unsigned int sv = decode(src, iter);
+
+ if (sv != 0xFFFF)
+ {
encode(sv, dst);
- } else {
+ }
+ else
+ {
dst.append(1, LOSSCHAR);
iter++;
}
- }
+ }
}
-void Transcoder::encodeUTF8(const LogString& src, std::string& dst) {
+void Transcoder::encodeUTF8(const LogString& src, std::string& dst)
+{
#if LOG4CXX_LOGCHAR_IS_UTF8
- dst.append(src);
+ dst.append(src);
#else
- LogString::const_iterator iter = src.begin();
- while(iter != src.end()) {
- unsigned int sv = decode(src, iter);
- if(sv != 0xFFFF) {
+ LogString::const_iterator iter = src.begin();
+
+ while (iter != src.end())
+ {
+ unsigned int sv = decode(src, iter);
+
+ if (sv != 0xFFFF)
+ {
encode(sv, dst);
- } else {
+ }
+ else
+ {
dst.append(1, LOSSCHAR);
iter++;
}
- }
+ }
+
#endif
}
-char* Transcoder::encodeUTF8(const LogString& src, Pool& p) {
+char* Transcoder::encodeUTF8(const LogString& src, Pool& p)
+{
#if LOG4CXX_LOGCHAR_IS_UTF8
- return p.pstrdup(src);
+ return p.pstrdup(src);
#else
- std::string tmp;
- encodeUTF8(src, tmp);
- return p.pstrdup(tmp);
+ std::string tmp;
+ encodeUTF8(src, tmp);
+ return p.pstrdup(tmp);
#endif
}
-void Transcoder::encodeUTF8(unsigned int sv, ByteBuffer& dst) {
+void Transcoder::encodeUTF8(unsigned int sv, ByteBuffer& dst)
+{
size_t bytes = encodeUTF8(sv, dst.current());
dst.position(dst.position() + bytes);
}
-size_t Transcoder::encodeUTF8(unsigned int ch, char* dst) {
- if (ch < 0x80) {
+size_t Transcoder::encodeUTF8(unsigned int ch, char* dst)
+{
+ if (ch < 0x80)
+ {
dst[0] = (char) ch;
return 1;
- } else if (ch < 0x800) {
+ }
+ else if (ch < 0x800)
+ {
dst[0] = (char) (0xC0 + (ch >> 6));
dst[1] = (char) (0x80 + (ch & 0x3F));
return 2;
- } else if (ch < 0x10000) {
+ }
+ else if (ch < 0x10000)
+ {
dst[0] = (char) (0xE0 + (ch >> 12));
dst[1] = (char) (0x80 + ((ch >> 6) & 0x3F));
dst[2] = (char) (0x80 + (ch & 0x3F));
return 3;
- } else if (ch <= 0x10FFFF) {
+ }
+ else if (ch <= 0x10FFFF)
+ {
dst[0] = (char) (0xF0 + (ch >> 18));
dst[1] = (char) (0x80 + ((ch >> 12) & 0x3F));
dst[2] = (char) (0x80 + ((ch >> 6) & 0x3F));
dst[3] = (char) (0x80 + (ch & 0x3F));
return 4;
- } else {
+ }
+ else
+ {
//
// output UTF-8 encoding of 0xFFFF
//
@@ -116,19 +143,24 @@
}
}
-void Transcoder::encodeUTF16BE(unsigned int sv, ByteBuffer& dst) {
+void Transcoder::encodeUTF16BE(unsigned int sv, ByteBuffer& dst)
+{
size_t bytes = encodeUTF16BE(sv, dst.current());
dst.position(dst.position() + bytes);
}
-size_t Transcoder::encodeUTF16BE(unsigned int ch, char* dst) {
- if (ch <= 0xFFFF) {
+size_t Transcoder::encodeUTF16BE(unsigned int ch, char* dst)
+{
+ if (ch <= 0xFFFF)
+ {
dst[0] = (char) (ch >> 8);
dst[1] = (char) (ch & 0xFF);
return 2;
}
- if (ch <= 0x10FFFF) {
+
+ if (ch <= 0x10FFFF)
+ {
unsigned char w = (unsigned char) ((ch >> 16) - 1);
dst[0] = (char) (0xD8 + (w >> 2));
dst[1] = (char) (((w & 0x03) << 6) + ((ch >> 10) & 0x3F));
@@ -136,22 +168,28 @@
dst[3] = (char) (ch & 0xFF);
return 4;
}
+
dst[0] = dst[1] = (char) 0xFF;
return 2;
}
-void Transcoder::encodeUTF16LE(unsigned int sv, ByteBuffer& dst) {
+void Transcoder::encodeUTF16LE(unsigned int sv, ByteBuffer& dst)
+{
size_t bytes = encodeUTF16LE(sv, dst.current());
dst.position(dst.position() + bytes);
}
-size_t Transcoder::encodeUTF16LE(unsigned int ch, char* dst) {
- if (ch <= 0xFFFF) {
+size_t Transcoder::encodeUTF16LE(unsigned int ch, char* dst)
+{
+ if (ch <= 0xFFFF)
+ {
dst[1] = (char) (ch >> 8);
dst[0] = (char) (ch & 0xFF);
return 2;
}
- if (ch <= 0x10FFFF) {
+
+ if (ch <= 0x10FFFF)
+ {
unsigned char w = (unsigned char) ((ch >> 16) - 1);
dst[1] = (char) (0xD8 + (w >> 2));
dst[0] = (char) (((w & 0x03) << 6) + ((ch >> 10) & 0x3F));
@@ -159,189 +197,260 @@
dst[2] = (char) (ch & 0xFF);
return 4;
}
+
dst[0] = dst[1] = (char) 0xFF;
return 2;
}
unsigned int Transcoder::decode(const std::string& src,
- std::string::const_iterator& iter) {
- std::string::const_iterator start(iter);
- unsigned char ch1 = *(iter++);
- if (ch1 <= 0x7F) {
- return ch1;
- }
- //
- // should not have continuation character here
- //
- if ((ch1 & 0xC0) != 0x80 && iter != src.end()) {
- unsigned char ch2 = *(iter++);
- //
- // should be continuation
- if ((ch2 & 0xC0) != 0x80) {
- iter = start;
- return 0xFFFF;
- }
- if((ch1 & 0xE0) == 0xC0) {
- if ((ch2 & 0xC0) == 0x80) {
- unsigned int rv = ((ch1 & 0x1F) << 6) + (ch2 & 0x3F);
- if (rv >= 0x80) {
- return rv;
- }
- }
- iter = start;
- return 0xFFFF;
- }
- if (iter != src.end()) {
- unsigned char ch3 = *(iter++);
- //
- // should be continuation
- //
- if ((ch3 & 0xC0) != 0x80) {
- iter = start;
- return 0xFFFF;
- }
- if ((ch1 & 0xF0) == 0xE0) {
- unsigned rv = ((ch1 & 0x0F) << 12)
- + ((ch2 & 0x3F) << 6)
- + (ch3 & 0x3F);
- if (rv <= 0x800) {
- iter = start;
- return 0xFFFF;
- }
- return rv;
- }
- if (iter != src.end()) {
- unsigned char ch4 = *(iter++);
- if ((ch4 & 0xC0) != 0x80) {
- iter = start;
- return 0xFFFF;
- }
- unsigned int rv = ((ch1 & 0x07) << 18)
- + ((ch2 & 0x3F) << 12)
- + ((ch3 & 0x3F) << 6)
- + (ch4 & 0x3F);
- if (rv > 0xFFFF) {
- return rv;
- }
+ std::string::const_iterator& iter)
+{
+ std::string::const_iterator start(iter);
+ unsigned char ch1 = *(iter++);
- }
- }
- }
- iter = start;
- return 0xFFFF;
+ if (ch1 <= 0x7F)
+ {
+ return ch1;
+ }
+
+ //
+ // should not have continuation character here
+ //
+ if ((ch1 & 0xC0) != 0x80 && iter != src.end())
+ {
+ unsigned char ch2 = *(iter++);
+
+ //
+ // should be continuation
+ if ((ch2 & 0xC0) != 0x80)
+ {
+ iter = start;
+ return 0xFFFF;
+ }
+
+ if ((ch1 & 0xE0) == 0xC0)
+ {
+ if ((ch2 & 0xC0) == 0x80)
+ {
+ unsigned int rv = ((ch1 & 0x1F) << 6) + (ch2 & 0x3F);
+
+ if (rv >= 0x80)
+ {
+ return rv;
+ }
+ }
+
+ iter = start;
+ return 0xFFFF;
+ }
+
+ if (iter != src.end())
+ {
+ unsigned char ch3 = *(iter++);
+
+ //
+ // should be continuation
+ //
+ if ((ch3 & 0xC0) != 0x80)
+ {
+ iter = start;
+ return 0xFFFF;
+ }
+
+ if ((ch1 & 0xF0) == 0xE0)
+ {
+ unsigned rv = ((ch1 & 0x0F) << 12)
+ + ((ch2 & 0x3F) << 6)
+ + (ch3 & 0x3F);
+
+ if (rv <= 0x800)
+ {
+ iter = start;
+ return 0xFFFF;
+ }
+
+ return rv;
+ }
+
+ if (iter != src.end())
+ {
+ unsigned char ch4 = *(iter++);
+
+ if ((ch4 & 0xC0) != 0x80)
+ {
+ iter = start;
+ return 0xFFFF;
+ }
+
+ unsigned int rv = ((ch1 & 0x07) << 18)
+ + ((ch2 & 0x3F) << 12)
+ + ((ch3 & 0x3F) << 6)
+ + (ch4 & 0x3F);
+
+ if (rv > 0xFFFF)
+ {
+ return rv;
+ }
+
+ }
+ }
+ }
+
+ iter = start;
+ return 0xFFFF;
}
-void Transcoder::encode(unsigned int sv, std::string& dst) {
+void Transcoder::encode(unsigned int sv, std::string& dst)
+{
char tmp[8];
size_t bytes = encodeUTF8(sv, tmp);
dst.append(tmp, bytes);
}
-void Transcoder::decode(const std::string& src, LogString& dst) {
+void Transcoder::decode(const std::string& src, LogString& dst)
+{
#if LOG4CXX_CHARSET_UTF8 && LOG4CXX_LOGCHAR_IS_UTF8
- dst.append(src);
+ dst.append(src);
#else
- static CharsetDecoderPtr decoder(CharsetDecoder::getDefaultDecoder());
- dst.reserve(dst.size() + src.size());
- std::string::const_iterator iter = src.begin();
+ static CharsetDecoderPtr decoder(CharsetDecoder::getDefaultDecoder());
+ dst.reserve(dst.size() + src.size());
+ std::string::const_iterator iter = src.begin();
#if !LOG4CXX_CHARSET_EBCDIC
- for(;
- iter != src.end() && ((unsigned char) *iter) < 0x80;
- iter++) {
- dst.append(1, *iter);
- }
-#endif
- if (iter != src.end()) {
- size_t offset = iter - src.begin();
- ByteBuffer buf(const_cast<char*>(src.data() + offset), src.size() - offset);
- while(buf.remaining() > 0) {
- log4cxx_status_t stat = decoder->decode(buf, dst);
- if(CharsetDecoder::isError(stat)) {
- dst.append(1, LOSSCHAR);
- buf.position(buf.position() + 1);
- }
+
+ for (;
+ iter != src.end() && ((unsigned char) *iter) < 0x80;
+ iter++)
+ {
+ dst.append(1, *iter);
}
- decoder->decode(buf, dst);
- }
+
+#endif
+
+ if (iter != src.end())
+ {
+ size_t offset = iter - src.begin();
+ ByteBuffer buf(const_cast<char*>(src.data() + offset), src.size() - offset);
+
+ while (buf.remaining() > 0)
+ {
+ log4cxx_status_t stat = decoder->decode(buf, dst);
+
+ if (CharsetDecoder::isError(stat))
+ {
+ dst.append(1, LOSSCHAR);
+ buf.position(buf.position() + 1);
+ }
+ }
+
+ decoder->decode(buf, dst);
+ }
+
#endif
}
-char* Transcoder::encode(const LogString& src, Pool& p) {
+char* Transcoder::encode(const LogString& src, Pool& p)
+{
#if LOG4CXX_CHARSET_UTF8 && LOG4CXX_LOGCHAR_IS_UTF8
- return p.pstrdup(src);
+ return p.pstrdup(src);
#else
- std::string tmp;
- encode(src, tmp);
- return p.pstrdup(tmp);
+ std::string tmp;
+ encode(src, tmp);
+ return p.pstrdup(tmp);
#endif
}
-void Transcoder::encode(const LogString& src, std::string& dst) {
+void Transcoder::encode(const LogString& src, std::string& dst)
+{
#if LOG4CXX_CHARSET_UTF8 && LOG4CXX_LOGCHAR_IS_UTF8
- dst.append(src);
+ dst.append(src);
#else
- static CharsetEncoderPtr encoder(CharsetEncoder::getDefaultEncoder());
- dst.reserve(dst.size() + src.size());
- LogString::const_iterator iter = src.begin();
+ static CharsetEncoderPtr encoder(CharsetEncoder::getDefaultEncoder());
+ dst.reserve(dst.size() + src.size());
+ LogString::const_iterator iter = src.begin();
#if !LOG4CXX_CHARSET_EBCDIC
- for(;
- iter != src.end() && ((unsigned int) *iter) < 0x80;
- iter++) {
- dst.append(1, *iter);
- }
-#endif
- if (iter != src.end()) {
- char buf[BUFSIZE];
- ByteBuffer out(buf, BUFSIZE);
- while(iter != src.end()) {
- log4cxx_status_t stat = encoder->encode(src, iter, out);
- out.flip();
- dst.append(out.data(), out.limit());
- out.clear();
- if (CharsetEncoder::isError(stat)) {
- dst.append(1, LOSSCHAR);
- iter++;
- }
+
+ for (;
+ iter != src.end() && ((unsigned int) *iter) < 0x80;
+ iter++)
+ {
+ dst.append(1, *iter);
}
- encoder->encode(src, iter, out);
- }
+
+#endif
+
+ if (iter != src.end())
+ {
+ char buf[BUFSIZE];
+ ByteBuffer out(buf, BUFSIZE);
+
+ while (iter != src.end())
+ {
+ log4cxx_status_t stat = encoder->encode(src, iter, out);
+ out.flip();
+ dst.append(out.data(), out.limit());
+ out.clear();
+
+ if (CharsetEncoder::isError(stat))
+ {
+ dst.append(1, LOSSCHAR);
+ iter++;
+ }
+ }
+
+ encoder->encode(src, iter, out);
+ }
+
#endif
}
template<class String, class Iterator>
-static unsigned int decodeUTF16(const String& in, Iterator& iter) {
+static unsigned int decodeUTF16(const String& in, Iterator& iter)
+{
unsigned int ch1 = *iter;
+
//
// if not surrogate pair
//
- if (ch1 < 0xD800 || ch1 > 0xDFFF) {
+ if (ch1 < 0xD800 || ch1 > 0xDFFF)
+ {
//
// then advance iterator and return wchar_t value
//
- if(ch1 != 0xFFFF) iter++;
+ if (ch1 != 0xFFFF)
+ {
+ iter++;
+ }
+
return ch1;
- } else if (ch1 < 0xDC00) {
+ }
+ else if (ch1 < 0xDC00)
+ {
//
// started with high-surrogate value
// if there is an additional wchar_t
Iterator iter2 = iter + 1;
- if (iter2 != in.end()) {
- unsigned int ch2 = *iter2;
- //
- // if it is a matching low surrogate then
- // advance the iterator and return the scalar value
- if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) {
- iter += 2;
- return (ch1 - 0xD800) * 0x400 + (ch2 - 0xDC00) + 0x10000;
- }
+
+ if (iter2 != in.end())
+ {
+ unsigned int ch2 = *iter2;
+
+ //
+ // if it is a matching low surrogate then
+ // advance the iterator and return the scalar value
+ if (ch2 >= 0xDC00 && ch2 <= 0xDFFF)
+ {
+ iter += 2;
+ return (ch1 - 0xD800) * 0x400 + (ch2 - 0xDC00) + 0x10000;
+ }
}
}
+
//
// unrecognized value, do not advance iterator
//
@@ -349,10 +458,14 @@
}
template<class String>
-static void encodeUTF16(unsigned int sv, String& dst) {
- if (sv < 0x10000) {
+static void encodeUTF16(unsigned int sv, String& dst)
+{
+ if (sv < 0x10000)
+ {
dst.append(1, sv);
- } else {
+ }
+ else
+ {
unsigned char u = (unsigned char) (sv >> 16);
unsigned char w = (unsigned char) (u - 1);
unsigned short hs = (0xD800 + ((w & 0xF) << 6) + ((sv & 0xFFFF) >> 10));
@@ -365,36 +478,49 @@
#if LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR_T || defined(WIN32) || defined(_WIN32)
-void Transcoder::decode(const std::wstring& src, LogString& dst) {
+void Transcoder::decode(const std::wstring& src, LogString& dst)
+{
#if LOG4CXX_LOGCHAR_IS_WCHAR_T
- dst.append(src, len);
+ dst.append(src, len);
#else
- std::wstring::const_iterator i = src.begin();
- while(i != src.end()) {
- unsigned int cp = decode(src, i);
- if (cp != 0xFFFF) {
+ std::wstring::const_iterator i = src.begin();
+
+ while (i != src.end())
+ {
+ unsigned int cp = decode(src, i);
+
+ if (cp != 0xFFFF)
+ {
+ encode(cp, dst);
+ }
+ else
+ {
+ dst.append(1, LOSSCHAR);
+ i++;
+ }
+ }
+
+#endif
+}
+
+void Transcoder::encode(const LogString& src, std::wstring& dst)
+{
+#if LOG4CXX_LOGCHAR_IS_WCHAR_T
+ dst.append(src);
+#else
+
+ for (LogString::const_iterator i = src.begin();
+ i != src.end();)
+ {
+ unsigned int cp = Transcoder::decode(src, i);
encode(cp, dst);
- } else {
- dst.append(1, LOSSCHAR);
- i++;
- }
- }
+ }
+
#endif
}
-void Transcoder::encode(const LogString& src, std::wstring& dst) {
-#if LOG4CXX_LOGCHAR_IS_WCHAR_T
- dst.append(src);
-#else
- for(LogString::const_iterator i = src.begin();
- i != src.end();) {
- unsigned int cp = Transcoder::decode(src, i);
- encode(cp, dst);
- }
-#endif
-}
-
-wchar_t* Transcoder::wencode(const LogString& src, Pool& p) {
+wchar_t* Transcoder::wencode(const LogString& src, Pool& p)
+{
#if LOG4CXX_LOGCHAR_IS_WCHAR_T
std::wstring& tmp = src;
#else
@@ -409,7 +535,8 @@
unsigned int Transcoder::decode(const std::wstring& in,
- std::wstring::const_iterator& iter) {
+ std::wstring::const_iterator& iter)
+{
#if defined(__STDC_ISO_10646__)
return *(iter++);
#else
@@ -418,15 +545,21 @@
}
-void Transcoder::encode(unsigned int sv, std::wstring& dst) {
+void Transcoder::encode(unsigned int sv, std::wstring& dst)
+{
#if defined(__STDC_ISO_10646__)
dst.append(1, sv);
#else
- if (sizeof(wchar_t) == 4) {
+
+ if (sizeof(wchar_t) == 4)
+ {
dst.append(1, sv);
- } else {
+ }
+ else
+ {
encodeUTF16(sv, dst);
}
+
#endif
}
@@ -435,78 +568,98 @@
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
-void Transcoder::decode(const std::basic_string<UniChar>& src, LogString& dst) {
+void Transcoder::decode(const std::basic_string<UniChar>& src, LogString& dst)
+{
#if LOG4CXX_LOGCHAR_IS_UNICHAR
- dst.append(src);
+ dst.append(src);
#else
- for(std::basic_string<UniChar>::const_iterator i = src.begin();
- i != src.end();) {
- unsigned int cp = decode(src, i);
- encode(cp, dst);
- }
+
+ for (std::basic_string<UniChar>::const_iterator i = src.begin();
+ i != src.end();)
+ {
+ unsigned int cp = decode(src, i);
+ encode(cp, dst);
+ }
+
#endif
}
-void Transcoder::encode(const LogString& src, std::basic_string<UniChar>& dst) {
+void Transcoder::encode(const LogString& src, std::basic_string<UniChar>& dst)
+{
#if LOG4CXX_LOGCHAR_IS_UNICHAR
- dst.append(src);
+ dst.append(src);
#else
- for(LogString::const_iterator i = src.begin();
- i != src.end();) {
- unsigned int cp = decode(src, i);
- encode(cp, dst);
- }
+
+ for (LogString::const_iterator i = src.begin();
+ i != src.end();)
+ {
+ unsigned int cp = decode(src, i);
+ encode(cp, dst);
+ }
+
#endif
}
unsigned int Transcoder::decode(const std::basic_string<UniChar>& in,
- std::basic_string<UniChar>::const_iterator& iter) {
+ std::basic_string<UniChar>::const_iterator& iter)
+{
return decodeUTF16(in, iter);
}
-void Transcoder::encode(unsigned int sv, std::basic_string<UniChar>& dst) {
+void Transcoder::encode(unsigned int sv, std::basic_string<UniChar>& dst)
+{
encodeUTF16(sv, dst);
}
#endif
#if LOG4CXX_CFSTRING_API
-void Transcoder::decode(const CFStringRef& src, LogString& dst) {
- const UniChar* chars = CFStringGetCharactersPtr(src);
- if (chars) {
- decode(chars, dst);
- } else {
- size_t length = CFStringGetLength(src);
- if (length > 0) {
- std::vector<UniChar> tmp(length);
- CFStringGetCharacters(src, CFRangeMake(0, length), &tmp[0]);
+void Transcoder::decode(const CFStringRef& src, LogString& dst)
+{
+ const UniChar* chars = CFStringGetCharactersPtr(src);
+
+ if (chars)
+ {
+ decode(chars, dst);
+ }
+ else
+ {
+ size_t length = CFStringGetLength(src);
+
+ if (length > 0)
+ {
+ std::vector<UniChar> tmp(length);
+ CFStringGetCharacters(src, CFRangeMake(0, length), &tmp[0]);
#if LOG4CXX_LOGCHAR_IS_UNICHAR
- dst.append(&tmp[0], tmp.size());
+ dst.append(&tmp[0], tmp.size());
#else
- decode(std::basic_string<UniChar>(&tmp[0], tmp.size()), dst);
+ decode(std::basic_string<UniChar>(&tmp[0], tmp.size()), dst);
#endif
- }
+ }
}
}
-CFStringRef Transcoder::encode(const LogString& src) {
+CFStringRef Transcoder::encode(const LogString& src)
+{
LOG4CXX_ENCODE_UNICHAR(tmp, src);
return CFStringCreateWithCharacters(kCFAllocatorDefault, tmp.data(), tmp.size());
}
#endif
-logchar Transcoder::decode(char val) {
+logchar Transcoder::decode(char val)
+{
#if LOG4CXX_CHARSET_EBCDIC
- LogString dst;
- Transcoder::decode(std::string(1, val), dst);
- return dst[0];
+ LogString dst;
+ Transcoder::decode(std::string(1, val), dst);
+ return dst[0];
#else
- return val;
+ return val;
#endif
}
-LogString Transcoder::decode(const char* val) {
+LogString Transcoder::decode(const char* val)
+{
#if LOG4CXX_LOGCHAR_IS_UTF8 && !LOG4CXX_CHARSET_EBCDIC
return val;
#else
@@ -517,22 +670,30 @@
}
-std::string Transcoder::encodeCharsetName(const LogString& val) {
- char asciiTable[] = { ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
- '0', '1', '2', '3', '4', '5', '6' , '7', '8', '9', ':', ';', '<', '=', '>', '?',
- '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
- '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~' };
+std::string Transcoder::encodeCharsetName(const LogString& val)
+{
+ char asciiTable[] = { ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+ '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'
+ };
std::string out;
- for(LogString::const_iterator iter = val.begin();
- iter != val.end();
- iter++) {
- if (*iter >= 0x20 && *iter < 0x7F) {
+
+ for (LogString::const_iterator iter = val.begin();
+ iter != val.end();
+ iter++)
+ {
+ if (*iter >= 0x20 && *iter < 0x7F)
+ {
out.append(1, asciiTable[*iter - 0x20]);
- } else {
+ }
+ else
+ {
out.append(1, LOSSCHAR);
}
}
+
return out;
}
diff --git a/src/main/cpp/transform.cpp b/src/main/cpp/transform.cpp
index 6528b3c..fbae6f8 100644
--- a/src/main/cpp/transform.cpp
+++ b/src/main/cpp/transform.cpp
@@ -24,94 +24,108 @@
void Transform::appendEscapingTags(
- LogString& buf, const LogString& input)
+ LogString& buf, const LogString& input)
{
- //Check if the string is zero length -- if so, return
- //what was sent in.
+ //Check if the string is zero length -- if so, return
+ //what was sent in.
- if(input.length() == 0 )
- {
- return;
- }
+ if (input.length() == 0 )
+ {
+ return;
+ }
- logchar specials[] = { 0x22 /* " */, 0x26 /* & */, 0x3C /* < */, 0x3E /* > */, 0x00 };
- size_t start = 0;
- size_t special = input.find_first_of(specials, start);
- while(special != LogString::npos) {
- if (special > start) {
+ logchar specials[] = { 0x22 /* " */, 0x26 /* & */, 0x3C /* < */, 0x3E /* > */, 0x00 };
+ size_t start = 0;
+ size_t special = input.find_first_of(specials, start);
+
+ while (special != LogString::npos)
+ {
+ if (special > start)
+ {
buf.append(input, start, special - start);
}
- switch(input[special]) {
+
+ switch (input[special])
+ {
case 0x22:
- buf.append(LOG4CXX_STR("""));
- break;
+ buf.append(LOG4CXX_STR("""));
+ break;
case 0x26:
- buf.append(LOG4CXX_STR("&"));
- break;
+ buf.append(LOG4CXX_STR("&"));
+ break;
case 0x3C:
- buf.append(LOG4CXX_STR("<"));
- break;
+ buf.append(LOG4CXX_STR("<"));
+ break;
case 0x3E:
- buf.append(LOG4CXX_STR(">"));
- break;
+ buf.append(LOG4CXX_STR(">"));
+ break;
default:
- buf.append(1, input[special]);
- break;
+ buf.append(1, input[special]);
+ break;
}
- start = special+1;
- if (special < input.size()) {
+
+ start = special + 1;
+
+ if (special < input.size())
+ {
special = input.find_first_of(specials, start);
- } else {
+ }
+ else
+ {
special = LogString::npos;
}
- }
+ }
- if (start < input.size()) {
+ if (start < input.size())
+ {
buf.append(input, start, input.size() - start);
}
}
void Transform::appendEscapingCDATA(
- LogString& buf, const LogString& input)
+ LogString& buf, const LogString& input)
{
- static const LogString CDATA_END(LOG4CXX_STR("]]>"));
- static const LogString CDATA_EMBEDED_END(LOG4CXX_STR("]]>]]><![CDATA["));
+ static const LogString CDATA_END(LOG4CXX_STR("]]>"));
+ static const LogString CDATA_EMBEDED_END(LOG4CXX_STR("]]>]]><![CDATA["));
- const LogString::size_type CDATA_END_LEN = 3;
+ const LogString::size_type CDATA_END_LEN = 3;
- if(input.length() == 0 )
- {
- return;
- }
+ if (input.length() == 0 )
+ {
+ return;
+ }
- LogString::size_type end = input.find(CDATA_END);
- if (end == LogString::npos)
- {
- buf.append(input);
- return;
- }
+ LogString::size_type end = input.find(CDATA_END);
- LogString::size_type start = 0;
- while (end != LogString::npos)
- {
- buf.append(input, start, end-start);
- buf.append(CDATA_EMBEDED_END);
- start = end + CDATA_END_LEN;
- if (start < input.length())
- {
- end = input.find(CDATA_END, start);
- }
- else
- {
- return;
- }
- }
+ if (end == LogString::npos)
+ {
+ buf.append(input);
+ return;
+ }
- buf.append(input, start, input.length() - start);
+ LogString::size_type start = 0;
+
+ while (end != LogString::npos)
+ {
+ buf.append(input, start, end - start);
+ buf.append(CDATA_EMBEDED_END);
+ start = end + CDATA_END_LEN;
+
+ if (start < input.length())
+ {
+ end = input.find(CDATA_END, start);
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ buf.append(input, start, input.length() - start);
}
diff --git a/src/main/cpp/triggeringpolicy.cpp b/src/main/cpp/triggeringpolicy.cpp
index 310e74e..b9ff531 100644
--- a/src/main/cpp/triggeringpolicy.cpp
+++ b/src/main/cpp/triggeringpolicy.cpp
@@ -23,13 +23,16 @@
IMPLEMENT_LOG4CXX_OBJECT(TriggeringPolicy)
-TriggeringPolicy::~TriggeringPolicy() {
+TriggeringPolicy::~TriggeringPolicy()
+{
}
-void TriggeringPolicy::addRef() const {
+void TriggeringPolicy::addRef() const
+{
ObjectImpl::addRef();
}
-void TriggeringPolicy::releaseRef() const {
+void TriggeringPolicy::releaseRef() const
+{
ObjectImpl::releaseRef();
}
diff --git a/src/main/cpp/ttcclayout.cpp b/src/main/cpp/ttcclayout.cpp
index f66409a..31a2117 100644
--- a/src/main/cpp/ttcclayout.cpp
+++ b/src/main/cpp/ttcclayout.cpp
@@ -29,49 +29,51 @@
IMPLEMENT_LOG4CXX_OBJECT(TTCCLayout)
TTCCLayout::TTCCLayout()
-: DateLayout(LOG4CXX_STR("RELATIVE")), threadPrinting(true), categoryPrefixing(true),
-contextPrinting(true), filePrinting(false)
+ : DateLayout(LOG4CXX_STR("RELATIVE")), threadPrinting(true), categoryPrefixing(true),
+ contextPrinting(true), filePrinting(false)
{
- Pool pool;
- activateOptions(pool);
+ Pool pool;
+ activateOptions(pool);
}
TTCCLayout::TTCCLayout(const LogString& dateFormatType)
-: DateLayout(dateFormatType), threadPrinting(true), categoryPrefixing(true),
-contextPrinting(true), filePrinting(false)
+ : DateLayout(dateFormatType), threadPrinting(true), categoryPrefixing(true),
+ contextPrinting(true), filePrinting(false)
{
- Pool pool;
- activateOptions(pool);
+ Pool pool;
+ activateOptions(pool);
}
void TTCCLayout::format(LogString& output,
- const spi::LoggingEventPtr& event,
- Pool& p) const
+ const spi::LoggingEventPtr& event,
+ Pool& p) const
{
- formatDate(output, event, p);
+ formatDate(output, event, p);
- if(threadPrinting)
- {
- output.append(1, (logchar) 0x5B /* '[' */);
- output.append(event->getThreadName());
- output.append(1, (logchar) 0x5D /* ']' */);
- output.append(1, (logchar) 0x20 /* ' ' */);
- }
-
- output.append(event->getLevel()->toString());
+ if (threadPrinting)
+ {
+ output.append(1, (logchar) 0x5B /* '[' */);
+ output.append(event->getThreadName());
+ output.append(1, (logchar) 0x5D /* ']' */);
output.append(1, (logchar) 0x20 /* ' ' */);
- if(categoryPrefixing)
- {
- output.append(event->getLoggerName());
- output.append(1, (logchar) 0x20 /* ' ' */);
- }
+ }
- if(contextPrinting && event->getNDC(output)) {
- output.append(1, (logchar) 0x20 /* ' ' */);
- }
+ output.append(event->getLevel()->toString());
+ output.append(1, (logchar) 0x20 /* ' ' */);
- output.append(1, (logchar) 0x2D /* '-' */);
+ if (categoryPrefixing)
+ {
+ output.append(event->getLoggerName());
output.append(1, (logchar) 0x20 /* ' ' */);
- output.append(event->getRenderedMessage());
- output.append(LOG4CXX_EOL);
+ }
+
+ if (contextPrinting && event->getNDC(output))
+ {
+ output.append(1, (logchar) 0x20 /* ' ' */);
+ }
+
+ output.append(1, (logchar) 0x2D /* '-' */);
+ output.append(1, (logchar) 0x20 /* ' ' */);
+ output.append(event->getRenderedMessage());
+ output.append(LOG4CXX_EOL);
}
diff --git a/src/main/cpp/writer.cpp b/src/main/cpp/writer.cpp
index ee44fca..b2dcaf8 100644
--- a/src/main/cpp/writer.cpp
+++ b/src/main/cpp/writer.cpp
@@ -23,14 +23,17 @@
IMPLEMENT_LOG4CXX_OBJECT(Writer)
-Writer::Writer() {
+Writer::Writer()
+{
}
-Writer::~Writer() {
+Writer::~Writer()
+{
}
#ifdef LOG4CXX_MULTI_PROCESS
-OutputStreamPtr Writer::getOutPutStreamPtr(){
+OutputStreamPtr Writer::getOutPutStreamPtr()
+{
throw std::logic_error("getOutPutStreamPtr must be implemented in the derived class that you are using");
}
#endif
diff --git a/src/main/cpp/writerappender.cpp b/src/main/cpp/writerappender.cpp
index ca1baf8..0b645e8 100644
--- a/src/main/cpp/writerappender.cpp
+++ b/src/main/cpp/writerappender.cpp
@@ -27,22 +27,25 @@
IMPLEMENT_LOG4CXX_OBJECT(WriterAppender)
-WriterAppender::WriterAppender() {
- LOCK_W sync(mutex);
- immediateFlush = true;
+WriterAppender::WriterAppender()
+{
+ LOCK_W sync(mutex);
+ immediateFlush = true;
}
WriterAppender::WriterAppender(const LayoutPtr& layout1,
- log4cxx::helpers::WriterPtr& writer1)
- : AppenderSkeleton(layout1), writer(writer1) {
- Pool p;
- LOCK_W sync(mutex);
- immediateFlush = true;
- activateOptions(p);
+ log4cxx::helpers::WriterPtr& writer1)
+ : AppenderSkeleton(layout1), writer(writer1)
+{
+ Pool p;
+ LOCK_W sync(mutex);
+ immediateFlush = true;
+ activateOptions(p);
}
WriterAppender::WriterAppender(const LayoutPtr& layout1)
- : AppenderSkeleton(layout1) {
+ : AppenderSkeleton(layout1)
+{
LOCK_W sync(mutex);
immediateFlush = true;
}
@@ -55,24 +58,28 @@
void WriterAppender::activateOptions(Pool& p)
{
- int errors = 0;
- if(layout == 0) {
- errorHandler->error(
- ((LogString) LOG4CXX_STR("No layout set for the appender named ["))
- + name+ LOG4CXX_STR("]."));
- errors++;
- }
+ int errors = 0;
- if(writer == 0) {
- errorHandler->error(
- ((LogString) LOG4CXX_STR("No writer 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 (errors == 0) {
- AppenderSkeleton::activateOptions(p);
- }
+ 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);
+ }
}
@@ -80,12 +87,12 @@
void WriterAppender::append(const spi::LoggingEventPtr& event, Pool& pool1)
{
- if(!checkEntryConditions())
- {
- return;
- }
+ if (!checkEntryConditions())
+ {
+ return;
+ }
- subAppend(event, pool1);
+ subAppend(event, pool1);
}
/**
@@ -94,36 +101,44 @@
<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. */
-bool WriterAppender::checkEntryConditions() const {
- 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;
- }
- return false;
- }
+bool WriterAppender::checkEntryConditions() const
+{
+ static bool warnedClosed = false;
+ static bool warnedNoWriter = false;
- if (writer == 0) {
- if (warnedNoWriter) {
+ if (closed)
+ {
+ if (!warnedClosed)
+ {
+ LogLog::warn(LOG4CXX_STR("Not allowed to write to a closed appender."));
+ warnedClosed = true;
+ }
+
+ 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;
+ }
+
+ return false;
+ }
+
+ if (layout == 0)
+ {
errorHandler->error(
- LogString(LOG4CXX_STR("No output stream or file set for the appender named [")) +
- name + LOG4CXX_STR("]."));
- warnedNoWriter = true;
+ LogString(LOG4CXX_STR("No layout set for the appender named [")) +
+ name + LOG4CXX_STR("]."));
+ return false;
}
- 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;
}
@@ -139,35 +154,40 @@
*/
void WriterAppender::close()
{
- LOCK_W sync(mutex);
+ LOCK_W sync(mutex);
- if(closed)
- {
- return;
- }
+ if (closed)
+ {
+ return;
+ }
- closed = true;
- closeWriter();
+ closed = true;
+ closeWriter();
}
/**
* Close the underlying {@link java.io.Writer}.
* */
-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);
+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);
+ }
}
- }
}
@@ -177,95 +197,120 @@
<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. */
-WriterPtr WriterAppender::createWriter(OutputStreamPtr& os) {
+WriterPtr WriterAppender::createWriter(OutputStreamPtr& os)
+{
- LogString enc(getEncoding());
+ LogString enc(getEncoding());
- 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);
+ CharsetEncoderPtr encoder;
+
+ if (enc.empty())
+ {
+ encoder = CharsetEncoder::getDefaultEncoder();
}
- if (encoder == NULL) {
- encoder = CharsetEncoder::getDefaultEncoder();
- LogLog::warn(LOG4CXX_STR("Error initializing output writer."));
- LogLog::warn(LOG4CXX_STR("Unsupported encoding?"));
- }
- }
+ 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);
+ }
- return new OutputStreamWriter(os, encoder);
+ 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);
}
-LogString WriterAppender::getEncoding() const {
- return encoding;
+LogString WriterAppender::getEncoding() const
+{
+ return encoding;
}
-void WriterAppender::setEncoding(const LogString& enc) {
- encoding = enc;
+void WriterAppender::setEncoding(const LogString& enc)
+{
+ encoding = enc;
}
void WriterAppender::subAppend(const spi::LoggingEventPtr& event, Pool& p)
{
- LogString msg;
- layout->format(msg, event, p);
+ LogString msg;
+ layout->format(msg, event, p);
+ {
+ LOCK_W sync(mutex);
+
+ if (writer != NULL)
{
- LOCK_W sync(mutex);
- if (writer != NULL) {
- writer->write(msg, p);
- if (immediateFlush) {
- writer->flush(p);
- }
- }
+ writer->write(msg, 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);
+ LOCK_W sync(mutex);
+ 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);
- }
-}
-
-
-void WriterAppender::setWriter(const WriterPtr& newWriter) {
- LOCK_W sync(mutex);
- writer = newWriter;
-}
-
-
-bool WriterAppender::requiresLayout() const {
- 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 (layout != NULL)
+ {
+ LogString header;
+ layout->appendHeader(header, p);
+ LOCK_W sync(mutex);
+ writer->write(header, p);
}
}
-void WriterAppender::setImmediateFlush(bool value) {
+void WriterAppender::setWriter(const WriterPtr& newWriter)
+{
+ LOCK_W sync(mutex);
+ writer = newWriter;
+}
+
+
+bool WriterAppender::requiresLayout() const
+{
+ 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);
+ }
+}
+
+
+void WriterAppender::setImmediateFlush(bool value)
+{
LOCK_W sync(mutex);
immediateFlush = value;
}
diff --git a/src/main/cpp/xmllayout.cpp b/src/main/cpp/xmllayout.cpp
index 49be88f..d7e683b 100644
--- a/src/main/cpp/xmllayout.cpp
+++ b/src/main/cpp/xmllayout.cpp
@@ -35,112 +35,127 @@
IMPLEMENT_LOG4CXX_OBJECT(XMLLayout)
XMLLayout::XMLLayout()
-: locationInfo(false), properties(false)
+ : locationInfo(false), properties(false)
{
}
void XMLLayout::setOption(const LogString& option,
- const LogString& value)
+ const LogString& value)
{
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo")))
- {
- setLocationInfo(OptionConverter::toBoolean(value, false));
- }
- if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("PROPERTIES"), LOG4CXX_STR("properties")))
- {
- setProperties(OptionConverter::toBoolean(value, false));
- }
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("LOCATIONINFO"), LOG4CXX_STR("locationinfo")))
+ {
+ setLocationInfo(OptionConverter::toBoolean(value, false));
+ }
+
+ if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR("PROPERTIES"), LOG4CXX_STR("properties")))
+ {
+ setProperties(OptionConverter::toBoolean(value, false));
+ }
}
void XMLLayout::format(LogString& output,
- const spi::LoggingEventPtr& event,
- Pool& p) const
+ const spi::LoggingEventPtr& event,
+ Pool& p) const
{
- output.append(LOG4CXX_STR("<log4j:event logger=\""));
- Transform::appendEscapingTags(output, event->getLoggerName());
- output.append(LOG4CXX_STR("\" timestamp=\""));
- StringHelper::toString(event->getTimeStamp()/1000L, p, output);
- output.append(LOG4CXX_STR("\" level=\""));
- Transform::appendEscapingTags(output, event->getLevel()->toString());
- output.append(LOG4CXX_STR("\" thread=\""));
- Transform::appendEscapingTags(output, event->getThreadName());
- output.append(LOG4CXX_STR("\">"));
+ output.append(LOG4CXX_STR("<log4j:event logger=\""));
+ Transform::appendEscapingTags(output, event->getLoggerName());
+ output.append(LOG4CXX_STR("\" timestamp=\""));
+ StringHelper::toString(event->getTimeStamp() / 1000L, p, output);
+ output.append(LOG4CXX_STR("\" level=\""));
+ Transform::appendEscapingTags(output, event->getLevel()->toString());
+ output.append(LOG4CXX_STR("\" thread=\""));
+ Transform::appendEscapingTags(output, event->getThreadName());
+ output.append(LOG4CXX_STR("\">"));
+ output.append(LOG4CXX_EOL);
+
+ output.append(LOG4CXX_STR("<log4j:message><![CDATA["));
+ // Append the rendered message. Also make sure to escape any
+ // existing CDATA sections.
+ Transform::appendEscapingCDATA(output, event->getRenderedMessage());
+ output.append(LOG4CXX_STR("]]></log4j:message>"));
+ output.append(LOG4CXX_EOL);
+
+ LogString ndc;
+
+ if (event->getNDC(ndc))
+ {
+ output.append(LOG4CXX_STR("<log4j:NDC><![CDATA["));
+ Transform::appendEscapingCDATA(output, ndc);
+ output.append(LOG4CXX_STR("]]></log4j:NDC>"));
output.append(LOG4CXX_EOL);
+ }
- output.append(LOG4CXX_STR("<log4j:message><![CDATA["));
- // Append the rendered message. Also make sure to escape any
- // existing CDATA sections.
- Transform::appendEscapingCDATA(output, event->getRenderedMessage());
- output.append(LOG4CXX_STR("]]></log4j:message>"));
+ if (locationInfo)
+ {
+ output.append(LOG4CXX_STR("<log4j:locationInfo class=\""));
+ const LocationInfo& locInfo = event->getLocationInformation();
+ LOG4CXX_DECODE_CHAR(className, locInfo.getClassName());
+ Transform::appendEscapingTags(output, className);
+ output.append(LOG4CXX_STR("\" method=\""));
+ LOG4CXX_DECODE_CHAR(method, locInfo.getMethodName());
+ Transform::appendEscapingTags(output, method);
+ output.append(LOG4CXX_STR("\" file=\""));
+ LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName());
+ Transform::appendEscapingTags(output, fileName);
+ output.append(LOG4CXX_STR("\" line=\""));
+ StringHelper::toString(locInfo.getLineNumber(), p, output);
+ output.append(LOG4CXX_STR("\"/>"));
output.append(LOG4CXX_EOL);
+ }
- LogString ndc;
- if(event->getNDC(ndc)) {
- output.append(LOG4CXX_STR("<log4j:NDC><![CDATA["));
- Transform::appendEscapingCDATA(output, ndc);
- output.append(LOG4CXX_STR("]]></log4j:NDC>"));
- output.append(LOG4CXX_EOL);
- }
+ if (properties)
+ {
+ LoggingEvent::KeySet propertySet(event->getPropertyKeySet());
+ LoggingEvent::KeySet keySet(event->getMDCKeySet());
- if(locationInfo)
+ if (!(keySet.empty() && propertySet.empty()))
{
- output.append(LOG4CXX_STR("<log4j:locationInfo class=\""));
- const LocationInfo& locInfo = event->getLocationInformation();
- LOG4CXX_DECODE_CHAR(className, locInfo.getClassName());
- Transform::appendEscapingTags(output, className);
- output.append(LOG4CXX_STR("\" method=\""));
- LOG4CXX_DECODE_CHAR(method, locInfo.getMethodName());
- Transform::appendEscapingTags(output, method);
- output.append(LOG4CXX_STR("\" file=\""));
- LOG4CXX_DECODE_CHAR(fileName, locInfo.getFileName());
- Transform::appendEscapingTags(output, fileName);
- output.append(LOG4CXX_STR("\" line=\""));
- StringHelper::toString(locInfo.getLineNumber(), p, output);
- output.append(LOG4CXX_STR("\"/>"));
- output.append(LOG4CXX_EOL);
- }
+ output.append(LOG4CXX_STR("<log4j:properties>"));
+ output.append(LOG4CXX_EOL);
- if (properties) {
- LoggingEvent::KeySet propertySet(event->getPropertyKeySet());
- LoggingEvent::KeySet keySet(event->getMDCKeySet());
- if (!(keySet.empty() && propertySet.empty())) {
- output.append(LOG4CXX_STR("<log4j:properties>"));
- output.append(LOG4CXX_EOL);
- for (LoggingEvent::KeySet::const_iterator i = keySet.begin();
- i != keySet.end();
- i++) {
- LogString key(*i);
- LogString value;
- if(event->getMDC(key, value)) {
- output.append(LOG4CXX_STR("<log4j:data name=\""));
- Transform::appendEscapingTags(output, key);
- output.append(LOG4CXX_STR("\" value=\""));
- Transform::appendEscapingTags(output, value);
- output.append(LOG4CXX_STR("\"/>"));
- output.append(LOG4CXX_EOL);
- }
+ for (LoggingEvent::KeySet::const_iterator i = keySet.begin();
+ i != keySet.end();
+ i++)
+ {
+ LogString key(*i);
+ LogString value;
+
+ if (event->getMDC(key, value))
+ {
+ output.append(LOG4CXX_STR("<log4j:data name=\""));
+ Transform::appendEscapingTags(output, key);
+ output.append(LOG4CXX_STR("\" value=\""));
+ Transform::appendEscapingTags(output, value);
+ output.append(LOG4CXX_STR("\"/>"));
+ output.append(LOG4CXX_EOL);
}
- for (LoggingEvent::KeySet::const_iterator i2 = propertySet.begin();
- i2 != propertySet.end();
- i2++) {
- LogString key(*i2);
- LogString value;
- if(event->getProperty(key, value)) {
- output.append(LOG4CXX_STR("<log4j:data name=\""));
- Transform::appendEscapingTags(output, key);
- output.append(LOG4CXX_STR("\" value=\""));
- Transform::appendEscapingTags(output, value);
- output.append(LOG4CXX_STR("\"/>"));
- output.append(LOG4CXX_EOL);
- }
- }
- output.append(LOG4CXX_STR("</log4j:properties>"));
- output.append(LOG4CXX_EOL);
}
- }
- output.append(LOG4CXX_STR("</log4j:event>"));
- output.append(LOG4CXX_EOL);
- output.append(LOG4CXX_EOL);
+ for (LoggingEvent::KeySet::const_iterator i2 = propertySet.begin();
+ i2 != propertySet.end();
+ i2++)
+ {
+ LogString key(*i2);
+ LogString value;
+
+ if (event->getProperty(key, value))
+ {
+ output.append(LOG4CXX_STR("<log4j:data name=\""));
+ Transform::appendEscapingTags(output, key);
+ output.append(LOG4CXX_STR("\" value=\""));
+ Transform::appendEscapingTags(output, value);
+ output.append(LOG4CXX_STR("\"/>"));
+ output.append(LOG4CXX_EOL);
+ }
+ }
+
+ output.append(LOG4CXX_STR("</log4j:properties>"));
+ output.append(LOG4CXX_EOL);
+ }
+ }
+
+ output.append(LOG4CXX_STR("</log4j:event>"));
+ output.append(LOG4CXX_EOL);
+ output.append(LOG4CXX_EOL);
}
diff --git a/src/main/cpp/xmlsocketappender.cpp b/src/main/cpp/xmlsocketappender.cpp
index 4a3a521..edecbd2 100644
--- a/src/main/cpp/xmlsocketappender.cpp
+++ b/src/main/cpp/xmlsocketappender.cpp
@@ -45,70 +45,87 @@
const int XMLSocketAppender::MAX_EVENT_LEN = 1024;
XMLSocketAppender::XMLSocketAppender()
-: SocketAppenderSkeleton(DEFAULT_PORT, DEFAULT_RECONNECTION_DELAY)
+ : SocketAppenderSkeleton(DEFAULT_PORT, DEFAULT_RECONNECTION_DELAY)
{
- layout = new XMLLayout();
+ layout = new XMLLayout();
}
XMLSocketAppender::XMLSocketAppender(InetAddressPtr address1, int port1)
-: SocketAppenderSkeleton(address1, port1, DEFAULT_RECONNECTION_DELAY)
+ : SocketAppenderSkeleton(address1, port1, DEFAULT_RECONNECTION_DELAY)
{
- layout = new XMLLayout();
- Pool p;
- activateOptions(p);
+ layout = new XMLLayout();
+ Pool p;
+ activateOptions(p);
}
XMLSocketAppender::XMLSocketAppender(const LogString& host, int port1)
-: SocketAppenderSkeleton(host, port1, DEFAULT_RECONNECTION_DELAY)
+ : SocketAppenderSkeleton(host, port1, DEFAULT_RECONNECTION_DELAY)
{
- layout = new XMLLayout();
- Pool p;
- activateOptions(p);
+ layout = new XMLLayout();
+ Pool p;
+ activateOptions(p);
}
-XMLSocketAppender::~XMLSocketAppender() {
+XMLSocketAppender::~XMLSocketAppender()
+{
finalize();
}
-int XMLSocketAppender::getDefaultDelay() const {
+int XMLSocketAppender::getDefaultDelay() const
+{
return DEFAULT_RECONNECTION_DELAY;
}
-int XMLSocketAppender::getDefaultPort() const {
+int XMLSocketAppender::getDefaultPort() const
+{
return DEFAULT_PORT;
}
-void XMLSocketAppender::setSocket(log4cxx::helpers::SocketPtr& socket, Pool& p) {
+void XMLSocketAppender::setSocket(log4cxx::helpers::SocketPtr& socket, Pool& p)
+{
OutputStreamPtr os(new SocketOutputStream(socket));
CharsetEncoderPtr charset(CharsetEncoder::getUTF8Encoder());
LOCK_W sync(mutex);
writer = new OutputStreamWriter(os, charset);
}
-void XMLSocketAppender::cleanUp(Pool& p) {
- if (writer != 0) {
- try {
+void XMLSocketAppender::cleanUp(Pool& p)
+{
+ if (writer != 0)
+ {
+ try
+ {
writer->close(p);
writer = 0;
- } catch(std::exception &e) {
+ }
+ catch (std::exception& e)
+ {
}
}
}
-void XMLSocketAppender::append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) {
- if (writer != 0) {
+void XMLSocketAppender::append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p)
+{
+ if (writer != 0)
+ {
LogString output;
layout->format(output, event, p);
- try {
+
+ try
+ {
writer->write(output, p);
writer->flush(p);
- } catch(std::exception& e) {
- writer = 0;
- LogLog::warn(LOG4CXX_STR("Detected problem with connection: "), e);
- if (getReconnectionDelay() > 0) {
- fireConnector();
- }
+ }
+ catch (std::exception& e)
+ {
+ writer = 0;
+ LogLog::warn(LOG4CXX_STR("Detected problem with connection: "), e);
+
+ if (getReconnectionDelay() > 0)
+ {
+ fireConnector();
+ }
}
}
}
diff --git a/src/main/cpp/zipcompressaction.cpp b/src/main/cpp/zipcompressaction.cpp
index a67d8ec..8704415 100644
--- a/src/main/cpp/zipcompressaction.cpp
+++ b/src/main/cpp/zipcompressaction.cpp
@@ -6,7 +6,7 @@
* (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
+ * 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,
@@ -28,67 +28,93 @@
IMPLEMENT_LOG4CXX_OBJECT(ZipCompressAction)
ZipCompressAction::ZipCompressAction(const File& src,
- const File& dest,
- bool del)
- : source(src), destination(dest), deleteSource(del) {
+ const File& dest,
+ bool del)
+ : source(src), destination(dest), deleteSource(del)
+{
}
bool ZipCompressAction::execute(log4cxx::helpers::Pool& p) const
{
- if (!source.exists(p))
- {
- return false;
- }
+ if (!source.exists(p))
+ {
+ return false;
+ }
- apr_pool_t* aprpool = p.getAPRPool();
- apr_procattr_t* attr;
- apr_status_t stat = apr_procattr_create(&attr, aprpool);
- if (stat != APR_SUCCESS) throw IOException(stat);
+ apr_pool_t* aprpool = p.getAPRPool();
+ apr_procattr_t* attr;
+ apr_status_t stat = apr_procattr_create(&attr, aprpool);
- stat = apr_procattr_io_set(attr, APR_NO_PIPE, APR_NO_PIPE, APR_FULL_BLOCK);
- if (stat != APR_SUCCESS) throw IOException(stat);
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
- stat = apr_procattr_cmdtype_set(attr, APR_PROGRAM_PATH);
- if (stat != APR_SUCCESS) throw IOException(stat);
+ stat = apr_procattr_io_set(attr, APR_NO_PIPE, APR_NO_PIPE, APR_FULL_BLOCK);
- //
- // redirect the child's error stream to this processes' error stream
- //
- apr_file_t* child_err;
- stat = apr_file_open_stderr(&child_err, aprpool);
- if (stat == APR_SUCCESS)
- {
- stat = apr_procattr_child_err_set(attr, child_err, NULL);
- if (stat != APR_SUCCESS) throw IOException(stat);
- }
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
- const char** args = (const char**)
- apr_palloc(aprpool, 5 * sizeof(*args));
- int i = 0;
+ stat = apr_procattr_cmdtype_set(attr, APR_PROGRAM_PATH);
- args[i++] = "zip";
- args[i++] = "-q";
- args[i++] = Transcoder::encode(destination.getPath(), p);
- args[i++] = Transcoder::encode(source.getPath(), p);
- args[i++] = NULL;
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
- if (destination.exists(p))
- {
- destination.deleteFile(p);
- }
+ //
+ // redirect the child's error stream to this processes' error stream
+ //
+ apr_file_t* child_err;
+ stat = apr_file_open_stderr(&child_err, aprpool);
- apr_proc_t pid;
- stat = apr_proc_create(&pid, "zip", args, NULL, attr, aprpool);
- if (stat != APR_SUCCESS) throw IOException(stat);
+ if (stat == APR_SUCCESS)
+ {
+ stat = apr_procattr_child_err_set(attr, child_err, NULL);
- int exitCode;
- apr_proc_wait(&pid, &exitCode, NULL, APR_WAIT);
- if (exitCode != APR_SUCCESS) throw IOException(exitCode);
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
+ }
- if (deleteSource)
- {
- source.deleteFile(p);
- }
+ const char** args = (const char**)
+ apr_palloc(aprpool, 5 * sizeof(*args));
+ int i = 0;
- return true;
+ args[i++] = "zip";
+ args[i++] = "-q";
+ args[i++] = Transcoder::encode(destination.getPath(), p);
+ args[i++] = Transcoder::encode(source.getPath(), p);
+ args[i++] = NULL;
+
+ if (destination.exists(p))
+ {
+ destination.deleteFile(p);
+ }
+
+ apr_proc_t pid;
+ stat = apr_proc_create(&pid, "zip", args, NULL, attr, aprpool);
+
+ if (stat != APR_SUCCESS)
+ {
+ throw IOException(stat);
+ }
+
+ int exitCode;
+ apr_proc_wait(&pid, &exitCode, NULL, APR_WAIT);
+
+ if (exitCode != APR_SUCCESS)
+ {
+ throw IOException(exitCode);
+ }
+
+ if (deleteSource)
+ {
+ source.deleteFile(p);
+ }
+
+ return true;
}
diff --git a/src/main/include/log4cxx/appender.h b/src/main/include/log4cxx/appender.h
index 8fd798e..10a63e9 100644
--- a/src/main/include/log4cxx/appender.h
+++ b/src/main/include/log4cxx/appender.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_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
@@ -32,30 +32,30 @@
namespace log4cxx
{
- // Forward declarations
- namespace spi
- {
- class LoggingEvent;
- typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
+// Forward declarations
+namespace spi
+{
+class LoggingEvent;
+typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
- class Filter;
- typedef helpers::ObjectPtrT<Filter> FilterPtr;
+class Filter;
+typedef helpers::ObjectPtrT<Filter> FilterPtr;
- class ErrorHandler;
- typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHandlerPtr;
- }
+class ErrorHandler;
+typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHandlerPtr;
+}
- class Layout;
- typedef log4cxx::helpers::ObjectPtrT<Layout> LayoutPtr;
+class Layout;
+typedef log4cxx::helpers::ObjectPtrT<Layout> LayoutPtr;
- /**
- Implement this interface for your own strategies for outputting log
- statements.
- */
- class LOG4CXX_EXPORT Appender :
- public virtual spi::OptionHandler
- {
+/**
+Implement this interface for your own strategies for outputting log
+statements.
+*/
+class LOG4CXX_EXPORT Appender :
+ public virtual spi::OptionHandler
+{
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(Appender)
@@ -92,7 +92,7 @@
implementations in order to log.
*/
virtual void doAppend(const spi::LoggingEventPtr& event,
- log4cxx::helpers::Pool& pool) = 0;
+ log4cxx::helpers::Pool& pool) = 0;
/**
@@ -102,47 +102,47 @@
virtual LogString getName() const = 0;
- /**
- Set the Layout for this appender.
- */
- virtual void setLayout(const LayoutPtr& layout) = 0;
+ /**
+ Set the Layout for this appender.
+ */
+ virtual void setLayout(const LayoutPtr& layout) = 0;
- /**
- Returns this appenders layout.
- */
- virtual LayoutPtr getLayout() const = 0;
+ /**
+ Returns this appenders layout.
+ */
+ virtual LayoutPtr getLayout() const = 0;
- /**
- Set the name of this appender. The name is used by other
- components to identify this appender.
- */
- virtual void setName(const LogString& name) = 0;
+ /**
+ Set the name of this appender. The name is used by other
+ components to identify this appender.
+ */
+ virtual void setName(const LogString& name) = 0;
- /**
- Configurators call this method to determine if the appender
- requires a layout. If this method returns <code>true</code>,
- meaning that layout is required, then the configurator will
- configure an layout using the configuration information at its
- disposal. If this method returns <code>false</code>, meaning that
- a layout is not required, then layout configuration will be
- skipped even if there is available layout configuration
- information at the disposal of the configurator..
+ /**
+ Configurators call this method to determine if the appender
+ requires a layout. If this method returns <code>true</code>,
+ meaning that layout is required, then the configurator will
+ configure an layout using the configuration information at its
+ disposal. If this method returns <code>false</code>, meaning that
+ a layout is not required, then layout configuration will be
+ skipped even if there is available layout configuration
+ information at the disposal of the configurator..
- <p>In the rather exceptional case, where the appender
- implementation admits a layout but can also work without it, then
- the appender should return <code>true</code>.
- */
- virtual bool requiresLayout() const = 0;
- };
+ <p>In the rather exceptional case, where the appender
+ implementation admits a layout but can also work without it, then
+ the appender should return <code>true</code>.
+ */
+ virtual bool requiresLayout() const = 0;
+};
- LOG4CXX_PTR_DEF(Appender);
- LOG4CXX_LIST_DEF(AppenderList, AppenderPtr);
+LOG4CXX_PTR_DEF(Appender);
+LOG4CXX_LIST_DEF(AppenderList, AppenderPtr);
}
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif //_LOG4CXX_APPENDER_H
diff --git a/src/main/include/log4cxx/appenderskeleton.h b/src/main/include/log4cxx/appenderskeleton.h
index dfdabb1..d51bf95 100644
--- a/src/main/include/log4cxx/appenderskeleton.h
+++ b/src/main/include/log4cxx/appenderskeleton.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_APPENDER_SKELETON_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
@@ -36,179 +36,203 @@
namespace log4cxx
{
+/**
+* Implementation base class for all appenders.
+*
+* This class provides the code for common functionality, such as
+* support for threshold filtering and support for general filters.
+* */
+class LOG4CXX_EXPORT AppenderSkeleton :
+ public virtual Appender,
+ public virtual helpers::ObjectImpl
+{
+ protected:
+ /** The layout variable does not need to be set if the appender
+ implementation has its own layout. */
+ LayoutPtr layout;
+
+ /** Appenders are named. */
+ LogString name;
+
/**
- * Implementation base class for all appenders.
- *
- * This class provides the code for common functionality, such as
- * support for threshold filtering and support for general filters.
- * */
- class LOG4CXX_EXPORT AppenderSkeleton :
- public virtual Appender,
- public virtual helpers::ObjectImpl
+ There is no level threshold filtering by default. */
+ LevelPtr threshold;
+
+ /**
+ It is assumed and enforced that errorHandler is never null.
+ */
+ spi::ErrorHandlerPtr errorHandler;
+
+ /** The first filter in the filter chain. Set to <code>null</code>
+ initially. */
+ spi::FilterPtr headFilter;
+
+ /** The last filter in the filter chain. */
+ spi::FilterPtr tailFilter;
+
+ /**
+ Is this appender closed?
+ */
+ bool closed;
+
+ log4cxx::helpers::Pool pool;
+ mutable SHARED_MUTEX mutex;
+
+ /**
+ Subclasses of <code>AppenderSkeleton</code> should implement this
+ method to perform actual logging. See also AppenderSkeleton::doAppend
+ method.
+ */
+ virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) = 0;
+
+ void doAppendImpl(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool);
+
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(AppenderSkeleton)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(AppenderSkeleton)
+ LOG4CXX_CAST_ENTRY(Appender)
+ LOG4CXX_CAST_ENTRY(spi::OptionHandler)
+ END_LOG4CXX_CAST_MAP()
+
+ AppenderSkeleton();
+ AppenderSkeleton(const LayoutPtr& layout);
+
+ void addRef() const;
+ void releaseRef() const;
+
+ /**
+ Finalize this appender by calling the derived class'
+ <code>close</code> method.
+ */
+ void finalize();
+
+ /**
+ Derived appenders should override this method if option structure
+ requires it.
+ */
+ virtual void activateOptions(log4cxx::helpers::Pool& /* pool */) {}
+ virtual void setOption(const LogString& option, const LogString& value);
+
+ /**
+ Add a filter to end of the filter list.
+ */
+ void addFilter(const spi::FilterPtr& newFilter) ;
+
+ public:
+ /**
+ Clear the filters chain.
+ */
+ void clearFilters();
+
+ /**
+ Return the currently set spi::ErrorHandler for this
+ Appender.
+ */
+ const spi::ErrorHandlerPtr& getErrorHandler() const
{
- protected:
- /** The layout variable does not need to be set if the appender
- implementation has its own layout. */
- LayoutPtr layout;
+ return errorHandler;
+ }
- /** Appenders are named. */
- LogString name;
+ /**
+ Returns the head Filter.
+ */
+ spi::FilterPtr getFilter() const
+ {
+ return headFilter;
+ }
- /**
- There is no level threshold filtering by default. */
- LevelPtr threshold;
+ /**
+ Return the first filter in the filter chain for this
+ Appender. The return value may be <code>0</code> if no is
+ filter is set.
+ */
+ const spi::FilterPtr& getFirstFilter() const
+ {
+ return headFilter;
+ }
- /**
- It is assumed and enforced that errorHandler is never null.
- */
- spi::ErrorHandlerPtr errorHandler;
-
- /** The first filter in the filter chain. Set to <code>null</code>
- initially. */
- spi::FilterPtr headFilter;
-
- /** The last filter in the filter chain. */
- spi::FilterPtr tailFilter;
-
- /**
- Is this appender closed?
- */
- bool closed;
-
- log4cxx::helpers::Pool pool;
- mutable SHARED_MUTEX mutex;
-
- /**
- Subclasses of <code>AppenderSkeleton</code> should implement this
- method to perform actual logging. See also AppenderSkeleton::doAppend
- method.
- */
- virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) = 0;
-
- void doAppendImpl(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool);
-
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(AppenderSkeleton)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(AppenderSkeleton)
- LOG4CXX_CAST_ENTRY(Appender)
- LOG4CXX_CAST_ENTRY(spi::OptionHandler)
- END_LOG4CXX_CAST_MAP()
-
- AppenderSkeleton();
- AppenderSkeleton(const LayoutPtr& layout);
-
- void addRef() const;
- void releaseRef() const;
-
- /**
- Finalize this appender by calling the derived class'
- <code>close</code> method.
- */
- void finalize();
-
- /**
- Derived appenders should override this method if option structure
- requires it.
- */
- virtual void activateOptions(log4cxx::helpers::Pool& /* pool */) {}
- virtual void setOption(const LogString& option, const LogString& value);
-
- /**
- Add a filter to end of the filter list.
- */
- void addFilter(const spi::FilterPtr& newFilter) ;
-
- public:
- /**
- Clear the filters chain.
- */
- void clearFilters();
-
- /**
- Return the currently set spi::ErrorHandler for this
- Appender.
- */
- const spi::ErrorHandlerPtr& getErrorHandler() const { return errorHandler; }
-
- /**
- Returns the head Filter.
- */
- spi::FilterPtr getFilter() const { return headFilter; }
-
- /**
- Return the first filter in the filter chain for this
- Appender. The return value may be <code>0</code> if no is
- filter is set.
- */
- const spi::FilterPtr& getFirstFilter() const { return headFilter; }
-
- /**
- Returns the layout of this appender. The value may be 0.
- */
- LayoutPtr getLayout() const { return layout; }
+ /**
+ Returns the layout of this appender. The value may be 0.
+ */
+ LayoutPtr getLayout() const
+ {
+ return layout;
+ }
- /**
- Returns the name of this Appender.
- */
- LogString getName() const { return name; }
+ /**
+ Returns the name of this Appender.
+ */
+ LogString getName() const
+ {
+ return name;
+ }
- /**
- Returns this appenders threshold level. See the #setThreshold
- method for the meaning of this option.
- */
- const LevelPtr& getThreshold() { return threshold; }
+ /**
+ Returns this appenders threshold level. See the #setThreshold
+ method for the meaning of this option.
+ */
+ const LevelPtr& getThreshold()
+ {
+ return threshold;
+ }
- /**
- Check whether the message level is below the appender's
- threshold. If there is no threshold set, then the return value is
- always <code>true</code>.
- */
- bool isAsSevereAsThreshold(const LevelPtr& level) const;
+ /**
+ Check whether the message level is below the appender's
+ threshold. If there is no threshold set, then the return value is
+ always <code>true</code>.
+ */
+ bool isAsSevereAsThreshold(const LevelPtr& level) const;
- /**
- * This method performs threshold checks and invokes filters before
- * delegating actual logging to the subclasses specific
- * AppenderSkeleton#append method.
- * */
- virtual void doAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool);
+ /**
+ * This method performs threshold checks and invokes filters before
+ * delegating actual logging to the subclasses specific
+ * AppenderSkeleton#append method.
+ * */
+ virtual void doAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool);
- /**
- Set the {@link spi::ErrorHandler ErrorHandler} for this Appender.
- */
- void setErrorHandler(const spi::ErrorHandlerPtr& eh);
+ /**
+ Set the {@link spi::ErrorHandler ErrorHandler} for this Appender.
+ */
+ void setErrorHandler(const spi::ErrorHandlerPtr& eh);
- /**
- Set the layout for this appender. Note that some appenders have
- their own (fixed) layouts or do not use one. For example, the
- {@link net::SocketAppender SocketAppender} ignores the layout set
- here.
- */
- void setLayout(const LayoutPtr& layout1) { this->layout = layout1; }
+ /**
+ Set the layout for this appender. Note that some appenders have
+ their own (fixed) layouts or do not use one. For example, the
+ {@link net::SocketAppender SocketAppender} ignores the layout set
+ here.
+ */
+ void setLayout(const LayoutPtr& layout1)
+ {
+ this->layout = layout1;
+ }
- /**
- Set the name of this Appender.
- */
- void setName(const LogString& name1) { this->name.assign(name1); }
+ /**
+ Set the name of this Appender.
+ */
+ void setName(const LogString& name1)
+ {
+ this->name.assign(name1);
+ }
- /**
- Set the threshold level. All log events with lower level
- than the threshold level are ignored by the appender.
+ /**
+ Set the threshold level. All log events with lower level
+ than the threshold level are ignored by the appender.
- <p>In configuration files this option is specified by setting the
- value of the <b>Threshold</b> option to a level
- string, such as "DEBUG", "INFO" and so on.
- */
- void setThreshold(const LevelPtr& threshold);
+ <p>In configuration files this option is specified by setting the
+ value of the <b>Threshold</b> option to a level
+ string, such as "DEBUG", "INFO" and so on.
+ */
+ void setThreshold(const LevelPtr& threshold);
- }; // class AppenderSkeleton
+}; // class AppenderSkeleton
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
diff --git a/src/main/include/log4cxx/asyncappender.h b/src/main/include/log4cxx/asyncappender.h
index 499b435..a45cc78 100644
--- a/src/main/include/log4cxx/asyncappender.h
+++ b/src/main/include/log4cxx/asyncappender.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_ASYNC_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
@@ -33,278 +33,279 @@
#include <log4cxx/helpers/condition.h>
#if defined(NON_BLOCKING)
-#include <boost/lockfree/queue.hpp>
+ #include <boost/lockfree/queue.hpp>
#endif
namespace log4cxx
{
- LOG4CXX_LIST_DEF(LoggingEventList, log4cxx::spi::LoggingEventPtr);
+LOG4CXX_LIST_DEF(LoggingEventList, log4cxx::spi::LoggingEventPtr);
+
+/**
+The AsyncAppender lets users log events asynchronously. It uses a
+bounded buffer to store logging events.
+
+<p>The AsyncAppender will collect the events sent to it and then
+dispatch them to all the appenders that are attached to it. You can
+attach multiple appenders to an AsyncAppender.
+
+<p>The AsyncAppender uses a separate thread to serve the events in
+its bounded buffer.
+
+<p><b>Important note:</b> The <code>AsyncAppender</code> can only
+be script configured using the {@link xml::DOMConfigurator DOMConfigurator}.
+*/
+class LOG4CXX_EXPORT AsyncAppender :
+ public virtual spi::AppenderAttachable,
+ public virtual AppenderSkeleton
+{
+ public:
+ DECLARE_LOG4CXX_OBJECT(AsyncAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(AsyncAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
+ END_LOG4CXX_CAST_MAP()
/**
- The AsyncAppender lets users log events asynchronously. It uses a
- bounded buffer to store logging events.
-
- <p>The AsyncAppender will collect the events sent to it and then
- dispatch them to all the appenders that are attached to it. You can
- attach multiple appenders to an AsyncAppender.
-
- <p>The AsyncAppender uses a separate thread to serve the events in
- its bounded buffer.
-
- <p><b>Important note:</b> The <code>AsyncAppender</code> can only
- be script configured using the {@link xml::DOMConfigurator DOMConfigurator}.
+ * Create new instance.
*/
- class LOG4CXX_EXPORT AsyncAppender :
- public virtual spi::AppenderAttachable,
- public virtual AppenderSkeleton
- {
- public:
- DECLARE_LOG4CXX_OBJECT(AsyncAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(AsyncAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
- END_LOG4CXX_CAST_MAP()
+ AsyncAppender();
+ /**
+ * Destructor.
+ */
+ virtual ~AsyncAppender();
+
+ void addRef() const;
+ void releaseRef() const;
+
+ /**
+ * Add appender.
+ *
+ * @param newAppender appender to add, may not be null.
+ */
+ void addAppender(const AppenderPtr& newAppender);
+
+ virtual void doAppend(const spi::LoggingEventPtr& event,
+ log4cxx::helpers::Pool& pool1);
+
+ void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+
+ /**
+ Close this <code>AsyncAppender</code> by interrupting the
+ dispatcher thread which will process all pending events before
+ exiting.
+ */
+ void close();
+
+ /**
+ * Get iterator over attached appenders.
+ * @return list of all attached appenders.
+ */
+ AppenderList getAllAppenders() const;
+
+ /**
+ * Get appender by name.
+ *
+ * @param name name, may not be null.
+ * @return matching appender or null.
+ */
+ AppenderPtr getAppender(const LogString& name) const;
+
+ /**
+ * Gets whether the location of the logging request call
+ * should be captured.
+ *
+ * @return the current value of the <b>LocationInfo</b> option.
+ */
+ bool getLocationInfo() const;
+ /**
+ * Determines if specified appender is attached.
+ * @param appender appender.
+ * @return true if attached.
+ */
+ bool isAttached(const AppenderPtr& appender) const;
+
+ virtual bool requiresLayout() const;
+
+ /**
+ * Removes and closes all attached appenders.
+ */
+ void removeAllAppenders();
+
+ /**
+ * Removes an appender.
+ * @param appender appender to remove.
+ */
+ void removeAppender(const AppenderPtr& appender);
+ /**
+ * Remove appender by name.
+ * @param name name.
+ */
+ void removeAppender(const LogString& name);
+
+ /**
+ * The <b>LocationInfo</b> attribute is provided for compatibility
+ * with log4j and has no effect on the log output.
+ * @param flag new value.
+ */
+ void setLocationInfo(bool flag);
+
+ /**
+ * The <b>BufferSize</b> option takes a non-negative integer value.
+ * This integer value determines the maximum size of the bounded
+ * buffer.
+ * */
+ void setBufferSize(int size);
+
+ /**
+ * Gets the current buffer size.
+ * @return the current value of the <b>BufferSize</b> option.
+ */
+ int getBufferSize() const;
+
+ /**
+ * Sets whether appender should wait if there is no
+ * space available in the event buffer or immediately return.
+ *
+ * @param value true if appender should wait until available space in buffer.
+ */
+ void setBlocking(bool value);
+
+ /**
+ * Gets whether appender should block calling thread when buffer is full.
+ * If false, messages will be counted by logger and a summary
+ * message appended after the contents of the buffer have been appended.
+ *
+ * @return true if calling thread will be blocked when buffer is full.
+ */
+ bool getBlocking() const;
+
+
+ /**
+ * Set appender properties by name.
+ * @param option property name.
+ * @param value property value.
+ */
+ void setOption(const LogString& option, const LogString& value);
+
+
+ private:
+ AsyncAppender(const AsyncAppender&);
+ AsyncAppender& operator=(const AsyncAppender&);
+ /**
+ * The default buffer size is set to 128 events.
+ */
+ enum { DEFAULT_BUFFER_SIZE = 128 };
+
+ /**
+ * Event buffer.
+ */
+#if defined(NON_BLOCKING)
+ boost::lockfree::queue<log4cxx::spi::LoggingEvent* > buffer;
+ std::atomic<size_t> discardedCount;
+#else
+ LoggingEventList buffer;
+#endif
+
+ /**
+ * Mutex used to guard access to buffer and discardMap.
+ */
+ SHARED_MUTEX bufferMutex;
+
+#if defined(NON_BLOCKING)
+ ::log4cxx::helpers::Semaphore bufferNotFull;
+ ::log4cxx::helpers::Semaphore bufferNotEmpty;
+#else
+ ::log4cxx::helpers::Condition bufferNotFull;
+ ::log4cxx::helpers::Condition bufferNotEmpty;
+#endif
+ class DiscardSummary
+ {
+ private:
+ /**
+ * First event of the highest severity.
+ */
+ ::log4cxx::spi::LoggingEventPtr maxEvent;
+
+ /**
+ * Total count of messages discarded.
+ */
+ int count;
+
+ public:
/**
* Create new instance.
- */
- AsyncAppender();
-
- /**
- * Destructor.
- */
- virtual ~AsyncAppender();
-
- void addRef() const;
- void releaseRef() const;
-
- /**
- * Add appender.
*
- * @param newAppender appender to add, may not be null.
+ * @param event event, may not be null.
*/
- void addAppender(const AppenderPtr& newAppender);
-
- virtual void doAppend(const spi::LoggingEventPtr& event,
- log4cxx::helpers::Pool& pool1);
-
- void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+ DiscardSummary(const ::log4cxx::spi::LoggingEventPtr& event);
+ /** Copy constructor. */
+ DiscardSummary(const DiscardSummary& src);
+ /** Assignment operator. */
+ DiscardSummary& operator=(const DiscardSummary& src);
/**
- Close this <code>AsyncAppender</code> by interrupting the
- dispatcher thread which will process all pending events before
- exiting.
- */
- void close();
-
- /**
- * Get iterator over attached appenders.
- * @return list of all attached appenders.
- */
- AppenderList getAllAppenders() const;
-
- /**
- * Get appender by name.
+ * Add discarded event to summary.
*
- * @param name name, may not be null.
- * @return matching appender or null.
+ * @param event event, may not be null.
*/
- AppenderPtr getAppender(const LogString& name) const;
+ void add(const ::log4cxx::spi::LoggingEventPtr& event);
/**
- * Gets whether the location of the logging request call
- * should be captured.
+ * Create event with summary information.
*
- * @return the current value of the <b>LocationInfo</b> option.
- */
- bool getLocationInfo() const;
- /**
- * Determines if specified appender is attached.
- * @param appender appender.
- * @return true if attached.
- */
- bool isAttached(const AppenderPtr& appender) const;
-
- virtual bool requiresLayout() const;
-
- /**
- * Removes and closes all attached appenders.
- */
- void removeAllAppenders();
-
- /**
- * Removes an appender.
- * @param appender appender to remove.
- */
- void removeAppender(const AppenderPtr& appender);
- /**
- * Remove appender by name.
- * @param name name.
- */
- void removeAppender(const LogString& name);
-
- /**
- * The <b>LocationInfo</b> attribute is provided for compatibility
- * with log4j and has no effect on the log output.
- * @param flag new value.
- */
- void setLocationInfo(bool flag);
-
- /**
- * The <b>BufferSize</b> option takes a non-negative integer value.
- * This integer value determines the maximum size of the bounded
- * buffer.
- * */
- void setBufferSize(int size);
-
- /**
- * Gets the current buffer size.
- * @return the current value of the <b>BufferSize</b> option.
- */
- int getBufferSize() const;
-
- /**
- * Sets whether appender should wait if there is no
- * space available in the event buffer or immediately return.
- *
- * @param value true if appender should wait until available space in buffer.
+ * @return new event.
*/
- void setBlocking(bool value);
+ ::log4cxx::spi::LoggingEventPtr createEvent(::log4cxx::helpers::Pool& p);
- /**
- * Gets whether appender should block calling thread when buffer is full.
- * If false, messages will be counted by logger and a summary
- * message appended after the contents of the buffer have been appended.
- *
- * @return true if calling thread will be blocked when buffer is full.
- */
- bool getBlocking() const;
+ static
+ ::log4cxx::spi::LoggingEventPtr createEvent(::log4cxx::helpers::Pool& p,
+ size_t discardedCount);
+ };
+ /**
+ * Map of DiscardSummary objects keyed by logger name.
+ */
+ typedef std::map<LogString, DiscardSummary> DiscardMap;
+ DiscardMap* discardMap;
- /**
- * Set appender properties by name.
- * @param option property name.
- * @param value property value.
- */
- void setOption(const LogString& option, const LogString& value);
+ /**
+ * Buffer size.
+ */
+ int bufferSize;
+ /**
+ * Nested appenders.
+ */
+ helpers::AppenderAttachableImplPtr appenders;
- private:
- AsyncAppender(const AsyncAppender&);
- AsyncAppender& operator=(const AsyncAppender&);
- /**
- * The default buffer size is set to 128 events.
- */
- enum { DEFAULT_BUFFER_SIZE = 128 };
+ /**
+ * Dispatcher.
+ */
+ helpers::Thread dispatcher;
- /**
- * Event buffer.
- */
-#if defined(NON_BLOCKING)
- boost::lockfree::queue<log4cxx::spi::LoggingEvent* > buffer;
- std::atomic<size_t> discardedCount;
-#else
- LoggingEventList buffer;
-#endif
+ /**
+ * Should location info be included in dispatched messages.
+ */
+ bool locationInfo;
- /**
- * Mutex used to guard access to buffer and discardMap.
- */
- SHARED_MUTEX bufferMutex;
-
-#if defined(NON_BLOCKING)
- ::log4cxx::helpers::Semaphore bufferNotFull;
- ::log4cxx::helpers::Semaphore bufferNotEmpty;
-#else
- ::log4cxx::helpers::Condition bufferNotFull;
- ::log4cxx::helpers::Condition bufferNotEmpty;
-#endif
- class DiscardSummary {
- private:
- /**
- * First event of the highest severity.
- */
- ::log4cxx::spi::LoggingEventPtr maxEvent;
+ /**
+ * Does appender block when buffer is full.
+ */
+ bool blocking;
- /**
- * Total count of messages discarded.
- */
- int count;
+ /**
+ * Dispatch routine.
+ */
+ static void* LOG4CXX_THREAD_FUNC dispatch(apr_thread_t* thread, void* data);
- public:
- /**
- * Create new instance.
- *
- * @param event event, may not be null.
- */
- DiscardSummary(const ::log4cxx::spi::LoggingEventPtr& event);
- /** Copy constructor. */
- DiscardSummary(const DiscardSummary& src);
- /** Assignment operator. */
- DiscardSummary& operator=(const DiscardSummary& src);
-
- /**
- * Add discarded event to summary.
- *
- * @param event event, may not be null.
- */
- void add(const ::log4cxx::spi::LoggingEventPtr& event);
-
- /**
- * Create event with summary information.
- *
- * @return new event.
- */
- ::log4cxx::spi::LoggingEventPtr createEvent(::log4cxx::helpers::Pool& p);
-
- static
- ::log4cxx::spi::LoggingEventPtr createEvent(::log4cxx::helpers::Pool& p,
- size_t discardedCount);
- };
-
- /**
- * Map of DiscardSummary objects keyed by logger name.
- */
- typedef std::map<LogString, DiscardSummary> DiscardMap;
- DiscardMap* discardMap;
-
- /**
- * Buffer size.
- */
- int bufferSize;
-
- /**
- * Nested appenders.
- */
- helpers::AppenderAttachableImplPtr appenders;
-
- /**
- * Dispatcher.
- */
- helpers::Thread dispatcher;
-
- /**
- * Should location info be included in dispatched messages.
- */
- bool locationInfo;
-
- /**
- * Does appender block when buffer is full.
- */
- bool blocking;
-
- /**
- * Dispatch routine.
- */
- static void* LOG4CXX_THREAD_FUNC dispatch(apr_thread_t* thread, void* data);
-
- }; // class AsyncAppender
- LOG4CXX_PTR_DEF(AsyncAppender);
+}; // class AsyncAppender
+LOG4CXX_PTR_DEF(AsyncAppender);
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
diff --git a/src/main/include/log4cxx/basicconfigurator.h b/src/main/include/log4cxx/basicconfigurator.h
index 3785139..2f6f45f 100644
--- a/src/main/include/log4cxx/basicconfigurator.h
+++ b/src/main/include/log4cxx/basicconfigurator.h
@@ -26,40 +26,40 @@
namespace log4cxx
{
- class Appender;
- typedef helpers::ObjectPtrT<Appender> AppenderPtr;
+class Appender;
+typedef helpers::ObjectPtrT<Appender> AppenderPtr;
- /**
- Use this class to quickly configure the package.
- <p>For file based configuration see
- PropertyConfigurator. For XML based configuration see
- DOMConfigurator.
- */
- class LOG4CXX_EXPORT BasicConfigurator
- {
- protected:
- BasicConfigurator() {}
+/**
+Use this class to quickly configure the package.
+<p>For file based configuration see
+PropertyConfigurator. For XML based configuration see
+DOMConfigurator.
+*/
+class LOG4CXX_EXPORT BasicConfigurator
+{
+ protected:
+ BasicConfigurator() {}
- public:
- /**
- Add a ConsoleAppender that uses PatternLayout
- using the PatternLayout#TTCC_CONVERSION_PATTERN and
- prints to <code>stdout</code> to the root logger.*/
- static void configure();
+ public:
+ /**
+ Add a ConsoleAppender that uses PatternLayout
+ using the PatternLayout#TTCC_CONVERSION_PATTERN and
+ prints to <code>stdout</code> to the root logger.*/
+ static void configure();
- /**
- Add <code>appender</code> to the root logger.
- @param appender The appender to add to the root logger.
- */
- static void configure(const AppenderPtr& appender);
+ /**
+ Add <code>appender</code> to the root logger.
+ @param appender The appender to add to the root logger.
+ */
+ static void configure(const AppenderPtr& appender);
- /**
- Reset the default hierarchy to its defaut. It is equivalent to
- calling
- <code>Logger::getDefaultHierarchy()->resetConfiguration()</code>.
- See Hierarchy#resetConfiguration() for more details. */
- static void resetConfiguration();
- }; // class BasicConfigurator
+ /**
+ Reset the default hierarchy to its defaut. It is equivalent to
+ calling
+ <code>Logger::getDefaultHierarchy()->resetConfiguration()</code>.
+ See Hierarchy#resetConfiguration() for more details. */
+ static void resetConfiguration();
+}; // class BasicConfigurator
} // namespace log4cxx
#endif //_LOG4CXX_BASIC_CONFIGURATOR_H
diff --git a/src/main/include/log4cxx/config/propertysetter.h b/src/main/include/log4cxx/config/propertysetter.h
index 91dc48c..5e1b74f 100644
--- a/src/main/include/log4cxx/config/propertysetter.h
+++ b/src/main/include/log4cxx/config/propertysetter.h
@@ -23,86 +23,86 @@
namespace log4cxx
{
- namespace helpers
- {
- class Object;
- typedef ObjectPtrT<Object> ObjectPtr;
+namespace helpers
+{
+class Object;
+typedef ObjectPtrT<Object> ObjectPtr;
- class Properties;
- class Pool;
- }
+class Properties;
+class Pool;
+}
- namespace config
- {
- /**
- General purpose Object property setter. Clients repeatedly invokes
- {@link #setProperty setProperty(name,value)} in order to invoke setters
- on the Object specified in the constructor.
+namespace config
+{
+/**
+General purpose Object property setter. Clients repeatedly invokes
+{@link #setProperty setProperty(name,value)} in order to invoke setters
+on the Object specified in the constructor.
- <p>Usage:
- <pre>
- PropertySetter ps(anObject);
- ps.set("name", "Joe");
- ps.set("age", "32");
- ps.set("isMale", "true");
- </pre>
- will cause the invocations anObject->setOption("name", "Joe"),
- anObject->setOption("age", "32") and anObject->setOption("isMale", "true")
- if the spi::OptionHandler interface is supported by anObject.
- */
- class LOG4CXX_EXPORT PropertySetter
- {
- protected:
- helpers::ObjectPtr obj;
+<p>Usage:
+<pre>
+PropertySetter ps(anObject);
+ps.set("name", "Joe");
+ps.set("age", "32");
+ps.set("isMale", "true");
+</pre>
+will cause the invocations anObject->setOption("name", "Joe"),
+anObject->setOption("age", "32") and anObject->setOption("isMale", "true")
+if the spi::OptionHandler interface is supported by anObject.
+*/
+class LOG4CXX_EXPORT PropertySetter
+{
+ protected:
+ helpers::ObjectPtr obj;
- public:
- /**
- Create a new PropertySetter for the specified Object. This is done
- in prepartion for invoking #setProperty one or more times.
+ public:
+ /**
+ Create a new PropertySetter for the specified Object. This is done
+ in prepartion for invoking #setProperty one or more times.
- @param obj the object for which to set properties
- */
- PropertySetter(const helpers::ObjectPtr& obj);
+ @param obj the object for which to set properties
+ */
+ PropertySetter(const helpers::ObjectPtr& obj);
- /**
- Set the properties of an object passed as a parameter in one
- go. The <code>properties</code> are parsed relative to a
- <code>prefix</code>.
+ /**
+ Set the properties of an object passed as a parameter in one
+ go. The <code>properties</code> are parsed relative to a
+ <code>prefix</code>.
- @param obj The object to configure.
- @param properties A java.util.Properties containing keys and values.
- @param prefix Only keys having the specified prefix will be set.
- @param p pool to use for any allocations required during call.
- */
- static void setProperties(const helpers::ObjectPtr& obj,
- helpers::Properties& properties,
- const LogString& prefix,
- log4cxx::helpers::Pool& p);
+ @param obj The object to configure.
+ @param properties A java.util.Properties containing keys and values.
+ @param prefix Only keys having the specified prefix will be set.
+ @param p pool to use for any allocations required during call.
+ */
+ static void setProperties(const helpers::ObjectPtr& obj,
+ helpers::Properties& properties,
+ const LogString& prefix,
+ log4cxx::helpers::Pool& p);
- /**
- Set the properites for the object that match the
- <code>prefix</code> passed as parameter.
- */
- void setProperties(helpers::Properties& properties,
- const LogString& prefix,
- log4cxx::helpers::Pool& p);
+ /**
+ Set the properites for the object that match the
+ <code>prefix</code> passed as parameter.
+ */
+ void setProperties(helpers::Properties& properties,
+ const LogString& prefix,
+ log4cxx::helpers::Pool& p);
- /**
- Set a property on this PropertySetter's Object. If the underlying
- Object supports the spi::OptionHandler interface, the
- {@link spi::OptionHandler#setOption setOption} method is called.
+ /**
+ Set a property on this PropertySetter's Object. If the underlying
+ Object supports the spi::OptionHandler interface, the
+ {@link spi::OptionHandler#setOption setOption} method is called.
- @param option name of the property
- @param value String value of the property
- @param p pool to use for any allocations required during call.
- */
- void setProperty(const LogString& option,
- const LogString& value,
- log4cxx::helpers::Pool& p);
+ @param option name of the property
+ @param value String value of the property
+ @param p pool to use for any allocations required during call.
+ */
+ void setProperty(const LogString& option,
+ const LogString& value,
+ log4cxx::helpers::Pool& p);
- void activate(log4cxx::helpers::Pool& p);
- }; // class PropertySetter
- } // namespace config;
+ void activate(log4cxx::helpers::Pool& p);
+}; // class PropertySetter
+} // namespace config;
} // namespace log4cxx
#endif //_LOG4CXX_CONFIG_PROPERTYSETTER_H
diff --git a/src/main/include/log4cxx/consoleappender.h b/src/main/include/log4cxx/consoleappender.h
index 94afe21..f6f92e2 100644
--- a/src/main/include/log4cxx/consoleappender.h
+++ b/src/main/include/log4cxx/consoleappender.h
@@ -23,55 +23,55 @@
namespace log4cxx
{
+/**
+* ConsoleAppender appends log events to <code>stdout</code> or
+* <code>stderr</code> using a layout specified by the user. The
+* default target is <code>stdout</code>.
+*/
+class LOG4CXX_EXPORT ConsoleAppender : public WriterAppender
+{
+ private:
+ LogString target;
+
+ public:
+ DECLARE_LOG4CXX_OBJECT(ConsoleAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(ConsoleAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
+
+ ConsoleAppender();
+ ConsoleAppender(const LayoutPtr& layout);
+ ConsoleAppender(const LayoutPtr& layout, const LogString& target);
+ ~ConsoleAppender();
+
+
/**
- * ConsoleAppender appends log events to <code>stdout</code> or
- * <code>stderr</code> using a layout specified by the user. The
- * default target is <code>stdout</code>.
- */
- class LOG4CXX_EXPORT ConsoleAppender : public WriterAppender
- {
- private:
- LogString target;
+ * Sets the value of the <b>target</b> property. Recognized values
+ * are "System.out" and "System.err". Any other value will be
+ * ignored.
+ * */
+ void setTarget(const LogString& value);
- public:
- DECLARE_LOG4CXX_OBJECT(ConsoleAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(ConsoleAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
+ /**
+ * Returns the current value of the <b>target</b> property. The
+ * default value of the option is "System.out".
+ *
+ * See also #setTarget.
+ * */
+ LogString getTarget() const;
- ConsoleAppender();
- ConsoleAppender(const LayoutPtr& layout);
- ConsoleAppender(const LayoutPtr& layout, const LogString& target);
- ~ConsoleAppender();
+ void activateOptions(log4cxx::helpers::Pool& p);
+ void setOption(const LogString& option, const LogString& value);
+ static const LogString& getSystemOut();
+ static const LogString& getSystemErr();
- /**
- * Sets the value of the <b>target</b> property. Recognized values
- * are "System.out" and "System.err". Any other value will be
- * ignored.
- * */
- void setTarget(const LogString& value);
+ private:
+ void targetWarn(const LogString& val);
- /**
- * Returns the current value of the <b>target</b> property. The
- * default value of the option is "System.out".
- *
- * See also #setTarget.
- * */
- LogString getTarget() const;
-
- void activateOptions(log4cxx::helpers::Pool& p);
- void setOption(const LogString& option, const LogString& value);
- static const LogString& getSystemOut();
- static const LogString& getSystemErr();
-
-
- private:
- void targetWarn(const LogString& val);
-
- };
- LOG4CXX_PTR_DEF(ConsoleAppender);
+};
+LOG4CXX_PTR_DEF(ConsoleAppender);
} //namespace log4cxx
#endif //_LOG4CXX_CONSOLE_APPENDER_H
diff --git a/src/main/include/log4cxx/dailyrollingfileappender.h b/src/main/include/log4cxx/dailyrollingfileappender.h
index 3c8f064..24f2401 100644
--- a/src/main/include/log4cxx/dailyrollingfileappender.h
+++ b/src/main/include/log4cxx/dailyrollingfileappender.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_DAILYROLLINGFILEAPPENDER_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
@@ -29,15 +29,18 @@
#include <log4cxx/spi/optionhandler.h>
#include <log4cxx/rolling/rollingfileappenderskeleton.h>
-namespace log4cxx {
- namespace helpers {
- class Pool;
- }
+namespace log4cxx
+{
+namespace helpers
+{
+class Pool;
+}
- namespace spi {
- class ErrorHandler;
- typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHandlerPtr;
- }
+namespace spi
+{
+class ErrorHandler;
+typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHandlerPtr;
+}
/**
@@ -140,54 +143,55 @@
you want.
*/
- class LOG4CXX_EXPORT DailyRollingFileAppender : public log4cxx::rolling::RollingFileAppenderSkeleton {
- DECLARE_LOG4CXX_OBJECT(DailyRollingFileAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(DailyRollingFileAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(FileAppender)
- END_LOG4CXX_CAST_MAP()
+class LOG4CXX_EXPORT DailyRollingFileAppender : public log4cxx::rolling::RollingFileAppenderSkeleton
+{
+ DECLARE_LOG4CXX_OBJECT(DailyRollingFileAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(DailyRollingFileAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(FileAppender)
+ END_LOG4CXX_CAST_MAP()
- /**
- The date pattern used to initiate rollover.
- */
- LogString datePattern;
+ /**
+ The date pattern used to initiate rollover.
+ */
+ LogString datePattern;
-public:
- /**
- The default constructor simply calls its {@link
- FileAppender#FileAppender parents constructor}. */
- DailyRollingFileAppender();
+ public:
+ /**
+ The default constructor simply calls its {@link
+ FileAppender#FileAppender parents constructor}. */
+ DailyRollingFileAppender();
- /**
- Instantiate a DailyRollingFileAppender and open the file designated by
- <code>filename</code>. The opened filename will become the ouput
- destination for this appender.
+ /**
+ Instantiate a DailyRollingFileAppender and open the file designated by
+ <code>filename</code>. The opened filename will become the ouput
+ destination for this appender.
- */
- DailyRollingFileAppender(
- const LayoutPtr& layout,
- const LogString& filename,
- const LogString& datePattern);
+ */
+ DailyRollingFileAppender(
+ const LayoutPtr& layout,
+ const LogString& filename,
+ const LogString& datePattern);
- /**
- The <b>DatePattern</b> takes a string in the same format as
- expected by {@link log4cxx::helpers::SimpleDateFormat SimpleDateFormat}. This options determines the
- rollover schedule.
- */
- void setDatePattern(const LogString& pattern);
+ /**
+ The <b>DatePattern</b> takes a string in the same format as
+ expected by {@link log4cxx::helpers::SimpleDateFormat SimpleDateFormat}. This options determines the
+ rollover schedule.
+ */
+ void setDatePattern(const LogString& pattern);
- /** Returns the value of the <b>DatePattern</b> option. */
- LogString getDatePattern();
+ /** Returns the value of the <b>DatePattern</b> option. */
+ LogString getDatePattern();
- void setOption(const LogString& option,
- const LogString& value);
+ void setOption(const LogString& option,
+ const LogString& value);
- /**
- * Prepares DailyRollingFileAppender for use.
- */
- void activateOptions(log4cxx::helpers::Pool&);
+ /**
+ * Prepares DailyRollingFileAppender for use.
+ */
+ void activateOptions(log4cxx::helpers::Pool&);
};
@@ -196,7 +200,7 @@
}
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
diff --git a/src/main/include/log4cxx/db/odbcappender.h b/src/main/include/log4cxx/db/odbcappender.h
index e1b8fd5..d3bbb1b 100644
--- a/src/main/include/log4cxx/db/odbcappender.h
+++ b/src/main/include/log4cxx/db/odbcappender.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_DB_ODBC_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
@@ -33,264 +33,285 @@
namespace log4cxx
{
- namespace db
+namespace db
+{
+class LOG4CXX_EXPORT SQLException : public log4cxx::helpers::Exception
+{
+ public:
+ SQLException(short fHandleType,
+ void* hInput, const char* prolog,
+ log4cxx::helpers::Pool& p);
+ SQLException(const char* msg);
+ SQLException(const SQLException& src);
+ private:
+ const char* formatMessage(short fHandleType,
+ void* hInput, const char* prolog,
+ log4cxx::helpers::Pool& p);
+};
+
+/**
+<p><b>WARNING: This version of ODBCAppender
+is very likely to be completely replaced in the future. Moreoever,
+it does not log exceptions.</b> </p>
+
+The ODBCAppender provides for sending log events to a database.
+
+
+<p>Each append call adds to an <code>ArrayList</code> buffer. When
+the buffer is filled each log event is placed in a sql statement
+(configurable) and executed.
+
+<b>BufferSize</b>, <b>db URL</b>, <b>User</b>, & <b>Password</b> are
+configurable options in the standard log4j ways.
+
+<p>The <code>setSql(String sql)</code> sets the SQL statement to be
+used for logging -- this statement is sent to a
+<code>PatternLayout</code> (either created automaticly by the
+appender or added by the user). Therefore by default all the
+conversion patterns in <code>PatternLayout</code> can be used
+inside of the statement. (see the test cases for examples)
+
+<p>Overriding the {@link #getLogStatement} method allows more
+explicit control of the statement used for logging.
+
+<p>For use as a base class:
+
+<ul>
+
+<li>Override getConnection() to pass any connection
+you want. Typically this is used to enable application wide
+connection pooling.
+
+<li>Override closeConnection -- if
+you override getConnection make sure to implement
+<code>closeConnection</code> to handle the connection you
+generated. Typically this would return the connection to the
+pool it came from.
+
+<li>Override getLogStatement to
+produce specialized or dynamic statements. The default uses the
+sql option value.
+
+</ul>
+*/
+
+class LOG4CXX_EXPORT ODBCAppender : public AppenderSkeleton
+{
+ protected:
+ /**
+ * URL of the DB for default connection handling
+ */
+ LogString databaseURL;
+
+ /**
+ * User to connect as for default connection handling
+ */
+ LogString databaseUser;
+
+ /**
+ * User to use for default connection handling
+ */
+ LogString databasePassword;
+
+ typedef void* SQLHDBC;
+ typedef void* SQLHENV;
+ typedef void* SQLHANDLE;
+ typedef short SQLSMALLINT;
+
+ /**
+ * Connection used by default. The connection is opened the first time it
+ * is needed and then held open until the appender is closed (usually at
+ * garbage collection). This behavior is best modified by creating a
+ * sub-class and overriding the <code>getConnection</code> and
+ * <code>closeConnection</code> methods.
+ */
+ SQLHDBC connection;
+ SQLHENV env;
+
+ /**
+ * Stores the string given to the pattern layout for conversion into a SQL
+ * statement, eg: insert into LogTable (Thread, File, Message) values
+ * ("%t", "%F", "%m")
+ *
+ * Be careful of quotes in your messages!
+ *
+ * Also see PatternLayout.
+ */
+ LogString sqlStatement;
+
+ /**
+ * size of LoggingEvent buffer before writing to the database.
+ * Default is 1.
+ */
+ size_t bufferSize;
+
+ /**
+ * ArrayList holding the buffer of Logging Events.
+ */
+ std::list<spi::LoggingEventPtr> buffer;
+
+ public:
+ DECLARE_LOG4CXX_OBJECT(ODBCAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(ODBCAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
+
+ ODBCAppender();
+ virtual ~ODBCAppender();
+
+ /**
+ Set options
+ */
+ virtual void setOption(const LogString& option, const LogString& value);
+
+ /**
+ Activate the specified options.
+ */
+ virtual void activateOptions(log4cxx::helpers::Pool& p);
+
+ /**
+ * Adds the event to the buffer. When full the buffer is flushed.
+ */
+ void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool&);
+
+ /**
+ * By default getLogStatement sends the event to the required Layout object.
+ * The layout will format the given pattern into a workable SQL string.
+ *
+ * Overriding this provides direct access to the LoggingEvent
+ * when constructing the logging statement.
+ *
+ */
+ protected:
+ LogString getLogStatement(const spi::LoggingEventPtr& event,
+ helpers::Pool& p) const;
+
+ /**
+ *
+ * Override this to provide an alertnate method of getting
+ * connections (such as caching). One method to fix this is to open
+ * connections at the start of flushBuffer() and close them at the
+ * end. I use a connection pool outside of ODBCAppender which is
+ * accessed in an override of this method.
+ * */
+ virtual void execute(const LogString& sql,
+ log4cxx::helpers::Pool& p) /*throw(SQLException)*/;
+
+ /**
+ * Override this to return the connection to a pool, or to clean up the
+ * resource.
+ *
+ * The default behavior holds a single connection open until the appender
+ * is closed (typically when garbage collected).
+ */
+ virtual void closeConnection(SQLHDBC con);
+
+ /**
+ * Override this to link with your connection pooling system.
+ *
+ * By default this creates a single connection which is held open
+ * until the object is garbage collected.
+ */
+ virtual SQLHDBC getConnection(log4cxx::helpers::Pool& p) /*throw(SQLException)*/;
+
+ /**
+ * Closes the appender, flushing the buffer first then closing the default
+ * connection if it is open.
+ */
+ public:
+ virtual void close();
+
+ /**
+ * loops through the buffer of LoggingEvents, gets a
+ * sql string from getLogStatement() and sends it to execute().
+ * Errors are sent to the errorHandler.
+ *
+ * If a statement fails the LoggingEvent stays in the buffer!
+ */
+ virtual void flushBuffer(log4cxx::helpers::Pool& p);
+
+ /**
+ * ODBCAppender requires a layout.
+ * */
+ virtual bool requiresLayout() const
{
- class LOG4CXX_EXPORT SQLException : public log4cxx::helpers::Exception {
- public:
- SQLException(short fHandleType,
- void* hInput, const char* prolog,
- log4cxx::helpers::Pool& p);
- SQLException(const char* msg);
- SQLException(const SQLException& src);
- private:
- const char* formatMessage(short fHandleType,
- void* hInput, const char* prolog,
- log4cxx::helpers::Pool& p);
- };
+ return true;
+ }
- /**
- <p><b>WARNING: This version of ODBCAppender
- is very likely to be completely replaced in the future. Moreoever,
- it does not log exceptions.</b> </p>
+ /**
+ * Set pre-formated statement eg: insert into LogTable (msg) values ("%m")
+ */
+ void setSql(const LogString& s);
- The ODBCAppender provides for sending log events to a database.
+ /**
+ * Returns pre-formated statement eg: insert into LogTable (msg) values ("%m")
+ */
+ inline const LogString& getSql() const
+ {
+ return sqlStatement;
+ }
- <p>Each append call adds to an <code>ArrayList</code> buffer. When
- the buffer is filled each log event is placed in a sql statement
- (configurable) and executed.
-
- <b>BufferSize</b>, <b>db URL</b>, <b>User</b>, & <b>Password</b> are
- configurable options in the standard log4j ways.
-
- <p>The <code>setSql(String sql)</code> sets the SQL statement to be
- used for logging -- this statement is sent to a
- <code>PatternLayout</code> (either created automaticly by the
- appender or added by the user). Therefore by default all the
- conversion patterns in <code>PatternLayout</code> can be used
- inside of the statement. (see the test cases for examples)
-
- <p>Overriding the {@link #getLogStatement} method allows more
- explicit control of the statement used for logging.
-
- <p>For use as a base class:
-
- <ul>
-
- <li>Override getConnection() to pass any connection
- you want. Typically this is used to enable application wide
- connection pooling.
-
- <li>Override closeConnection -- if
- you override getConnection make sure to implement
- <code>closeConnection</code> to handle the connection you
- generated. Typically this would return the connection to the
- pool it came from.
-
- <li>Override getLogStatement to
- produce specialized or dynamic statements. The default uses the
- sql option value.
-
- </ul>
- */
-
- class LOG4CXX_EXPORT ODBCAppender : public AppenderSkeleton
- {
- protected:
- /**
- * URL of the DB for default connection handling
- */
- LogString databaseURL;
-
- /**
- * User to connect as for default connection handling
- */
- LogString databaseUser;
-
- /**
- * User to use for default connection handling
- */
- LogString databasePassword;
-
- typedef void* SQLHDBC;
- typedef void* SQLHENV;
- typedef void* SQLHANDLE;
- typedef short SQLSMALLINT;
-
- /**
- * Connection used by default. The connection is opened the first time it
- * is needed and then held open until the appender is closed (usually at
- * garbage collection). This behavior is best modified by creating a
- * sub-class and overriding the <code>getConnection</code> and
- * <code>closeConnection</code> methods.
- */
- SQLHDBC connection;
- SQLHENV env;
-
- /**
- * Stores the string given to the pattern layout for conversion into a SQL
- * statement, eg: insert into LogTable (Thread, File, Message) values
- * ("%t", "%F", "%m")
- *
- * Be careful of quotes in your messages!
- *
- * Also see PatternLayout.
- */
- LogString sqlStatement;
-
- /**
- * size of LoggingEvent buffer before writing to the database.
- * Default is 1.
- */
- size_t bufferSize;
-
- /**
- * ArrayList holding the buffer of Logging Events.
- */
- std::list<spi::LoggingEventPtr> buffer;
-
- public:
- DECLARE_LOG4CXX_OBJECT(ODBCAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(ODBCAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
-
- ODBCAppender();
- virtual ~ODBCAppender();
-
- /**
- Set options
- */
- virtual void setOption(const LogString& option, const LogString& value);
-
- /**
- Activate the specified options.
- */
- virtual void activateOptions(log4cxx::helpers::Pool& p);
-
- /**
- * Adds the event to the buffer. When full the buffer is flushed.
- */
- void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool&);
-
- /**
- * By default getLogStatement sends the event to the required Layout object.
- * The layout will format the given pattern into a workable SQL string.
- *
- * Overriding this provides direct access to the LoggingEvent
- * when constructing the logging statement.
- *
- */
- protected:
- LogString getLogStatement(const spi::LoggingEventPtr& event,
- helpers::Pool& p) const;
-
- /**
- *
- * Override this to provide an alertnate method of getting
- * connections (such as caching). One method to fix this is to open
- * connections at the start of flushBuffer() and close them at the
- * end. I use a connection pool outside of ODBCAppender which is
- * accessed in an override of this method.
- * */
- virtual void execute(const LogString& sql,
- log4cxx::helpers::Pool& p) /*throw(SQLException)*/;
-
- /**
- * Override this to return the connection to a pool, or to clean up the
- * resource.
- *
- * The default behavior holds a single connection open until the appender
- * is closed (typically when garbage collected).
- */
- virtual void closeConnection(SQLHDBC con);
-
- /**
- * Override this to link with your connection pooling system.
- *
- * By default this creates a single connection which is held open
- * until the object is garbage collected.
- */
- virtual SQLHDBC getConnection(log4cxx::helpers::Pool& p) /*throw(SQLException)*/;
-
- /**
- * Closes the appender, flushing the buffer first then closing the default
- * connection if it is open.
- */
- public:
- virtual void close();
-
- /**
- * loops through the buffer of LoggingEvents, gets a
- * sql string from getLogStatement() and sends it to execute().
- * Errors are sent to the errorHandler.
- *
- * If a statement fails the LoggingEvent stays in the buffer!
- */
- virtual void flushBuffer(log4cxx::helpers::Pool& p);
-
- /**
- * ODBCAppender requires a layout.
- * */
- virtual bool requiresLayout() const
- { return true; }
-
- /**
- * Set pre-formated statement eg: insert into LogTable (msg) values ("%m")
- */
- void setSql(const LogString& s);
-
- /**
- * Returns pre-formated statement eg: insert into LogTable (msg) values ("%m")
- */
- inline const LogString& getSql() const
- { return sqlStatement; }
+ inline void setUser(const LogString& user)
+ {
+ databaseUser = user;
+ }
- inline void setUser(const LogString& user)
- { databaseUser = user; }
+ inline void setURL(const LogString& url)
+ {
+ databaseURL = url;
+ }
- inline void setURL(const LogString& url)
- { databaseURL = url; }
+ inline void setPassword(const LogString& password)
+ {
+ databasePassword = password;
+ }
- inline void setPassword(const LogString& password)
- { databasePassword = password; }
+ inline void setBufferSize(size_t newBufferSize)
+ {
+ bufferSize = newBufferSize;
+ }
+
+ inline const LogString& getUser() const
+ {
+ return databaseUser;
+ }
- inline void setBufferSize(size_t newBufferSize)
- { bufferSize = newBufferSize; }
-
- inline const LogString& getUser() const
- { return databaseUser; }
+ inline const LogString& getURL() const
+ {
+ return databaseURL;
+ }
- inline const LogString& getURL() const
- { return databaseURL; }
+ inline const LogString& getPassword() const
+ {
+ return databasePassword;
+ }
+ inline size_t getBufferSize() const
+ {
+ return bufferSize;
+ }
+ private:
+ ODBCAppender(const ODBCAppender&);
+ ODBCAppender& operator=(const ODBCAppender&);
+ static void encode(wchar_t** dest, const LogString& src,
+ log4cxx::helpers::Pool& p);
+ static void encode(unsigned short** dest, const LogString& src,
+ log4cxx::helpers::Pool& p);
+}; // class ODBCAppender
+LOG4CXX_PTR_DEF(ODBCAppender);
- inline const LogString& getPassword() const
- { return databasePassword; }
-
- inline size_t getBufferSize() const
- { return bufferSize; }
- private:
- ODBCAppender(const ODBCAppender&);
- ODBCAppender& operator=(const ODBCAppender&);
- static void encode(wchar_t** dest, const LogString& src,
- log4cxx::helpers::Pool& p);
- static void encode(unsigned short** dest, const LogString& src,
- log4cxx::helpers::Pool& p);
- }; // class ODBCAppender
- LOG4CXX_PTR_DEF(ODBCAppender);
-
- } // namespace db
+} // namespace db
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif // _LOG4CXX_DB_ODBC_APPENDER_H
diff --git a/src/main/include/log4cxx/defaultconfigurator.h b/src/main/include/log4cxx/defaultconfigurator.h
index c88d337..56c17c0 100644
--- a/src/main/include/log4cxx/defaultconfigurator.h
+++ b/src/main/include/log4cxx/defaultconfigurator.h
@@ -22,34 +22,35 @@
namespace log4cxx
{
- namespace spi {
- class LoggerRepository;
- typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
- }
+namespace spi
+{
+class LoggerRepository;
+typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
+}
- /**
- * Configures the repository from environmental settings and files.
- *
- */
- class LOG4CXX_EXPORT DefaultConfigurator
- {
- private:
- DefaultConfigurator() {}
+/**
+ * Configures the repository from environmental settings and files.
+*
+*/
+class LOG4CXX_EXPORT DefaultConfigurator
+{
+ private:
+ DefaultConfigurator() {}
- public:
- /**
- Add a ConsoleAppender that uses PatternLayout
- using the PatternLayout#TTCC_CONVERSION_PATTERN and
- prints to <code>stdout</code> to the root logger.*/
- static void configure(log4cxx::spi::LoggerRepository*);
+ public:
+ /**
+ Add a ConsoleAppender that uses PatternLayout
+ using the PatternLayout#TTCC_CONVERSION_PATTERN and
+ prints to <code>stdout</code> to the root logger.*/
+ static void configure(log4cxx::spi::LoggerRepository*);
- private:
- static const LogString getConfigurationFileName();
- static const LogString getConfiguratorClass();
+ private:
+ static const LogString getConfigurationFileName();
+ static const LogString getConfiguratorClass();
- }; // class DefaultConfigurator
+}; // class DefaultConfigurator
} // namespace log4cxx
#endif //_LOG4CXX_DEFAULT_CONFIGURATOR_H
diff --git a/src/main/include/log4cxx/defaultloggerfactory.h b/src/main/include/log4cxx/defaultloggerfactory.h
index 17c2685..6de3677 100644
--- a/src/main/include/log4cxx/defaultloggerfactory.h
+++ b/src/main/include/log4cxx/defaultloggerfactory.h
@@ -23,23 +23,23 @@
namespace log4cxx
{
- class Logger;
- typedef helpers::ObjectPtrT<Logger> LoggerPtr;
+class Logger;
+typedef helpers::ObjectPtrT<Logger> LoggerPtr;
- class LOG4CXX_EXPORT DefaultLoggerFactory :
- public virtual spi::LoggerFactory,
- public virtual helpers::ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(DefaultLoggerFactory)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(spi::LoggerFactory)
- END_LOG4CXX_CAST_MAP()
+class LOG4CXX_EXPORT DefaultLoggerFactory :
+ public virtual spi::LoggerFactory,
+ public virtual helpers::ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(DefaultLoggerFactory)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(spi::LoggerFactory)
+ END_LOG4CXX_CAST_MAP()
- virtual LoggerPtr makeNewLoggerInstance(
- log4cxx::helpers::Pool& pool,
- const LogString& name) const;
- };
+ virtual LoggerPtr makeNewLoggerInstance(
+ log4cxx::helpers::Pool& pool,
+ const LogString& name) const;
+};
} // namespace log4cxx
#endif //_LOG4CXX_DEFAULT_LOGGER_FACTORY_H
diff --git a/src/main/include/log4cxx/file.h b/src/main/include/log4cxx/file.h
index e723b98..c7ad9cd 100644
--- a/src/main/include/log4cxx/file.h
+++ b/src/main/include/log4cxx/file.h
@@ -22,164 +22,165 @@
#include <log4cxx/logstring.h>
extern "C" {
-struct apr_file_t;
-struct apr_finfo_t;
+ struct apr_file_t;
+ struct apr_finfo_t;
}
namespace log4cxx
{
- namespace helpers {
- class Transcoder;
- class Pool;
- }
+namespace helpers
+{
+class Transcoder;
+class Pool;
+}
- /**
- * An abstract representation of file and directory path names.
- */
- class LOG4CXX_EXPORT File
- {
- public:
- /**
- * Construct a new instance.
- */
- File();
- /**
- * Construct a new instance. Use setPath to specify path using a LogString.
- * @param path file path in local encoding.
- */
- File(const char* path);
- /**
- * Construct a new instance. Use setPath to specify path using a LogString.
- * @param path file path in current encoding.
- */
- File(const std::string& path);
+/**
+* An abstract representation of file and directory path names.
+*/
+class LOG4CXX_EXPORT File
+{
+ public:
+ /**
+ * Construct a new instance.
+ */
+ File();
+ /**
+ * Construct a new instance. Use setPath to specify path using a LogString.
+ * @param path file path in local encoding.
+ */
+ File(const char* path);
+ /**
+ * Construct a new instance. Use setPath to specify path using a LogString.
+ * @param path file path in current encoding.
+ */
+ File(const std::string& path);
#if LOG4CXX_WCHAR_T_API
- /**
- * Construct a new instance. Use setPath to specify path using a LogString.
- * @param path file path.
- */
- File(const wchar_t* path);
- /**
- * Construct a new instance. Use setPath to specify path using a LogString.
- * @param path file path.
- */
- File(const std::wstring& path);
+ /**
+ * Construct a new instance. Use setPath to specify path using a LogString.
+ * @param path file path.
+ */
+ File(const wchar_t* path);
+ /**
+ * Construct a new instance. Use setPath to specify path using a LogString.
+ * @param path file path.
+ */
+ File(const std::wstring& path);
#endif
#if LOG4CXX_UNICHAR_API
- /**
- * Construct a new instance. Use setPath to specify path using a LogString.
- * @param path file path.
- */
- File(const UniChar* path);
- /**
- * Construct a new instance. Use setPath to specify path using a LogString.
- * @param path file path.
- */
- File(const std::basic_string<UniChar>& path);
+ /**
+ * Construct a new instance. Use setPath to specify path using a LogString.
+ * @param path file path.
+ */
+ File(const UniChar* path);
+ /**
+ * Construct a new instance. Use setPath to specify path using a LogString.
+ * @param path file path.
+ */
+ File(const std::basic_string<UniChar>& path);
#endif
#if LOG4CXX_CFSTRING_API
- /**
- * Construct a new instance. Use setPath to specify path using a LogString.
- * @param path file path.
- */
- File(const CFStringRef& path);
+ /**
+ * Construct a new instance. Use setPath to specify path using a LogString.
+ * @param path file path.
+ */
+ File(const CFStringRef& path);
#endif
- /**
- * Copy constructor.
- */
- File(const File& src);
- /**
- * Assignment operator.
- */
- File& operator=(const File& src);
- /**
- * Destructor.
- */
- ~File();
+ /**
+ * Copy constructor.
+ */
+ File(const File& src);
+ /**
+ * Assignment operator.
+ */
+ File& operator=(const File& src);
+ /**
+ * Destructor.
+ */
+ ~File();
- /**
- * Determines if file exists.
- * @param p pool.
- * @return true if file exists.
- */
- bool exists(log4cxx::helpers::Pool& p) const;
- /**
- * Determines length of file. May not be accurate if file is current open.
- * @param p pool.
- * @return length of file.
- */
- size_t length(log4cxx::helpers::Pool& p) const;
- /**
- * Determines last modification date.
- * @param p pool.
- * @return length of file.
- */
- log4cxx_time_t lastModified(log4cxx::helpers::Pool& p) const;
- /**
- * Get final portion of file path.
- * @return file name.
- */
- LogString getName() const;
- /**
- * Get file path.
- * @return file path.
- */
- LogString getPath() const;
- /**
- * Set file path
- */
- File& setPath(const LogString&);
+ /**
+ * Determines if file exists.
+ * @param p pool.
+ * @return true if file exists.
+ */
+ bool exists(log4cxx::helpers::Pool& p) const;
+ /**
+ * Determines length of file. May not be accurate if file is current open.
+ * @param p pool.
+ * @return length of file.
+ */
+ size_t length(log4cxx::helpers::Pool& p) const;
+ /**
+ * Determines last modification date.
+ * @param p pool.
+ * @return length of file.
+ */
+ log4cxx_time_t lastModified(log4cxx::helpers::Pool& p) const;
+ /**
+ * Get final portion of file path.
+ * @return file name.
+ */
+ LogString getName() const;
+ /**
+ * Get file path.
+ * @return file path.
+ */
+ LogString getPath() const;
+ /**
+ * Set file path
+ */
+ File& setPath(const LogString&);
- /**
- * Open file. See apr_file_open for details.
- * @param file APR file handle.
- * @param flags flags.
- * @param perm permissions.
- * @param p pool.
- * @return APR_SUCCESS if successful.
- */
- log4cxx_status_t open(apr_file_t** file, int flags,
- int perm, log4cxx::helpers::Pool& p) const;
+ /**
+ * Open file. See apr_file_open for details.
+ * @param file APR file handle.
+ * @param flags flags.
+ * @param perm permissions.
+ * @param p pool.
+ * @return APR_SUCCESS if successful.
+ */
+ log4cxx_status_t open(apr_file_t** file, int flags,
+ int perm, log4cxx::helpers::Pool& p) const;
- /**
- * List files if current file is a directory.
- * @param p pool.
- * @return list of files in this directory, operation of non-directory returns empty list.
- */
- std::vector<LogString> list(log4cxx::helpers::Pool& p) const;
+ /**
+ * List files if current file is a directory.
+ * @param p pool.
+ * @return list of files in this directory, operation of non-directory returns empty list.
+ */
+ std::vector<LogString> list(log4cxx::helpers::Pool& p) const;
- /**
- * Delete file.
- * @param p pool.
- * @return true if file successfully deleted.
- */
- bool deleteFile(log4cxx::helpers::Pool& p) const;
- /**
- * Rename file.
- * @param dest new path for file.
- * @param p pool.
- * @return true if file successfully renamed.
- */
- bool renameTo(const File& dest, log4cxx::helpers::Pool& p) const;
+ /**
+ * Delete file.
+ * @param p pool.
+ * @return true if file successfully deleted.
+ */
+ bool deleteFile(log4cxx::helpers::Pool& p) const;
+ /**
+ * Rename file.
+ * @param dest new path for file.
+ * @param p pool.
+ * @return true if file successfully renamed.
+ */
+ bool renameTo(const File& dest, log4cxx::helpers::Pool& p) const;
- /**
- * Get path of parent directory.
- * @param p pool.
- * @return path of parent directory.
- */
- LogString getParent(log4cxx::helpers::Pool& p) const;
- /**
- * Make directories recursively.
- * @param p pool.
- * @return true if all requested directories existed or have been created.
- */
- bool mkdirs(log4cxx::helpers::Pool& p) const;
+ /**
+ * Get path of parent directory.
+ * @param p pool.
+ * @return path of parent directory.
+ */
+ LogString getParent(log4cxx::helpers::Pool& p) const;
+ /**
+ * Make directories recursively.
+ * @param p pool.
+ * @return true if all requested directories existed or have been created.
+ */
+ bool mkdirs(log4cxx::helpers::Pool& p) const;
- private:
- LogString path;
- static char* convertBackSlashes(char*);
- char* getPath(log4cxx::helpers::Pool& p) const;
- };
+ private:
+ LogString path;
+ static char* convertBackSlashes(char*);
+ char* getPath(log4cxx::helpers::Pool& p) const;
+};
} // namespace log4cxx
diff --git a/src/main/include/log4cxx/fileappender.h b/src/main/include/log4cxx/fileappender.h
index d0491db..1693a7d 100644
--- a/src/main/include/log4cxx/fileappender.h
+++ b/src/main/include/log4cxx/fileappender.h
@@ -26,197 +26,213 @@
namespace log4cxx
{
- namespace helpers {
- class Pool;
+namespace helpers
+{
+class Pool;
+}
+
+/**
+* FileAppender appends log events to a file.
+*
+* <p>Support for <code>java.io.Writer</code> and console appending
+* has been deprecated and then removed. See the replacement
+* solutions: WriterAppender and ConsoleAppender.
+*/
+class LOG4CXX_EXPORT FileAppender : public WriterAppender
+{
+ protected:
+ /** Append to or truncate the file? The default value for this
+ variable is <code>true</code>, meaning that by default a
+ <code>FileAppender</code> will append to an existing file and
+ not truncate it.
+ <p>This option is meaningful only if the FileAppender opens the
+ file.
+ */
+ bool fileAppend;
+
+ /**
+ The name of the log file. */
+ LogString fileName;
+
+ /**
+ Do we do bufferedIO? */
+ bool bufferedIO;
+
+ /**
+ How big should the IO buffer be? Default is 8K. */
+ int bufferSize;
+
+ public:
+ DECLARE_LOG4CXX_OBJECT(FileAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(FileAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(WriterAppender)
+ END_LOG4CXX_CAST_MAP()
+
+ /**
+ The default constructor does not do anything.
+ */
+ FileAppender();
+
+ /**
+ Instantiate a <code>FileAppender</code> and open the file
+ designated by <code>filename</code>. The opened filename will
+ become the output destination for this appender.
+
+ <p>If the <code>append</code> parameter is true, the file will be
+ appended to. Otherwise, the file designated by
+ <code>filename</code> will be truncated before being opened.
+
+ <p>If the <code>bufferedIO</code> parameter is <code>true</code>,
+ then buffered IO will be used to write to the output file.
+
+ */
+ FileAppender(const LayoutPtr& layout, const LogString& filename, bool append,
+ bool bufferedIO, int bufferSize);
+
+ /**
+ Instantiate a FileAppender and open the file designated by
+ <code>filename</code>. The opened filename will become the output
+ destination for this appender.
+
+ <p>If the <code>append</code> parameter is true, the file will be
+ appended to. Otherwise, the file designated by
+ <code>filename</code> will be truncated before being opened.
+ */
+ FileAppender(const LayoutPtr& layout, const LogString& filename, bool append);
+
+ /**
+ Instantiate a FileAppender and open the file designated by
+ <code>filename</code>. The opened filename will become the output
+ destination for this appender.
+
+ <p>The file will be appended to. */
+ FileAppender(const LayoutPtr& layout, const LogString& filename);
+
+ ~FileAppender();
+
+ /**
+ The <b>File</b> property takes a string value which should be the
+ name of the file to append to.
+
+ <p><b>Note that the special values
+ "System.out" or "System.err" are no longer honored.</b>
+
+ <p>Note: Actual opening of the file is made when
+ #activateOptions is called, not when the options are set. */
+ 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
+ {
+ return fileAppend;
+ }
+
+ /** Returns the value of the <b>File</b> option. */
+ inline LogString getFile() const
+ {
+ return fileName;
}
/**
- * FileAppender appends log events to a file.
- *
- * <p>Support for <code>java.io.Writer</code> and console appending
- * has been deprecated and then removed. See the replacement
- * solutions: WriterAppender and ConsoleAppender.
+ <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.*/
+ void activateOptions(log4cxx::helpers::Pool& p);
+ void setOption(const LogString& option,
+ const LogString& value);
+
+ /**
+ Get the value of the <b>BufferedIO</b> option.
+
+ <p>BufferedIO will significatnly increase performance on heavily
+ loaded systems.
+
*/
- class LOG4CXX_EXPORT FileAppender : public WriterAppender
+ inline bool getBufferedIO() const
{
- protected:
- /** Append to or truncate the file? The default value for this
- variable is <code>true</code>, meaning that by default a
- <code>FileAppender</code> will append to an existing file and
- not truncate it.
- <p>This option is meaningful only if the FileAppender opens the
- file.
- */
- bool fileAppend;
+ return bufferedIO;
+ }
- /**
- The name of the log file. */
- LogString fileName;
+ /**
+ Get the size of the IO buffer.
+ */
+ inline int getBufferSize() const
+ {
+ return bufferSize;
+ }
- /**
- Do we do bufferedIO? */
- bool bufferedIO;
+ /**
+ The <b>Append</b> option takes a boolean value. It is set to
+ <code>true</code> by default. If true, then <code>File</code>
+ will be opened in append mode by #setFile (see
+ above). Otherwise, setFile will open
+ <code>File</code> in truncate mode.
- /**
- How big should the IO buffer be? Default is 8K. */
- int bufferSize;
+ <p>Note: Actual opening of the file is made when
+ #activateOptions is called, not when the options are set.
+ */
+ void setAppend(bool fileAppend1);
- public:
- DECLARE_LOG4CXX_OBJECT(FileAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(FileAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(WriterAppender)
- END_LOG4CXX_CAST_MAP()
+ /**
+ The <b>BufferedIO</b> option takes a boolean value. It is set to
+ <code>false</code> by default. If true, then <code>File</code>
+ will be opened in buffered mode.
- /**
- The default constructor does not do anything.
- */
- FileAppender();
+ BufferedIO will significantly increase performance on heavily
+ loaded systems.
- /**
- Instantiate a <code>FileAppender</code> and open the file
- designated by <code>filename</code>. The opened filename will
- become the output destination for this appender.
+ */
+ void setBufferedIO(bool bufferedIO);
- <p>If the <code>append</code> parameter is true, the file will be
- appended to. Otherwise, the file designated by
- <code>filename</code> will be truncated before being opened.
+ /**
+ Set the size of the IO buffer.
+ */
+ void setBufferSize(int bufferSize1)
+ {
+ this->bufferSize = bufferSize1;
+ }
- <p>If the <code>bufferedIO</code> parameter is <code>true</code>,
- then buffered IO will be used to write to the output file.
+ /**
+ * Replaces double backslashes with single backslashes
+ * for compatibility with paths from earlier XML configurations files.
+ * @param name file name
+ * @return corrected file name
+ */
+ static LogString stripDuplicateBackslashes(const LogString& name);
- */
- FileAppender(const LayoutPtr& layout, const LogString& filename, bool append,
- bool bufferedIO, int bufferSize);
+ private:
+ FileAppender(const FileAppender&);
+ FileAppender& operator=(const FileAppender&);
- /**
- Instantiate a FileAppender and open the file designated by
- <code>filename</code>. The opened filename will become the output
- destination for this appender.
-
- <p>If the <code>append</code> parameter is true, the file will be
- appended to. Otherwise, the file designated by
- <code>filename</code> will be truncated before being opened.
- */
- FileAppender(const LayoutPtr& layout, const LogString& filename, bool append);
-
- /**
- Instantiate a FileAppender and open the file designated by
- <code>filename</code>. The opened filename will become the output
- destination for this appender.
-
- <p>The file will be appended to. */
- FileAppender(const LayoutPtr& layout, const LogString& filename);
-
- ~FileAppender();
-
- /**
- The <b>File</b> property takes a string value which should be the
- name of the file to append to.
-
- <p><b>Note that the special values
- "System.out" or "System.err" are no longer honored.</b>
-
- <p>Note: Actual opening of the file is made when
- #activateOptions is called, not when the options are set. */
- 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 { return fileAppend; }
-
- /** Returns the value of the <b>File</b> option. */
- inline LogString getFile() const { return fileName; }
-
- /**
- <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.*/
- void activateOptions(log4cxx::helpers::Pool& p);
- void setOption(const LogString& option,
- const LogString& value);
-
- /**
- Get the value of the <b>BufferedIO</b> option.
-
- <p>BufferedIO will significatnly increase performance on heavily
- loaded systems.
-
- */
- inline bool getBufferedIO() const { return bufferedIO; }
-
- /**
- Get the size of the IO buffer.
- */
- inline int getBufferSize() const { return bufferSize; }
-
- /**
- The <b>Append</b> option takes a boolean value. It is set to
- <code>true</code> by default. If true, then <code>File</code>
- will be opened in append mode by #setFile (see
- above). Otherwise, setFile will open
- <code>File</code> in truncate mode.
-
- <p>Note: Actual opening of the file is made when
- #activateOptions is called, not when the options are set.
- */
- void setAppend(bool fileAppend1);
-
- /**
- The <b>BufferedIO</b> option takes a boolean value. It is set to
- <code>false</code> by default. If true, then <code>File</code>
- will be opened in buffered mode.
-
- BufferedIO will significantly increase performance on heavily
- loaded systems.
-
- */
- void setBufferedIO(bool bufferedIO);
-
- /**
- Set the size of the IO buffer.
- */
- void setBufferSize(int bufferSize1) { this->bufferSize = bufferSize1; }
-
- /**
- * Replaces double backslashes with single backslashes
- * for compatibility with paths from earlier XML configurations files.
- * @param name file name
- * @return corrected file name
- */
- static LogString stripDuplicateBackslashes(const LogString& name);
-
- private:
- FileAppender(const FileAppender&);
- FileAppender& operator=(const FileAppender&);
-
- }; // class FileAppender
- LOG4CXX_PTR_DEF(FileAppender);
+}; // class FileAppender
+LOG4CXX_PTR_DEF(FileAppender);
} // namespace log4cxx
diff --git a/src/main/include/log4cxx/filter/andfilter.h b/src/main/include/log4cxx/filter/andfilter.h
index 9f962ac..9ddb5ac 100644
--- a/src/main/include/log4cxx/filter/andfilter.h
+++ b/src/main/include/log4cxx/filter/andfilter.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_FILTER_ANDFILTER_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
@@ -28,8 +28,8 @@
namespace log4cxx
{
- namespace filter
- {
+namespace filter
+{
/**
* A filter that 'and's the results of any number of contained filters together.
@@ -74,37 +74,37 @@
*
*
*/
- class LOG4CXX_EXPORT AndFilter:public log4cxx::spi::Filter
- {
- private:
- log4cxx::spi::FilterPtr headFilter;
- log4cxx::spi::FilterPtr tailFilter;
- bool acceptOnMatch;
- AndFilter(const AndFilter &);
- AndFilter & operator=(const AndFilter &);
+class LOG4CXX_EXPORT AndFilter: public log4cxx::spi::Filter
+{
+ private:
+ log4cxx::spi::FilterPtr headFilter;
+ log4cxx::spi::FilterPtr tailFilter;
+ bool acceptOnMatch;
+ AndFilter(const AndFilter&);
+ AndFilter& operator=(const AndFilter&);
- public:
- DECLARE_LOG4CXX_OBJECT(AndFilter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_OBJECT(AndFilter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
+ END_LOG4CXX_CAST_MAP()
- AndFilter();
+ AndFilter();
- void addFilter(const log4cxx::spi::FilterPtr & filter);
+ void addFilter(const log4cxx::spi::FilterPtr& filter);
- void setAcceptOnMatch(bool acceptOnMatch);
+ void setAcceptOnMatch(bool acceptOnMatch);
- FilterDecision decide(const spi::LoggingEventPtr & event) const;
- };
- LOG4CXX_PTR_DEF(AndFilter);
+ FilterDecision decide(const spi::LoggingEventPtr& event) const;
+};
+LOG4CXX_PTR_DEF(AndFilter);
- }
+}
}
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif
diff --git a/src/main/include/log4cxx/filter/denyallfilter.h b/src/main/include/log4cxx/filter/denyallfilter.h
index f4d5bad..a4472d2 100644
--- a/src/main/include/log4cxx/filter/denyallfilter.h
+++ b/src/main/include/log4cxx/filter/denyallfilter.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_FILTER_DENY_ALL_FILTER_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
@@ -28,45 +28,48 @@
namespace log4cxx
{
- namespace filter
+namespace filter
+{
+/**
+This filter drops all logging events.
+<p>You can add this filter to the end of a filter chain to
+switch from the default "accept all unless instructed otherwise"
+filtering behaviour to a "deny all unless instructed otherwise"
+behaviour.
+*/
+
+class LOG4CXX_EXPORT DenyAllFilter : public spi::Filter
+{
+ public:
+ DenyAllFilter() : spi::Filter()
{
- /**
- This filter drops all logging events.
- <p>You can add this filter to the end of a filter chain to
- switch from the default "accept all unless instructed otherwise"
- filtering behaviour to a "deny all unless instructed otherwise"
- behaviour.
- */
+ }
- class LOG4CXX_EXPORT DenyAllFilter : public spi::Filter
- {
- public:
- DenyAllFilter() : spi::Filter() {
- }
+ typedef spi::Filter BASE_CLASS;
+ DECLARE_LOG4CXX_OBJECT(DenyAllFilter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(DenyAllFilter)
+ LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
+ END_LOG4CXX_CAST_MAP()
- typedef spi::Filter BASE_CLASS;
- DECLARE_LOG4CXX_OBJECT(DenyAllFilter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(DenyAllFilter)
- LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
- END_LOG4CXX_CAST_MAP()
+ /**
+ Always returns the integer constant {@link spi::Filter#DENY DENY}
+ regardless of the {@link spi::LoggingEventPtr LoggingEvent} parameter.
+ @param event The LoggingEvent to filter.
+ @return Always returns {@link spi::Filter#DENY DENY}.
+ */
+ FilterDecision decide(const spi::LoggingEventPtr& event) const
+ {
+ return spi::Filter::DENY;
+ }
+}; // class DenyAllFilter
- /**
- Always returns the integer constant {@link spi::Filter#DENY DENY}
- regardless of the {@link spi::LoggingEventPtr LoggingEvent} parameter.
- @param event The LoggingEvent to filter.
- @return Always returns {@link spi::Filter#DENY DENY}.
- */
- FilterDecision decide(const spi::LoggingEventPtr& event) const
- { return spi::Filter::DENY; }
- }; // class DenyAllFilter
-
- LOG4CXX_PTR_DEF(DenyAllFilter);
- } // namespace filter
+LOG4CXX_PTR_DEF(DenyAllFilter);
+} // namespace filter
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
diff --git a/src/main/include/log4cxx/filter/expressionfilter.h b/src/main/include/log4cxx/filter/expressionfilter.h
index e2a3ce9..5609f35 100644
--- a/src/main/include/log4cxx/filter/expressionfilter.h
+++ b/src/main/include/log4cxx/filter/expressionfilter.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_FILTER_EXPRESSIONFILTER_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
@@ -28,15 +28,15 @@
namespace log4cxx
{
- namespace rule
- {
- class Rule;
- typedef helpers::ObjectPtrT < Rule > RulePtr;
- }
+namespace rule
+{
+class Rule;
+typedef helpers::ObjectPtrT < Rule > RulePtr;
+}
- namespace filter
- {
+namespace filter
+{
/**
@@ -81,49 +81,49 @@
*
*
*/
- class LOG4CXX_EXPORT ExpressionFilter:public log4cxx::spi::Filter
- {
- private:
- bool acceptOnMatch;
- bool convertInFixToPostFix;
- LogString expression;
- log4cxx::rule::RulePtr expressionRule;
- ExpressionFilter(const ExpressionFilter &);
- ExpressionFilter & operator=(const ExpressionFilter &);
+class LOG4CXX_EXPORT ExpressionFilter: public log4cxx::spi::Filter
+{
+ private:
+ bool acceptOnMatch;
+ bool convertInFixToPostFix;
+ LogString expression;
+ log4cxx::rule::RulePtr expressionRule;
+ ExpressionFilter(const ExpressionFilter&);
+ ExpressionFilter& operator=(const ExpressionFilter&);
- public:
- DECLARE_LOG4CXX_OBJECT(ExpressionFilter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_OBJECT(ExpressionFilter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
+ END_LOG4CXX_CAST_MAP()
- ExpressionFilter();
+ ExpressionFilter();
- void activateOptions(log4cxx::helpers::Pool & p);
+ void activateOptions(log4cxx::helpers::Pool& p);
- void setExpression(const LogString & expression);
+ void setExpression(const LogString& expression);
- LogString getExpression() const;
+ LogString getExpression() const;
- void setConvertInFixToPostFix(bool convertInFixToPostFix);
+ void setConvertInFixToPostFix(bool convertInFixToPostFix);
- bool getConvertInFixToPostFix() const;
+ bool getConvertInFixToPostFix() const;
- void setAcceptOnMatch(bool acceptOnMatch);
+ void setAcceptOnMatch(bool acceptOnMatch);
- bool getAcceptOnMatch() const;
+ bool getAcceptOnMatch() const;
- /**
- Returns {@link log4cxx::spi::Filter#NEUTRAL} is there is no string match.
- */
- FilterDecision decide(const spi::LoggingEventPtr & event) const;
- };
- }
+ /**
+ Returns {@link log4cxx::spi::Filter#NEUTRAL} is there is no string match.
+ */
+ FilterDecision decide(const spi::LoggingEventPtr& event) const;
+};
+}
}
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
diff --git a/src/main/include/log4cxx/filter/levelmatchfilter.h b/src/main/include/log4cxx/filter/levelmatchfilter.h
index aaa5d1c..38f3aec 100644
--- a/src/main/include/log4cxx/filter/levelmatchfilter.h
+++ b/src/main/include/log4cxx/filter/levelmatchfilter.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_FILTER_LEVEL_MATCH_FILTER_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
@@ -29,74 +29,78 @@
namespace log4cxx
{
- class Level;
+class Level;
- namespace filter
+namespace filter
+{
+/**
+This is a very simple filter based on level matching.
+
+<p>The filter admits two options <b>LevelToMatch</b> and
+<b>AcceptOnMatch</b>. If there is an exact match between the value
+of the <b>LevelToMatch</b> option and the level of the {@link
+spi::LoggingEvent LoggingEvent}, then the #decide method returns {@link
+spi::Filter#ACCEPT ACCEPT} in case the <b>AcceptOnMatch</b>
+option value is set to <code>true</code>, if it is <code>false</code>
+then {@link spi::Filter#DENY DENY} is returned. If there is no match,
+{@link spi::Filter#NEUTRAL NEUTRAL} is returned.
+*/
+
+class LOG4CXX_EXPORT LevelMatchFilter : public spi::Filter
+{
+ private:
+ bool acceptOnMatch;
+ LevelPtr levelToMatch;
+
+ public:
+ typedef spi::Filter BASE_CLASS;
+ DECLARE_LOG4CXX_OBJECT(LevelMatchFilter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(LevelMatchFilter)
+ LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
+ END_LOG4CXX_CAST_MAP()
+
+ LevelMatchFilter();
+
+ /**
+ Set options
+ */
+ virtual void setOption(const LogString& option,
+ const LogString& value);
+
+ void setLevelToMatch(const LogString& levelToMatch);
+
+ LogString getLevelToMatch() const;
+
+ inline void setAcceptOnMatch(bool acceptOnMatch1)
{
- /**
- This is a very simple filter based on level matching.
+ this->acceptOnMatch = acceptOnMatch1;
+ }
- <p>The filter admits two options <b>LevelToMatch</b> and
- <b>AcceptOnMatch</b>. If there is an exact match between the value
- of the <b>LevelToMatch</b> option and the level of the {@link
- spi::LoggingEvent LoggingEvent}, then the #decide method returns {@link
- spi::Filter#ACCEPT ACCEPT} in case the <b>AcceptOnMatch</b>
- option value is set to <code>true</code>, if it is <code>false</code>
- then {@link spi::Filter#DENY DENY} is returned. If there is no match,
- {@link spi::Filter#NEUTRAL NEUTRAL} is returned.
- */
+ inline bool getAcceptOnMatch() const
+ {
+ return acceptOnMatch;
+ }
- class LOG4CXX_EXPORT LevelMatchFilter : public spi::Filter
- {
- private:
- bool acceptOnMatch;
- LevelPtr levelToMatch;
+ /**
+ Return the decision of this filter.
- public:
- typedef spi::Filter BASE_CLASS;
- DECLARE_LOG4CXX_OBJECT(LevelMatchFilter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(LevelMatchFilter)
- LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
- END_LOG4CXX_CAST_MAP()
-
- LevelMatchFilter();
-
- /**
- Set options
- */
- virtual void setOption(const LogString& option,
- const LogString& value);
-
- void setLevelToMatch(const LogString& levelToMatch);
-
- LogString getLevelToMatch() const;
-
- inline void setAcceptOnMatch(bool acceptOnMatch1)
- { this->acceptOnMatch = acceptOnMatch1; }
-
- inline bool getAcceptOnMatch() const
- { return acceptOnMatch; }
-
- /**
- Return the decision of this filter.
-
- Returns {@link spi::Filter#NEUTRAL NEUTRAL} if the
- <b>LevelToMatch</b> option is not set or if there is not match.
- Otherwise, if there is a match, then the returned decision is
- {@link spi::Filter#ACCEPT ACCEPT} if the <b>AcceptOnMatch</b>
- property is set to <code>true</code>. The returned decision is
- {@link spi::Filter#DENY DENY} if the
- <b>AcceptOnMatch</b> property is set to false.
- */
- FilterDecision decide(const spi::LoggingEventPtr& event) const;
- }; // class LevelMatchFilter
- LOG4CXX_PTR_DEF(LevelMatchFilter);
- } // namespace filter
+ Returns {@link spi::Filter#NEUTRAL NEUTRAL} if the
+ <b>LevelToMatch</b> option is not set or if there is not match.
+ Otherwise, if there is a match, then the returned decision is
+ {@link spi::Filter#ACCEPT ACCEPT} if the <b>AcceptOnMatch</b>
+ property is set to <code>true</code>. The returned decision is
+ {@link spi::Filter#DENY DENY} if the
+ <b>AcceptOnMatch</b> property is set to false.
+ */
+ FilterDecision decide(const spi::LoggingEventPtr& event) const;
+}; // class LevelMatchFilter
+LOG4CXX_PTR_DEF(LevelMatchFilter);
+} // namespace filter
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif // _LOG4CXX_FILTER_LEVEL_MATCH_FILTER_H
diff --git a/src/main/include/log4cxx/filter/levelrangefilter.h b/src/main/include/log4cxx/filter/levelrangefilter.h
index 326d7c9..5b7a73a 100644
--- a/src/main/include/log4cxx/filter/levelrangefilter.h
+++ b/src/main/include/log4cxx/filter/levelrangefilter.h
@@ -23,115 +23,127 @@
namespace log4cxx
{
- namespace filter
+namespace filter
+{
+/**
+This is a very simple filter based on level matching, which can be
+used to reject messages with priorities outside a certain range.
+
+<p>The filter admits three options <b>LevelMin</b>, <b>LevelMax</b>
+and <b>AcceptOnMatch</b>.
+
+<p>If the level of the {@link spi::LoggingEvent LoggingEvent} is not
+between Min and Max (inclusive), then {@link spi::Filter#DENY DENY}
+is returned.
+
+<p> If the Logging event level is within the specified range, then if
+<b>AcceptOnMatch</b> is true, {@link spi::Filter#ACCEPT ACCEPT} is
+returned, and if <b>AcceptOnMatch</b> is false,
+{@link spi::Filter#NEUTRAL NEUTRAL} is returned.
+
+<p>If <code>LevelMin</code>w is not defined, then there is no
+minimum acceptable level (ie a level is never rejected for
+being too "low"/unimportant). If <code>LevelMax</code> is not
+defined, then there is no maximum acceptable level (ie a
+level is never rejected for beeing too "high"/important).
+
+<p>Refer to the {@link
+AppenderSkeleton#setThreshold setThreshold} method
+available to <code>all</code> appenders extending
+AppenderSkeleton for a more convenient way to
+filter out events by level.
+*/
+
+class LOG4CXX_EXPORT LevelRangeFilter : public spi::Filter
+{
+ private:
+ /**
+ Do we return ACCEPT when a match occurs. Default is
+ <code>false</code>, so that later filters get run by default
+ */
+ bool acceptOnMatch;
+ LevelPtr levelMin;
+ LevelPtr levelMax;
+
+ public:
+ typedef spi::Filter BASE_CLASS;
+ DECLARE_LOG4CXX_OBJECT(LevelRangeFilter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(LevelRangeFilter)
+ LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
+ END_LOG4CXX_CAST_MAP()
+
+ LevelRangeFilter();
+
+ /**
+ Set options
+ */
+ virtual void setOption(const LogString& option,
+ const LogString& value);
+
+ /**
+ Set the <code>LevelMin</code> option.
+ */
+ void setLevelMin(const LevelPtr& levelMin1)
{
- /**
- This is a very simple filter based on level matching, which can be
- used to reject messages with priorities outside a certain range.
+ this->levelMin = levelMin1;
+ }
- <p>The filter admits three options <b>LevelMin</b>, <b>LevelMax</b>
- and <b>AcceptOnMatch</b>.
+ /**
+ Get the value of the <code>LevelMin</code> option.
+ */
+ const LevelPtr& getLevelMin() const
+ {
+ return levelMin;
+ }
- <p>If the level of the {@link spi::LoggingEvent LoggingEvent} is not
- between Min and Max (inclusive), then {@link spi::Filter#DENY DENY}
- is returned.
+ /**
+ Set the <code>LevelMax</code> option.
+ */
+ void setLevelMax(const LevelPtr& levelMax1)
+ {
+ this->levelMax = levelMax1;
+ }
- <p> If the Logging event level is within the specified range, then if
- <b>AcceptOnMatch</b> is true, {@link spi::Filter#ACCEPT ACCEPT} is
- returned, and if <b>AcceptOnMatch</b> is false,
- {@link spi::Filter#NEUTRAL NEUTRAL} is returned.
+ /**
+ Get the value of the <code>LevelMax</code> option.
+ */
+ const LevelPtr& getLevelMax() const
+ {
+ return levelMax;
+ }
- <p>If <code>LevelMin</code>w is not defined, then there is no
- minimum acceptable level (ie a level is never rejected for
- being too "low"/unimportant). If <code>LevelMax</code> is not
- defined, then there is no maximum acceptable level (ie a
- level is never rejected for beeing too "high"/important).
+ /**
+ Set the <code>AcceptOnMatch</code> option.
+ */
+ inline void setAcceptOnMatch(bool acceptOnMatch1)
+ {
+ this->acceptOnMatch = acceptOnMatch1;
+ }
- <p>Refer to the {@link
- AppenderSkeleton#setThreshold setThreshold} method
- available to <code>all</code> appenders extending
- AppenderSkeleton for a more convenient way to
- filter out events by level.
- */
+ /**
+ Get the value of the <code>AcceptOnMatch</code> option.
+ */
+ inline bool getAcceptOnMatch() const
+ {
+ return acceptOnMatch;
+ }
- class LOG4CXX_EXPORT LevelRangeFilter : public spi::Filter
- {
- private:
- /**
- Do we return ACCEPT when a match occurs. Default is
- <code>false</code>, so that later filters get run by default
- */
- bool acceptOnMatch;
- LevelPtr levelMin;
- LevelPtr levelMax;
+ /**
+ Return the decision of this filter.
- public:
- typedef spi::Filter BASE_CLASS;
- DECLARE_LOG4CXX_OBJECT(LevelRangeFilter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(LevelRangeFilter)
- LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
- END_LOG4CXX_CAST_MAP()
-
- LevelRangeFilter();
-
- /**
- Set options
- */
- virtual void setOption(const LogString& option,
- const LogString& value);
-
- /**
- Set the <code>LevelMin</code> option.
- */
- void setLevelMin(const LevelPtr& levelMin1)
- { this->levelMin = levelMin1; }
-
- /**
- Get the value of the <code>LevelMin</code> option.
- */
- const LevelPtr& getLevelMin() const
- { return levelMin; }
-
- /**
- Set the <code>LevelMax</code> option.
- */
- void setLevelMax(const LevelPtr& levelMax1)
- { this->levelMax = levelMax1; }
-
- /**
- Get the value of the <code>LevelMax</code> option.
- */
- const LevelPtr& getLevelMax() const
- { return levelMax; }
-
- /**
- Set the <code>AcceptOnMatch</code> option.
- */
- inline void setAcceptOnMatch(bool acceptOnMatch1)
- { this->acceptOnMatch = acceptOnMatch1; }
-
- /**
- Get the value of the <code>AcceptOnMatch</code> option.
- */
- inline bool getAcceptOnMatch() const
- { return acceptOnMatch; }
-
- /**
- Return the decision of this filter.
-
- Returns {@link spi::Filter#NEUTRAL NEUTRAL} if the
- <b>LevelToMatch</b> option is not set or if there is not match.
- Otherwise, if there is a match, then the returned decision is
- {@link spi::Filter#ACCEPT ACCEPT} if the
- <b>AcceptOnMatch</b> property is set to <code>true</code>. The
- returned decision is {@link spi::Filter#DENY DENY} if the
- <b>AcceptOnMatch</b> property is set to false.
- */
- FilterDecision decide(const spi::LoggingEventPtr& event) const;
- }; // class LevelRangeFilter
- LOG4CXX_PTR_DEF(LevelRangeFilter);
- } // namespace filter
+ Returns {@link spi::Filter#NEUTRAL NEUTRAL} if the
+ <b>LevelToMatch</b> option is not set or if there is not match.
+ Otherwise, if there is a match, then the returned decision is
+ {@link spi::Filter#ACCEPT ACCEPT} if the
+ <b>AcceptOnMatch</b> property is set to <code>true</code>. The
+ returned decision is {@link spi::Filter#DENY DENY} if the
+ <b>AcceptOnMatch</b> property is set to false.
+ */
+ FilterDecision decide(const spi::LoggingEventPtr& event) const;
+}; // class LevelRangeFilter
+LOG4CXX_PTR_DEF(LevelRangeFilter);
+} // namespace filter
} // namespace log4cxx
#endif // _LOG4CXX_FILTER_LEVEL_RANGE_FILTER_H
diff --git a/src/main/include/log4cxx/filter/locationinfofilter.h b/src/main/include/log4cxx/filter/locationinfofilter.h
index b31f476..343ee01 100644
--- a/src/main/include/log4cxx/filter/locationinfofilter.h
+++ b/src/main/include/log4cxx/filter/locationinfofilter.h
@@ -21,16 +21,16 @@
namespace log4cxx
{
- namespace rule
- {
- class ExpressionRule;
- class Rule;
- typedef helpers::ObjectPtrT < Rule > RulePtr;
- typedef helpers::ObjectPtrT < ExpressionRule > ExpressionRulePtr;
- }
+namespace rule
+{
+class ExpressionRule;
+class Rule;
+typedef helpers::ObjectPtrT < Rule > RulePtr;
+typedef helpers::ObjectPtrT < ExpressionRule > ExpressionRulePtr;
+}
- namespace filter
- {
+namespace filter
+{
/**
* Location information is usually specified at the appender level - all events associated
* with an appender either create and parse stack traces or they do not. This is
@@ -43,45 +43,45 @@
*
*
*/
- class LOG4CXX_EXPORT LocationInfoFilter:public log4cxx::spi::Filter
- {
- bool convertInFixToPostFix;
- LogString expression;
- log4cxx::rule::RulePtr expressionRule;
- //HACK: Category is the last of the internal layers - pass this in as the class name
- //in order for parsing to work correctly
- LogString className;
+class LOG4CXX_EXPORT LocationInfoFilter: public log4cxx::spi::Filter
+{
+ bool convertInFixToPostFix;
+ LogString expression;
+ log4cxx::rule::RulePtr expressionRule;
+ //HACK: Category is the last of the internal layers - pass this in as the class name
+ //in order for parsing to work correctly
+ LogString className;
- public:
- DECLARE_LOG4CXX_OBJECT(LocationInfoFilter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_OBJECT(LocationInfoFilter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
+ END_LOG4CXX_CAST_MAP()
- LocationInfoFilter();
+ LocationInfoFilter();
- void activateOptions(log4cxx::helpers::Pool &);
+ void activateOptions(log4cxx::helpers::Pool&);
- void setExpression(const LogString & expression);
+ void setExpression(const LogString& expression);
- LogString getExpression() const;
+ LogString getExpression() const;
- void setConvertInFixToPostFix(bool convertInFixToPostFix);
+ void setConvertInFixToPostFix(bool convertInFixToPostFix);
- bool getConvertInFixToPostFix() const;
+ bool getConvertInFixToPostFix() const;
- /**
- * If this event does not already contain location information,
- * evaluate the event against the expression.
- *
- * If the expression evaluates to true, generate a LocationInfo instance
- * by creating an exception and set this LocationInfo on the event.
- *
- * Returns {@link log4cxx::spi::Filter#NEUTRAL}
- */
- FilterDecision decide(const spi::LoggingEventPtr & event) const;
+ /**
+ * If this event does not already contain location information,
+ * evaluate the event against the expression.
+ *
+ * If the expression evaluates to true, generate a LocationInfo instance
+ * by creating an exception and set this LocationInfo on the event.
+ *
+ * Returns {@link log4cxx::spi::Filter#NEUTRAL}
+ */
+ FilterDecision decide(const spi::LoggingEventPtr& event) const;
- };
- }
+};
+}
}
#endif
diff --git a/src/main/include/log4cxx/filter/loggermatchfilter.h b/src/main/include/log4cxx/filter/loggermatchfilter.h
index dc58e36..0f80dd2 100644
--- a/src/main/include/log4cxx/filter/loggermatchfilter.h
+++ b/src/main/include/log4cxx/filter/loggermatchfilter.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_FILTER_LOGGER_MATCH_FILTER_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
@@ -29,10 +29,10 @@
namespace log4cxx
{
- class Level;
+class Level;
- namespace filter
- {
+namespace filter
+{
/**
This is a very simple filter based on logger name matching.
@@ -48,57 +48,61 @@
*/
- class LOG4CXX_EXPORT LoggerMatchFilter : public spi::Filter
- {
- private:
- bool acceptOnMatch;
- LogString loggerToMatch;
+class LOG4CXX_EXPORT LoggerMatchFilter : public spi::Filter
+{
+ private:
+ bool acceptOnMatch;
+ LogString loggerToMatch;
- public:
- typedef spi::Filter BASE_CLASS;
- DECLARE_LOG4CXX_OBJECT(LoggerMatchFilter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(LoggerMatchFilter)
- LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
- END_LOG4CXX_CAST_MAP()
+ public:
+ typedef spi::Filter BASE_CLASS;
+ DECLARE_LOG4CXX_OBJECT(LoggerMatchFilter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(LoggerMatchFilter)
+ LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
+ END_LOG4CXX_CAST_MAP()
- LoggerMatchFilter();
+ LoggerMatchFilter();
- /**
- Set options
- */
- virtual void setOption(const LogString& option,
- const LogString& value);
+ /**
+ Set options
+ */
+ virtual void setOption(const LogString& option,
+ const LogString& value);
- void setLoggerToMatch(const LogString& levelToMatch);
+ void setLoggerToMatch(const LogString& levelToMatch);
- LogString getLoggerToMatch() const;
+ LogString getLoggerToMatch() const;
- inline void setAcceptOnMatch(bool acceptOnMatch1)
- { this->acceptOnMatch = acceptOnMatch1; }
+ inline void setAcceptOnMatch(bool acceptOnMatch1)
+ {
+ this->acceptOnMatch = acceptOnMatch1;
+ }
- inline bool getAcceptOnMatch() const
- { return acceptOnMatch; }
+ inline bool getAcceptOnMatch() const
+ {
+ return acceptOnMatch;
+ }
- /**
- Return the decision of this filter.
+ /**
+ Return the decision of this filter.
- Returns {@link spi::Filter#NEUTRAL NEUTRAL} if the
- <b>LoggerToMatch</b> option is not set or if there is not match.
- Otherwise, if there is a match, then the returned decision is
- {@link spi::Filter#ACCEPT ACCEPT} if the <b>AcceptOnMatch</b>
- property is set to <code>true</code>. The returned decision is
- {@link spi::Filter#DENY DENY} if the
- <b>AcceptOnMatch</b> property is set to false.
- */
- FilterDecision decide(const spi::LoggingEventPtr& event) const;
- }; // class LoggerMatchFilter
- LOG4CXX_PTR_DEF(LoggerMatchFilter);
- } // namespace filter
+ Returns {@link spi::Filter#NEUTRAL NEUTRAL} if the
+ <b>LoggerToMatch</b> option is not set or if there is not match.
+ Otherwise, if there is a match, then the returned decision is
+ {@link spi::Filter#ACCEPT ACCEPT} if the <b>AcceptOnMatch</b>
+ property is set to <code>true</code>. The returned decision is
+ {@link spi::Filter#DENY DENY} if the
+ <b>AcceptOnMatch</b> property is set to false.
+ */
+ FilterDecision decide(const spi::LoggingEventPtr& event) const;
+}; // class LoggerMatchFilter
+LOG4CXX_PTR_DEF(LoggerMatchFilter);
+} // namespace filter
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif // _LOG4CXX_FILTER_LOGGER_MATCH_FILTER_H
diff --git a/src/main/include/log4cxx/filter/mapfilter.h b/src/main/include/log4cxx/filter/mapfilter.h
index e956bef..4edd0f7 100644
--- a/src/main/include/log4cxx/filter/mapfilter.h
+++ b/src/main/include/log4cxx/filter/mapfilter.h
@@ -21,24 +21,24 @@
namespace log4cxx
{
- namespace filter
- {
+namespace filter
+{
- class LOG4CXX_EXPORT MapFilter:public log4cxx::spi::Filter
- {
- public:
- DECLARE_LOG4CXX_OBJECT(MapFilter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
- END_LOG4CXX_CAST_MAP()
+class LOG4CXX_EXPORT MapFilter: public log4cxx::spi::Filter
+{
+ public:
+ DECLARE_LOG4CXX_OBJECT(MapFilter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
+ END_LOG4CXX_CAST_MAP()
- MapFilter();
+ MapFilter();
- FilterDecision decide(const spi::LoggingEventPtr & event) const;
+ FilterDecision decide(const spi::LoggingEventPtr& event) const;
- };
- }
+};
+}
}
#endif
diff --git a/src/main/include/log4cxx/filter/propertyfilter.h b/src/main/include/log4cxx/filter/propertyfilter.h
index d38d02b..de67cd1 100644
--- a/src/main/include/log4cxx/filter/propertyfilter.h
+++ b/src/main/include/log4cxx/filter/propertyfilter.h
@@ -20,8 +20,8 @@
#define _LOG4CXX_FILTER_PROPERTYFILTER_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
@@ -30,8 +30,8 @@
namespace log4cxx
{
- namespace filter
- {
+namespace filter
+{
/**
* NOTE: This filter modifies logging events by adding properties to the event.
@@ -50,32 +50,32 @@
*
*
*/
- class LOG4CXX_EXPORT PropertyFilter : public log4cxx::spi::Filter
- {
- typedef std::map < LogString, LogString > PropertyMap;
- PropertyMap* properties;
- PropertyFilter(const PropertyFilter &);
- PropertyFilter & operator=(const PropertyFilter &);
+class LOG4CXX_EXPORT PropertyFilter : public log4cxx::spi::Filter
+{
+ typedef std::map < LogString, LogString > PropertyMap;
+ PropertyMap* properties;
+ PropertyFilter(const PropertyFilter&);
+ PropertyFilter& operator=(const PropertyFilter&);
- public:
- DECLARE_LOG4CXX_OBJECT(PropertyFilter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_OBJECT(PropertyFilter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
+ END_LOG4CXX_CAST_MAP()
- PropertyFilter();
- ~PropertyFilter();
- void setProperties(const LogString & props);
+ PropertyFilter();
+ ~PropertyFilter();
+ void setProperties(const LogString& props);
- FilterDecision decide(const spi::LoggingEventPtr & event) const;
+ FilterDecision decide(const spi::LoggingEventPtr& event) const;
- };
+};
- }
+}
}
#if defined(_MSC_VER)
-#pragma warning (pop)
+ #pragma warning (pop)
#endif
#endif
diff --git a/src/main/include/log4cxx/filter/stringmatchfilter.h b/src/main/include/log4cxx/filter/stringmatchfilter.h
index 77a78da..9fa9d2e 100644
--- a/src/main/include/log4cxx/filter/stringmatchfilter.h
+++ b/src/main/include/log4cxx/filter/stringmatchfilter.h
@@ -22,71 +22,79 @@
namespace log4cxx
{
- namespace filter
+namespace filter
+{
+/**
+This is a very simple filter based on string matching.
+
+<p>The filter admits two options <b>StringToMatch</b> and
+<b>AcceptOnMatch</b>. If there is a match between the value of the
+StringToMatch option and the message of the {@link spi::LoggingEvent
+LoggingEvent}, then the #decide method returns
+{@link log4cxx::spi::Filter#ACCEPT ACCEPT} if the <b>AcceptOnMatch</b> option
+value is true, if it is false then {@link log4cxx::spi::Filter#DENY DENY} is
+returned. If there is no match, {@link log4cxx::spi::Filter#NEUTRAL NEUTRAL}
+is returned.
+
+<p>See configuration files <a
+href="../xml/doc-files/test6.xml">test6.xml</a>, <a
+href="../xml/doc-files/test7.xml">test7.xml</a>, <a
+href="../xml/doc-files/test8.xml">test8.xml</a>, <a
+href="../xml/doc-files/test9.xml">test9.xml</a>, and <a
+href="../xml/doc-files/test10.xml">test10.xml</a> for examples of
+seeting up a <code>StringMatchFilter</code>.
+*/
+
+class LOG4CXX_EXPORT StringMatchFilter : public spi::Filter
+{
+ private:
+ bool acceptOnMatch;
+ LogString stringToMatch;
+
+ public:
+ typedef spi::Filter BASE_CLASS;
+ DECLARE_LOG4CXX_OBJECT(StringMatchFilter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(StringMatchFilter)
+ LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
+ END_LOG4CXX_CAST_MAP()
+
+ StringMatchFilter();
+
+ /**
+ Set options
+ */
+ virtual void setOption(const LogString& option,
+ const LogString& value);
+
+ inline void setStringToMatch(const LogString& stringToMatch1)
{
- /**
- This is a very simple filter based on string matching.
+ this->stringToMatch.assign(stringToMatch1);
+ }
- <p>The filter admits two options <b>StringToMatch</b> and
- <b>AcceptOnMatch</b>. If there is a match between the value of the
- StringToMatch option and the message of the {@link spi::LoggingEvent
- LoggingEvent}, then the #decide method returns
- {@link log4cxx::spi::Filter#ACCEPT ACCEPT} if the <b>AcceptOnMatch</b> option
- value is true, if it is false then {@link log4cxx::spi::Filter#DENY DENY} is
- returned. If there is no match, {@link log4cxx::spi::Filter#NEUTRAL NEUTRAL}
- is returned.
+ inline const LogString& getStringToMatch() const
+ {
+ return stringToMatch;
+ }
- <p>See configuration files <a
- href="../xml/doc-files/test6.xml">test6.xml</a>, <a
- href="../xml/doc-files/test7.xml">test7.xml</a>, <a
- href="../xml/doc-files/test8.xml">test8.xml</a>, <a
- href="../xml/doc-files/test9.xml">test9.xml</a>, and <a
- href="../xml/doc-files/test10.xml">test10.xml</a> for examples of
- seeting up a <code>StringMatchFilter</code>.
- */
+ inline void setAcceptOnMatch(bool acceptOnMatch1)
+ {
+ this->acceptOnMatch = acceptOnMatch1;
+ }
- class LOG4CXX_EXPORT StringMatchFilter : public spi::Filter
- {
- private:
- bool acceptOnMatch;
- LogString stringToMatch;
+ inline bool getAcceptOnMatch() const
+ {
+ return acceptOnMatch;
+ }
- public:
- typedef spi::Filter BASE_CLASS;
- DECLARE_LOG4CXX_OBJECT(StringMatchFilter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(StringMatchFilter)
- LOG4CXX_CAST_ENTRY_CHAIN(BASE_CLASS)
- END_LOG4CXX_CAST_MAP()
-
- StringMatchFilter();
-
- /**
- Set options
- */
- virtual void setOption(const LogString& option,
- const LogString& value);
-
- inline void setStringToMatch(const LogString& stringToMatch1)
- { this->stringToMatch.assign(stringToMatch1); }
-
- inline const LogString& getStringToMatch() const
- { return stringToMatch; }
-
- inline void setAcceptOnMatch(bool acceptOnMatch1)
- { this->acceptOnMatch = acceptOnMatch1; }
-
- inline bool getAcceptOnMatch() const
- { return acceptOnMatch; }
-
- /**
- Returns {@link log4cxx::spi::Filter#NEUTRAL NEUTRAL}
- is there is no string match.
- */
- FilterDecision decide(const spi::LoggingEventPtr& event) const;
- }; // class StringMatchFilter
- LOG4CXX_PTR_DEF(StringMatchFilter);
- } // namespace filter
+ /**
+ Returns {@link log4cxx::spi::Filter#NEUTRAL NEUTRAL}
+ is there is no string match.
+ */
+ FilterDecision decide(const spi::LoggingEventPtr& event) const;
+}; // class StringMatchFilter
+LOG4CXX_PTR_DEF(StringMatchFilter);
+} // namespace filter
} // namespace log4cxx
#endif // _LOG4CXX_FILTER_STRING_MATCH_FILTER_H
diff --git a/src/main/include/log4cxx/helpers/absolutetimedateformat.h b/src/main/include/log4cxx/helpers/absolutetimedateformat.h
index a06cfa6..c974339 100644
--- a/src/main/include/log4cxx/helpers/absolutetimedateformat.h
+++ b/src/main/include/log4cxx/helpers/absolutetimedateformat.h
@@ -22,19 +22,19 @@
namespace log4cxx
{
- namespace helpers
- {
- /**
- Formats a date in the format <b>HH:mm:ss,SSS</b> for example,
- "15:49:37,459".
- */
- class LOG4CXX_EXPORT AbsoluteTimeDateFormat : public SimpleDateFormat
- {
- public:
- AbsoluteTimeDateFormat()
- : SimpleDateFormat(LOG4CXX_STR("HH:mm:ss,SSS")) {}
- };
- } // namespace helpers
+namespace helpers
+{
+/**
+Formats a date in the format <b>HH:mm:ss,SSS</b> for example,
+"15:49:37,459".
+*/
+class LOG4CXX_EXPORT AbsoluteTimeDateFormat : public SimpleDateFormat
+{
+ public:
+ AbsoluteTimeDateFormat()
+ : SimpleDateFormat(LOG4CXX_STR("HH:mm:ss,SSS")) {}
+};
+} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_ABSOLUTE_TIME_DATE_FORMAT_H
diff --git a/src/main/include/log4cxx/helpers/appenderattachableimpl.h b/src/main/include/log4cxx/helpers/appenderattachableimpl.h
index 62e1dcf..a865108 100644
--- a/src/main/include/log4cxx/helpers/appenderattachableimpl.h
+++ b/src/main/include/log4cxx/helpers/appenderattachableimpl.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_HELPERS_APPENDER_ATTACHABLE_IMPL_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
@@ -31,98 +31,101 @@
namespace log4cxx
{
- namespace spi
- {
- class LoggingEvent;
- typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
- }
+namespace spi
+{
+class LoggingEvent;
+typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
+}
- namespace helpers
- {
+namespace helpers
+{
- class LOG4CXX_EXPORT AppenderAttachableImpl :
- public virtual spi::AppenderAttachable,
- public virtual helpers::ObjectImpl
+class LOG4CXX_EXPORT AppenderAttachableImpl :
+ public virtual spi::AppenderAttachable,
+ public virtual helpers::ObjectImpl
+{
+ protected:
+ /** Array of appenders. */
+ AppenderList appenderList;
+
+ public:
+ /**
+ * Create new instance.
+ * @param pool pool, must be longer-lived than instance.
+ */
+ AppenderAttachableImpl(Pool& pool);
+
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(AppenderAttachableImpl)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(AppenderAttachableImpl)
+ LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
+ END_LOG4CXX_CAST_MAP()
+
+ void addRef() const;
+ void releaseRef() const;
+
+ // Methods
+ /**
+ * Add an appender.
+ */
+ virtual void addAppender(const AppenderPtr& newAppender);
+
+ /**
+ Call the <code>doAppend</code> method on all attached appenders.
+ */
+ int appendLoopOnAppenders(const spi::LoggingEventPtr& event,
+ log4cxx::helpers::Pool& p);
+
+ /**
+ * Get all previously added appenders as an Enumeration.
+ */
+ virtual AppenderList getAllAppenders() const;
+
+ /**
+ * Get an appender by name.
+ */
+ virtual AppenderPtr getAppender(const LogString& name) const;
+
+ /**
+ Returns <code>true</code> if the specified appender is in the
+ list of attached appenders, <code>false</code> otherwise.
+ */
+ virtual bool isAttached(const AppenderPtr& appender) const;
+
+ /**
+ * Remove all previously added appenders.
+ */
+ virtual void removeAllAppenders();
+
+ /**
+ * Remove the appender passed as parameter from the list of appenders.
+ */
+ virtual void removeAppender(const AppenderPtr& appender);
+
+ /**
+ * Remove the appender with the name passed as parameter from the
+ * list of appenders.
+ */
+ virtual void removeAppender(const LogString& name);
+
+ inline const log4cxx::helpers::Mutex& getMutex() const
{
- protected:
- /** Array of appenders. */
- AppenderList appenderList;
+ return mutex;
+ }
- public:
- /**
- * Create new instance.
- * @param pool pool, must be longer-lived than instance.
- */
- AppenderAttachableImpl(Pool& pool);
+ private:
+ log4cxx::helpers::Mutex mutex;
+ AppenderAttachableImpl(const AppenderAttachableImpl&);
+ AppenderAttachableImpl& operator=(const AppenderAttachableImpl&);
+};
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(AppenderAttachableImpl)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(AppenderAttachableImpl)
- LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
- END_LOG4CXX_CAST_MAP()
+LOG4CXX_PTR_DEF(AppenderAttachableImpl);
- void addRef() const;
- void releaseRef() const;
-
- // Methods
- /**
- * Add an appender.
- */
- virtual void addAppender(const AppenderPtr& newAppender);
-
- /**
- Call the <code>doAppend</code> method on all attached appenders.
- */
- int appendLoopOnAppenders(const spi::LoggingEventPtr& event,
- log4cxx::helpers::Pool& p);
-
- /**
- * Get all previously added appenders as an Enumeration.
- */
- virtual AppenderList getAllAppenders() const;
-
- /**
- * Get an appender by name.
- */
- virtual AppenderPtr getAppender(const LogString& name) const;
-
- /**
- Returns <code>true</code> if the specified appender is in the
- list of attached appenders, <code>false</code> otherwise.
- */
- virtual bool isAttached(const AppenderPtr& appender) const;
-
- /**
- * Remove all previously added appenders.
- */
- virtual void removeAllAppenders();
-
- /**
- * Remove the appender passed as parameter from the list of appenders.
- */
- virtual void removeAppender(const AppenderPtr& appender);
-
- /**
- * Remove the appender with the name passed as parameter from the
- * list of appenders.
- */
- virtual void removeAppender(const LogString& name);
-
- inline const log4cxx::helpers::Mutex& getMutex() const { return mutex; }
-
- private:
- log4cxx::helpers::Mutex mutex;
- AppenderAttachableImpl(const AppenderAttachableImpl&);
- AppenderAttachableImpl& operator=(const AppenderAttachableImpl&);
- };
-
- LOG4CXX_PTR_DEF(AppenderAttachableImpl);
-
- }
+}
}
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif //_LOG4CXX_HELPERS_APPENDER_ATTACHABLE_IMPL_H
diff --git a/src/main/include/log4cxx/helpers/aprinitializer.h b/src/main/include/log4cxx/helpers/aprinitializer.h
index 1a91a7a..49e49b0 100644
--- a/src/main/include/log4cxx/helpers/aprinitializer.h
+++ b/src/main/include/log4cxx/helpers/aprinitializer.h
@@ -19,55 +19,55 @@
#define _LOG4CXX_HELPERS_APRINITIALIZER_H
#ifndef LOG4CXX
-#error "aprinitializer.h should only be included by log4cxx implementation"
+ #error "aprinitializer.h should only be included by log4cxx implementation"
#endif
#include <list>
extern "C" {
-typedef struct apr_thread_mutex_t apr_thread_mutex_t;
-typedef struct apr_threadkey_t apr_threadkey_t;
+ typedef struct apr_thread_mutex_t apr_thread_mutex_t;
+ typedef struct apr_threadkey_t apr_threadkey_t;
}
#include <apr_time.h>
namespace log4cxx
{
- namespace helpers
- {
- class FileWatchdog;
+namespace helpers
+{
+class FileWatchdog;
- class APRInitializer
- {
+class APRInitializer
+{
public:
- static log4cxx_time_t initialize();
- static apr_pool_t* getRootPool();
- static apr_threadkey_t* getTlsKey();
- static bool isDestructed;
+ static log4cxx_time_t initialize();
+ static apr_pool_t* getRootPool();
+ static apr_threadkey_t* getTlsKey();
+ static bool isDestructed;
- /**
- * Register a FileWatchdog for deletion prior to
- * APR termination. FileWatchdog must be
- * allocated on heap and not deleted elsewhere.
- */
- static void registerCleanup(FileWatchdog* watchdog);
- static void unregisterCleanup(FileWatchdog* watchdog);
+ /**
+ * Register a FileWatchdog for deletion prior to
+ * APR termination. FileWatchdog must be
+ * allocated on heap and not deleted elsewhere.
+ */
+ static void registerCleanup(FileWatchdog* watchdog);
+ static void unregisterCleanup(FileWatchdog* watchdog);
private:
- APRInitializer();
- APRInitializer(const APRInitializer&);
- APRInitializer& operator=(const APRInitializer&);
- apr_pool_t* p;
- apr_thread_mutex_t* mutex;
- std::list<FileWatchdog*> watchdogs;
- apr_time_t startTime;
- apr_threadkey_t* tlsKey;
- static APRInitializer& getInstance();
+ APRInitializer();
+ APRInitializer(const APRInitializer&);
+ APRInitializer& operator=(const APRInitializer&);
+ apr_pool_t* p;
+ apr_thread_mutex_t* mutex;
+ std::list<FileWatchdog*> watchdogs;
+ apr_time_t startTime;
+ apr_threadkey_t* tlsKey;
+ static APRInitializer& getInstance();
public:
- ~APRInitializer();
- };
- } // namespace helpers
+ ~APRInitializer();
+};
+} // namespace helpers
} // namespace log4cxx
#endif //_LOG4CXX_HELPERS_APRINITIALIZER_H
diff --git a/src/main/include/log4cxx/helpers/bufferedoutputstream.h b/src/main/include/log4cxx/helpers/bufferedoutputstream.h
index 9d4aa18..45a9664 100644
--- a/src/main/include/log4cxx/helpers/bufferedoutputstream.h
+++ b/src/main/include/log4cxx/helpers/bufferedoutputstream.h
@@ -23,40 +23,41 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
- /**
- * Abstract class for writing to character streams.
- */
- class LOG4CXX_EXPORT BufferedOutputStream : public OutputStream
- {
- private:
- size_t count;
- LogString buf;
+/**
+* Abstract class for writing to character streams.
+*/
+class LOG4CXX_EXPORT BufferedOutputStream : public OutputStream
+{
+ private:
+ size_t count;
+ LogString buf;
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(BufferedOutputStream)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(BufferedOutputStream)
- LOG4CXX_CAST_ENTRY_CHAIN(OutputStream)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(BufferedOutputStream)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(BufferedOutputStream)
+ LOG4CXX_CAST_ENTRY_CHAIN(OutputStream)
+ END_LOG4CXX_CAST_MAP()
- protected:
- BufferedOutputStream(OutputStreamPtr& out, size_t size = 4096);
- ~BufferedOutputStream();
+ protected:
+ BufferedOutputStream(OutputStreamPtr& out, size_t size = 4096);
+ ~BufferedOutputStream();
- public:
- void close(Pool& p);
- void flush(Pool& p);
- void write(ByteBuffer& buf, Pool& p);
+ public:
+ void close(Pool& p);
+ void flush(Pool& p);
+ void write(ByteBuffer& buf, Pool& p);
- private:
- BufferedOutputStream(const BufferedOutputStream&);
- BufferedOutputStream& operator=(const BufferedOutputStream&);
- };
+ private:
+ BufferedOutputStream(const BufferedOutputStream&);
+ BufferedOutputStream& operator=(const BufferedOutputStream&);
+};
- LOG4CXX_PTR_DEF(BufferedOutputStream);
- } // namespace helpers
+LOG4CXX_PTR_DEF(BufferedOutputStream);
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/bufferedwriter.h b/src/main/include/log4cxx/helpers/bufferedwriter.h
index 570da09..7e33d18 100644
--- a/src/main/include/log4cxx/helpers/bufferedwriter.h
+++ b/src/main/include/log4cxx/helpers/bufferedwriter.h
@@ -23,40 +23,41 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
- /**
- * Writes text to a character-output stream buffering
- * requests to increase efficiency.
- */
- class LOG4CXX_EXPORT BufferedWriter : public Writer
- {
- private:
- WriterPtr out;
- size_t sz;
- LogString buf;
+/**
+* Writes text to a character-output stream buffering
+* requests to increase efficiency.
+*/
+class LOG4CXX_EXPORT BufferedWriter : public Writer
+{
+ private:
+ WriterPtr out;
+ size_t sz;
+ LogString buf;
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(BufferedWriter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(BufferedWriter)
- LOG4CXX_CAST_ENTRY_CHAIN(Writer)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(BufferedWriter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(BufferedWriter)
+ LOG4CXX_CAST_ENTRY_CHAIN(Writer)
+ END_LOG4CXX_CAST_MAP()
- BufferedWriter(WriterPtr& out);
- BufferedWriter(WriterPtr& out, size_t sz);
- virtual ~BufferedWriter();
+ BufferedWriter(WriterPtr& out);
+ BufferedWriter(WriterPtr& out, size_t sz);
+ virtual ~BufferedWriter();
- virtual void close(Pool& p);
- virtual void flush(Pool& p);
- virtual void write(const LogString& str, Pool& p);
+ virtual void close(Pool& p);
+ virtual void flush(Pool& p);
+ virtual void write(const LogString& str, Pool& p);
- private:
- BufferedWriter(const BufferedWriter&);
- BufferedWriter& operator=(const BufferedWriter&);
- };
+ private:
+ BufferedWriter(const BufferedWriter&);
+ BufferedWriter& operator=(const BufferedWriter&);
+};
- } // namespace helpers
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/bytearrayinputstream.h b/src/main/include/log4cxx/helpers/bytearrayinputstream.h
index 3596925..5b032d9 100644
--- a/src/main/include/log4cxx/helpers/bytearrayinputstream.h
+++ b/src/main/include/log4cxx/helpers/bytearrayinputstream.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_HELPERS_BYTEARRAYINPUTSTREAM_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
@@ -31,64 +31,65 @@
namespace log4cxx
{
- namespace helpers {
- LOG4CXX_LIST_DEF(ByteList, unsigned char);
+namespace helpers
+{
+LOG4CXX_LIST_DEF(ByteList, unsigned char);
- /**
- * InputStream implemented on top of a byte array.
- */
- class LOG4CXX_EXPORT ByteArrayInputStream : public InputStream
- {
- private:
- ByteList buf;
- size_t pos;
+/**
+ * InputStream implemented on top of a byte array.
+ */
+class LOG4CXX_EXPORT ByteArrayInputStream : public InputStream
+{
+ private:
+ ByteList buf;
+ size_t pos;
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(ByteArrayInputStream)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(ByteArrayInputStream)
- LOG4CXX_CAST_ENTRY_CHAIN(InputStream)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(ByteArrayInputStream)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(ByteArrayInputStream)
+ LOG4CXX_CAST_ENTRY_CHAIN(InputStream)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Creates a ByteArrayInputStream.
- *
- * @param bytes array of bytes to copy into stream.
- */
- ByteArrayInputStream(const ByteList& bytes);
+ /**
+ * Creates a ByteArrayInputStream.
+ *
+ * @param bytes array of bytes to copy into stream.
+ */
+ ByteArrayInputStream(const ByteList& bytes);
- virtual ~ByteArrayInputStream();
+ virtual ~ByteArrayInputStream();
- /**
- * Closes this file input stream and releases any system
- * resources associated with the stream.
- */
- virtual void close();
+ /**
+ * Closes this file input stream and releases any system
+ * resources associated with the stream.
+ */
+ virtual void close();
- /**
- * Reads a sequence of bytes into the given buffer.
- *
- * @param buf The buffer into which bytes are to be transferred.
- * @return the total number of bytes read into the buffer, or -1 if there
- * is no more data because the end of the stream has been reached.
- */
- virtual int read(ByteBuffer& buf);
+ /**
+ * Reads a sequence of bytes into the given buffer.
+ *
+ * @param buf The buffer into which bytes are to be transferred.
+ * @return the total number of bytes read into the buffer, or -1 if there
+ * is no more data because the end of the stream has been reached.
+ */
+ virtual int read(ByteBuffer& buf);
- private:
+ private:
- ByteArrayInputStream(const ByteArrayInputStream&);
+ ByteArrayInputStream(const ByteArrayInputStream&);
- ByteArrayInputStream& operator=(const ByteArrayInputStream&);
+ ByteArrayInputStream& operator=(const ByteArrayInputStream&);
- };
+};
- LOG4CXX_PTR_DEF(ByteArrayInputStream);
- } // namespace helpers
+LOG4CXX_PTR_DEF(ByteArrayInputStream);
+} // namespace helpers
} //namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif //_LOG4CXX_HELPERS_BYTEARRAYINPUTSTREAM_H
diff --git a/src/main/include/log4cxx/helpers/bytearrayoutputstream.h b/src/main/include/log4cxx/helpers/bytearrayoutputstream.h
index c8a2f8f..2e98f77 100644
--- a/src/main/include/log4cxx/helpers/bytearrayoutputstream.h
+++ b/src/main/include/log4cxx/helpers/bytearrayoutputstream.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_HELPERS_BYTEARRAYOUTPUTSTREAM_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
@@ -32,46 +32,47 @@
namespace log4cxx
{
- namespace helpers {
- class Pool;
+namespace helpers
+{
+class Pool;
- LOG4CXX_LIST_DEF(ByteList, unsigned char);
+LOG4CXX_LIST_DEF(ByteList, unsigned char);
- /**
- * OutputStream implemented on top of std::vector
- */
- class LOG4CXX_EXPORT ByteArrayOutputStream : public OutputStream
- {
- private:
- ByteList array;
+/**
+* OutputStream implemented on top of std::vector
+*/
+class LOG4CXX_EXPORT ByteArrayOutputStream : public OutputStream
+{
+ private:
+ ByteList array;
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(ByteArrayOutputStream)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(ByteArrayOutputStream)
- LOG4CXX_CAST_ENTRY_CHAIN(OutputStream)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(ByteArrayOutputStream)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(ByteArrayOutputStream)
+ LOG4CXX_CAST_ENTRY_CHAIN(OutputStream)
+ END_LOG4CXX_CAST_MAP()
- ByteArrayOutputStream();
- virtual ~ByteArrayOutputStream();
+ ByteArrayOutputStream();
+ virtual ~ByteArrayOutputStream();
- virtual void close(Pool& p);
- virtual void flush(Pool& p);
- virtual void write(ByteBuffer& buf, Pool& p);
- ByteList toByteArray() const;
+ virtual void close(Pool& p);
+ virtual void flush(Pool& p);
+ virtual void write(ByteBuffer& buf, Pool& p);
+ ByteList toByteArray() const;
- private:
- ByteArrayOutputStream(const ByteArrayOutputStream&);
- ByteArrayOutputStream& operator=(const ByteArrayOutputStream&);
- };
+ private:
+ ByteArrayOutputStream(const ByteArrayOutputStream&);
+ ByteArrayOutputStream& operator=(const ByteArrayOutputStream&);
+};
- LOG4CXX_PTR_DEF(ByteArrayOutputStream);
- } // namespace helpers
+LOG4CXX_PTR_DEF(ByteArrayOutputStream);
+} // namespace helpers
} //namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
diff --git a/src/main/include/log4cxx/helpers/bytebuffer.h b/src/main/include/log4cxx/helpers/bytebuffer.h
index da235b6..7692a29 100644
--- a/src/main/include/log4cxx/helpers/bytebuffer.h
+++ b/src/main/include/log4cxx/helpers/bytebuffer.h
@@ -24,45 +24,67 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
- /**
- * A byte buffer.
- */
- class LOG4CXX_EXPORT ByteBuffer
- {
- private:
- char* base;
- size_t pos;
- size_t lim;
- size_t cap;
+/**
+* A byte buffer.
+*/
+class LOG4CXX_EXPORT ByteBuffer
+{
+ private:
+ char* base;
+ size_t pos;
+ size_t lim;
+ size_t cap;
- public:
- ByteBuffer(char* data, size_t capacity);
- ~ByteBuffer();
+ public:
+ ByteBuffer(char* data, size_t capacity);
+ ~ByteBuffer();
- void clear();
- void flip();
+ void clear();
+ void flip();
- inline char* data() { return base; }
- inline const char* data() const { return base; }
- inline char* current() { return base + pos; }
- inline const char* current() const { return base + pos; }
- inline size_t limit() const { return lim; }
- void limit(size_t newLimit);
- inline size_t position() const { return pos; }
- inline size_t remaining() const { return lim - pos; }
- void position(size_t newPosition);
+ inline char* data()
+ {
+ return base;
+ }
+ inline const char* data() const
+ {
+ return base;
+ }
+ inline char* current()
+ {
+ return base + pos;
+ }
+ inline const char* current() const
+ {
+ return base + pos;
+ }
+ inline size_t limit() const
+ {
+ return lim;
+ }
+ void limit(size_t newLimit);
+ inline size_t position() const
+ {
+ return pos;
+ }
+ inline size_t remaining() const
+ {
+ return lim - pos;
+ }
+ void position(size_t newPosition);
- bool put(char byte);
+ bool put(char byte);
- private:
- ByteBuffer(const ByteBuffer&);
- ByteBuffer& operator=(const ByteBuffer&);
- };
+ private:
+ ByteBuffer(const ByteBuffer&);
+ ByteBuffer& operator=(const ByteBuffer&);
+};
- } // namespace helpers
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/cacheddateformat.h b/src/main/include/log4cxx/helpers/cacheddateformat.h
index 527ed25..4cb1bc6 100644
--- a/src/main/include/log4cxx/helpers/cacheddateformat.h
+++ b/src/main/include/log4cxx/helpers/cacheddateformat.h
@@ -22,199 +22,202 @@
namespace log4cxx
{
- namespace pattern
+namespace pattern
+{
+class LOG4CXX_EXPORT CachedDateFormat : public log4cxx::helpers::DateFormat
+{
+ public:
+ enum
{
- class LOG4CXX_EXPORT CachedDateFormat : public log4cxx::helpers::DateFormat {
- public:
- enum {
- /*
- * Constant used to represent that there was no change
- * observed when changing the millisecond count.
- */
- NO_MILLISECONDS = -2,
- /*
- * Constant used to represent that there was an
- * observed change, but was an expected change.
- */
- UNRECOGNIZED_MILLISECONDS = -1
- };
-
- private:
- /**
- * Supported digit set. If the wrapped DateFormat uses
- * a different unit set, the millisecond pattern
- * will not be recognized and duplicate requests
- * will use the cache.
- */
- static const logchar digits[];
-
- enum {
- /**
- * First magic number used to detect the millisecond position.
- */
- magic1 = 654000,
- /**
- * Second magic number used to detect the millisecond position.
- */
- magic2 = 987000
- };
-
- /**
- * Expected representation of first magic number.
- */
- static const logchar magicString1[];
-
-
- /**
- * Expected representation of second magic number.
- */
- static const logchar magicString2[];
-
-
- /**
- * Expected representation of 0 milliseconds.
- */
- static const logchar zeroString[];
-
- /**
- * Wrapped formatter.
+ /*
+ * Constant used to represent that there was no change
+ * observed when changing the millisecond count.
*/
- log4cxx::helpers::DateFormatPtr formatter;
-
- /**
- * Index of initial digit of millisecond pattern or
- * UNRECOGNIZED_MILLISECONDS or NO_MILLISECONDS.
+ NO_MILLISECONDS = -2,
+ /*
+ * Constant used to represent that there was an
+ * observed change, but was an expected change.
*/
- mutable int millisecondStart;
+ UNRECOGNIZED_MILLISECONDS = -1
+ };
+ private:
+ /**
+ * Supported digit set. If the wrapped DateFormat uses
+ * a different unit set, the millisecond pattern
+ * will not be recognized and duplicate requests
+ * will use the cache.
+ */
+ static const logchar digits[];
+
+ enum
+ {
/**
- * Integral second preceding the previous convered Date.
+ * First magic number used to detect the millisecond position.
*/
- mutable log4cxx_time_t slotBegin;
-
-
+ magic1 = 654000,
/**
- * Cache of previous conversion.
+ * Second magic number used to detect the millisecond position.
*/
- mutable LogString cache;
+ magic2 = 987000
+ };
+
+ /**
+ * Expected representation of first magic number.
+ */
+ static const logchar magicString1[];
- /**
- * Maximum validity period for the cache.
- * Typically 1, use cache for duplicate requests only, or
- * 1000000, use cache for requests within the same integral second.
- */
- const int expiration;
-
- /**
- * Date requested in previous conversion.
- */
- mutable log4cxx_time_t previousTime;
-
- public:
- /**
- * Creates a new CachedDateFormat object.
- * @param dateFormat Date format, may not be null.
- * @param expiration maximum cached range in microseconds.
- * If the dateFormat is known to be incompatible with the
- * caching algorithm, use a value of 0 to totally disable
- * caching or 1 to only use cache for duplicate requests.
- */
- CachedDateFormat(const log4cxx::helpers::DateFormatPtr& dateFormat, int expiration);
-
- /**
- * Finds start of millisecond field in formatted time.
- * @param time long time, must be integral number of seconds
- * @param formatted String corresponding formatted string
- * @param formatter DateFormat date format
- * @param pool pool.
- * @return int position in string of first digit of milliseconds,
- * -1 indicates no millisecond field, -2 indicates unrecognized
- * field (likely RelativeTimeDateFormat)
- */
- static int findMillisecondStart(
- log4cxx_time_t time, const LogString& formatted,
- const log4cxx::helpers::DateFormatPtr& formatter,
- log4cxx::helpers::Pool& pool);
-
- /**
- * Formats a Date into a date/time string.
- *
- * @param date the date to format.
- * @param sbuf the string buffer to write to.
- * @param p memory pool.
- */
- virtual void format(LogString &sbuf,
- log4cxx_time_t date,
- log4cxx::helpers::Pool& p) const;
-
- private:
- /**
- * Formats a count of milliseconds (0-999) into a numeric representation.
- * @param millis Millisecond coun between 0 and 999.
- * @buf String buffer, may not be null.
- * @offset Starting position in buffer, the length of the
- * buffer must be at least offset + 3.
- */
- static void millisecondFormat(int millis,
- LogString& buf,
- int offset);
+ /**
+ * Expected representation of second magic number.
+ */
+ static const logchar magicString2[];
- public:
- /**
- * Set timezone.
- *
- * @remarks Setting the timezone using getCalendar().setTimeZone()
- * will likely cause caching to misbehave.
- * @param zone TimeZone new timezone
- */
- virtual void setTimeZone(const log4cxx::helpers::TimeZonePtr& zone);
+ /**
+ * Expected representation of 0 milliseconds.
+ */
+ static const logchar zeroString[];
- /**
- * Format an integer consistent with the format method.
- * @param s string to which the numeric string is appended.
- * @param n integer value.
- * @param p memory pool used during formatting.
- */
- virtual void numberFormat(LogString& s,
- int n,
- log4cxx::helpers::Pool& p) const;
+ /**
+ * Wrapped formatter.
+ */
+ log4cxx::helpers::DateFormatPtr formatter;
- /**
- * Gets maximum cache validity for the specified SimpleDateTime
- * conversion pattern.
- * @param pattern conversion pattern, may not be null.
- * @returns Duration in microseconds from an integral second
- * that the cache will return consistent results.
- */
- static int getMaximumCacheValidity(const LogString& pattern);
+ /**
+ * Index of initial digit of millisecond pattern or
+ * UNRECOGNIZED_MILLISECONDS or NO_MILLISECONDS.
+ */
+ mutable int millisecondStart;
- private:
- CachedDateFormat(const CachedDateFormat&);
- CachedDateFormat& operator=(const CachedDateFormat&);
+ /**
+ * Integral second preceding the previous convered Date.
+ */
+ mutable log4cxx_time_t slotBegin;
- /**
- * Tests if two string regions are equal.
- * @param target target string.
- * @param toffset character position in target to start comparison.
- * @param other other string.
- * @param ooffset character position in other to start comparison.
- * @param len length of region.
- * @return true if regions are equal.
- */
- static bool regionMatches(
- const LogString& target,
- size_t toffset,
- const LogString& other,
- size_t ooffset,
- size_t len);
- };
+ /**
+ * Cache of previous conversion.
+ */
+ mutable LogString cache;
+
+
+ /**
+ * Maximum validity period for the cache.
+ * Typically 1, use cache for duplicate requests only, or
+ * 1000000, use cache for requests within the same integral second.
+ */
+ const int expiration;
+
+ /**
+ * Date requested in previous conversion.
+ */
+ mutable log4cxx_time_t previousTime;
+
+ public:
+ /**
+ * Creates a new CachedDateFormat object.
+ * @param dateFormat Date format, may not be null.
+ * @param expiration maximum cached range in microseconds.
+ * If the dateFormat is known to be incompatible with the
+ * caching algorithm, use a value of 0 to totally disable
+ * caching or 1 to only use cache for duplicate requests.
+ */
+ CachedDateFormat(const log4cxx::helpers::DateFormatPtr& dateFormat, int expiration);
+
+ /**
+ * Finds start of millisecond field in formatted time.
+ * @param time long time, must be integral number of seconds
+ * @param formatted String corresponding formatted string
+ * @param formatter DateFormat date format
+ * @param pool pool.
+ * @return int position in string of first digit of milliseconds,
+ * -1 indicates no millisecond field, -2 indicates unrecognized
+ * field (likely RelativeTimeDateFormat)
+ */
+ static int findMillisecondStart(
+ log4cxx_time_t time, const LogString& formatted,
+ const log4cxx::helpers::DateFormatPtr& formatter,
+ log4cxx::helpers::Pool& pool);
+
+ /**
+ * Formats a Date into a date/time string.
+ *
+ * @param date the date to format.
+ * @param sbuf the string buffer to write to.
+ * @param p memory pool.
+ */
+ virtual void format(LogString& sbuf,
+ log4cxx_time_t date,
+ log4cxx::helpers::Pool& p) const;
+
+ private:
+ /**
+ * Formats a count of milliseconds (0-999) into a numeric representation.
+ * @param millis Millisecond coun between 0 and 999.
+ * @buf String buffer, may not be null.
+ * @offset Starting position in buffer, the length of the
+ * buffer must be at least offset + 3.
+ */
+ static void millisecondFormat(int millis,
+ LogString& buf,
+ int offset);
+
+
+ public:
+ /**
+ * Set timezone.
+ *
+ * @remarks Setting the timezone using getCalendar().setTimeZone()
+ * will likely cause caching to misbehave.
+ * @param zone TimeZone new timezone
+ */
+ virtual void setTimeZone(const log4cxx::helpers::TimeZonePtr& zone);
+
+ /**
+ * Format an integer consistent with the format method.
+ * @param s string to which the numeric string is appended.
+ * @param n integer value.
+ * @param p memory pool used during formatting.
+ */
+ virtual void numberFormat(LogString& s,
+ int n,
+ log4cxx::helpers::Pool& p) const;
+
+ /**
+ * Gets maximum cache validity for the specified SimpleDateTime
+ * conversion pattern.
+ * @param pattern conversion pattern, may not be null.
+ * @returns Duration in microseconds from an integral second
+ * that the cache will return consistent results.
+ */
+ static int getMaximumCacheValidity(const LogString& pattern);
+
+ private:
+ CachedDateFormat(const CachedDateFormat&);
+ CachedDateFormat& operator=(const CachedDateFormat&);
+
+ /**
+ * Tests if two string regions are equal.
+ * @param target target string.
+ * @param toffset character position in target to start comparison.
+ * @param other other string.
+ * @param ooffset character position in other to start comparison.
+ * @param len length of region.
+ * @return true if regions are equal.
+ */
+ static bool regionMatches(
+ const LogString& target,
+ size_t toffset,
+ const LogString& other,
+ size_t ooffset,
+ size_t len);
+
+};
- } // namespace helpers
+} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_SIMPLE_DATE_FORMAT_H
diff --git a/src/main/include/log4cxx/helpers/charsetdecoder.h b/src/main/include/log4cxx/helpers/charsetdecoder.h
index e2b1ea1..7523505 100644
--- a/src/main/include/log4cxx/helpers/charsetdecoder.h
+++ b/src/main/include/log4cxx/helpers/charsetdecoder.h
@@ -22,92 +22,94 @@
namespace log4cxx
{
- namespace helpers {
- class CharsetDecoder;
- LOG4CXX_PTR_DEF(CharsetDecoder);
- class ByteBuffer;
+namespace helpers
+{
+class CharsetDecoder;
+LOG4CXX_PTR_DEF(CharsetDecoder);
+class ByteBuffer;
- /**
- * An abstract engine to transform a sequences of bytes in a specific charset
- * into a LogString.
- */
- class LOG4CXX_EXPORT CharsetDecoder : public ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(CharsetDecoder)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(CharsetDecoder)
- END_LOG4CXX_CAST_MAP()
- protected:
- /**
- * Protected constructor.
- */
- CharsetDecoder();
- public:
- /**
- * Destructor.
- */
- virtual ~CharsetDecoder();
+/**
+* An abstract engine to transform a sequences of bytes in a specific charset
+* into a LogString.
+*/
+class LOG4CXX_EXPORT CharsetDecoder : public ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(CharsetDecoder)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(CharsetDecoder)
+ END_LOG4CXX_CAST_MAP()
+ protected:
+ /**
+ * Protected constructor.
+ */
+ CharsetDecoder();
+ public:
+ /**
+ * Destructor.
+ */
+ virtual ~CharsetDecoder();
- /**
- * Get decoder for default charset.
- */
- static CharsetDecoderPtr getDefaultDecoder();
- /**
- * Get decoder for specified character set.
- * @param charset the following values should be recognized:
- * "US-ASCII", "ISO-8859-1", "UTF-8",
- * "UTF-16BE", "UTF-16LE".
- * @return decoder
- * @throws IllegalArgumentException if charset is not recognized.
- */
- static CharsetDecoderPtr getDecoder(const LogString& charset);
+ /**
+ * Get decoder for default charset.
+ */
+ static CharsetDecoderPtr getDefaultDecoder();
+ /**
+ * Get decoder for specified character set.
+ * @param charset the following values should be recognized:
+ * "US-ASCII", "ISO-8859-1", "UTF-8",
+ * "UTF-16BE", "UTF-16LE".
+ * @return decoder
+ * @throws IllegalArgumentException if charset is not recognized.
+ */
+ static CharsetDecoderPtr getDecoder(const LogString& charset);
- /**
- * Get decoder for UTF-8.
- */
- static CharsetDecoderPtr getUTF8Decoder();
- /**
- * Get decoder for ISO-8859-1.
- */
- static CharsetDecoderPtr getISOLatinDecoder();
+ /**
+ * Get decoder for UTF-8.
+ */
+ static CharsetDecoderPtr getUTF8Decoder();
+ /**
+ * Get decoder for ISO-8859-1.
+ */
+ static CharsetDecoderPtr getISOLatinDecoder();
- /**
- * Decodes as many bytes as possible from the given
- * input buffer, writing the results to the given output string.
- * @param in input buffer.
- * @param out output string.
- * @return APR_SUCCESS if not encoding errors were found.
- */
- virtual log4cxx_status_t decode(ByteBuffer& in,
- LogString& out) = 0;
+ /**
+ * Decodes as many bytes as possible from the given
+ * input buffer, writing the results to the given output string.
+ * @param in input buffer.
+ * @param out output string.
+ * @return APR_SUCCESS if not encoding errors were found.
+ */
+ virtual log4cxx_status_t decode(ByteBuffer& in,
+ LogString& out) = 0;
- /**
- * Determins if status value indicates an invalid byte sequence.
- */
- inline static bool isError(log4cxx_status_t stat) {
- return (stat != 0);
- }
+ /**
+ * Determins if status value indicates an invalid byte sequence.
+ */
+ inline static bool isError(log4cxx_status_t stat)
+ {
+ return (stat != 0);
+ }
- private:
- /**
- * Private copy constructor.
- */
- CharsetDecoder(const CharsetDecoder&);
- /**
- * Private assignment operator.
- */
- CharsetDecoder& operator=(const CharsetDecoder&);
- /**
- * Creates a new decoder for the default charset.
- */
- static CharsetDecoder* createDefaultDecoder();
- };
+ private:
+ /**
+ * Private copy constructor.
+ */
+ CharsetDecoder(const CharsetDecoder&);
+ /**
+ * Private assignment operator.
+ */
+ CharsetDecoder& operator=(const CharsetDecoder&);
+ /**
+ * Creates a new decoder for the default charset.
+ */
+ static CharsetDecoder* createDefaultDecoder();
+};
- } // namespace helpers
+} // namespace helpers
} //namespace log4cxx
#endif //_LOG4CXX_HELPERS_CHARSETENCODER_H
diff --git a/src/main/include/log4cxx/helpers/charsetencoder.h b/src/main/include/log4cxx/helpers/charsetencoder.h
index c815ebc..f9e5465 100644
--- a/src/main/include/log4cxx/helpers/charsetencoder.h
+++ b/src/main/include/log4cxx/helpers/charsetencoder.h
@@ -24,111 +24,113 @@
namespace log4cxx
{
- namespace helpers {
- class ByteBuffer;
- class CharsetEncoder;
- LOG4CXX_PTR_DEF(CharsetEncoder);
+namespace helpers
+{
+class ByteBuffer;
+class CharsetEncoder;
+LOG4CXX_PTR_DEF(CharsetEncoder);
- /**
- * An engine to transform LogStrings into bytes
- * for the specific character set.
- */
- class LOG4CXX_EXPORT CharsetEncoder : public ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(CharsetEncoder)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(CharsetEncoder)
- END_LOG4CXX_CAST_MAP()
+/**
+* An engine to transform LogStrings into bytes
+* for the specific character set.
+*/
+class LOG4CXX_EXPORT CharsetEncoder : public ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(CharsetEncoder)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(CharsetEncoder)
+ END_LOG4CXX_CAST_MAP()
- protected:
- /**
- * Protected constructor.
- */
- CharsetEncoder();
+ protected:
+ /**
+ * Protected constructor.
+ */
+ CharsetEncoder();
- public:
- /**
- * Destructor.
- */
- virtual ~CharsetEncoder();
- /**
- * Get encoder for default charset.
- */
- static CharsetEncoderPtr getDefaultEncoder();
+ public:
+ /**
+ * Destructor.
+ */
+ virtual ~CharsetEncoder();
+ /**
+ * Get encoder for default charset.
+ */
+ static CharsetEncoderPtr getDefaultEncoder();
- /**
- * Get encoder for specified character set.
- * @param charset the following values should be recognized:
- * "US-ASCII", "ISO-8859-1", "UTF-8",
- * "UTF-16BE", "UTF-16LE".
- * @return encoder.
- * @throws IllegalArgumentException if encoding is not recognized.
- */
- static CharsetEncoderPtr getEncoder(const LogString& charset);
+ /**
+ * Get encoder for specified character set.
+ * @param charset the following values should be recognized:
+ * "US-ASCII", "ISO-8859-1", "UTF-8",
+ * "UTF-16BE", "UTF-16LE".
+ * @return encoder.
+ * @throws IllegalArgumentException if encoding is not recognized.
+ */
+ static CharsetEncoderPtr getEncoder(const LogString& charset);
- /**
- * Get encoder for UTF-8.
- */
- static CharsetEncoderPtr getUTF8Encoder();
+ /**
+ * Get encoder for UTF-8.
+ */
+ static CharsetEncoderPtr getUTF8Encoder();
- /**
- * Encodes a string replacing unmappable
- * characters with escape sequences.
- *
- */
- static void encode(CharsetEncoderPtr& enc,
- const LogString& src,
- LogString::const_iterator& iter,
- ByteBuffer& dst);
+ /**
+ * Encodes a string replacing unmappable
+ * characters with escape sequences.
+ *
+ */
+ static void encode(CharsetEncoderPtr& enc,
+ const LogString& src,
+ LogString::const_iterator& iter,
+ ByteBuffer& dst);
- /**
- * Encodes as many characters from the input string as possible
- * to the output buffer.
- * @param in input string
- * @param iter position in string to start.
- * @param out output buffer.
- * @return APR_SUCCESS unless a character can not be represented in
- * the encoding.
- */
- virtual log4cxx_status_t encode(const LogString& in,
- LogString::const_iterator& iter,
- ByteBuffer& out) = 0;
+ /**
+ * Encodes as many characters from the input string as possible
+ * to the output buffer.
+ * @param in input string
+ * @param iter position in string to start.
+ * @param out output buffer.
+ * @return APR_SUCCESS unless a character can not be represented in
+ * the encoding.
+ */
+ virtual log4cxx_status_t encode(const LogString& in,
+ LogString::const_iterator& iter,
+ ByteBuffer& out) = 0;
- /**
- * Resets any internal state.
- */
- virtual void reset();
+ /**
+ * Resets any internal state.
+ */
+ virtual void reset();
- /**
- * Flushes the encoder.
- */
- virtual void flush(ByteBuffer& out);
+ /**
+ * Flushes the encoder.
+ */
+ virtual void flush(ByteBuffer& out);
- /**
- * Determines if the return value from encode indicates
- * an unconvertable character.
- */
- inline static bool isError(log4cxx_status_t stat) {
- return (stat != 0);
- }
+ /**
+ * Determines if the return value from encode indicates
+ * an unconvertable character.
+ */
+ inline static bool isError(log4cxx_status_t stat)
+ {
+ return (stat != 0);
+ }
- private:
- /**
- * Private copy constructor.
- */
- CharsetEncoder(const CharsetEncoder&);
- /**
- * Private assignment operator.
- */
- CharsetEncoder& operator=(const CharsetEncoder&);
+ private:
+ /**
+ * Private copy constructor.
+ */
+ CharsetEncoder(const CharsetEncoder&);
+ /**
+ * Private assignment operator.
+ */
+ CharsetEncoder& operator=(const CharsetEncoder&);
- static CharsetEncoder* createDefaultEncoder();
- };
+ static CharsetEncoder* createDefaultEncoder();
+};
- } // namespace helpers
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/class.h b/src/main/include/log4cxx/helpers/class.h
index c7f708b..1d9655d 100644
--- a/src/main/include/log4cxx/helpers/class.h
+++ b/src/main/include/log4cxx/helpers/class.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_HELPERS_CLASS_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
@@ -30,37 +30,37 @@
namespace log4cxx
{
- namespace helpers
- {
- class Object;
- typedef ObjectPtrT<Object> ObjectPtr;
+namespace helpers
+{
+class Object;
+typedef ObjectPtrT<Object> ObjectPtr;
- class LOG4CXX_EXPORT Class
- {
- public:
- virtual ~Class();
- virtual ObjectPtr newInstance() const;
- LogString toString() const;
- virtual LogString getName() const = 0;
- static const Class& forName(const LogString& className);
- static bool registerClass(const Class& newClass);
+class LOG4CXX_EXPORT Class
+{
+ public:
+ virtual ~Class();
+ virtual ObjectPtr newInstance() const;
+ LogString toString() const;
+ virtual LogString getName() const = 0;
+ static const Class& forName(const LogString& className);
+ static bool registerClass(const Class& newClass);
- protected:
- Class();
+ protected:
+ Class();
- private:
- Class(const Class&);
- Class& operator=(const Class&);
- typedef std::map<LogString, const Class *> ClassMap;
- static ClassMap& getRegistry();
- static void registerClasses();
- };
- } // namespace log4cxx
+ private:
+ Class(const Class&);
+ Class& operator=(const Class&);
+ typedef std::map<LogString, const Class*> ClassMap;
+ static ClassMap& getRegistry();
+ static void registerClasses();
+};
+} // namespace log4cxx
} // namespace helper
#if defined(_MSC_VER)
-#pragma warning (pop)
+ #pragma warning (pop)
#endif
diff --git a/src/main/include/log4cxx/helpers/classregistration.h b/src/main/include/log4cxx/helpers/classregistration.h
index af06319..45468ae 100644
--- a/src/main/include/log4cxx/helpers/classregistration.h
+++ b/src/main/include/log4cxx/helpers/classregistration.h
@@ -22,20 +22,20 @@
namespace log4cxx
{
- namespace helpers
- {
- class Class;
- class LOG4CXX_EXPORT ClassRegistration
- {
- public:
- typedef const Class& (*ClassAccessor)();
- ClassRegistration(ClassAccessor classAccessor);
+namespace helpers
+{
+class Class;
+class LOG4CXX_EXPORT ClassRegistration
+{
+ public:
+ typedef const Class& (*ClassAccessor)();
+ ClassRegistration(ClassAccessor classAccessor);
- private:
- ClassRegistration(const ClassRegistration&);
- ClassRegistration& operator=(const ClassRegistration&);
- };
- } // namespace log4cxx
+ private:
+ ClassRegistration(const ClassRegistration&);
+ ClassRegistration& operator=(const ClassRegistration&);
+};
+} // namespace log4cxx
} // namespace helper
#endif //_LOG4CXX_HELPERS_CLASSREGISTRATION_H
diff --git a/src/main/include/log4cxx/helpers/condition.h b/src/main/include/log4cxx/helpers/condition.h
index 3da4262..8b25c4f 100644
--- a/src/main/include/log4cxx/helpers/condition.h
+++ b/src/main/include/log4cxx/helpers/condition.h
@@ -22,52 +22,52 @@
#include <log4cxx/helpers/mutex.h>
extern "C" {
- struct apr_thread_cond_t;
+ struct apr_thread_cond_t;
}
namespace log4cxx
{
- namespace helpers
- {
- class Pool;
+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);
+/**
+ * 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
+ 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/cyclicbuffer.h b/src/main/include/log4cxx/helpers/cyclicbuffer.h
index dbf9ce9..e0badd1 100644
--- a/src/main/include/log4cxx/helpers/cyclicbuffer.h
+++ b/src/main/include/log4cxx/helpers/cyclicbuffer.h
@@ -22,71 +22,75 @@
namespace log4cxx
{
- namespace helpers
+namespace helpers
+{
+/**
+CyclicBuffer is used by other appenders to hold instances of
+{@link log4cxx::spi::LoggingEvent LoggingEvent} for immediate
+or deferred display.
+<p>This buffer gives read access to any element in the buffer not
+just the first or last element.
+*/
+class LOG4CXX_EXPORT CyclicBuffer
+{
+ log4cxx::spi::LoggingEventList ea;
+ int first;
+ int last;
+ int numElems;
+ int maxSize;
+
+ public:
+ /**
+ Instantiate a new CyclicBuffer of at most <code>maxSize</code>
+ events.
+ The <code>maxSize</code> argument must a positive integer.
+ @param maxSize The maximum number of elements in the buffer.
+ @throws IllegalArgumentException if <code>maxSize</code>
+ is negative.
+ */
+ CyclicBuffer(int maxSize);
+ ~CyclicBuffer();
+
+ /**
+ Add an <code>event</code> as the last event in the buffer.
+ */
+ void add(const spi::LoggingEventPtr& event);
+
+ /**
+ Get the <i>i</i>th oldest event currently in the buffer. If
+ <em>i</em> is outside the range 0 to the number of elements
+ currently in the buffer, then <code>null</code> is returned.
+ */
+ spi::LoggingEventPtr get(int i);
+
+ int getMaxSize() const
{
- /**
- CyclicBuffer is used by other appenders to hold instances of
- {@link log4cxx::spi::LoggingEvent LoggingEvent} for immediate
- or deferred display.
- <p>This buffer gives read access to any element in the buffer not
- just the first or last element.
- */
- class LOG4CXX_EXPORT CyclicBuffer
- {
- log4cxx::spi::LoggingEventList ea;
- int first;
- int last;
- int numElems;
- int maxSize;
+ return maxSize;
+ }
- public:
- /**
- Instantiate a new CyclicBuffer of at most <code>maxSize</code>
- events.
- The <code>maxSize</code> argument must a positive integer.
- @param maxSize The maximum number of elements in the buffer.
- @throws IllegalArgumentException if <code>maxSize</code>
- is negative.
- */
- CyclicBuffer(int maxSize);
- ~CyclicBuffer();
+ /**
+ Get the oldest (first) element in the buffer. The oldest element
+ is removed from the buffer.
+ */
+ spi::LoggingEventPtr get();
- /**
- Add an <code>event</code> as the last event in the buffer.
- */
- void add(const spi::LoggingEventPtr& event);
+ /**
+ Get the number of elements in the buffer. This number is
+ guaranteed to be in the range 0 to <code>maxSize</code>
+ (inclusive).
+ */
+ int length() const
+ {
+ return numElems;
+ }
- /**
- Get the <i>i</i>th oldest event currently in the buffer. If
- <em>i</em> is outside the range 0 to the number of elements
- currently in the buffer, then <code>null</code> is returned.
- */
- spi::LoggingEventPtr get(int i);
-
- int getMaxSize() const
- { return maxSize; }
-
- /**
- Get the oldest (first) element in the buffer. The oldest element
- is removed from the buffer.
- */
- spi::LoggingEventPtr get();
-
- /**
- Get the number of elements in the buffer. This number is
- guaranteed to be in the range 0 to <code>maxSize</code>
- (inclusive).
- */
- int length() const
- { return numElems; }
-
- /**
- Resize the cyclic buffer to <code>newSize</code>.
- @throws IllegalArgumentException if <code>newSize</code> is negative.
- */
- void resize(int newSize);
- }; // class CyclicBuffer
- } //namespace helpers
+ /**
+ Resize the cyclic buffer to <code>newSize</code>.
+ @throws IllegalArgumentException if <code>newSize</code> is negative.
+ */
+ void resize(int newSize);
+}; // class CyclicBuffer
+} //namespace helpers
} //namespace log4cxx
#endif //_LOG4CXX_HELPERS_CYCLICBUFFER_H
diff --git a/src/main/include/log4cxx/helpers/datagrampacket.h b/src/main/include/log4cxx/helpers/datagrampacket.h
index 5bdbf48..29a2595 100644
--- a/src/main/include/log4cxx/helpers/datagrampacket.h
+++ b/src/main/include/log4cxx/helpers/datagrampacket.h
@@ -24,112 +24,134 @@
namespace log4cxx
{
- namespace helpers
+namespace helpers
+{
+
+/** This class represents a datagram packet.
+<p>Datagram packets are used to implement a connectionless packet
+delivery service. Each message is routed from one machine to another
+based solely on information contained within that packet. Multiple
+packets sent from one machine to another might be routed differently,
+and might arrive in any order.
+*/
+class LOG4CXX_EXPORT DatagramPacket : public helpers::ObjectImpl
+{
+ protected:
+ /** the data for this packet. */
+ void* buf;
+
+ /** The offset of the data for this packet. */
+ int offset;
+
+ /** The length of the data for this packet. */
+ int length;
+
+ /** The IP address for this packet. */
+ InetAddressPtr address;
+
+ /** The UDP port number of the remote host. */
+ int port;
+
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(DatagramPacket)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(DatagramPacket)
+ END_LOG4CXX_CAST_MAP()
+
+ /** Constructs a DatagramPacket for receiving packets of length
+ <code>length</code>. */
+ DatagramPacket(void* buf, int length);
+
+ /** Constructs a datagram packet for sending packets of length
+ <code>length</code> to the specified port number on the specified
+ host. */
+ DatagramPacket(void* buf, int length, InetAddressPtr address, int port);
+
+ /** Constructs a DatagramPacket for receiving packets of length
+ <code>length</code>, specifying an offset into the buffer. */
+ DatagramPacket(void* buf, int offset, int length);
+
+ /** Constructs a datagram packet for sending packets of length
+ <code>length</code> with offset <code>offset</code> to the
+ specified port number on the specified host. */
+ DatagramPacket(void* buf, int offset, int length, InetAddressPtr address,
+ int port);
+
+ ~DatagramPacket();
+
+ /** Returns the IP address of the machine to which this datagram
+ is being sent or from which the datagram was received. */
+ inline InetAddressPtr getAddress() const
{
+ return address;
+ }
- /** This class represents a datagram packet.
- <p>Datagram packets are used to implement a connectionless packet
- delivery service. Each message is routed from one machine to another
- based solely on information contained within that packet. Multiple
- packets sent from one machine to another might be routed differently,
- and might arrive in any order.
- */
- class LOG4CXX_EXPORT DatagramPacket : public helpers::ObjectImpl
- {
- protected:
- /** the data for this packet. */
- void * buf;
+ /** Returns the data received or the data to be sent. */
+ inline void* getData() const
+ {
+ return buf;
+ }
- /** The offset of the data for this packet. */
- int offset;
+ /** Returns the length of the data to be sent or the length of the
+ data received. */
+ inline int getLength() const
+ {
+ return length;
+ }
- /** The length of the data for this packet. */
- int length;
+ /** Returns the offset of the data to be sent or the offset of the
+ data received. */
+ inline int getOffset() const
+ {
+ return offset;
+ }
- /** The IP address for this packet. */
- InetAddressPtr address;
+ /** Returns the port number on the remote host to which this
+ datagram is being sent or from which the datagram was received. */
+ inline int getPort() const
+ {
+ return port;
+ }
- /** The UDP port number of the remote host. */
- int port;
+ inline void setAddress(InetAddressPtr address1)
+ {
+ this->address = address1;
+ }
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(DatagramPacket)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(DatagramPacket)
- END_LOG4CXX_CAST_MAP()
+ /** Set the data buffer for this packet. */
+ inline void setData(void* buf1)
+ {
+ this->buf = buf1;
+ }
- /** Constructs a DatagramPacket for receiving packets of length
- <code>length</code>. */
- DatagramPacket(void * buf, int length);
+ /** Set the data buffer for this packet. */
+ inline void setData(void* buf1, int offset1, int length1)
+ {
+ this->buf = buf1;
+ this->offset = offset1;
+ this->length = length1;
+ }
- /** Constructs a datagram packet for sending packets of length
- <code>length</code> to the specified port number on the specified
- host. */
- DatagramPacket(void * buf, int length, InetAddressPtr address, int port);
+ /** Set the length for this packet. */
+ inline void setLength(int length1)
+ {
+ this->length = length1;
+ }
- /** Constructs a DatagramPacket for receiving packets of length
- <code>length</code>, specifying an offset into the buffer. */
- DatagramPacket(void * buf, int offset, int length);
+ inline void setPort(int port1)
+ {
+ this->port = port1;
+ }
- /** Constructs a datagram packet for sending packets of length
- <code>length</code> with offset <code>offset</code> to the
- specified port number on the specified host. */
- DatagramPacket(void * buf, int offset, int length, InetAddressPtr address,
- int port);
+ private:
+ //
+ // prevent copy and assignment statements
+ DatagramPacket(const DatagramPacket&);
+ DatagramPacket& operator=(const DatagramPacket&);
- ~DatagramPacket();
-
- /** Returns the IP address of the machine to which this datagram
- is being sent or from which the datagram was received. */
- inline InetAddressPtr getAddress() const
- { return address; }
-
- /** Returns the data received or the data to be sent. */
- inline void * getData() const
- { return buf; }
-
- /** Returns the length of the data to be sent or the length of the
- data received. */
- inline int getLength() const
- { return length; }
-
- /** Returns the offset of the data to be sent or the offset of the
- data received. */
- inline int getOffset() const
- { return offset; }
-
- /** Returns the port number on the remote host to which this
- datagram is being sent or from which the datagram was received. */
- inline int getPort() const
- { return port; }
-
- inline void setAddress(InetAddressPtr address1)
- { this->address = address1; }
-
- /** Set the data buffer for this packet. */
- inline void setData(void * buf1)
- { this->buf = buf1; }
-
- /** Set the data buffer for this packet. */
- inline void setData(void * buf1, int offset1, int length1)
- { this->buf = buf1; this->offset = offset1; this->length = length1; }
-
- /** Set the length for this packet. */
- inline void setLength(int length1)
- { this->length = length1; }
-
- inline void setPort(int port1)
- { this->port = port1; }
-
- private:
- //
- // prevent copy and assignment statements
- DatagramPacket(const DatagramPacket&);
- DatagramPacket& operator=(const DatagramPacket&);
-
- }; // class DatagramPacket
- LOG4CXX_PTR_DEF(DatagramPacket);
- } // namespace helpers
+}; // class DatagramPacket
+LOG4CXX_PTR_DEF(DatagramPacket);
+} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_DATAGRAM_PACKET
diff --git a/src/main/include/log4cxx/helpers/datagramsocket.h b/src/main/include/log4cxx/helpers/datagramsocket.h
index 5e7db94..aa1ef35 100644
--- a/src/main/include/log4cxx/helpers/datagramsocket.h
+++ b/src/main/include/log4cxx/helpers/datagramsocket.h
@@ -24,105 +24,121 @@
#include <log4cxx/helpers/pool.h>
#include <log4cxx/helpers/datagrampacket.h>
-extern "C" { struct apr_socket_t; }
+extern "C" {
+ struct apr_socket_t;
+}
namespace log4cxx
{
- namespace helpers
+namespace helpers
+{
+/** This class represents a socket for sending and receiving
+datagram packets.*/
+class LOG4CXX_EXPORT DatagramSocket : public helpers::ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(DatagramSocket)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(DatagramSocket)
+ END_LOG4CXX_CAST_MAP()
+
+ /** Constructs a datagram socket and binds it to any available port
+ on the local host machine.*/
+ DatagramSocket();
+
+ /** Constructs a datagram socket and binds it to the specified
+ port on the local host machine. */
+ DatagramSocket(int port);
+
+ /** Creates a datagram socket, bound to the specified local
+ address. */
+ DatagramSocket(int port, InetAddressPtr laddr);
+
+ /** ensure the socket is closed. */
+ ~DatagramSocket();
+
+ /** Binds a datagram socket to a local port and address.*/
+ void bind(int lport, InetAddressPtr laddress);
+
+ /** Creates a datagram socket.*/
+ void create();
+
+ /** Closes this datagram socket */
+ void close();
+
+ /** Connects the socket to a remote address for this socket. */
+ void connect(InetAddressPtr address, int port);
+
+ /** Returns the address to which this socket is connected. */
+ inline InetAddressPtr getInetAddress() const
{
- /** This class represents a socket for sending and receiving
- datagram packets.*/
- class LOG4CXX_EXPORT DatagramSocket : public helpers::ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(DatagramSocket)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(DatagramSocket)
- END_LOG4CXX_CAST_MAP()
+ return address;
+ }
- /** Constructs a datagram socket and binds it to any available port
- on the local host machine.*/
- DatagramSocket();
+ /** Gets the local address to which the socket is bound. */
+ inline InetAddressPtr getLocalAddress() const
+ {
+ return localAddress;
+ }
- /** Constructs a datagram socket and binds it to the specified
- port on the local host machine. */
- DatagramSocket(int port);
+ /** Returns the port number on the local host to which this
+ socket is bound. */
+ inline int getLocalPort() const
+ {
+ return localPort;
+ }
- /** Creates a datagram socket, bound to the specified local
- address. */
- DatagramSocket(int port, InetAddressPtr laddr);
+ /** Returns the port for this socket */
+ inline int getPort() const
+ {
+ return port;
+ }
- /** ensure the socket is closed. */
- ~DatagramSocket();
+ /** Returns the binding state of the socket. **/
+ inline bool isBound() const
+ {
+ return localPort != 0;
+ }
- /** Binds a datagram socket to a local port and address.*/
- void bind(int lport, InetAddressPtr laddress);
+ /** Returns wether the socket is closed or not. */
+ inline bool isClosed() const
+ {
+ return socket != 0;
+ }
- /** Creates a datagram socket.*/
- void create();
+ /** Returns the connection state of the socket. */
+ inline bool isConnected() const
+ {
+ return port != 0;
+ }
- /** Closes this datagram socket */
- void close();
+ /** Receives a datagram packet from this socket. */
+ void receive(DatagramPacketPtr& p);
- /** Connects the socket to a remote address for this socket. */
- void connect(InetAddressPtr address, int port);
+ /** Sends a datagram packet from this socket. */
+ void send(DatagramPacketPtr& p);
- /** Returns the address to which this socket is connected. */
- inline InetAddressPtr getInetAddress() const
- { return address; }
+ private:
+ DatagramSocket(const DatagramSocket&);
+ DatagramSocket& operator=(const DatagramSocket&);
+ /** The APR socket */
+ apr_socket_t* socket;
- /** Gets the local address to which the socket is bound. */
- inline InetAddressPtr getLocalAddress() const
- { return localAddress; }
+ /** The memory pool for the socket */
+ Pool socketPool;
- /** Returns the port number on the local host to which this
- socket is bound. */
- inline int getLocalPort() const
- { return localPort; }
+ InetAddressPtr address;
- /** Returns the port for this socket */
- inline int getPort() const
- { return port; }
+ InetAddressPtr localAddress;
- /** Returns the binding state of the socket. **/
- inline bool isBound() const
- { return localPort != 0; }
+ int port;
- /** Returns wether the socket is closed or not. */
- inline bool isClosed() const
- { return socket != 0; }
+ /** The local port number to which this socket is connected. */
+ int localPort;
- /** Returns the connection state of the socket. */
- inline bool isConnected() const
- { return port != 0; }
-
- /** Receives a datagram packet from this socket. */
- void receive(DatagramPacketPtr& p);
-
- /** Sends a datagram packet from this socket. */
- void send(DatagramPacketPtr& p);
-
- private:
- DatagramSocket(const DatagramSocket&);
- DatagramSocket& operator=(const DatagramSocket&);
- /** The APR socket */
- apr_socket_t *socket;
-
- /** The memory pool for the socket */
- Pool socketPool;
-
- InetAddressPtr address;
-
- InetAddressPtr localAddress;
-
- int port;
-
- /** The local port number to which this socket is connected. */
- int localPort;
-
- };
- LOG4CXX_PTR_DEF(DatagramSocket);
- } // namespace helpers
+};
+LOG4CXX_PTR_DEF(DatagramSocket);
+} // namespace helpers
} // namespace log4cxx
#endif //_LOG4CXX_HELPERS_DATAGRAM_SOCKET_H
diff --git a/src/main/include/log4cxx/helpers/date.h b/src/main/include/log4cxx/helpers/date.h
index 6e3dc04..79217b5 100644
--- a/src/main/include/log4cxx/helpers/date.h
+++ b/src/main/include/log4cxx/helpers/date.h
@@ -22,45 +22,49 @@
#include <log4cxx/log4cxx.h>
-namespace log4cxx {
- namespace helpers {
- /**
- * Simple transcoder for converting between
- * external char and wchar_t strings and
- * internal strings.
- *
- */
- class LOG4CXX_EXPORT Date : public ObjectImpl {
- const log4cxx_time_t time;
+namespace log4cxx
+{
+namespace helpers
+{
+/**
+* Simple transcoder for converting between
+* external char and wchar_t strings and
+* internal strings.
+*
+*/
+class LOG4CXX_EXPORT Date : public ObjectImpl
+{
+ const log4cxx_time_t time;
- public:
- DECLARE_LOG4CXX_OBJECT(Date)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(Date)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_OBJECT(Date)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(Date)
+ END_LOG4CXX_CAST_MAP()
- Date();
- Date(log4cxx_time_t time);
- virtual ~Date();
+ Date();
+ Date(log4cxx_time_t time);
+ virtual ~Date();
- inline log4cxx_time_t getTime() const {
- return time;
- }
+ inline log4cxx_time_t getTime() const
+ {
+ return time;
+ }
- /**
- * Get start of next second
- */
- log4cxx_time_t getNextSecond() const;
+ /**
+ * Get start of next second
+ */
+ log4cxx_time_t getNextSecond() const;
- static log4cxx_time_t getMicrosecondsPerDay();
- static log4cxx_time_t getMicrosecondsPerSecond();
+ static log4cxx_time_t getMicrosecondsPerDay();
+ static log4cxx_time_t getMicrosecondsPerSecond();
- };
+};
- LOG4CXX_PTR_DEF(Date);
+LOG4CXX_PTR_DEF(Date);
- }
+}
}
diff --git a/src/main/include/log4cxx/helpers/dateformat.h b/src/main/include/log4cxx/helpers/dateformat.h
index 86bf1a9..11f9724 100644
--- a/src/main/include/log4cxx/helpers/dateformat.h
+++ b/src/main/include/log4cxx/helpers/dateformat.h
@@ -23,70 +23,71 @@
namespace log4cxx
{
- namespace helpers
- {
+namespace helpers
+{
- /**
- * DateFormat is an abstract class for date/time formatting
- * patterned after java.text.DateFormat.
- */
- class LOG4CXX_EXPORT DateFormat : public ObjectImpl {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(DateFormat)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(DateFormat)
- END_LOG4CXX_CAST_MAP()
+/**
+* DateFormat is an abstract class for date/time formatting
+* patterned after java.text.DateFormat.
+*/
+class LOG4CXX_EXPORT DateFormat : public ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(DateFormat)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(DateFormat)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Destructor
- */
- virtual ~DateFormat();
+ /**
+ * Destructor
+ */
+ virtual ~DateFormat();
- /**
- * Formats an log4cxx_time_t into a date/time string.
- * @param s string to which the date/time string is appended.
- * @param tm date to be formatted.
- * @param p memory pool used during formatting.
- */
- virtual void format(LogString &s, log4cxx_time_t tm, log4cxx::helpers::Pool& p) const = 0;
+ /**
+ * Formats an log4cxx_time_t into a date/time string.
+ * @param s string to which the date/time string is appended.
+ * @param tm date to be formatted.
+ * @param p memory pool used during formatting.
+ */
+ virtual void format(LogString& s, log4cxx_time_t tm, log4cxx::helpers::Pool& p) const = 0;
- /**
- * Sets the time zone.
- * @param zone the given new time zone.
- */
- virtual void setTimeZone(const TimeZonePtr& zone);
+ /**
+ * Sets the time zone.
+ * @param zone the given new time zone.
+ */
+ virtual void setTimeZone(const TimeZonePtr& zone);
- /**
- * Format an integer consistent with the format method.
- * @param s string to which the numeric string is appended.
- * @param n integer value.
- * @param p memory pool used during formatting.
- * @remarks This method is used by CachedDateFormat to
- * format the milliseconds.
- */
- virtual void numberFormat(LogString& s, int n, log4cxx::helpers::Pool& p) const;
+ /**
+ * Format an integer consistent with the format method.
+ * @param s string to which the numeric string is appended.
+ * @param n integer value.
+ * @param p memory pool used during formatting.
+ * @remarks This method is used by CachedDateFormat to
+ * format the milliseconds.
+ */
+ virtual void numberFormat(LogString& s, int n, log4cxx::helpers::Pool& p) const;
- protected:
- /**
- * Constructor.
- */
- DateFormat();
+ protected:
+ /**
+ * Constructor.
+ */
+ DateFormat();
- private:
- /**
- * Copy constructor definition to prevent copying.
- */
- DateFormat(const DateFormat&);
- /**
- * Assignment definition to prevent assignment.
- */
- DateFormat& operator=(const DateFormat&);
- };
- LOG4CXX_PTR_DEF(DateFormat);
+ private:
+ /**
+ * Copy constructor definition to prevent copying.
+ */
+ DateFormat(const DateFormat&);
+ /**
+ * Assignment definition to prevent assignment.
+ */
+ DateFormat& operator=(const DateFormat&);
+};
+LOG4CXX_PTR_DEF(DateFormat);
- } // namespace helpers
+} // namespace helpers
} // namespace log4cxx
#endif //_LOG4CXX_HELPERS_DATE_FORMAT_H
diff --git a/src/main/include/log4cxx/helpers/datelayout.h b/src/main/include/log4cxx/helpers/datelayout.h
index ca271ca..eb255c9 100644
--- a/src/main/include/log4cxx/helpers/datelayout.h
+++ b/src/main/include/log4cxx/helpers/datelayout.h
@@ -24,68 +24,76 @@
namespace log4cxx
{
- namespace helpers
+namespace helpers
+{
+/**
+This abstract layout takes care of all the date related options and
+formatting work.
+*/
+class LOG4CXX_EXPORT DateLayout : public Layout
+{
+ private:
+ LogString timeZoneID;
+ LogString dateFormatOption;
+
+ protected:
+ DateFormatPtr dateFormat;
+
+ public:
+ DateLayout(const LogString& dateLayoutOption);
+ virtual ~DateLayout();
+
+ virtual void activateOptions(log4cxx::helpers::Pool& p);
+ virtual void setOption(const LogString& option, const LogString& value);
+
+ /**
+ The value of the <b>DateFormat</b> option should be either an
+ argument to the constructor of helpers::DateFormat or one of
+ the strings <b>"NULL"</b>, <b>"RELATIVE"</b>, <b>"ABSOLUTE"</b>,
+ <b>"DATE"</b> or <b>"ISO8601</b>.
+ */
+ inline void setDateFormat(const LogString& dateFormat1)
{
- /**
- This abstract layout takes care of all the date related options and
- formatting work.
- */
- class LOG4CXX_EXPORT DateLayout : public Layout
- {
- private:
- LogString timeZoneID;
- LogString dateFormatOption;
+ this->dateFormatOption.assign(dateFormat1);
+ }
- protected:
- DateFormatPtr dateFormat;
+ /**
+ Returns value of the <b>DateFormat</b> option.
+ */
+ inline const LogString& getDateFormat() const
+ {
+ return dateFormatOption;
+ }
- public:
- DateLayout(const LogString& dateLayoutOption);
- virtual ~DateLayout();
+ /**
+ The <b>TimeZoneID</b> option is a time zone ID string in the format
+ expected by the <code>locale</code> C++ standard class.
+ */
+ inline void setTimeZone(const LogString& timeZone)
+ {
+ this->timeZoneID.assign(timeZone);
+ }
- virtual void activateOptions(log4cxx::helpers::Pool& p);
- virtual void setOption(const LogString& option, const LogString& value);
+ /**
+ Returns value of the <b>TimeZone</b> option.
+ */
+ inline const LogString& getTimeZone() const
+ {
+ return timeZoneID;
+ }
- /**
- The value of the <b>DateFormat</b> option should be either an
- argument to the constructor of helpers::DateFormat or one of
- the strings <b>"NULL"</b>, <b>"RELATIVE"</b>, <b>"ABSOLUTE"</b>,
- <b>"DATE"</b> or <b>"ISO8601</b>.
- */
- inline void setDateFormat(const LogString& dateFormat1)
- { this->dateFormatOption.assign(dateFormat1); }
+ void formatDate(LogString& s,
+ const spi::LoggingEventPtr& event,
+ log4cxx::helpers::Pool& p) const;
- /**
- Returns value of the <b>DateFormat</b> option.
- */
- inline const LogString& getDateFormat() const
- { return dateFormatOption; }
+ private:
+ //
+ // prevent copy and assignment
+ DateLayout(const DateLayout&);
+ DateLayout& operator=(const DateLayout&);
- /**
- The <b>TimeZoneID</b> option is a time zone ID string in the format
- expected by the <code>locale</code> C++ standard class.
- */
- inline void setTimeZone(const LogString& timeZone)
- { this->timeZoneID.assign(timeZone); }
-
- /**
- Returns value of the <b>TimeZone</b> option.
- */
- inline const LogString& getTimeZone() const
- { return timeZoneID; }
-
- void formatDate(LogString &s,
- const spi::LoggingEventPtr& event,
- log4cxx::helpers::Pool& p) const;
-
- private:
- //
- // prevent copy and assignment
- DateLayout(const DateLayout&);
- DateLayout& operator=(const DateLayout&);
-
- };
- } // namespace helpers
+};
+} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_DATE_LAYOUT_H
diff --git a/src/main/include/log4cxx/helpers/datetimedateformat.h b/src/main/include/log4cxx/helpers/datetimedateformat.h
index 1ed8988..f3521f5 100644
--- a/src/main/include/log4cxx/helpers/datetimedateformat.h
+++ b/src/main/include/log4cxx/helpers/datetimedateformat.h
@@ -22,21 +22,21 @@
namespace log4cxx
{
- namespace helpers
- {
- /**
- Formats a date in the format <b>dd MMM yyyy HH:mm:ss,SSS</b> for example,
- "06 Nov 1994 15:49:37,459".
- */
- class LOG4CXX_EXPORT DateTimeDateFormat : public SimpleDateFormat
- {
- public:
- DateTimeDateFormat()
- : SimpleDateFormat(LOG4CXX_STR("dd MMM yyyy HH:mm:ss,SSS")) {}
- DateTimeDateFormat(const std::locale* locale)
- : SimpleDateFormat(LOG4CXX_STR("dd MMM yyyy HH:mm:ss,SSS"), locale) {}
- };
- } // namespace helpers
+namespace helpers
+{
+/**
+Formats a date in the format <b>dd MMM yyyy HH:mm:ss,SSS</b> for example,
+"06 Nov 1994 15:49:37,459".
+*/
+class LOG4CXX_EXPORT DateTimeDateFormat : public SimpleDateFormat
+{
+ public:
+ DateTimeDateFormat()
+ : SimpleDateFormat(LOG4CXX_STR("dd MMM yyyy HH:mm:ss,SSS")) {}
+ DateTimeDateFormat(const std::locale* locale)
+ : SimpleDateFormat(LOG4CXX_STR("dd MMM yyyy HH:mm:ss,SSS"), locale) {}
+};
+} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_DATE_TIME_DATE_FORMAT_H
diff --git a/src/main/include/log4cxx/helpers/exception.h b/src/main/include/log4cxx/helpers/exception.h
index 0bfcae8..6e5c826 100644
--- a/src/main/include/log4cxx/helpers/exception.h
+++ b/src/main/include/log4cxx/helpers/exception.h
@@ -24,264 +24,268 @@
namespace log4cxx
{
- namespace helpers
- {
- /** The class Exception and its subclasses indicate conditions that a
- reasonable application might want to catch.
- */
- class LOG4CXX_EXPORT Exception : public ::std::exception
- {
- public:
- Exception(const char* msg);
- Exception(const LogString& msg);
- Exception(const Exception& src);
- Exception& operator=(const Exception& src);
- const char* what() const throw();
- private:
- enum { MSG_SIZE = 128 };
- char msg[MSG_SIZE + 1];
- }; // class Exception
+namespace helpers
+{
+/** The class Exception and its subclasses indicate conditions that a
+reasonable application might want to catch.
+*/
+class LOG4CXX_EXPORT Exception : public ::std::exception
+{
+ public:
+ Exception(const char* msg);
+ Exception(const LogString& msg);
+ Exception(const Exception& src);
+ Exception& operator=(const Exception& src);
+ const char* what() const throw();
+ private:
+ enum { MSG_SIZE = 128 };
+ char msg[MSG_SIZE + 1];
+}; // class Exception
- /** RuntimeException is the parent class of those exceptions that can be
- thrown during the normal operation of the process.
- */
- class LOG4CXX_EXPORT RuntimeException : public Exception
- {
- public:
- RuntimeException(log4cxx_status_t stat);
- RuntimeException(const LogString& msg);
- RuntimeException(const RuntimeException& msg);
- RuntimeException& operator=(const RuntimeException& src);
- private:
- static LogString formatMessage(log4cxx_status_t stat);
- }; // class RuntimeException
+/** RuntimeException is the parent class of those exceptions that can be
+thrown during the normal operation of the process.
+*/
+class LOG4CXX_EXPORT RuntimeException : public Exception
+{
+ public:
+ RuntimeException(log4cxx_status_t stat);
+ RuntimeException(const LogString& msg);
+ RuntimeException(const RuntimeException& msg);
+ RuntimeException& operator=(const RuntimeException& src);
+ private:
+ static LogString formatMessage(log4cxx_status_t stat);
+}; // class RuntimeException
- /** Thrown when an application attempts to use null in a case where an
- object is required.
- */
- class LOG4CXX_EXPORT NullPointerException : public RuntimeException
- {
- public:
- NullPointerException(const LogString& msg);
- NullPointerException(const NullPointerException& msg);
- NullPointerException& operator=(const NullPointerException& src);
- }; // class NullPointerException
+/** Thrown when an application attempts to use null in a case where an
+object is required.
+*/
+class LOG4CXX_EXPORT NullPointerException : public RuntimeException
+{
+ public:
+ NullPointerException(const LogString& msg);
+ NullPointerException(const NullPointerException& msg);
+ NullPointerException& operator=(const NullPointerException& src);
+}; // class NullPointerException
- /** Thrown to indicate that a method has been passed
- an illegal or inappropriate argument.*/
- class LOG4CXX_EXPORT IllegalArgumentException : public RuntimeException
- {
- public:
- IllegalArgumentException(const LogString& msg);
- IllegalArgumentException(const IllegalArgumentException&);
- IllegalArgumentException& operator=(const IllegalArgumentException&);
- }; // class IllegalArgumentException
+/** Thrown to indicate that a method has been passed
+an illegal or inappropriate argument.*/
+class LOG4CXX_EXPORT IllegalArgumentException : public RuntimeException
+{
+ public:
+ IllegalArgumentException(const LogString& msg);
+ IllegalArgumentException(const IllegalArgumentException&);
+ IllegalArgumentException& operator=(const IllegalArgumentException&);
+}; // class IllegalArgumentException
- /** Signals that an I/O exception of some sort has occurred. This class
- is the general class of exceptions produced by failed or interrupted
- I/O operations.
- */
- class LOG4CXX_EXPORT IOException : public Exception
- {
- public:
- IOException();
- IOException(log4cxx_status_t stat);
- IOException(const LogString& msg);
- IOException(const IOException &src);
- IOException& operator=(const IOException&);
- private:
- static LogString formatMessage(log4cxx_status_t stat);
- };
+/** Signals that an I/O exception of some sort has occurred. This class
+is the general class of exceptions produced by failed or interrupted
+I/O operations.
+*/
+class LOG4CXX_EXPORT IOException : public Exception
+{
+ public:
+ IOException();
+ IOException(log4cxx_status_t stat);
+ IOException(const LogString& msg);
+ IOException(const IOException& src);
+ IOException& operator=(const IOException&);
+ private:
+ static LogString formatMessage(log4cxx_status_t stat);
+};
- class LOG4CXX_EXPORT MissingResourceException : public Exception
- {
- public:
- MissingResourceException(const LogString& key);
- MissingResourceException(const MissingResourceException &src);
- MissingResourceException& operator=(const MissingResourceException&);
- private:
- static LogString formatMessage(const LogString& key);
- };
+class LOG4CXX_EXPORT MissingResourceException : public Exception
+{
+ public:
+ MissingResourceException(const LogString& key);
+ MissingResourceException(const MissingResourceException& src);
+ MissingResourceException& operator=(const MissingResourceException&);
+ private:
+ static LogString formatMessage(const LogString& key);
+};
- class LOG4CXX_EXPORT PoolException : public Exception
- {
- public:
- PoolException(log4cxx_status_t stat);
- PoolException(const PoolException &src);
- PoolException& operator=(const PoolException&);
- private:
- static LogString formatMessage(log4cxx_status_t stat);
- };
+class LOG4CXX_EXPORT PoolException : public Exception
+{
+ public:
+ PoolException(log4cxx_status_t stat);
+ PoolException(const PoolException& src);
+ PoolException& operator=(const PoolException&);
+ private:
+ static LogString formatMessage(log4cxx_status_t stat);
+};
- 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 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:
- InterruptedException();
- InterruptedException(log4cxx_status_t stat);
- InterruptedException(const InterruptedException &src);
- InterruptedException& operator=(const InterruptedException&);
- private:
- static LogString formatMessage(log4cxx_status_t stat);
- };
+class LOG4CXX_EXPORT InterruptedException : public Exception
+{
+ public:
+ InterruptedException();
+ InterruptedException(log4cxx_status_t stat);
+ InterruptedException(const InterruptedException& src);
+ InterruptedException& operator=(const InterruptedException&);
+ private:
+ static LogString formatMessage(log4cxx_status_t stat);
+};
- class LOG4CXX_EXPORT ThreadException
- : public Exception {
- public:
- ThreadException(log4cxx_status_t stat);
- ThreadException(const LogString& msg);
- ThreadException(const ThreadException &src);
- ThreadException& operator=(const ThreadException&);
- private:
- static LogString formatMessage(log4cxx_status_t stat);
- };
+class LOG4CXX_EXPORT ThreadException
+ : public Exception
+{
+ public:
+ ThreadException(log4cxx_status_t stat);
+ ThreadException(const LogString& msg);
+ ThreadException(const ThreadException& src);
+ ThreadException& operator=(const ThreadException&);
+ private:
+ static LogString formatMessage(log4cxx_status_t stat);
+};
- class LOG4CXX_EXPORT TranscoderException : public Exception
- {
- public:
- TranscoderException(log4cxx_status_t stat);
- TranscoderException(const TranscoderException &src);
- TranscoderException& operator=(const TranscoderException&);
- private:
- static LogString formatMessage(log4cxx_status_t stat);
- };
+class LOG4CXX_EXPORT TranscoderException : public Exception
+{
+ public:
+ TranscoderException(log4cxx_status_t stat);
+ TranscoderException(const TranscoderException& src);
+ TranscoderException& operator=(const TranscoderException&);
+ private:
+ static LogString formatMessage(log4cxx_status_t stat);
+};
- class LOG4CXX_EXPORT IllegalMonitorStateException
- : public Exception {
- public:
- IllegalMonitorStateException(const LogString& msg);
- IllegalMonitorStateException(const IllegalMonitorStateException& msg);
- IllegalMonitorStateException& operator=(const IllegalMonitorStateException& msg);
- };
+class LOG4CXX_EXPORT IllegalMonitorStateException
+ : public Exception
+{
+ public:
+ IllegalMonitorStateException(const LogString& msg);
+ IllegalMonitorStateException(const IllegalMonitorStateException& msg);
+ IllegalMonitorStateException& operator=(const IllegalMonitorStateException& msg);
+};
- /**
- Thrown when an application tries to create an instance of a class using
- the newInstance method in class Class, but the specified class object
- cannot be instantiated because it is an interface or is an abstract class.
- */
- class LOG4CXX_EXPORT InstantiationException : public Exception
- {
- public:
- InstantiationException(const LogString& msg);
- InstantiationException(const InstantiationException& msg);
- InstantiationException& operator=(const InstantiationException& msg);
- };
+/**
+Thrown when an application tries to create an instance of a class using
+the newInstance method in class Class, but the specified class object
+cannot be instantiated because it is an interface or is an abstract class.
+*/
+class LOG4CXX_EXPORT InstantiationException : public Exception
+{
+ public:
+ InstantiationException(const LogString& msg);
+ InstantiationException(const InstantiationException& msg);
+ InstantiationException& operator=(const InstantiationException& msg);
+};
- /**
- Thrown when an application tries to load in a class through its
- string name but no definition for the class with the specified name
- could be found.
- */
- class LOG4CXX_EXPORT ClassNotFoundException : public Exception
- {
- public:
- ClassNotFoundException(const LogString& className);
- ClassNotFoundException(const ClassNotFoundException& msg);
- ClassNotFoundException& operator=(const ClassNotFoundException& msg);
- private:
- static LogString formatMessage(const LogString& className);
- };
+/**
+Thrown when an application tries to load in a class through its
+string name but no definition for the class with the specified name
+could be found.
+*/
+class LOG4CXX_EXPORT ClassNotFoundException : public Exception
+{
+ public:
+ ClassNotFoundException(const LogString& className);
+ ClassNotFoundException(const ClassNotFoundException& msg);
+ ClassNotFoundException& operator=(const ClassNotFoundException& msg);
+ private:
+ static LogString formatMessage(const LogString& className);
+};
- class NoSuchElementException : public Exception {
- public:
- NoSuchElementException();
- NoSuchElementException(const NoSuchElementException&);
- NoSuchElementException& operator=(const NoSuchElementException&);
- };
+class NoSuchElementException : public Exception
+{
+ public:
+ NoSuchElementException();
+ NoSuchElementException(const NoSuchElementException&);
+ NoSuchElementException& operator=(const NoSuchElementException&);
+};
- class IllegalStateException : public Exception {
- public:
- IllegalStateException();
- IllegalStateException(const IllegalStateException&);
- IllegalStateException& operator=(const IllegalStateException&);
- };
+class IllegalStateException : public Exception
+{
+ public:
+ IllegalStateException();
+ IllegalStateException(const IllegalStateException&);
+ IllegalStateException& operator=(const IllegalStateException&);
+};
- /** Thrown to indicate that there is an error in the underlying
- protocol, such as a TCP error.
- */
- class LOG4CXX_EXPORT SocketException : public IOException
- {
- public:
- SocketException(const LogString& msg);
- SocketException(log4cxx_status_t status);
- SocketException(const SocketException&);
- SocketException& operator=(const SocketException&);
- };
+/** Thrown to indicate that there is an error in the underlying
+protocol, such as a TCP error.
+*/
+class LOG4CXX_EXPORT SocketException : public IOException
+{
+ public:
+ SocketException(const LogString& msg);
+ SocketException(log4cxx_status_t status);
+ SocketException(const SocketException&);
+ SocketException& operator=(const SocketException&);
+};
- /** Signals that an error occurred while attempting to connect a socket
- to a remote address and port. Typically, the connection was refused
- remotely (e.g., no process is listening on the remote address/port).
- */
- class LOG4CXX_EXPORT ConnectException : public SocketException
- {
- public:
- ConnectException(log4cxx_status_t status);
- ConnectException(const ConnectException& src);
- ConnectException& operator=(const ConnectException&);
- };
+/** Signals that an error occurred while attempting to connect a socket
+to a remote address and port. Typically, the connection was refused
+remotely (e.g., no process is listening on the remote address/port).
+*/
+class LOG4CXX_EXPORT ConnectException : public SocketException
+{
+ public:
+ ConnectException(log4cxx_status_t status);
+ ConnectException(const ConnectException& src);
+ ConnectException& operator=(const ConnectException&);
+};
- class LOG4CXX_EXPORT ClosedChannelException : public SocketException
- {
- public:
- ClosedChannelException();
- ClosedChannelException(const ClosedChannelException& src);
- ClosedChannelException& operator=(const ClosedChannelException&);
- };
+class LOG4CXX_EXPORT ClosedChannelException : public SocketException
+{
+ public:
+ ClosedChannelException();
+ ClosedChannelException(const ClosedChannelException& src);
+ ClosedChannelException& operator=(const ClosedChannelException&);
+};
- /** Signals that an error occurred while attempting to bind a socket to
- a local address and port. Typically, the port is in use, or the
- requested local address could not be assigned.
- */
- class LOG4CXX_EXPORT BindException : public SocketException
- {
- public:
- BindException(log4cxx_status_t status);
- BindException(const BindException&);
- BindException& operator=(const BindException&);
- };
+/** Signals that an error occurred while attempting to bind a socket to
+a local address and port. Typically, the port is in use, or the
+requested local address could not be assigned.
+*/
+class LOG4CXX_EXPORT BindException : public SocketException
+{
+ public:
+ BindException(log4cxx_status_t status);
+ BindException(const BindException&);
+ BindException& operator=(const BindException&);
+};
- /** Signals that an I/O operation has been interrupted. An
- InterruptedIOException is thrown to indicate that an input or output
- transfer has been terminated because the thread performing it was
- interrupted. The field bytesTransferred indicates how many bytes were
- successfully transferred before the interruption occurred.
- */
- class LOG4CXX_EXPORT InterruptedIOException : public IOException
- {
- public:
- InterruptedIOException(const LogString& msg);
- InterruptedIOException(const InterruptedIOException&);
- InterruptedIOException& operator=(const InterruptedIOException&);
- };
+/** Signals that an I/O operation has been interrupted. An
+InterruptedIOException is thrown to indicate that an input or output
+transfer has been terminated because the thread performing it was
+interrupted. The field bytesTransferred indicates how many bytes were
+successfully transferred before the interruption occurred.
+*/
+class LOG4CXX_EXPORT InterruptedIOException : public IOException
+{
+ public:
+ InterruptedIOException(const LogString& msg);
+ InterruptedIOException(const InterruptedIOException&);
+ InterruptedIOException& operator=(const InterruptedIOException&);
+};
- /** Signals that an I/O operation has been interrupted. An
- InterruptedIOException is thrown to indicate that an input or output
- transfer has been terminated because the thread performing it was
- interrupted. The field bytesTransferred indicates how many bytes were
- successfully transferred before the interruption occurred.
- */
- class LOG4CXX_EXPORT SocketTimeoutException : public InterruptedIOException
- {
- public:
- SocketTimeoutException();
- SocketTimeoutException(const SocketTimeoutException&);
- SocketTimeoutException& operator=(const SocketTimeoutException&);
- };
+/** Signals that an I/O operation has been interrupted. An
+InterruptedIOException is thrown to indicate that an input or output
+transfer has been terminated because the thread performing it was
+interrupted. The field bytesTransferred indicates how many bytes were
+successfully transferred before the interruption occurred.
+*/
+class LOG4CXX_EXPORT SocketTimeoutException : public InterruptedIOException
+{
+ public:
+ SocketTimeoutException();
+ SocketTimeoutException(const SocketTimeoutException&);
+ SocketTimeoutException& operator=(const SocketTimeoutException&);
+};
- } // namespace helpers
+} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_EXCEPTION_H
diff --git a/src/main/include/log4cxx/helpers/fileinputstream.h b/src/main/include/log4cxx/helpers/fileinputstream.h
index bfd4f92..6815307 100644
--- a/src/main/include/log4cxx/helpers/fileinputstream.h
+++ b/src/main/include/log4cxx/helpers/fileinputstream.h
@@ -26,70 +26,71 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
- /**
- * InputStream implemented on top of APR file IO.
- *
- */
- class LOG4CXX_EXPORT FileInputStream : public InputStream
- {
- private:
- Pool pool;
- apr_file_t* fileptr;
+/**
+ * InputStream implemented on top of APR file IO.
+ *
+ */
+class LOG4CXX_EXPORT FileInputStream : public InputStream
+{
+ private:
+ Pool pool;
+ apr_file_t* fileptr;
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(FileInputStream)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(FileInputStream)
- LOG4CXX_CAST_ENTRY_CHAIN(InputStream)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(FileInputStream)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(FileInputStream)
+ LOG4CXX_CAST_ENTRY_CHAIN(InputStream)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Creates a FileInputStream by opening a connection to an actual
- * file, the file named by the path name name in the file system.
- *
- * @param filename The system-dependent file name.
- */
- FileInputStream(const LogString& filename);
- FileInputStream(const logchar* filename);
+ /**
+ * Creates a FileInputStream by opening a connection to an actual
+ * file, the file named by the path name name in the file system.
+ *
+ * @param filename The system-dependent file name.
+ */
+ FileInputStream(const LogString& filename);
+ FileInputStream(const logchar* filename);
- /**
- * Creates a FileInputStream by opening a connection to an actual
- * file, the file named by the File object file in the file system.
- *
- * @param aFile The file to be opened for reading.
- */
- FileInputStream(const File& aFile);
+ /**
+ * Creates a FileInputStream by opening a connection to an actual
+ * file, the file named by the File object file in the file system.
+ *
+ * @param aFile The file to be opened for reading.
+ */
+ FileInputStream(const File& aFile);
- virtual ~FileInputStream();
+ virtual ~FileInputStream();
- /**
- * Closes this file input stream and releases any system
- * resources associated with the stream.
- */
- virtual void close();
+ /**
+ * Closes this file input stream and releases any system
+ * resources associated with the stream.
+ */
+ virtual void close();
- /**
- * Reads a sequence of bytes into the given buffer.
- *
- * @param buf The buffer into which bytes are to be transferred.
- * @return the total number of bytes read into the buffer, or -1 if there
- * is no more data because the end of the stream has been reached.
- */
- virtual int read(ByteBuffer& buf);
+ /**
+ * Reads a sequence of bytes into the given buffer.
+ *
+ * @param buf The buffer into which bytes are to be transferred.
+ * @return the total number of bytes read into the buffer, or -1 if there
+ * is no more data because the end of the stream has been reached.
+ */
+ virtual int read(ByteBuffer& buf);
- private:
+ private:
- FileInputStream(const FileInputStream&);
+ FileInputStream(const FileInputStream&);
- FileInputStream& operator=(const FileInputStream&);
- void open(const LogString&);
+ FileInputStream& operator=(const FileInputStream&);
+ void open(const LogString&);
- };
+};
- LOG4CXX_PTR_DEF(FileInputStream);
- } // namespace helpers
+LOG4CXX_PTR_DEF(FileInputStream);
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/fileoutputstream.h b/src/main/include/log4cxx/helpers/fileoutputstream.h
index 86ab41e..961f90a 100644
--- a/src/main/include/log4cxx/helpers/fileoutputstream.h
+++ b/src/main/include/log4cxx/helpers/fileoutputstream.h
@@ -26,44 +26,48 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
- /**
- * OutputStream implemented on top of APR file IO.
- */
- class LOG4CXX_EXPORT FileOutputStream : public OutputStream
- {
- private:
- Pool pool;
- apr_file_t* fileptr;
+/**
+* OutputStream implemented on top of APR file IO.
+*/
+class LOG4CXX_EXPORT FileOutputStream : public OutputStream
+{
+ private:
+ Pool pool;
+ apr_file_t* fileptr;
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(FileOutputStream)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(FileOutputStream)
- LOG4CXX_CAST_ENTRY_CHAIN(OutputStream)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(FileOutputStream)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(FileOutputStream)
+ LOG4CXX_CAST_ENTRY_CHAIN(OutputStream)
+ END_LOG4CXX_CAST_MAP()
- FileOutputStream(const LogString& filename, bool append = false);
- FileOutputStream(const logchar* filename, bool append = false);
- virtual ~FileOutputStream();
+ FileOutputStream(const LogString& filename, bool append = false);
+ FileOutputStream(const logchar* filename, bool append = false);
+ virtual ~FileOutputStream();
- virtual void close(Pool& p);
- virtual void flush(Pool& p);
- virtual void write(ByteBuffer& buf, Pool& p);
+ virtual void close(Pool& p);
+ virtual void flush(Pool& p);
+ virtual void write(ByteBuffer& buf, Pool& p);
#ifdef LOG4CXX_MULTI_PROCESS
- apr_file_t* getFilePtr() { return fileptr; }
+ apr_file_t* getFilePtr()
+ {
+ return fileptr;
+ }
#endif
- private:
- FileOutputStream(const FileOutputStream&);
- FileOutputStream& operator=(const FileOutputStream&);
- static apr_file_t* open(const LogString& fn, bool append,
- log4cxx::helpers::Pool& p);
- };
+ private:
+ FileOutputStream(const FileOutputStream&);
+ FileOutputStream& operator=(const FileOutputStream&);
+ static apr_file_t* open(const LogString& fn, bool append,
+ log4cxx::helpers::Pool& p);
+};
- LOG4CXX_PTR_DEF(FileOutputStream);
- } // namespace helpers
+LOG4CXX_PTR_DEF(FileOutputStream);
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/filewatchdog.h b/src/main/include/log4cxx/helpers/filewatchdog.h
index 0b8aa65..5ea94ba 100644
--- a/src/main/include/log4cxx/helpers/filewatchdog.h
+++ b/src/main/include/log4cxx/helpers/filewatchdog.h
@@ -26,60 +26,62 @@
namespace log4cxx
{
- namespace helpers
+namespace helpers
+{
+
+/**
+Check every now and then that a certain file has not changed. If it
+has, then call the #doOnChange method.
+*/
+class LOG4CXX_EXPORT FileWatchdog
+{
+ public:
+ virtual ~FileWatchdog();
+ /**
+ The default delay between every file modification check, set to 60
+ seconds. */
+ static long DEFAULT_DELAY /*= 60000*/;
+
+ protected:
+ /**
+ The name of the file to observe for changes.
+ */
+ File file;
+
+ /**
+ The delay to observe between every check.
+ By default set DEFAULT_DELAY.*/
+ long delay;
+ log4cxx_time_t lastModif;
+ bool warnedAlready;
+ volatile unsigned int interrupted;
+
+ protected:
+ FileWatchdog(const File& filename);
+ virtual void doOnChange() = 0;
+ void checkAndConfigure();
+
+ public:
+ /**
+ Set the delay to observe between each check of the file changes.
+ */
+ void setDelay(long delay1)
{
+ this->delay = delay1;
+ }
- /**
- Check every now and then that a certain file has not changed. If it
- has, then call the #doOnChange method.
- */
- class LOG4CXX_EXPORT FileWatchdog
- {
- public:
- virtual ~FileWatchdog();
- /**
- The default delay between every file modification check, set to 60
- seconds. */
- static long DEFAULT_DELAY /*= 60000*/;
+ void start();
- protected:
- /**
- The name of the file to observe for changes.
- */
- File file;
+ private:
+ static void* LOG4CXX_THREAD_FUNC run(apr_thread_t* thread, void* data);
+ Pool pool;
+ Thread thread;
- /**
- The delay to observe between every check.
- By default set DEFAULT_DELAY.*/
- long delay;
- log4cxx_time_t lastModif;
- bool warnedAlready;
- volatile unsigned int interrupted;
+ FileWatchdog(const FileWatchdog&);
+ FileWatchdog& operator=(const FileWatchdog&);
- protected:
- FileWatchdog(const File& filename);
- virtual void doOnChange() = 0;
- void checkAndConfigure();
-
- public:
- /**
- Set the delay to observe between each check of the file changes.
- */
- void setDelay(long delay1)
- { this->delay = delay1; }
-
- void start();
-
- private:
- static void* LOG4CXX_THREAD_FUNC run(apr_thread_t* thread, void* data);
- Pool pool;
- Thread thread;
-
- FileWatchdog(const FileWatchdog&);
- FileWatchdog& operator=(const FileWatchdog&);
-
- };
- } // namespace helpers
+};
+} // namespace helpers
} // namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/inetaddress.h b/src/main/include/log4cxx/helpers/inetaddress.h
index 155205e..1b0072d 100644
--- a/src/main/include/log4cxx/helpers/inetaddress.h
+++ b/src/main/include/log4cxx/helpers/inetaddress.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_HELPER_INETADDRESS_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
@@ -33,72 +33,72 @@
namespace log4cxx
{
- namespace helpers
- {
- class LOG4CXX_EXPORT UnknownHostException : public Exception
- {
- public:
- UnknownHostException(const LogString& msg);
- UnknownHostException(const UnknownHostException& src);
- UnknownHostException& operator=(const UnknownHostException& src);
- };
+namespace helpers
+{
+class LOG4CXX_EXPORT UnknownHostException : public Exception
+{
+ public:
+ UnknownHostException(const LogString& msg);
+ UnknownHostException(const UnknownHostException& src);
+ UnknownHostException& operator=(const UnknownHostException& src);
+};
- class InetAddress;
- LOG4CXX_PTR_DEF(InetAddress);
- LOG4CXX_LIST_DEF(InetAddressList, InetAddressPtr);
+class InetAddress;
+LOG4CXX_PTR_DEF(InetAddress);
+LOG4CXX_LIST_DEF(InetAddressList, InetAddressPtr);
- class LOG4CXX_EXPORT InetAddress : public ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(InetAddress)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(InetAddress)
- END_LOG4CXX_CAST_MAP()
+class LOG4CXX_EXPORT InetAddress : public ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(InetAddress)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(InetAddress)
+ END_LOG4CXX_CAST_MAP()
- InetAddress(const LogString& hostName, const LogString& hostAddr);
+ InetAddress(const LogString& hostName, const LogString& hostAddr);
- /** Determines all the IP addresses of a host, given the host's name.
- */
- static InetAddressList getAllByName(const LogString& host);
+ /** Determines all the IP addresses of a host, given the host's name.
+ */
+ static InetAddressList getAllByName(const LogString& host);
- /** Determines the IP address of a host, given the host's name.
- */
- static InetAddressPtr getByName(const LogString& host);
+ /** Determines the IP address of a host, given the host's name.
+ */
+ static InetAddressPtr getByName(const LogString& host);
- /** Returns the IP address string "%d.%d.%d.%d".
- */
- LogString getHostAddress() const;
+ /** Returns the IP address string "%d.%d.%d.%d".
+ */
+ LogString getHostAddress() const;
- /** Gets the host name for this IP address.
- */
- LogString getHostName() const;
+ /** Gets the host name for this IP address.
+ */
+ LogString getHostName() const;
- /** Returns the local host.
- */
- static InetAddressPtr getLocalHost();
+ /** Returns the local host.
+ */
+ static InetAddressPtr getLocalHost();
- /** Returns an InetAddress which can be used as any
- * address, for example when listening on a port from any
- * remote addresss.
- */
- static InetAddressPtr anyAddress();
+ /** Returns an InetAddress which can be used as any
+ * address, for example when listening on a port from any
+ * remote addresss.
+ */
+ static InetAddressPtr anyAddress();
- /** Converts this IP address to a String.
- */
- LogString toString() const;
+ /** Converts this IP address to a String.
+ */
+ LogString toString() const;
- private:
- LogString ipAddrString;
+ private:
+ LogString ipAddrString;
- LogString hostNameString;
+ LogString hostNameString;
- }; // class InetAddress
- } // namespace helpers
+}; // class InetAddress
+} // namespace helpers
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
diff --git a/src/main/include/log4cxx/helpers/inputstream.h b/src/main/include/log4cxx/helpers/inputstream.h
index 2885212..b13216c 100644
--- a/src/main/include/log4cxx/helpers/inputstream.h
+++ b/src/main/include/log4cxx/helpers/inputstream.h
@@ -23,49 +23,50 @@
namespace log4cxx
{
- namespace helpers {
- class ByteBuffer;
+namespace helpers
+{
+class ByteBuffer;
- /**
- * Abstract class for reading from character streams.
- *
- */
- class LOG4CXX_EXPORT InputStream : public ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(InputStream)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(InputStream)
- END_LOG4CXX_CAST_MAP()
+/**
+ * Abstract class for reading from character streams.
+ *
+ */
+class LOG4CXX_EXPORT InputStream : public ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(InputStream)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(InputStream)
+ END_LOG4CXX_CAST_MAP()
- protected:
- InputStream();
+ protected:
+ InputStream();
- virtual ~InputStream();
+ virtual ~InputStream();
- public:
- /**
- * Reads a sequence of bytes into the given buffer.
- *
- * @param dst The buffer into which bytes are to be transferred.
- * @return the total number of bytes read into the buffer, or -1 if there
- * is no more data because the end of the stream has been reached.
- */
- virtual int read(ByteBuffer& dst) = 0;
+ public:
+ /**
+ * Reads a sequence of bytes into the given buffer.
+ *
+ * @param dst The buffer into which bytes are to be transferred.
+ * @return the total number of bytes read into the buffer, or -1 if there
+ * is no more data because the end of the stream has been reached.
+ */
+ virtual int read(ByteBuffer& dst) = 0;
- /**
- * Closes this input stream and releases any system
- * resources associated with the stream.
- */
- virtual void close() = 0;
+ /**
+ * Closes this input stream and releases any system
+ * resources associated with the stream.
+ */
+ virtual void close() = 0;
- private:
- InputStream(const InputStream&);
- InputStream& operator=(const InputStream&);
- };
+ private:
+ InputStream(const InputStream&);
+ InputStream& operator=(const InputStream&);
+};
- LOG4CXX_PTR_DEF(InputStream);
- } // namespace helpers
+LOG4CXX_PTR_DEF(InputStream);
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/inputstreamreader.h b/src/main/include/log4cxx/helpers/inputstreamreader.h
index b2f1057..f34e8c9 100644
--- a/src/main/include/log4cxx/helpers/inputstreamreader.h
+++ b/src/main/include/log4cxx/helpers/inputstreamreader.h
@@ -25,69 +25,70 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
- /**
- * Class for reading from character streams.
- * Decorates a byte based InputStream and provides appropriate
- * conversion to characters.
- */
- class LOG4CXX_EXPORT InputStreamReader : public Reader
- {
- private:
- InputStreamPtr in;
- CharsetDecoderPtr dec;
+/**
+ * Class for reading from character streams.
+ * Decorates a byte based InputStream and provides appropriate
+ * conversion to characters.
+ */
+class LOG4CXX_EXPORT InputStreamReader : public Reader
+{
+ private:
+ InputStreamPtr in;
+ CharsetDecoderPtr dec;
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(InputStreamReader)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(InputStreamReader)
- LOG4CXX_CAST_ENTRY_CHAIN(Reader)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(InputStreamReader)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(InputStreamReader)
+ LOG4CXX_CAST_ENTRY_CHAIN(Reader)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Creates an InputStreamReader that uses the default charset.
- *
- * @param in The input stream to decorate.
- */
- InputStreamReader(const InputStreamPtr& in);
+ /**
+ * Creates an InputStreamReader that uses the default charset.
+ *
+ * @param in The input stream to decorate.
+ */
+ InputStreamReader(const InputStreamPtr& in);
- /**
- * Creates an InputStreamReader that uses the given charset decoder.
- *
- * @param in The input stream to decorate.
- * @param enc The charset decoder to use for the conversion.
- */
- InputStreamReader(const InputStreamPtr& in, const CharsetDecoderPtr &enc);
+ /**
+ * Creates an InputStreamReader that uses the given charset decoder.
+ *
+ * @param in The input stream to decorate.
+ * @param enc The charset decoder to use for the conversion.
+ */
+ InputStreamReader(const InputStreamPtr& in, const CharsetDecoderPtr& enc);
- ~InputStreamReader();
+ ~InputStreamReader();
- /**
- * Closes the stream.
- *
- * @param p The memory pool associated with the reader.
- */
- virtual void close(Pool& p);
+ /**
+ * Closes the stream.
+ *
+ * @param p The memory pool associated with the reader.
+ */
+ virtual void close(Pool& p);
- /**
- * @return The complete stream contents as a LogString.
- * @param p The memory pool associated with the reader.
- */
- virtual LogString read(Pool& p);
+ /**
+ * @return The complete stream contents as a LogString.
+ * @param p The memory pool associated with the reader.
+ */
+ virtual LogString read(Pool& p);
- /**
- * @return The name of the character encoding being used by this stream.
- */
- LogString getEncoding() const;
+ /**
+ * @return The name of the character encoding being used by this stream.
+ */
+ LogString getEncoding() const;
- private:
- InputStreamReader(const InputStreamReader&);
+ private:
+ InputStreamReader(const InputStreamReader&);
- InputStreamReader& operator=(const InputStreamReader&);
- };
+ InputStreamReader& operator=(const InputStreamReader&);
+};
- LOG4CXX_PTR_DEF(InputStreamReader);
- } // namespace helpers
+LOG4CXX_PTR_DEF(InputStreamReader);
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/integer.h b/src/main/include/log4cxx/helpers/integer.h
index 957edb0..3e8ed61 100644
--- a/src/main/include/log4cxx/helpers/integer.h
+++ b/src/main/include/log4cxx/helpers/integer.h
@@ -21,29 +21,33 @@
#include <log4cxx/helpers/objectimpl.h>
-namespace log4cxx {
- namespace helpers {
- class LOG4CXX_EXPORT Integer : public ObjectImpl {
- const int val;
- public:
- DECLARE_LOG4CXX_OBJECT(Integer)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(Integer)
- END_LOG4CXX_CAST_MAP()
+namespace log4cxx
+{
+namespace helpers
+{
+class LOG4CXX_EXPORT Integer : public ObjectImpl
+{
+ const int val;
+ public:
+ DECLARE_LOG4CXX_OBJECT(Integer)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(Integer)
+ END_LOG4CXX_CAST_MAP()
- Integer();
- Integer(int i);
- virtual ~Integer();
+ Integer();
+ Integer(int i);
+ virtual ~Integer();
- inline int intValue() const {
- return val;
- }
+ inline int intValue() const
+ {
+ return val;
+ }
- };
+};
- LOG4CXX_PTR_DEF(Integer);
+LOG4CXX_PTR_DEF(Integer);
- }
+}
}
diff --git a/src/main/include/log4cxx/helpers/iso8601dateformat.h b/src/main/include/log4cxx/helpers/iso8601dateformat.h
index b4e7e6e..1580538 100644
--- a/src/main/include/log4cxx/helpers/iso8601dateformat.h
+++ b/src/main/include/log4cxx/helpers/iso8601dateformat.h
@@ -22,24 +22,24 @@
namespace log4cxx
{
- namespace helpers
- {
- /**
- Formats a date in the format <b>yyyy-MM-dd HH:mm:ss,SSS</b> for example
- "1999-11-27 15:49:37,459".
+namespace helpers
+{
+/**
+Formats a date in the format <b>yyyy-MM-dd HH:mm:ss,SSS</b> for example
+"1999-11-27 15:49:37,459".
- <p>Refer to the
- <a href=http://www.cl.cam.ac.uk/~mgk25/iso-time.html>summary of the
- International Standard Date and Time Notation</a> for more
- information on this format.
- */
- class LOG4CXX_EXPORT ISO8601DateFormat : public SimpleDateFormat
- {
- public:
- ISO8601DateFormat()
- : SimpleDateFormat(LOG4CXX_STR("yyyy-MM-dd HH:mm:ss,SSS")) {}
- };
- } // namespace helpers
+<p>Refer to the
+<a href=http://www.cl.cam.ac.uk/~mgk25/iso-time.html>summary of the
+International Standard Date and Time Notation</a> for more
+information on this format.
+*/
+class LOG4CXX_EXPORT ISO8601DateFormat : public SimpleDateFormat
+{
+ public:
+ ISO8601DateFormat()
+ : SimpleDateFormat(LOG4CXX_STR("yyyy-MM-dd HH:mm:ss,SSS")) {}
+};
+} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_ISO_8601_DATE_FORMAT_H
diff --git a/src/main/include/log4cxx/helpers/loader.h b/src/main/include/log4cxx/helpers/loader.h
index 613b323..ae371c7 100644
--- a/src/main/include/log4cxx/helpers/loader.h
+++ b/src/main/include/log4cxx/helpers/loader.h
@@ -26,18 +26,18 @@
namespace log4cxx
{
- namespace helpers
- {
- class Class;
+namespace helpers
+{
+class Class;
- class LOG4CXX_EXPORT Loader
- {
- public:
- static const Class& loadClass(const LogString& clazz);
+class LOG4CXX_EXPORT Loader
+{
+ public:
+ static const Class& loadClass(const LogString& clazz);
- static InputStreamPtr getResourceAsStream(
- const LogString& name);
- };
- } // namespace helpers
+ static InputStreamPtr getResourceAsStream(
+ const LogString& name);
+};
+} // namespace helpers
} // namespace log4cxx
#endif //_LOG4CXX_HELPERS_LOADER_H
diff --git a/src/main/include/log4cxx/helpers/locale.h b/src/main/include/log4cxx/helpers/locale.h
index 6b0c881..e91d03b 100644
--- a/src/main/include/log4cxx/helpers/locale.h
+++ b/src/main/include/log4cxx/helpers/locale.h
@@ -22,28 +22,28 @@
namespace log4cxx
{
- namespace helpers
- {
- class LOG4CXX_EXPORT Locale
- {
- public:
- Locale(const LogString& language);
- Locale(const LogString& language, const LogString& country);
- Locale(const LogString& language, const LogString& country,
- const LogString& variant);
+namespace helpers
+{
+class LOG4CXX_EXPORT Locale
+{
+ public:
+ Locale(const LogString& language);
+ Locale(const LogString& language, const LogString& country);
+ Locale(const LogString& language, const LogString& country,
+ const LogString& variant);
- const LogString& getLanguage() const;
- const LogString& getCountry() const;
- const LogString& getVariant() const;
+ const LogString& getLanguage() const;
+ const LogString& getCountry() const;
+ const LogString& getVariant() const;
- protected:
- Locale(const Locale&);
- Locale& operator=(const Locale&);
- const LogString language;
- const LogString country;
- const LogString variant;
- }; // class Locale
- } // namespace helpers
+ protected:
+ Locale(const Locale&);
+ Locale& operator=(const Locale&);
+ const LogString language;
+ const LogString country;
+ const LogString variant;
+}; // class Locale
+} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_LOCALE_H
diff --git a/src/main/include/log4cxx/helpers/loglog.h b/src/main/include/log4cxx/helpers/loglog.h
index 913a0ef..9cc53b1 100644
--- a/src/main/include/log4cxx/helpers/loglog.h
+++ b/src/main/include/log4cxx/helpers/loglog.h
@@ -24,81 +24,81 @@
namespace log4cxx
{
- namespace helpers
- {
- /**
- This class used to output log statements from within the log4cxx package.
+namespace helpers
+{
+/**
+This class used to output log statements from within the log4cxx package.
- <p>Log4cxx components cannot make log4cxx logging calls. However, it is
- sometimes useful for the user to learn about what log4cxx is
- doing. You can enable log4cxx internal logging by calling the
- <b>#setInternalDebugging</b> method.
+<p>Log4cxx components cannot make log4cxx logging calls. However, it is
+sometimes useful for the user to learn about what log4cxx is
+doing. You can enable log4cxx internal logging by calling the
+<b>#setInternalDebugging</b> method.
- <p>All log4cxx internal debug calls go to standard output
- where as internal error messages are sent to
- standard error output. All internal messages are prepended with
- the string "log4cxx: ".
- */
- class LOG4CXX_EXPORT LogLog
- {
- private:
- bool debugEnabled;
+<p>All log4cxx internal debug calls go to standard output
+where as internal error messages are sent to
+standard error output. All internal messages are prepended with
+the string "log4cxx: ".
+*/
+class LOG4CXX_EXPORT LogLog
+{
+ private:
+ bool debugEnabled;
- /**
- In quietMode not even errors generate any output.
- */
- bool quietMode;
- Mutex mutex;
- LogLog();
- LogLog(const LogLog&);
- LogLog& operator=(const LogLog&);
- static LogLog& getInstance();
+ /**
+ In quietMode not even errors generate any output.
+ */
+ bool quietMode;
+ Mutex mutex;
+ LogLog();
+ LogLog(const LogLog&);
+ LogLog& operator=(const LogLog&);
+ static LogLog& getInstance();
- public:
- /**
- Allows to enable/disable log4cxx internal logging.
- */
- static void setInternalDebugging(bool enabled);
+ public:
+ /**
+ Allows to enable/disable log4cxx internal logging.
+ */
+ static void setInternalDebugging(bool enabled);
- /**
- This method is used to output log4cxx internal debug
- statements. Output goes to the standard output.
- */
- static void debug(const LogString& msg);
- static void debug(const LogString& msg, const std::exception& e);
+ /**
+ This method is used to output log4cxx internal debug
+ statements. Output goes to the standard output.
+ */
+ static void debug(const LogString& msg);
+ static void debug(const LogString& msg, const std::exception& e);
- /**
- This method is used to output log4cxx internal error
- statements. There is no way to disable error statements.
- Output goes to stderr.
- */
- static void error(const LogString& msg);
- static void error(const LogString& msg, const std::exception& e);
+ /**
+ This method is used to output log4cxx internal error
+ statements. There is no way to disable error statements.
+ Output goes to stderr.
+ */
+ static void error(const LogString& msg);
+ static void error(const LogString& msg, const std::exception& e);
- /**
- In quiet mode LogLog generates strictly no output, not even
- for errors.
+ /**
+ In quiet mode LogLog generates strictly no output, not even
+ for errors.
- @param quietMode <code>true</code> for no output.
- */
- static void setQuietMode(bool quietMode);
+ @param quietMode <code>true</code> for no output.
+ */
+ static void setQuietMode(bool quietMode);
- /**
- This method is used to output log4cxx internal warning
- statements. There is no way to disable warning statements.
- Output goes to stderr.
- */
- static void warn(const LogString& msg);
- static void warn(const LogString& msg, const std::exception& e);
+ /**
+ This method is used to output log4cxx internal warning
+ statements. There is no way to disable warning statements.
+ Output goes to stderr.
+ */
+ static void warn(const LogString& msg);
+ static void warn(const LogString& msg, const std::exception& e);
- private:
- static void emit(const LogString& msg);
- static void emit(const std::exception& ex);
- };
- } // namespace helpers
+ private:
+ static void emit(const LogString& msg);
+ static void emit(const std::exception& ex);
+};
+} // namespace helpers
} // namespace log4cxx
#define LOGLOG_DEBUG(log) { \
diff --git a/src/main/include/log4cxx/helpers/messagebuffer.h b/src/main/include/log4cxx/helpers/messagebuffer.h
index 3e5388d..fed365c 100644
--- a/src/main/include/log4cxx/helpers/messagebuffer.h
+++ b/src/main/include/log4cxx/helpers/messagebuffer.h
@@ -22,26 +22,29 @@
#include <log4cxx/logstring.h>
#include <sstream>
-namespace log4cxx {
+namespace log4cxx
+{
- namespace helpers {
+namespace helpers
+{
- void MessageBufferUseStaticStream();
+void MessageBufferUseStaticStream();
- typedef std::ios_base& (*ios_base_manip)(std::ios_base&);
+typedef std::ios_base& (*ios_base_manip)(std::ios_base&);
- /**
- * This class is used by the LOG4CXX_INFO and similar
- * macros to support insertion operators in the message parameter.
- * The class is not intended for use outside of that context.
- */
- class LOG4CXX_EXPORT CharMessageBuffer {
- public:
+/**
+ * This class is used by the LOG4CXX_INFO and similar
+ * macros to support insertion operators in the message parameter.
+ * The class is not intended for use outside of that context.
+ */
+class LOG4CXX_EXPORT CharMessageBuffer
+{
+ public:
/**
* Creates a new instance.
*/
- CharMessageBuffer();
+ CharMessageBuffer();
/**
* Destructor.
*/
@@ -142,24 +145,24 @@
*/
std::ostream& operator<<(void* val);
- /**
- * Cast to ostream.
- */
- operator std::basic_ostream<char>&();
+ /**
+ * Cast to ostream.
+ */
+ operator std::basic_ostream<char>& ();
- /**
- * Get content of buffer.
- * @param os used only to signal that
- * the embedded stream was used.
- */
- const std::basic_string<char>& str(std::basic_ostream<char>& os);
+ /**
+ * Get content of buffer.
+ * @param os used only to signal that
+ * the embedded stream was used.
+ */
+ const std::basic_string<char>& str(std::basic_ostream<char>& os);
- /**
- * Get content of buffer.
- * @param buf used only to signal that
- * the embedded stream was not used.
- */
- const std::basic_string<char>& str(CharMessageBuffer& buf);
+ /**
+ * Get content of buffer.
+ * @param buf used only to signal that
+ * the embedded stream was not used.
+ */
+ const std::basic_string<char>& str(CharMessageBuffer& buf);
/**
* Returns true if buffer has an encapsulated STL stream.
@@ -167,43 +170,45 @@
*/
bool hasStream() const;
- private:
+ private:
/**
* Prevent use of default copy constructor.
*/
- CharMessageBuffer(const CharMessageBuffer&);
+ CharMessageBuffer(const CharMessageBuffer&);
/**
* Prevent use of default assignment operator.
*/
- CharMessageBuffer& operator=(const CharMessageBuffer&);
+ CharMessageBuffer& operator=(const CharMessageBuffer&);
- /**
- * Encapsulated std::string.
- */
+ /**
+ * Encapsulated std::string.
+ */
std::basic_string<char> buf;
/**
* Encapsulated stream, created on demand.
*/
std::basic_ostringstream<char>* stream;
- };
+};
template<class V>
-std::basic_ostream<char>& operator<<(CharMessageBuffer& os, const V& val) {
- return ((std::basic_ostream<char>&) os) << val;
+std::basic_ostream<char>& operator<<(CharMessageBuffer& os, const V& val)
+{
+ return ((std::basic_ostream<char>&) os) << val;
}
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API || LOG4CXX_LOGCHAR_IS_UNICHAR
- /**
- * This class is designed to support insertion operations
- * in the message argument to the LOG4CXX_INFO and similar
- * macros and is not designed for general purpose use.
- */
- class LOG4CXX_EXPORT UniCharMessageBuffer {
- public:
+/**
+ * This class is designed to support insertion operations
+* in the message argument to the LOG4CXX_INFO and similar
+* macros and is not designed for general purpose use.
+*/
+class LOG4CXX_EXPORT UniCharMessageBuffer
+{
+ public:
/**
* Creates a new instance.
*/
- UniCharMessageBuffer();
+ UniCharMessageBuffer();
/**
* Destructor.
*/
@@ -239,12 +244,12 @@
UniCharMessageBuffer& operator<<(const UniChar msg);
#if LOG4CXX_CFSTRING_API
- /**
- * Appends a string into the buffer and
- * fixes the buffer to use char characters.
- * @param msg message to append.
- * @return encapsulated CharMessageBuffer.
- */
+ /**
+ * Appends a string into the buffer and
+ * fixes the buffer to use char characters.
+ * @param msg message to append.
+ * @return encapsulated CharMessageBuffer.
+ */
UniCharMessageBuffer& operator<<(const CFStringRef& msg);
#endif
@@ -318,23 +323,23 @@
/**
- * Cast to ostream.
- */
- operator uostream&();
+ * Cast to ostream.
+ */
+ operator uostream& ();
- /**
- * Get content of buffer.
- * @param os used only to signal that
- * the embedded stream was used.
- */
- const std::basic_string<UniChar>& str(uostream& os);
+ /**
+ * Get content of buffer.
+ * @param os used only to signal that
+ * the embedded stream was used.
+ */
+ const std::basic_string<UniChar>& str(uostream& os);
- /**
- * Get content of buffer.
- * @param buf used only to signal that
- * the embedded stream was not used.
- */
- const std::basic_string<UniChar>& str(UniCharMessageBuffer& buf);
+ /**
+ * Get content of buffer.
+ * @param buf used only to signal that
+ * the embedded stream was not used.
+ */
+ const std::basic_string<UniChar>& str(UniCharMessageBuffer& buf);
/**
* Returns true if buffer has an encapsulated STL stream.
@@ -342,44 +347,46 @@
*/
bool hasStream() const;
- private:
+ private:
/**
* Prevent use of default copy constructor.
*/
- UniCharMessageBuffer(const UniCharMessageBuffer&);
+ UniCharMessageBuffer(const UniCharMessageBuffer&);
/**
* Prevent use of default assignment operator.
*/
- UniCharMessageBuffer& operator=(const UniCharMessageBuffer&);
+ UniCharMessageBuffer& operator=(const UniCharMessageBuffer&);
- /**
- * Encapsulated std::string.
- */
+ /**
+ * Encapsulated std::string.
+ */
std::basic_string<UniChar> buf;
/**
* Encapsulated stream, created on demand.
*/
std::basic_ostringstream<UniChar>* stream;
- };
+};
template<class V>
-UniCharMessageBuffer::uostream& operator<<(UniCharMessageBuffer& os, const V& val) {
- return ((UniCharMessageBuffer::uostream&) os) << val;
+UniCharMessageBuffer::uostream& operator<<(UniCharMessageBuffer& os, const V& val)
+{
+ return ((UniCharMessageBuffer::uostream&) os) << val;
}
#endif
#if LOG4CXX_WCHAR_T_API
- /**
- * This class is designed to support insertion operations
- * in the message argument to the LOG4CXX_INFO and similar
- * macros and is not designed for general purpose use.
- */
- class LOG4CXX_EXPORT WideMessageBuffer {
- public:
+/**
+ * This class is designed to support insertion operations
+* in the message argument to the LOG4CXX_INFO and similar
+* macros and is not designed for general purpose use.
+*/
+class LOG4CXX_EXPORT WideMessageBuffer
+{
+ public:
/**
* Creates a new instance.
*/
- WideMessageBuffer();
+ WideMessageBuffer();
/**
* Destructor.
*/
@@ -482,23 +489,23 @@
/**
- * Cast to ostream.
- */
- operator std::basic_ostream<wchar_t>&();
+ * Cast to ostream.
+ */
+ operator std::basic_ostream<wchar_t>& ();
- /**
- * Get content of buffer.
- * @param os used only to signal that
- * the embedded stream was used.
- */
- const std::basic_string<wchar_t>& str(std::basic_ostream<wchar_t>& os);
+ /**
+ * Get content of buffer.
+ * @param os used only to signal that
+ * the embedded stream was used.
+ */
+ const std::basic_string<wchar_t>& str(std::basic_ostream<wchar_t>& os);
- /**
- * Get content of buffer.
- * @param buf used only to signal that
- * the embedded stream was not used.
- */
- const std::basic_string<wchar_t>& str(WideMessageBuffer& buf);
+ /**
+ * Get content of buffer.
+ * @param buf used only to signal that
+ * the embedded stream was not used.
+ */
+ const std::basic_string<wchar_t>& str(WideMessageBuffer& buf);
/**
* Returns true if buffer has an encapsulated STL stream.
@@ -506,58 +513,60 @@
*/
bool hasStream() const;
- private:
+ private:
/**
* Prevent use of default copy constructor.
*/
- WideMessageBuffer(const WideMessageBuffer&);
+ WideMessageBuffer(const WideMessageBuffer&);
/**
* Prevent use of default assignment operator.
*/
- WideMessageBuffer& operator=(const WideMessageBuffer&);
+ WideMessageBuffer& operator=(const WideMessageBuffer&);
- /**
- * Encapsulated std::string.
- */
+ /**
+ * Encapsulated std::string.
+ */
std::basic_string<wchar_t> buf;
/**
* Encapsulated stream, created on demand.
*/
std::basic_ostringstream<wchar_t>* stream;
- };
+};
template<class V>
-std::basic_ostream<wchar_t>& operator<<(WideMessageBuffer& os, const V& val) {
- return ((std::basic_ostream<wchar_t>&) os) << val;
+std::basic_ostream<wchar_t>& operator<<(WideMessageBuffer& os, const V& val)
+{
+ return ((std::basic_ostream<wchar_t>&) os) << val;
}
- /**
- * This class is used by the LOG4CXX_INFO and similar
- * macros to support insertion operators in the message parameter.
- * The class is not intended for use outside of that context.
- */
- class LOG4CXX_EXPORT MessageBuffer {
- public:
+/**
+ * This class is used by the LOG4CXX_INFO and similar
+ * macros to support insertion operators in the message parameter.
+ * The class is not intended for use outside of that context.
+ */
+class LOG4CXX_EXPORT MessageBuffer
+{
+ public:
/**
* Creates a new instance.
*/
- MessageBuffer();
- /**
- * Destructor.
- */
- ~MessageBuffer();
+ MessageBuffer();
+ /**
+ * Destructor.
+ */
+ ~MessageBuffer();
- /**
- * Cast to ostream.
- */
- operator std::ostream&();
-
- /**
- * Appends a string into the buffer and
- * fixes the buffer to use char characters.
- * @param msg message to append.
- * @return encapsulated CharMessageBuffer.
+ /**
+ * Cast to ostream.
*/
+ operator std::ostream& ();
+
+ /**
+ * Appends a string into the buffer and
+ * fixes the buffer to use char characters.
+ * @param msg message to append.
+ * @return encapsulated CharMessageBuffer.
+ */
CharMessageBuffer& operator<<(const std::string& msg);
/**
* Appends a string into the buffer and
@@ -582,28 +591,28 @@
*/
CharMessageBuffer& operator<<(const char msg);
- /**
- * Get content of buffer.
- * @param buf used only to signal
- * the character type and that
- * the embedded stream was not used.
- */
- const std::string& str(CharMessageBuffer& buf);
-
- /**
- * Get content of buffer.
- * @param os used only to signal
- * the character type and that
- * the embedded stream was used.
- */
- const std::string& str(std::ostream& os);
-
- /**
- * Appends a string into the buffer and
- * fixes the buffer to use char characters.
- * @param msg message to append.
- * @return encapsulated CharMessageBuffer.
+ /**
+ * Get content of buffer.
+ * @param buf used only to signal
+ * the character type and that
+ * the embedded stream was not used.
*/
+ const std::string& str(CharMessageBuffer& buf);
+
+ /**
+ * Get content of buffer.
+ * @param os used only to signal
+ * the character type and that
+ * the embedded stream was used.
+ */
+ const std::string& str(std::ostream& os);
+
+ /**
+ * Appends a string into the buffer and
+ * fixes the buffer to use char characters.
+ * @param msg message to append.
+ * @return encapsulated CharMessageBuffer.
+ */
WideMessageBuffer& operator<<(const std::wstring& msg);
/**
* Appends a string into the buffer and
@@ -628,12 +637,12 @@
WideMessageBuffer& operator<<(const wchar_t msg);
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
- /**
- * Appends a string into the buffer and
- * fixes the buffer to use char characters.
- * @param msg message to append.
- * @return encapsulated CharMessageBuffer.
- */
+ /**
+ * Appends a string into the buffer and
+ * fixes the buffer to use char characters.
+ * @param msg message to append.
+ * @return encapsulated CharMessageBuffer.
+ */
UniCharMessageBuffer& operator<<(const std::basic_string<UniChar>& msg);
/**
* Appends a string into the buffer and
@@ -659,12 +668,12 @@
#endif
#if LOG4CXX_CFSTRING_API
- /**
- * Appends a string into the buffer and
- * fixes the buffer to use char characters.
- * @param msg message to append.
- * @return encapsulated CharMessageBuffer.
- */
+ /**
+ * Appends a string into the buffer and
+ * fixes the buffer to use char characters.
+ * @param msg message to append.
+ * @return encapsulated CharMessageBuffer.
+ */
UniCharMessageBuffer& operator<<(const CFStringRef& msg);
#endif
@@ -736,38 +745,38 @@
* @return encapsulated STL stream.
*/
std::ostream& operator<<(void* val);
- /**
- * Get content of buffer.
- * @param buf used only to signal
- * the character type and that
- * the embedded stream was not used.
- */
- const std::wstring& str(WideMessageBuffer& buf);
+ /**
+ * Get content of buffer.
+ * @param buf used only to signal
+ * the character type and that
+ * the embedded stream was not used.
+ */
+ const std::wstring& str(WideMessageBuffer& buf);
- /**
- * Get content of buffer.
- * @param os used only to signal
- * the character type and that
- * the embedded stream was used.
- */
- const std::wstring& str(std::basic_ostream<wchar_t>& os);
+ /**
+ * Get content of buffer.
+ * @param os used only to signal
+ * the character type and that
+ * the embedded stream was used.
+ */
+ const std::wstring& str(std::basic_ostream<wchar_t>& os);
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
- /**
- * Get content of buffer.
- * @param buf used only to signal
- * the character type and that
- * the embedded stream was not used.
- */
- const std::basic_string<UniChar>& str(UniCharMessageBuffer& buf);
+ /**
+ * Get content of buffer.
+ * @param buf used only to signal
+ * the character type and that
+ * the embedded stream was not used.
+ */
+ const std::basic_string<UniChar>& str(UniCharMessageBuffer& buf);
- /**
- * Get content of buffer.
- * @param os used only to signal
- * the character type and that
- * the embedded stream was used.
- */
- const std::basic_string<UniChar>& str(UniCharMessageBuffer::uostream& os);
+ /**
+ * Get content of buffer.
+ * @param os used only to signal
+ * the character type and that
+ * the embedded stream was used.
+ */
+ const std::basic_string<UniChar>& str(UniCharMessageBuffer::uostream& os);
#endif
/**
@@ -776,7 +785,7 @@
*/
bool hasStream() const;
- private:
+ private:
/**
* Prevent use of default copy constructor.
*/
@@ -801,23 +810,24 @@
*/
UniCharMessageBuffer* ubuf;
#endif
- };
+};
template<class V>
-std::ostream& operator<<(MessageBuffer& os, const V& val) {
- return ((std::ostream&) os) << val;
+std::ostream& operator<<(MessageBuffer& os, const V& val)
+{
+ return ((std::ostream&) os) << val;
}
#if LOG4CXX_LOGCHAR_IS_UTF8
-typedef CharMessageBuffer LogCharMessageBuffer;
+ typedef CharMessageBuffer LogCharMessageBuffer;
#endif
#if LOG4CXX_LOGCHAR_IS_WCHAR
-typedef WideMessageBuffer LogCharMessageBuffer;
+ typedef WideMessageBuffer LogCharMessageBuffer;
#endif
#if LOG4CXX_LOGCHAR_IS_UNICHAR
-typedef UniCharMessageBuffer LogCharMessageBuffer;
+ typedef UniCharMessageBuffer LogCharMessageBuffer;
#endif
#else
@@ -825,6 +835,7 @@
typedef CharMessageBuffer LogCharMessageBuffer;
#endif
-}}
+}
+}
#endif
diff --git a/src/main/include/log4cxx/helpers/mutex.h b/src/main/include/log4cxx/helpers/mutex.h
index abb912c..6b7001f 100644
--- a/src/main/include/log4cxx/helpers/mutex.h
+++ b/src/main/include/log4cxx/helpers/mutex.h
@@ -21,37 +21,37 @@
#include <log4cxx/log4cxx.h>
#if defined(RW_MUTEX)
-#include <apr_portable.h>
-#include <atomic>
+ #include <apr_portable.h>
+ #include <atomic>
#endif
extern "C" {
- struct apr_thread_mutex_t;
- struct apr_pool_t;
- struct apr_thread_rwlock_t;
+ struct apr_thread_mutex_t;
+ struct apr_pool_t;
+ struct apr_thread_rwlock_t;
}
namespace log4cxx
{
- namespace helpers
- {
- class Pool;
+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;
+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
+ private:
+ Mutex(const Mutex&);
+ Mutex& operator=(const Mutex&);
+ apr_thread_mutex_t* mutex;
+};
+} // namespace helpers
} // namespace log4cxx
@@ -59,31 +59,31 @@
namespace log4cxx
{
- namespace helpers
- {
- class Pool;
+namespace helpers
+{
+class Pool;
- class LOG4CXX_EXPORT RWMutex
- {
- public:
- RWMutex(log4cxx::helpers::Pool& p);
- RWMutex(apr_pool_t* p);
- ~RWMutex();
+class LOG4CXX_EXPORT RWMutex
+{
+ public:
+ RWMutex(log4cxx::helpers::Pool& p);
+ RWMutex(apr_pool_t* p);
+ ~RWMutex();
- void rdLock() const;
- void rdUnlock() const;
+ void rdLock() const;
+ void rdUnlock() const;
- void wrLock() const;
- void wrUnlock() 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
+ 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
@@ -100,26 +100,26 @@
namespace log4cxx
{
- namespace helpers
- {
- struct SemaphoreImpl;
+namespace helpers
+{
+struct SemaphoreImpl;
- class LOG4CXX_EXPORT Semaphore
- {
- public:
- Semaphore(log4cxx::helpers::Pool& p);
- ~Semaphore();
+class LOG4CXX_EXPORT Semaphore
+{
+ public:
+ Semaphore(log4cxx::helpers::Pool& p);
+ ~Semaphore();
- void await() const;
- void signalAll() const;
+ void await() const;
+ void signalAll() const;
- private:
- Semaphore(const Semaphore&);
- Semaphore& operator=(const Semaphore&);
+ private:
+ Semaphore(const Semaphore&);
+ Semaphore& operator=(const Semaphore&);
- SemaphoreImpl *impl;
- };
- } // namespace helpers
+ SemaphoreImpl* impl;
+};
+} // namespace helpers
} // namespace log4cxx
#endif // NON_BLOCKING
diff --git a/src/main/include/log4cxx/helpers/object.h b/src/main/include/log4cxx/helpers/object.h
index b9386c4..3980802 100644
--- a/src/main/include/log4cxx/helpers/object.h
+++ b/src/main/include/log4cxx/helpers/object.h
@@ -25,114 +25,114 @@
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)\
-public:\
-class Clazz##object : public helpers::Class\
-{\
-public:\
- Clazz##object() : helpers::Class() {}\
- virtual ~Clazz##object() {}\
- virtual log4cxx::LogString getName() const { return LOG4CXX_STR(#object); } \
-};\
-virtual const helpers::Class& getClass() const;\
-static const helpers::Class& getStaticClass(); \
-static const log4cxx::helpers::ClassRegistration& registerClass();
+ public:\
+ class Clazz##object : public helpers::Class\
+ {\
+ public:\
+ Clazz##object() : helpers::Class() {}\
+ virtual ~Clazz##object() {}\
+ virtual log4cxx::LogString getName() const { return LOG4CXX_STR(#object); } \
+ };\
+ virtual const helpers::Class& getClass() const;\
+ static const helpers::Class& getStaticClass(); \
+ static const log4cxx::helpers::ClassRegistration& registerClass();
#define DECLARE_LOG4CXX_OBJECT(object)\
-public:\
-class Clazz##object : public helpers::Class\
-{\
-public:\
- Clazz##object() : helpers::Class() {}\
- virtual ~Clazz##object() {}\
- virtual log4cxx::LogString getName() const { return LOG4CXX_STR(#object); } \
- virtual helpers::ObjectPtr newInstance() const\
- {\
+ public:\
+ class Clazz##object : public helpers::Class\
+ {\
+ public:\
+ Clazz##object() : helpers::Class() {}\
+ virtual ~Clazz##object() {}\
+ virtual log4cxx::LogString getName() const { return LOG4CXX_STR(#object); } \
+ virtual helpers::ObjectPtr newInstance() const\
+ {\
return new object();\
- }\
-};\
-virtual const helpers::Class& getClass() const;\
-static const helpers::Class& getStaticClass(); \
-static const log4cxx::helpers::ClassRegistration& registerClass();
+ }\
+ };\
+ virtual const helpers::Class& getClass() const;\
+ static const helpers::Class& getStaticClass(); \
+ static const log4cxx::helpers::ClassRegistration& registerClass();
#define DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\
-public:\
-virtual const helpers::Class& getClass() const;\
-static const helpers::Class& getStaticClass();\
-static const log4cxx::helpers::ClassRegistration& registerClass();
+ public:\
+ virtual const helpers::Class& getClass() const;\
+ static const helpers::Class& getStaticClass();\
+ static const log4cxx::helpers::ClassRegistration& registerClass();
#define IMPLEMENT_LOG4CXX_OBJECT(object)\
-const ::log4cxx::helpers::Class& object::getClass() const { return getStaticClass(); }\
-const ::log4cxx::helpers::Class& object::getStaticClass() { \
- static Clazz##object theClass; \
- return theClass; \
-} \
-const log4cxx::helpers::ClassRegistration& object::registerClass() { \
- static log4cxx::helpers::ClassRegistration classReg(object::getStaticClass); \
- return classReg; \
-}\
-namespace log4cxx { namespace classes { \
-const ::log4cxx::helpers::ClassRegistration& object##Registration = object::registerClass(); \
-} }
+ const ::log4cxx::helpers::Class& object::getClass() const { return getStaticClass(); }\
+ const ::log4cxx::helpers::Class& object::getStaticClass() { \
+ static Clazz##object theClass; \
+ return theClass; \
+ } \
+ const log4cxx::helpers::ClassRegistration& object::registerClass() { \
+ static log4cxx::helpers::ClassRegistration classReg(object::getStaticClass); \
+ return classReg; \
+ }\
+ namespace log4cxx { namespace classes { \
+ const ::log4cxx::helpers::ClassRegistration& object##Registration = object::registerClass(); \
+ } }
#define IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(object, class)\
-const log4cxx::helpers::Class& object::getClass() const { return getStaticClass(); }\
-const log4cxx::helpers::Class& object::getStaticClass() { \
- static class theClass; \
- return theClass; \
-} \
-const log4cxx::helpers::ClassRegistration& object::registerClass() { \
- static log4cxx::helpers::ClassRegistration classReg(object::getStaticClass); \
- return classReg; \
-}\
-namespace log4cxx { namespace classes { \
-const log4cxx::helpers::ClassRegistration& object##Registration = object::registerClass(); \
-} }
+ const log4cxx::helpers::Class& object::getClass() const { return getStaticClass(); }\
+ const log4cxx::helpers::Class& object::getStaticClass() { \
+ static class theClass; \
+ return theClass; \
+ } \
+ const log4cxx::helpers::ClassRegistration& object::registerClass() { \
+ static log4cxx::helpers::ClassRegistration classReg(object::getStaticClass); \
+ return classReg; \
+ }\
+ namespace log4cxx { namespace classes { \
+ const log4cxx::helpers::ClassRegistration& object##Registration = object::registerClass(); \
+ } }
namespace log4cxx
{
- class AppenderSkeleton;
- class Logger;
+class AppenderSkeleton;
+class Logger;
- namespace helpers
- {
- class Pool;
+namespace helpers
+{
+class Pool;
- /** base class for java-like objects.*/
- class LOG4CXX_EXPORT Object
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(Object)
- virtual ~Object() {}
- virtual void addRef() const = 0;
- virtual void releaseRef() const = 0;
- virtual bool instanceof(const Class& clazz) const = 0;
- virtual const void * cast(const Class& clazz) const = 0;
- };
- LOG4CXX_PTR_DEF(Object);
- }
+/** base class for java-like objects.*/
+class LOG4CXX_EXPORT Object
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(Object)
+ virtual ~Object() {}
+ virtual void addRef() const = 0;
+ virtual void releaseRef() const = 0;
+ virtual bool instanceof(const Class& clazz) const = 0;
+ virtual const void* cast(const Class& clazz) const = 0;
+};
+LOG4CXX_PTR_DEF(Object);
+}
}
#define BEGIN_LOG4CXX_CAST_MAP()\
-const void * cast(const helpers::Class& clazz) const\
-{\
+ const void * cast(const helpers::Class& clazz) const\
+ {\
const void * object = 0;\
if (&clazz == &helpers::Object::getStaticClass()) return (const helpers::Object *)this;
#define END_LOG4CXX_CAST_MAP()\
- return object;\
-}\
-bool instanceof(const helpers::Class& clazz) const\
-{ return cast(clazz) != 0; }
+ return object;\
+ }\
+ bool instanceof(const helpers::Class& clazz) const\
+ { return cast(clazz) != 0; }
#define LOG4CXX_CAST_ENTRY(Interface)\
-if (&clazz == &Interface::getStaticClass()) return (const Interface *)this;
+ if (&clazz == &Interface::getStaticClass()) return (const Interface *)this;
#define LOG4CXX_CAST_ENTRY2(Interface, interface2)\
-if (&clazz == &Interface::getStaticClass()) return (Interface *)(interface2 *)this;
+ if (&clazz == &Interface::getStaticClass()) return (Interface *)(interface2 *)this;
#define LOG4CXX_CAST_ENTRY_CHAIN(Interface)\
-object = Interface::cast(clazz);\
-if (object != 0) return object;
+ object = Interface::cast(clazz);\
+ if (object != 0) return object;
#endif //_LOG4CXX_HELPERS_OBJECT_H
diff --git a/src/main/include/log4cxx/helpers/objectimpl.h b/src/main/include/log4cxx/helpers/objectimpl.h
index 7de9417..8a59986 100644
--- a/src/main/include/log4cxx/helpers/objectimpl.h
+++ b/src/main/include/log4cxx/helpers/objectimpl.h
@@ -22,28 +22,28 @@
namespace log4cxx
{
- namespace helpers
- {
- /** Implementation class for Object.*/
- class LOG4CXX_EXPORT ObjectImpl : public virtual Object
- {
- public:
- ObjectImpl();
- virtual ~ObjectImpl();
- void addRef() const;
- void releaseRef() const;
+namespace helpers
+{
+/** Implementation class for Object.*/
+class LOG4CXX_EXPORT ObjectImpl : public virtual Object
+{
+ public:
+ ObjectImpl();
+ virtual ~ObjectImpl();
+ void addRef() const;
+ void releaseRef() const;
- protected:
- mutable unsigned int volatile ref;
+ protected:
+ mutable unsigned int volatile ref;
- private:
- //
- // prevent object copy and assignment
- //
- ObjectImpl(const ObjectImpl&);
- ObjectImpl& operator=(const ObjectImpl&);
- };
- }
+ private:
+ //
+ // prevent object copy and assignment
+ //
+ ObjectImpl(const ObjectImpl&);
+ ObjectImpl& operator=(const ObjectImpl&);
+};
+}
}
#endif //_LOG4CXX_HELPERS_OBJECT_IMPL_H
diff --git a/src/main/include/log4cxx/helpers/objectoutputstream.h b/src/main/include/log4cxx/helpers/objectoutputstream.h
index 515634a..cf1742e 100644
--- a/src/main/include/log4cxx/helpers/objectoutputstream.h
+++ b/src/main/include/log4cxx/helpers/objectoutputstream.h
@@ -25,76 +25,76 @@
namespace log4cxx
{
- namespace helpers
- {
- /**
- * Emulates java serialization.
- */
- class LOG4CXX_EXPORT ObjectOutputStream : public ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(ObjectOutputStream)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(ObjectOutputStream)
- END_LOG4CXX_CAST_MAP()
+namespace helpers
+{
+/**
+ * Emulates java serialization.
+ */
+class LOG4CXX_EXPORT ObjectOutputStream : public ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(ObjectOutputStream)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(ObjectOutputStream)
+ END_LOG4CXX_CAST_MAP()
- ObjectOutputStream(OutputStreamPtr os, Pool& p);
- virtual ~ObjectOutputStream();
+ ObjectOutputStream(OutputStreamPtr os, Pool& p);
+ virtual ~ObjectOutputStream();
- void close(Pool& p);
- void flush(Pool& p);
- void reset(Pool& p);
+ void close(Pool& p);
+ void flush(Pool& p);
+ void reset(Pool& p);
- void writeObject(const LogString&, Pool& p);
- void writeUTFString(const std::string&, Pool& p);
- void writeObject(const MDC::Map& mdc, Pool& p);
- void writeInt(int val, Pool& p);
- void writeLong(log4cxx_time_t val, Pool& p);
- void writeProlog(const char* className,
- int classDescIncrement,
- char* bytes,
- size_t len,
- Pool& p);
- void writeNull(Pool& p);
+ void writeObject(const LogString&, Pool& p);
+ void writeUTFString(const std::string&, Pool& p);
+ void writeObject(const MDC::Map& mdc, Pool& p);
+ void writeInt(int val, Pool& p);
+ void writeLong(log4cxx_time_t val, Pool& p);
+ void writeProlog(const char* className,
+ int classDescIncrement,
+ char* bytes,
+ size_t len,
+ Pool& p);
+ void writeNull(Pool& p);
- enum { STREAM_MAGIC = 0xACED };
- enum { STREAM_VERSION = 5 };
- enum
- {
- TC_NULL = 0x70,
- TC_REFERENCE = 0x71,
- TC_CLASSDESC = 0x72,
- TC_OBJECT = 0x73,
- TC_STRING = 0x74,
- TC_ARRAY = 0x75,
- TC_CLASS = 0x76,
- TC_BLOCKDATA = 0x77,
- TC_ENDBLOCKDATA = 0x78,
- TC_RESET = 0x79
- };
- enum
- {
- SC_WRITE_METHOD = 0x01,
- SC_SERIALIZABLE = 0x02
- };
+ enum { STREAM_MAGIC = 0xACED };
+ enum { STREAM_VERSION = 5 };
+ enum
+ {
+ TC_NULL = 0x70,
+ TC_REFERENCE = 0x71,
+ TC_CLASSDESC = 0x72,
+ TC_OBJECT = 0x73,
+ TC_STRING = 0x74,
+ TC_ARRAY = 0x75,
+ TC_CLASS = 0x76,
+ TC_BLOCKDATA = 0x77,
+ TC_ENDBLOCKDATA = 0x78,
+ TC_RESET = 0x79
+ };
+ enum
+ {
+ SC_WRITE_METHOD = 0x01,
+ SC_SERIALIZABLE = 0x02
+ };
- void writeByte(char val, Pool& p);
- void writeBytes(const char* bytes, size_t len, Pool& p);
+ void writeByte(char val, Pool& p);
+ void writeBytes(const char* bytes, size_t len, Pool& p);
- private:
- ObjectOutputStream(const ObjectOutputStream&);
- ObjectOutputStream& operator=(const ObjectOutputStream&);
+ private:
+ ObjectOutputStream(const ObjectOutputStream&);
+ ObjectOutputStream& operator=(const ObjectOutputStream&);
- OutputStreamPtr os;
- log4cxx::helpers::CharsetEncoderPtr utf8Encoder;
- const unsigned int objectHandleDefault;
- unsigned int objectHandle;
- typedef std::map<std::string, unsigned int> ClassDescriptionMap;
- ClassDescriptionMap* classDescriptions;
- };
+ OutputStreamPtr os;
+ log4cxx::helpers::CharsetEncoderPtr utf8Encoder;
+ const unsigned int objectHandleDefault;
+ unsigned int objectHandle;
+ typedef std::map<std::string, unsigned int> ClassDescriptionMap;
+ ClassDescriptionMap* classDescriptions;
+};
- LOG4CXX_PTR_DEF(ObjectOutputStream);
- } // namespace helpers
+LOG4CXX_PTR_DEF(ObjectOutputStream);
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/objectptr.h b/src/main/include/log4cxx/helpers/objectptr.h
index e547287..fd10083 100644
--- a/src/main/include/log4cxx/helpers/objectptr.h
+++ b/src/main/include/log4cxx/helpers/objectptr.h
@@ -28,161 +28,219 @@
// switching between the initialization styles.
//
#if LOG4CXX_HELGRIND
-#define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase() { exchange(x);
+ #define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase() { exchange(x);
#else
-#define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase(), p(x) {
+ #define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase(), p(x) {
#endif
namespace log4cxx
{
- namespace helpers
+namespace helpers
+{
+class Class;
+
+class LOG4CXX_EXPORT ObjectPtrBase
+{
+ public:
+ ObjectPtrBase();
+ virtual ~ObjectPtrBase();
+ static void checkNull(const int& null);
+ static void* exchange(void** destination, void* newValue);
+ virtual void* cast(const Class& cls) const = 0;
+};
+
+
+/** smart pointer to a Object descendant */
+template<typename T> class ObjectPtrT : public ObjectPtrBase
+{
+ public:
+ ObjectPtrT(const int& null)
+ _LOG4CXX_OBJECTPTR_INIT(0)
+ ObjectPtrBase::checkNull(null);
+}
+
+ObjectPtrT()
+_LOG4CXX_OBJECTPTR_INIT(0)
+}
+
+ObjectPtrT(T* p1)
+_LOG4CXX_OBJECTPTR_INIT(p1)
+
+if (this->p != 0)
+{
+ this->p->addRef();
+}
+}
+
+
+ObjectPtrT(const ObjectPtrT& p1)
+_LOG4CXX_OBJECTPTR_INIT(p1.p)
+
+if (this->p != 0)
+{
+ this->p->addRef();
+}
+}
+
+ObjectPtrT(const ObjectPtrBase& p1)
+_LOG4CXX_OBJECTPTR_INIT(reinterpret_cast<T*>(p1.cast(T::getStaticClass())))
+
+if (this->p != 0)
+{
+ this->p->addRef();
+}
+}
+
+ObjectPtrT(ObjectPtrBase& p1)
+_LOG4CXX_OBJECTPTR_INIT(reinterpret_cast<T*>(p1.cast(T::getStaticClass())))
+
+if (this->p != 0)
+{
+ this->p->addRef();
+}
+}
+
+
+~ObjectPtrT()
+{
+ if (p != 0)
{
- class Class;
-
- class LOG4CXX_EXPORT ObjectPtrBase {
- public:
- ObjectPtrBase();
- virtual ~ObjectPtrBase();
- static void checkNull(const int& null);
- static void* exchange(void** destination, void* newValue);
- virtual void* cast(const Class& cls) const = 0;
- };
-
-
- /** smart pointer to a Object descendant */
- template<typename T> class ObjectPtrT : public ObjectPtrBase
- {
- public:
- ObjectPtrT(const int& null)
- _LOG4CXX_OBJECTPTR_INIT(0)
- ObjectPtrBase::checkNull(null);
- }
-
- ObjectPtrT()
- _LOG4CXX_OBJECTPTR_INIT(0)
- }
-
- ObjectPtrT(T * p1)
- _LOG4CXX_OBJECTPTR_INIT(p1)
- if (this->p != 0)
- {
- this->p->addRef();
- }
- }
-
-
- ObjectPtrT(const ObjectPtrT& p1)
- _LOG4CXX_OBJECTPTR_INIT(p1.p)
- if (this->p != 0)
- {
- this->p->addRef();
- }
- }
-
- ObjectPtrT(const ObjectPtrBase& p1)
- _LOG4CXX_OBJECTPTR_INIT(reinterpret_cast<T*>(p1.cast(T::getStaticClass())))
- if (this->p != 0) {
- this->p->addRef();
- }
- }
-
- ObjectPtrT(ObjectPtrBase& p1)
- _LOG4CXX_OBJECTPTR_INIT(reinterpret_cast<T*>(p1.cast(T::getStaticClass())))
- if (this->p != 0) {
- this->p->addRef();
- }
- }
-
-
- ~ObjectPtrT()
- {
- if (p != 0) {
- p->releaseRef();
- }
- }
-
- ObjectPtrT& operator=(const ObjectPtrT& p1) {
- T* newPtr = p1.p;
- if (newPtr != 0) {
- newPtr->addRef();
- }
- T* oldPtr = exchange(newPtr);
- if (oldPtr != 0) {
- oldPtr->releaseRef();
- }
- return *this;
- }
-
- ObjectPtrT& operator=(const int& null) //throw(IllegalArgumentException)
- {
- //
- // throws IllegalArgumentException if null != 0
- //
- ObjectPtrBase::checkNull(null);
- T* oldPtr = exchange(0);
- if (oldPtr != 0) {
- oldPtr->releaseRef();
- }
- return *this;
- }
-
- ObjectPtrT& operator=(T* p1) {
- if (p1 != 0) {
- p1->addRef();
- }
- T* oldPtr = exchange(p1);
- if (oldPtr != 0) {
- oldPtr->releaseRef();
- }
- return *this;
- }
-
-
- ObjectPtrT& operator=(ObjectPtrBase& p1) {
- T* newPtr = reinterpret_cast<T*>(p1.cast(T::getStaticClass()));
- return operator=(newPtr);
- }
-
- ObjectPtrT& operator=(const ObjectPtrBase& p1) {
- T* newPtr = reinterpret_cast<T*>(p1.cast(T::getStaticClass()));
- return operator=(newPtr);
- }
-
- bool operator==(const ObjectPtrT& p1) const { return (this->p == p1.p); }
- bool operator!=(const ObjectPtrT& p1) const { return (this->p != p1.p); }
- bool operator<(const ObjectPtrT& p1) const { return (this->p < p1.p); }
- bool operator==(const T* p1) const { return (this->p == p1); }
- bool operator!=(const T* p1) const { return (this->p != p1); }
- bool operator<(const T* p1) const { return (this->p < p1); }
- T* operator->() const {return p; }
- T& operator*() const {return *p; }
- operator T*() const {return p; }
-
-
-
- private:
- T * p;
- virtual void* cast(const Class& cls) const {
- if (p != 0) {
- return const_cast<void*>(p->cast(cls));
- }
- return 0;
- }
- T* exchange(const T* newValue) {
- // Avoid GCC strict aliasing warnings
- union {
- T** in;
- void** out;
- } temp = { &p };
- return static_cast<T*>(ObjectPtrBase::exchange(
- temp.out,
- const_cast<T*>(newValue)));
- }
-
- };
-
-
+ p->releaseRef();
}
}
+ObjectPtrT& operator=(const ObjectPtrT& p1)
+{
+ T* newPtr = p1.p;
+
+ if (newPtr != 0)
+ {
+ newPtr->addRef();
+ }
+
+ T* oldPtr = exchange(newPtr);
+
+ if (oldPtr != 0)
+ {
+ oldPtr->releaseRef();
+ }
+
+ return *this;
+}
+
+ObjectPtrT& operator=(const int& null) //throw(IllegalArgumentException)
+{
+ //
+ // throws IllegalArgumentException if null != 0
+ //
+ ObjectPtrBase::checkNull(null);
+ T* oldPtr = exchange(0);
+
+ if (oldPtr != 0)
+ {
+ oldPtr->releaseRef();
+ }
+
+ return *this;
+}
+
+ObjectPtrT& operator=(T* p1)
+{
+ if (p1 != 0)
+ {
+ p1->addRef();
+ }
+
+ T* oldPtr = exchange(p1);
+
+ if (oldPtr != 0)
+ {
+ oldPtr->releaseRef();
+ }
+
+ return *this;
+}
+
+
+ObjectPtrT& operator=(ObjectPtrBase& p1)
+{
+ T* newPtr = reinterpret_cast<T*>(p1.cast(T::getStaticClass()));
+ return operator=(newPtr);
+}
+
+ObjectPtrT& operator=(const ObjectPtrBase& p1)
+{
+ T* newPtr = reinterpret_cast<T*>(p1.cast(T::getStaticClass()));
+ return operator=(newPtr);
+}
+
+bool operator==(const ObjectPtrT& p1) const
+{
+ return (this->p == p1.p);
+}
+bool operator!=(const ObjectPtrT& p1) const
+{
+ return (this->p != p1.p);
+}
+bool operator<(const ObjectPtrT& p1) const
+{
+ return (this->p < p1.p);
+}
+bool operator==(const T* p1) const
+{
+ return (this->p == p1);
+}
+bool operator!=(const T* p1) const
+{
+ return (this->p != p1);
+}
+bool operator<(const T* p1) const
+{
+ return (this->p < p1);
+}
+T* operator->() const
+{
+ return p;
+}
+T& operator*() const
+{
+ return *p;
+}
+operator T* () const
+{
+ return p;
+}
+
+
+
+private:
+T* p;
+virtual void* cast(const Class& cls) const
+{
+ if (p != 0)
+ {
+ return const_cast<void*>(p->cast(cls));
+ }
+
+ return 0;
+}
+T* exchange(const T* newValue)
+{
+ // Avoid GCC strict aliasing warnings
+ union
+ {
+ T** in;
+ void** out;
+ } temp = { &p };
+ return static_cast<T*>(ObjectPtrBase::exchange(
+ temp.out,
+ const_cast<T*>(newValue)));
+}
+
+};
+
+
+}
+}
+
#endif //_LOG4CXX_HELPERS_OBJECT_PTR_H
diff --git a/src/main/include/log4cxx/helpers/onlyonceerrorhandler.h b/src/main/include/log4cxx/helpers/onlyonceerrorhandler.h
index 296aa94..8a0e328 100644
--- a/src/main/include/log4cxx/helpers/onlyonceerrorhandler.h
+++ b/src/main/include/log4cxx/helpers/onlyonceerrorhandler.h
@@ -23,80 +23,80 @@
namespace log4cxx
{
- namespace helpers
- {
- /**
- The <code>OnlyOnceErrorHandler</code> implements log4cxx's default
- error handling policy which consists of emitting a message for the
- first error in an appender and ignoring all following errors.
+namespace helpers
+{
+/**
+The <code>OnlyOnceErrorHandler</code> implements log4cxx's default
+error handling policy which consists of emitting a message for the
+first error in an appender and ignoring all following errors.
- <p>The error message is printed on <code>System.err</code>.
+<p>The error message is printed on <code>System.err</code>.
- <p>This policy aims at protecting an otherwise working application
- from being flooded with error messages when logging fails
- */
- class LOG4CXX_EXPORT OnlyOnceErrorHandler :
- public virtual spi::ErrorHandler,
- public virtual ObjectImpl
- {
- private:
- LogString WARN_PREFIX;
- LogString ERROR_PREFIX;
- mutable bool firstTime;
+<p>This policy aims at protecting an otherwise working application
+from being flooded with error messages when logging fails
+*/
+class LOG4CXX_EXPORT OnlyOnceErrorHandler :
+ public virtual spi::ErrorHandler,
+ public virtual ObjectImpl
+{
+ private:
+ LogString WARN_PREFIX;
+ LogString ERROR_PREFIX;
+ mutable bool firstTime;
- public:
- DECLARE_LOG4CXX_OBJECT(OnlyOnceErrorHandler)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(spi::OptionHandler)
- LOG4CXX_CAST_ENTRY(spi::ErrorHandler)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_OBJECT(OnlyOnceErrorHandler)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(spi::OptionHandler)
+ LOG4CXX_CAST_ENTRY(spi::ErrorHandler)
+ END_LOG4CXX_CAST_MAP()
- OnlyOnceErrorHandler();
- void addRef() const;
- void releaseRef() const;
+ OnlyOnceErrorHandler();
+ void addRef() const;
+ void releaseRef() const;
- /**
- Does not do anything.
- */
- void setLogger(const LoggerPtr& logger);
+ /**
+ Does not do anything.
+ */
+ void setLogger(const LoggerPtr& logger);
- /**
- No options to activate.
- */
- void activateOptions(log4cxx::helpers::Pool& p);
- void setOption(const LogString& option, const LogString& value);
+ /**
+ No options to activate.
+ */
+ void activateOptions(log4cxx::helpers::Pool& p);
+ void setOption(const LogString& option, const LogString& value);
- /**
- Prints the message and the stack trace of the exception on
- <code>System.err</code>. */
- void error(const LogString& message, const std::exception& e,
- int errorCode) const;
- /**
- Prints the message and the stack trace of the exception on
- <code>System.err</code>.
- */
- void error(const LogString& message, const std::exception& e,
- int errorCode, const spi::LoggingEventPtr& event) const;
+ /**
+ Prints the message and the stack trace of the exception on
+ <code>System.err</code>. */
+ void error(const LogString& message, const std::exception& e,
+ int errorCode) const;
+ /**
+ Prints the message and the stack trace of the exception on
+ <code>System.err</code>.
+ */
+ void error(const LogString& message, const std::exception& e,
+ int errorCode, const spi::LoggingEventPtr& event) const;
- /**
- Print a the error message passed as parameter on
- <code>System.err</code>.
- */
- void error(const LogString& message) const;
+ /**
+ Print a the error message passed as parameter on
+ <code>System.err</code>.
+ */
+ void error(const LogString& message) const;
- /**
- Does not do anything.
- */
- void setAppender(const AppenderPtr& appender);
+ /**
+ Does not do anything.
+ */
+ void setAppender(const AppenderPtr& appender);
- /**
- Does not do anything.
- */
- void setBackupAppender(const AppenderPtr& appender);
- };
- } // namespace helpers
+ /**
+ Does not do anything.
+ */
+ void setBackupAppender(const AppenderPtr& appender);
+};
+} // namespace helpers
} // namespace log4cxx
#endif //_LOG4CXX_HELPERS_ONLY_ONCE_ERROR_HANDLER_H
diff --git a/src/main/include/log4cxx/helpers/optionconverter.h b/src/main/include/log4cxx/helpers/optionconverter.h
index 0aa3115..f95d91b 100644
--- a/src/main/include/log4cxx/helpers/optionconverter.h
+++ b/src/main/include/log4cxx/helpers/optionconverter.h
@@ -23,141 +23,141 @@
namespace log4cxx
{
- class Level;
- class File;
- typedef helpers::ObjectPtrT<Level> LevelPtr;
+class Level;
+class File;
+typedef helpers::ObjectPtrT<Level> LevelPtr;
- namespace spi
- {
- class LoggerRepository;
- typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
- }
+namespace spi
+{
+class LoggerRepository;
+typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
+}
- namespace helpers
- {
- class Properties;
+namespace helpers
+{
+class Properties;
- class Object;
- typedef ObjectPtrT<Object> ObjectPtr;
+class Object;
+typedef ObjectPtrT<Object> ObjectPtr;
- class Class;
+class Class;
- /** A convenience class to convert property values to specific types.*/
- class LOG4CXX_EXPORT OptionConverter
- {
- /** OptionConverter is a static class. */
- private:
- OptionConverter() {}
+/** A convenience class to convert property values to specific types.*/
+class LOG4CXX_EXPORT OptionConverter
+{
+ /** OptionConverter is a static class. */
+ private:
+ OptionConverter() {}
- public:
- static LogString convertSpecialChars(const LogString& s);
+ public:
+ static LogString convertSpecialChars(const LogString& s);
- /**
- If <code>value</code> is "true", then <code>true</code> is
- returned. If <code>value</code> is "false", then
- <code>true</code> is returned. Otherwise, <code>default</code> is
- returned.
+ /**
+ If <code>value</code> is "true", then <code>true</code> is
+ returned. If <code>value</code> is "false", then
+ <code>true</code> is returned. Otherwise, <code>default</code> is
+ returned.
- <p>Case of value is unimportant.
- */
- static bool toBoolean(const LogString& value, bool dEfault);
- static int toInt(const LogString& value, int dEfault);
- static long toFileSize(const LogString& value, long dEfault);
- static LevelPtr toLevel(const LogString& value,
+ <p>Case of value is unimportant.
+ */
+ static bool toBoolean(const LogString& value, bool dEfault);
+ static int toInt(const LogString& value, int dEfault);
+ static long toFileSize(const LogString& value, long dEfault);
+ static LevelPtr toLevel(const LogString& value,
const LevelPtr& defaultValue);
- /**
- Find the value corresponding to <code>key</code> in
- <code>props</code>. Then perform variable substitution on the
- found value.
- */
- static LogString findAndSubst(const LogString& key, Properties& props);
+ /**
+ Find the value corresponding to <code>key</code> in
+ <code>props</code>. Then perform variable substitution on the
+ found value.
+ */
+ static LogString findAndSubst(const LogString& key, Properties& props);
-/**
-Perform variable substitution in string <code>val</code> from the
-values of keys found in the system propeties.
+ /**
+ Perform variable substitution in string <code>val</code> from the
+ values of keys found in the system propeties.
-<p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
+ <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
-<p>For example, if the System properties contains "key=value", then
-the call
-<pre>
-String s = OptionConverter.substituteVars("Value of key is ${key}.");
-</pre>
+ <p>For example, if the System properties contains "key=value", then
+ the call
+ <pre>
+ String s = OptionConverter.substituteVars("Value of key is ${key}.");
+ </pre>
-will set the variable <code>s</code> to "Value of key is value.".
+ will set the variable <code>s</code> to "Value of key is value.".
-<p>If no value could be found for the specified key, then the
-<code>props</code> parameter is searched, if the value could not
-be found there, then substitution defaults to the empty string.
+ <p>If no value could be found for the specified key, then the
+ <code>props</code> parameter is searched, if the value could not
+ be found there, then substitution defaults to the empty string.
-<p>For example, if system propeties contains no value for the key
-"inexistentKey", then the call
+ <p>For example, if system propeties contains no value for the key
+ "inexistentKey", then the call
-<pre>
-String s = OptionConverter.subsVars("Value of inexistentKey is [${inexistentKey}]");
-</pre>
-will set <code>s</code> to "Value of inexistentKey is []"
+ <pre>
+ String s = OptionConverter.subsVars("Value of inexistentKey is [${inexistentKey}]");
+ </pre>
+ will set <code>s</code> to "Value of inexistentKey is []"
-<p>An IllegalArgumentException is thrown if
-<code>val</code> contains a start delimeter "${" which is not
-balanced by a stop delimeter "}". </p>
+ <p>An IllegalArgumentException is thrown if
+ <code>val</code> contains a start delimeter "${" which is not
+ balanced by a stop delimeter "}". </p>
-@param val The string on which variable substitution is performed.
-@param props The properties from which variable substitution is performed.
-@throws IllegalArgumentException if <code>val</code> is malformed.
-*/
- static LogString substVars(const LogString& val, Properties& props);
+ @param val The string on which variable substitution is performed.
+ @param props The properties from which variable substitution is performed.
+ @throws IllegalArgumentException if <code>val</code> is malformed.
+ */
+ static LogString substVars(const LogString& val, Properties& props);
- /**
- * Gets the specified system property.
- @param key The key to search for.
- @param def The default value to return.
- @return the string value of the system property, or the default
- value if there is no property with that key.
- */
- static LogString getSystemProperty(const LogString& key, const LogString& def);
+ /**
+ * Gets the specified system property.
+ @param key The key to search for.
+ @param def The default value to return.
+ @return the string value of the system property, or the default
+ value if there is no property with that key.
+ */
+ static LogString getSystemProperty(const LogString& key, const LogString& def);
- /**
- Instantiate an object given a class name. Check that the
- <code>className</code> is a subclass of
- <code>superClass</code>. If that test fails or the object could
- not be instantiated, then <code>defaultValue</code> is returned.
+ /**
+ Instantiate an object given a class name. Check that the
+ <code>className</code> is a subclass of
+ <code>superClass</code>. If that test fails or the object could
+ not be instantiated, then <code>defaultValue</code> is returned.
- @param className The fully qualified class name of the object to instantiate.
- @param superClass The class to which the new object should belong.
- @param defaultValue The object to return in case of non-fulfillment
- */
- static ObjectPtr instantiateByClassName(const LogString& className,
- const Class& superClass, const ObjectPtr& defaultValue);
+ @param className The fully qualified class name of the object to instantiate.
+ @param superClass The class to which the new object should belong.
+ @param defaultValue The object to return in case of non-fulfillment
+ */
+ static ObjectPtr instantiateByClassName(const LogString& className,
+ const Class& superClass, const ObjectPtr& defaultValue);
- static ObjectPtr instantiateByKey(Properties& props,
- const LogString& key, const Class& superClass,
- const ObjectPtr& defaultValue);
+ static ObjectPtr instantiateByKey(Properties& props,
+ const LogString& key, const Class& superClass,
+ const ObjectPtr& defaultValue);
- /**
- Configure log4cxx given a configFileName.
+ /**
+ Configure log4cxx given a configFileName.
- <p>The configFileName must point to a file which will be
- interpreted by a new instance of a log4cxx configurator.
+ <p>The configFileName must point to a file which will be
+ interpreted by a new instance of a log4cxx configurator.
- <p>All configurations steps are taken on the
- <code>hierarchy</code> passed as a parameter.
+ <p>All configurations steps are taken on the
+ <code>hierarchy</code> passed as a parameter.
- <p>
- @param configFileName The location of the configuration file.
- @param clazz The classname, of the log4cxx configurator which
- will parse the file <code>configFileName</code>. This must be
- a subclass of Configurator, or null. If this value is null then
- a default configurator of PropertyConfigurator is used, unless the
- filename pointed to by <code>configFileName</code> ends in '.xml',
- in which case DOMConfigurator is used.
- @param hierarchy The Hierarchy to act on.
- */
- static void selectAndConfigure(const File& configFileName,
- const LogString& clazz, spi::LoggerRepositoryPtr& hierarchy);
- };
- } // namespace helpers
+ <p>
+ @param configFileName The location of the configuration file.
+ @param clazz The classname, of the log4cxx configurator which
+ will parse the file <code>configFileName</code>. This must be
+ a subclass of Configurator, or null. If this value is null then
+ a default configurator of PropertyConfigurator is used, unless the
+ filename pointed to by <code>configFileName</code> ends in '.xml',
+ in which case DOMConfigurator is used.
+ @param hierarchy The Hierarchy to act on.
+ */
+ static void selectAndConfigure(const File& configFileName,
+ const LogString& clazz, spi::LoggerRepositoryPtr& hierarchy);
+};
+} // namespace helpers
} // namespace log4cxx
#endif //_LOG4CXX_HELPER_OPTION_CONVERTER_H
diff --git a/src/main/include/log4cxx/helpers/outputstream.h b/src/main/include/log4cxx/helpers/outputstream.h
index d8b11d7..f283355 100644
--- a/src/main/include/log4cxx/helpers/outputstream.h
+++ b/src/main/include/log4cxx/helpers/outputstream.h
@@ -20,46 +20,47 @@
#include <log4cxx/helpers/objectimpl.h>
#ifdef LOG4CXX_MULTI_PROCESS
-#include <apr_file_io.h>
+ #include <apr_file_io.h>
#endif
namespace log4cxx
{
- namespace helpers {
- class ByteBuffer;
+namespace helpers
+{
+class ByteBuffer;
- /**
- * Abstract class for writing to character streams.
- */
- class LOG4CXX_EXPORT OutputStream : public ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(OutputStream)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(OutputStream)
- END_LOG4CXX_CAST_MAP()
+/**
+* Abstract class for writing to character streams.
+*/
+class LOG4CXX_EXPORT OutputStream : public ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(OutputStream)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(OutputStream)
+ END_LOG4CXX_CAST_MAP()
- protected:
- OutputStream();
- virtual ~OutputStream();
+ protected:
+ OutputStream();
+ virtual ~OutputStream();
- public:
- virtual void close(Pool& p) = 0;
- virtual void flush(Pool& p) = 0;
- virtual void write(ByteBuffer& buf, Pool& p) = 0;
+ public:
+ virtual void close(Pool& p) = 0;
+ virtual void flush(Pool& p) = 0;
+ virtual void write(ByteBuffer& buf, Pool& p) = 0;
#ifdef LOG4CXX_MULTI_PROCESS
- virtual apr_file_t* getFilePtr();
- virtual OutputStream& getFileOutPutStreamPtr();
+ virtual apr_file_t* getFilePtr();
+ virtual OutputStream& getFileOutPutStreamPtr();
#endif
- private:
- OutputStream(const OutputStream&);
- OutputStream& operator=(const OutputStream&);
- };
+ private:
+ OutputStream(const OutputStream&);
+ OutputStream& operator=(const OutputStream&);
+};
- LOG4CXX_PTR_DEF(OutputStream);
- } // namespace helpers
+LOG4CXX_PTR_DEF(OutputStream);
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/outputstreamwriter.h b/src/main/include/log4cxx/helpers/outputstreamwriter.h
index c01db7a..3491e6d 100644
--- a/src/main/include/log4cxx/helpers/outputstreamwriter.h
+++ b/src/main/include/log4cxx/helpers/outputstreamwriter.h
@@ -25,44 +25,48 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
- /**
- * Abstract class for writing to character streams.
- */
- class LOG4CXX_EXPORT OutputStreamWriter : public Writer
- {
- private:
- OutputStreamPtr out;
- CharsetEncoderPtr enc;
+/**
+* Abstract class for writing to character streams.
+*/
+class LOG4CXX_EXPORT OutputStreamWriter : public Writer
+{
+ private:
+ OutputStreamPtr out;
+ CharsetEncoderPtr enc;
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(OutputStreamWriter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(OutputStreamWriter)
- LOG4CXX_CAST_ENTRY_CHAIN(Writer)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(OutputStreamWriter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(OutputStreamWriter)
+ LOG4CXX_CAST_ENTRY_CHAIN(Writer)
+ END_LOG4CXX_CAST_MAP()
- OutputStreamWriter(OutputStreamPtr& out);
- OutputStreamWriter(OutputStreamPtr& out, CharsetEncoderPtr &enc);
- ~OutputStreamWriter();
+ OutputStreamWriter(OutputStreamPtr& out);
+ OutputStreamWriter(OutputStreamPtr& out, CharsetEncoderPtr& enc);
+ ~OutputStreamWriter();
- virtual void close(Pool& p);
- virtual void flush(Pool& p);
- virtual void write(const LogString& str, Pool& p);
- LogString getEncoding() const;
+ virtual void close(Pool& p);
+ virtual void flush(Pool& p);
+ virtual void write(const LogString& str, Pool& p);
+ LogString getEncoding() const;
#ifdef LOG4CXX_MULTI_PROCESS
- OutputStreamPtr getOutPutStreamPtr() { return out; }
+ OutputStreamPtr getOutPutStreamPtr()
+ {
+ return out;
+ }
#endif
- private:
- OutputStreamWriter(const OutputStreamWriter&);
- OutputStreamWriter& operator=(const OutputStreamWriter&);
- };
+ private:
+ OutputStreamWriter(const OutputStreamWriter&);
+ OutputStreamWriter& operator=(const OutputStreamWriter&);
+};
- LOG4CXX_PTR_DEF(OutputStreamWriter);
- } // namespace helpers
+LOG4CXX_PTR_DEF(OutputStreamWriter);
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/pool.h b/src/main/include/log4cxx/helpers/pool.h
index 2c902f6..9a18da1 100644
--- a/src/main/include/log4cxx/helpers/pool.h
+++ b/src/main/include/log4cxx/helpers/pool.h
@@ -22,38 +22,38 @@
#include <string>
extern "C" {
- struct apr_pool_t;
+ struct apr_pool_t;
}
namespace log4cxx
{
- namespace helpers
- {
- class LOG4CXX_EXPORT Pool
- {
- public:
- Pool();
- Pool(apr_pool_t* pool, bool release);
- ~Pool();
+namespace helpers
+{
+class LOG4CXX_EXPORT Pool
+{
+ public:
+ Pool();
+ Pool(apr_pool_t* pool, bool release);
+ ~Pool();
- apr_pool_t* getAPRPool();
- apr_pool_t* create();
- void* palloc(size_t length);
- char* pstralloc(size_t length);
- char* itoa(int n);
- char* pstrndup(const char* s, size_t len);
- char* pstrdup(const char*s);
- char* pstrdup(const std::string&);
+ apr_pool_t* getAPRPool();
+ apr_pool_t* create();
+ void* palloc(size_t length);
+ char* pstralloc(size_t length);
+ char* itoa(int n);
+ char* pstrndup(const char* s, size_t len);
+ char* pstrdup(const char* s);
+ char* pstrdup(const std::string&);
- protected:
- apr_pool_t* pool;
- const bool release;
+ protected:
+ apr_pool_t* pool;
+ const bool release;
- private:
- Pool(const log4cxx::helpers::Pool&);
- Pool& operator=(const Pool&);
- };
- } // namespace helpers
+ private:
+ Pool(const log4cxx::helpers::Pool&);
+ Pool& operator=(const Pool&);
+};
+} // namespace helpers
} // namespace log4cxx
#endif //_LOG4CXX_HELPERS_POOL_H
diff --git a/src/main/include/log4cxx/helpers/properties.h b/src/main/include/log4cxx/helpers/properties.h
index c238496..951cad6 100644
--- a/src/main/include/log4cxx/helpers/properties.h
+++ b/src/main/include/log4cxx/helpers/properties.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_HELPER_PROPERTIES_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
@@ -34,152 +34,152 @@
namespace log4cxx
{
- namespace helpers
- {
- class LOG4CXX_EXPORT Properties
- {
- private:
- typedef std::map<LogString, LogString> PropertyMap;
- PropertyMap* properties;
- Properties(const Properties&);
- Properties& operator=(const Properties&);
+namespace helpers
+{
+class LOG4CXX_EXPORT Properties
+{
+ private:
+ typedef std::map<LogString, LogString> PropertyMap;
+ PropertyMap* properties;
+ Properties(const Properties&);
+ Properties& operator=(const Properties&);
- public:
- /**
- * Create new instance.
- */
- Properties();
- /**
- * Destructor.
- */
- ~Properties();
- /**
- Reads a property list (key and element pairs) from the input stream.
- The stream is assumed to be using the ISO 8859-1 character encoding.
+ public:
+ /**
+ * Create new instance.
+ */
+ Properties();
+ /**
+ * Destructor.
+ */
+ ~Properties();
+ /**
+ Reads a property list (key and element pairs) from the input stream.
+ The stream is assumed to be using the ISO 8859-1 character encoding.
- <p>Every property occupies one line of the input stream.
- Each line is terminated by a line terminator (<code>\\n</code> or
- <code>\\r</code> or <code>\\r\\n</code>).
- Lines from the input stream are processed until end of file is reached
- on the input stream.
+ <p>Every property occupies one line of the input stream.
+ Each line is terminated by a line terminator (<code>\\n</code> or
+ <code>\\r</code> or <code>\\r\\n</code>).
+ Lines from the input stream are processed until end of file is reached
+ on the input stream.
- <p>A line that contains only whitespace or whose first non-whitespace
- character is an ASCII <code>#</code> or <code>!</code> is ignored
- (thus, <code>#</code> or <code>!</code> indicate comment lines).
+ <p>A line that contains only whitespace or whose first non-whitespace
+ character is an ASCII <code>#</code> or <code>!</code> is ignored
+ (thus, <code>#</code> or <code>!</code> indicate comment lines).
- <p>Every line other than a blank line or a comment line describes one
- property to be added to the table (except that if a line ends with \,
- then the following line, if it exists, is treated as a continuation
- line, as described below). The key consists of all the characters in
- the line starting with the first non-whitespace character and up to,
- but not including, the first ASCII <code>=</code>, <code>:</code>,
- or whitespace character. All of the
- key termination characters may be included in the key by preceding them
- with a <code>\\</code>. Any whitespace after the key is skipped;
- if the first
- non-whitespace character after the key is <code>=</code> or
- <code>:</code>, then it is ignored
- and any whitespace characters after it are also skipped. All remaining
- characters on the line become part of the associated element string.
- Within the element string, the ASCII escape sequences <code>\\t</code>,
- <code>\\n</code>, <code>\\r</code>, <code>\\</code>, <code>\\"</code>,
- <code>\\'</code>, <code>\\</code> (a backslash and a space), and
- <code>\\uxxxx</code> are recognized
- and converted to single characters. Moreover, if the last character on
- the line is <code>\\</code>, then the next line is treated as a
- continuation of the
- current line; the <code>\\</code> and line terminator are simply
- discarded, and any
- leading whitespace characters on the continuation line are also
- discarded and are not part of the element string.
+ <p>Every line other than a blank line or a comment line describes one
+ property to be added to the table (except that if a line ends with \,
+ then the following line, if it exists, is treated as a continuation
+ line, as described below). The key consists of all the characters in
+ the line starting with the first non-whitespace character and up to,
+ but not including, the first ASCII <code>=</code>, <code>:</code>,
+ or whitespace character. All of the
+ key termination characters may be included in the key by preceding them
+ with a <code>\\</code>. Any whitespace after the key is skipped;
+ if the first
+ non-whitespace character after the key is <code>=</code> or
+ <code>:</code>, then it is ignored
+ and any whitespace characters after it are also skipped. All remaining
+ characters on the line become part of the associated element string.
+ Within the element string, the ASCII escape sequences <code>\\t</code>,
+ <code>\\n</code>, <code>\\r</code>, <code>\\</code>, <code>\\"</code>,
+ <code>\\'</code>, <code>\\</code> (a backslash and a space), and
+ <code>\\uxxxx</code> are recognized
+ and converted to single characters. Moreover, if the last character on
+ the line is <code>\\</code>, then the next line is treated as a
+ continuation of the
+ current line; the <code>\\</code> and line terminator are simply
+ discarded, and any
+ leading whitespace characters on the continuation line are also
+ discarded and are not part of the element string.
- <p>As an example, each of the following four lines specifies the key
- "Truth" and the associated element value "Beauty":
+ <p>As an example, each of the following four lines specifies the key
+ "Truth" and the associated element value "Beauty":
- <pre>
- Truth = Beauty
+ <pre>
+ Truth = Beauty
Truth:Beauty
- Truth :Beauty
- </pre>
+ Truth :Beauty
+ </pre>
- As another example, the following three lines specify a single
- property:
- <pre>
- fruits apple, banana, pear, \
- cantaloupe, watermelon, \
- kiwi, mango
- </pre>
- The key is "<code>fruits</code>" and the associated element is:
- <pre>
-"apple, banana, pear, cantaloupe, watermelon, kiwi, mango"
- </pre>
- Note that a space appears before each \ so that a space will appear
- after each comma in the final result; the \, line terminator, and
- leading whitespace on the continuation line are merely discarded and are
- not replaced by one or more other characters.
+ As another example, the following three lines specify a single
+ property:
+ <pre>
+ fruits apple, banana, pear, \
+ cantaloupe, watermelon, \
+ kiwi, mango
+ </pre>
+ The key is "<code>fruits</code>" and the associated element is:
+ <pre>
+ "apple, banana, pear, cantaloupe, watermelon, kiwi, mango"
+ </pre>
+ Note that a space appears before each \ so that a space will appear
+ after each comma in the final result; the \, line terminator, and
+ leading whitespace on the continuation line are merely discarded and are
+ not replaced by one or more other characters.
- <p>As a third example, the line:
- <pre>
-cheeses
- </pre>
- specifies that the key is "<code>cheeses</code>" and the associated
- element is the empty string.
+ <p>As a third example, the line:
+ <pre>
+ cheeses
+ </pre>
+ specifies that the key is "<code>cheeses</code>" and the associated
+ element is the empty string.
- @param inStream the input stream.
+ @param inStream the input stream.
- @throw IOException if an error occurred when reading from the input
- stream.
- */
- void load(InputStreamPtr inStream);
+ @throw IOException if an error occurred when reading from the input
+ stream.
+ */
+ void load(InputStreamPtr inStream);
- /**
- * Calls Properties::put.
- * @param key the key to be placed into this property list.
- * @param value the value corresponding to key.
- * @return the previous value of the specified key in this
- * property list, or an empty string if it did not have one.
- */
- LogString setProperty(const LogString& key, const LogString& value);
- /**
- * Puts a property value into the collection.
- * @param key the key to be placed into this property list.
- * @param value the value corresponding to key.
- * @return the previous value of the specified key in this
- * property list, or an empty string if it did not have one.
- */
- LogString put(const LogString& key, const LogString& value);
+ /**
+ * Calls Properties::put.
+ * @param key the key to be placed into this property list.
+ * @param value the value corresponding to key.
+ * @return the previous value of the specified key in this
+ * property list, or an empty string if it did not have one.
+ */
+ LogString setProperty(const LogString& key, const LogString& value);
+ /**
+ * Puts a property value into the collection.
+ * @param key the key to be placed into this property list.
+ * @param value the value corresponding to key.
+ * @return the previous value of the specified key in this
+ * property list, or an empty string if it did not have one.
+ */
+ LogString put(const LogString& key, const LogString& value);
- /**
- * Calls Properties::get.
- * @param key the property key.
- * @return the value in this property list with the specified
- * key value or empty string.
- */
- LogString getProperty(const LogString& key) const;
- /**
- * Gets a property value.
- * @param key the property key.
- * @return the value in this property list with the specified
- * key value or empty string.
- */
- LogString get(const LogString& key) const;
+ /**
+ * Calls Properties::get.
+ * @param key the property key.
+ * @return the value in this property list with the specified
+ * key value or empty string.
+ */
+ LogString getProperty(const LogString& key) const;
+ /**
+ * Gets a property value.
+ * @param key the property key.
+ * @return the value in this property list with the specified
+ * key value or empty string.
+ */
+ LogString get(const LogString& key) const;
- /**
- Returns an enumeration of all the keys in this property list,
- including distinct keys in the default property list if a key
- of the same name has not already been found from the main
- properties list.
- @return an array of all the keys in this
- property list, including the keys in the default property list.
- */
- std::vector<LogString> propertyNames() const;
- }; // class Properties
- } // namespace helpers
+ /**
+ Returns an enumeration of all the keys in this property list,
+ including distinct keys in the default property list if a key
+ of the same name has not already been found from the main
+ properties list.
+ @return an array of all the keys in this
+ property list, including the keys in the default property list.
+ */
+ std::vector<LogString> propertyNames() const;
+}; // class Properties
+} // namespace helpers
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning (pop)
+ #pragma warning (pop)
#endif
diff --git a/src/main/include/log4cxx/helpers/propertyresourcebundle.h b/src/main/include/log4cxx/helpers/propertyresourcebundle.h
index 5032873..2ab2f0c 100644
--- a/src/main/include/log4cxx/helpers/propertyresourcebundle.h
+++ b/src/main/include/log4cxx/helpers/propertyresourcebundle.h
@@ -24,38 +24,38 @@
namespace log4cxx
{
- namespace helpers
- {
+namespace helpers
+{
- /**
- PropertyResourceBundle is a concrete subclass of ResourceBundle that
- manages resources for a locale using a set of static strings from a
- property file.
- */
- class LOG4CXX_EXPORT PropertyResourceBundle : public ResourceBundle
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(PropertyResourceBundle)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(PropertyResourceBundle)
- LOG4CXX_CAST_ENTRY_CHAIN(ResourceBundle)
- END_LOG4CXX_CAST_MAP()
+/**
+PropertyResourceBundle is a concrete subclass of ResourceBundle that
+manages resources for a locale using a set of static strings from a
+property file.
+*/
+class LOG4CXX_EXPORT PropertyResourceBundle : public ResourceBundle
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(PropertyResourceBundle)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(PropertyResourceBundle)
+ LOG4CXX_CAST_ENTRY_CHAIN(ResourceBundle)
+ END_LOG4CXX_CAST_MAP()
- /**
- Creates a property resource bundle.
- @param inStream property file to read from.
- @throw IOException if an error occurred when reading from the
- input stream.
- */
- PropertyResourceBundle(InputStreamPtr inStream);
+ /**
+ Creates a property resource bundle.
+ @param inStream property file to read from.
+ @throw IOException if an error occurred when reading from the
+ input stream.
+ */
+ PropertyResourceBundle(InputStreamPtr inStream);
- virtual LogString getString(const LogString& key) const;
+ virtual LogString getString(const LogString& key) const;
- protected:
- Properties properties;
- }; // class PropertyResourceBundle
- LOG4CXX_PTR_DEF(PropertyResourceBundle);
- } // namespace helpers
+ protected:
+ Properties properties;
+}; // class PropertyResourceBundle
+LOG4CXX_PTR_DEF(PropertyResourceBundle);
+} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_PROPERTY_RESOURCE_BUNDLE_H
diff --git a/src/main/include/log4cxx/helpers/reader.h b/src/main/include/log4cxx/helpers/reader.h
index 488b5fd..19ab81c 100644
--- a/src/main/include/log4cxx/helpers/reader.h
+++ b/src/main/include/log4cxx/helpers/reader.h
@@ -23,49 +23,50 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
- /**
- * Abstract class for reading from character streams.
- *
- */
- class LOG4CXX_EXPORT Reader : public ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(Reader)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(Reader)
- END_LOG4CXX_CAST_MAP()
+/**
+ * Abstract class for reading from character streams.
+ *
+ */
+class LOG4CXX_EXPORT Reader : public ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(Reader)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(Reader)
+ END_LOG4CXX_CAST_MAP()
- protected:
- /**
- * Creates a new character-stream reader.
- */
- Reader();
+ protected:
+ /**
+ * Creates a new character-stream reader.
+ */
+ Reader();
- virtual ~Reader();
+ virtual ~Reader();
- public:
- /**
- * Closes the stream.
- * @param p The memory pool associated with the reader.
- */
- virtual void close(Pool& p) = 0;
+ public:
+ /**
+ * Closes the stream.
+ * @param p The memory pool associated with the reader.
+ */
+ virtual void close(Pool& p) = 0;
- /**
- * @return The complete stream contents as a LogString.
- * @param p The memory pool associated with the reader.
- */
- virtual LogString read(Pool& p) = 0;
+ /**
+ * @return The complete stream contents as a LogString.
+ * @param p The memory pool associated with the reader.
+ */
+ virtual LogString read(Pool& p) = 0;
- private:
- Reader(const Reader&);
+ private:
+ Reader(const Reader&);
- Reader& operator=(const Reader&);
- };
+ Reader& operator=(const Reader&);
+};
- LOG4CXX_PTR_DEF(Reader);
- } // namespace helpers
+LOG4CXX_PTR_DEF(Reader);
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/relativetimedateformat.h b/src/main/include/log4cxx/helpers/relativetimedateformat.h
index 85daade..b92997e 100644
--- a/src/main/include/log4cxx/helpers/relativetimedateformat.h
+++ b/src/main/include/log4cxx/helpers/relativetimedateformat.h
@@ -22,26 +22,26 @@
namespace log4cxx
{
- namespace helpers
- {
- /**
- Formats a date by printing the number of milliseconds
- elapsed since the start of the application. This is the fastest
- printing DateFormat in the package.
- */
- class LOG4CXX_EXPORT RelativeTimeDateFormat : public DateFormat
- {
- public:
- RelativeTimeDateFormat();
- virtual void format(LogString &s,
- log4cxx_time_t tm,
- log4cxx::helpers::Pool& p) const;
+namespace helpers
+{
+/**
+Formats a date by printing the number of milliseconds
+elapsed since the start of the application. This is the fastest
+printing DateFormat in the package.
+*/
+class LOG4CXX_EXPORT RelativeTimeDateFormat : public DateFormat
+{
+ public:
+ RelativeTimeDateFormat();
+ virtual void format(LogString& s,
+ log4cxx_time_t tm,
+ log4cxx::helpers::Pool& p) const;
- private:
- log4cxx_time_t startTime;
+ private:
+ log4cxx_time_t startTime;
- };
- } // namespace helpers
+};
+} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_RELATIVE_TIME_DATE_FORMAT_H
diff --git a/src/main/include/log4cxx/helpers/resourcebundle.h b/src/main/include/log4cxx/helpers/resourcebundle.h
index 44c52e2..4dddd36 100644
--- a/src/main/include/log4cxx/helpers/resourcebundle.h
+++ b/src/main/include/log4cxx/helpers/resourcebundle.h
@@ -23,66 +23,68 @@
namespace log4cxx
{
- namespace helpers
+namespace helpers
+{
+class Locale;
+
+class ResourceBundle;
+LOG4CXX_PTR_DEF(ResourceBundle);
+
+/**
+Resource bundles contain locale-specific objects
+*/
+class LOG4CXX_EXPORT ResourceBundle : public ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(ResourceBundle)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(ResourceBundle)
+ END_LOG4CXX_CAST_MAP()
+
+ /**
+ Gets a string for the given key from this resource bundle or one of
+ its parents. Calling this method is equivalent to calling
+
+ @param key the key for the desired string
+ @return the string for the given key
+ @throw MissingResourceException - if no object for the given key
+ can be found
+ */
+ virtual LogString getString(const LogString& key) const = 0;
+
+ /**
+ Gets a resource bundle using the specified base name and locale
+
+ @param baseName the base name of the resource bundle, a fully
+ qualified class name or property filename
+ @param locale the locale for which a resource bundle is desired
+ */
+ static ResourceBundlePtr getBundle(const LogString& baseName,
+ const Locale& locale);
+
+ protected:
+ /*
+ Sets the parent bundle of this bundle. The parent bundle is
+ searched by #getString when this bundle does not contain a particular
+ resource.
+
+ Parameters:
+ parent - this bundle's parent bundle.
+ */
+ inline void setParent(const ResourceBundlePtr& parent1)
{
- class Locale;
+ this->parent = parent1;
+ }
- class ResourceBundle;
- LOG4CXX_PTR_DEF(ResourceBundle);
+ /**
+ The parent bundle of this bundle.
- /**
- Resource bundles contain locale-specific objects
- */
- class LOG4CXX_EXPORT ResourceBundle : public ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(ResourceBundle)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(ResourceBundle)
- END_LOG4CXX_CAST_MAP()
-
- /**
- Gets a string for the given key from this resource bundle or one of
- its parents. Calling this method is equivalent to calling
-
- @param key the key for the desired string
- @return the string for the given key
- @throw MissingResourceException - if no object for the given key
- can be found
- */
- virtual LogString getString(const LogString& key) const = 0;
-
- /**
- Gets a resource bundle using the specified base name and locale
-
- @param baseName the base name of the resource bundle, a fully
- qualified class name or property filename
- @param locale the locale for which a resource bundle is desired
- */
- static ResourceBundlePtr getBundle(const LogString& baseName,
- const Locale& locale);
-
- protected:
- /*
- Sets the parent bundle of this bundle. The parent bundle is
- searched by #getString when this bundle does not contain a particular
- resource.
-
- Parameters:
- parent - this bundle's parent bundle.
- */
- inline void setParent(const ResourceBundlePtr& parent1)
- { this->parent = parent1; }
-
- /**
- The parent bundle of this bundle.
-
- The parent bundle is searched by #getString when this bundle does
- not contain a particular resource.
- */
- ResourceBundlePtr parent;
- }; // class ResourceBundle
- } // namespace helpers
+ The parent bundle is searched by #getString when this bundle does
+ not contain a particular resource.
+ */
+ ResourceBundlePtr parent;
+}; // class ResourceBundle
+} // namespace helpers
} // namespace log4cxx
#endif
diff --git a/src/main/include/log4cxx/helpers/serversocket.h b/src/main/include/log4cxx/helpers/serversocket.h
index 5eee0ee..935d455 100644
--- a/src/main/include/log4cxx/helpers/serversocket.h
+++ b/src/main/include/log4cxx/helpers/serversocket.h
@@ -23,42 +23,42 @@
namespace log4cxx
{
- namespace helpers
- {
- class LOG4CXX_EXPORT ServerSocket
- {
- public:
- /** Creates a server socket on a specified port.
- */
- ServerSocket(int port);
+namespace helpers
+{
+class LOG4CXX_EXPORT ServerSocket
+{
+ public:
+ /** Creates a server socket on a specified port.
+ */
+ ServerSocket(int port);
- virtual ~ServerSocket();
+ virtual ~ServerSocket();
- /** Listens for a connection to be made to this socket and
- accepts it
- */
- SocketPtr accept();
+ /** Listens for a connection to be made to this socket and
+ accepts it
+ */
+ SocketPtr accept();
- /** Closes this socket.
- */
- void close();
+ /** Closes this socket.
+ */
+ void close();
- /** Retrive setting for SO_TIMEOUT.
- */
- int getSoTimeout() const;
+ /** Retrive setting for SO_TIMEOUT.
+ */
+ int getSoTimeout() const;
- /** Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
- */
- void setSoTimeout(int timeout);
+ /** Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
+ */
+ void setSoTimeout(int timeout);
- private:
- Pool pool;
- Mutex mutex;
- apr_socket_t* socket;
- int timeout;
+ private:
+ Pool pool;
+ Mutex mutex;
+ apr_socket_t* socket;
+ int timeout;
- };
- } // namespace helpers
+};
+} // namespace helpers
} // namespace log4cxx
#endif //_LOG4CXX_HELPERS_SERVER_SOCKET_H
diff --git a/src/main/include/log4cxx/helpers/simpledateformat.h b/src/main/include/log4cxx/helpers/simpledateformat.h
index 42a930f..a650b4d 100644
--- a/src/main/include/log4cxx/helpers/simpledateformat.h
+++ b/src/main/include/log4cxx/helpers/simpledateformat.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_HELPERS_SIMPLE_DATE_FORMAT_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
@@ -35,63 +35,64 @@
namespace log4cxx
{
- namespace helpers
- {
- namespace SimpleDateFormatImpl {
- class PatternToken;
- }
+namespace helpers
+{
+namespace SimpleDateFormatImpl
+{
+class PatternToken;
+}
- LOG4CXX_LIST_DEF(PatternTokenList, log4cxx::helpers::SimpleDateFormatImpl::PatternToken*);
+LOG4CXX_LIST_DEF(PatternTokenList, log4cxx::helpers::SimpleDateFormatImpl::PatternToken*);
- /**
- * Concrete class for formatting and parsing dates in a
- * locale-sensitive manner.
- */
- class LOG4CXX_EXPORT SimpleDateFormat : public DateFormat
- {
- public:
- /**
- * Constructs a DateFormat using the given pattern and the default
- * time zone.
- *
- * @param pattern the pattern describing the date and time format
- */
- SimpleDateFormat(const LogString& pattern);
- SimpleDateFormat(const LogString& pattern, const std::locale* locale);
- ~SimpleDateFormat();
+/**
+ * Concrete class for formatting and parsing dates in a
+ * locale-sensitive manner.
+ */
+class LOG4CXX_EXPORT SimpleDateFormat : public DateFormat
+{
+ public:
+ /**
+ * Constructs a DateFormat using the given pattern and the default
+ * time zone.
+ *
+ * @param pattern the pattern describing the date and time format
+ */
+ SimpleDateFormat(const LogString& pattern);
+ SimpleDateFormat(const LogString& pattern, const std::locale* locale);
+ ~SimpleDateFormat();
- virtual void format(LogString& s,
- log4cxx_time_t tm,
- log4cxx::helpers::Pool& p) const;
+ virtual void format(LogString& s,
+ log4cxx_time_t tm,
+ log4cxx::helpers::Pool& p) const;
- /**
- * Set time zone.
- * @param zone new time zone.
- */
- void setTimeZone(const TimeZonePtr& zone);
+ /**
+ * Set time zone.
+ * @param zone new time zone.
+ */
+ void setTimeZone(const TimeZonePtr& zone);
- private:
- /**
- * Time zone.
- */
- TimeZonePtr timeZone;
+ private:
+ /**
+ * Time zone.
+ */
+ TimeZonePtr timeZone;
- /**
- * List of tokens.
- */
- PatternTokenList pattern;
+ /**
+ * List of tokens.
+ */
+ PatternTokenList pattern;
- static void addToken(const logchar spec, const int repeat, const std::locale* locale, PatternTokenList& pattern);
- static void parsePattern(const LogString& spec, const std::locale* locale, PatternTokenList& pattern);
- };
+ static void addToken(const logchar spec, const int repeat, const std::locale* locale, PatternTokenList& pattern);
+ static void parsePattern(const LogString& spec, const std::locale* locale, PatternTokenList& pattern);
+};
- } // namespace helpers
+} // namespace helpers
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
diff --git a/src/main/include/log4cxx/helpers/socket.h b/src/main/include/log4cxx/helpers/socket.h
index 6b41a64..11c84ac 100644
--- a/src/main/include/log4cxx/helpers/socket.h
+++ b/src/main/include/log4cxx/helpers/socket.h
@@ -19,7 +19,7 @@
#define _LOG4CXX_HELPERS_SOCKET_H
extern "C" {
- struct apr_socket_t;
+ struct apr_socket_t;
}
@@ -29,62 +29,62 @@
namespace log4cxx
{
- namespace helpers
- {
- class ByteBuffer;
- /**
- <p>This class implements client sockets (also called just "sockets"). A socket
- is an endpoint for communication between two machines.
- <p>The actual work of the socket is performed by an instance of the SocketImpl
- class. An application, by changing the socket factory that creates the socket
- implementation, can configure itself to create sockets appropriate to the
- local firewall.
- */
- class LOG4CXX_EXPORT Socket : public helpers::ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(Socket)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(Socket)
- END_LOG4CXX_CAST_MAP()
+namespace helpers
+{
+class ByteBuffer;
+/**
+<p>This class implements client sockets (also called just "sockets"). A socket
+is an endpoint for communication between two machines.
+<p>The actual work of the socket is performed by an instance of the SocketImpl
+class. An application, by changing the socket factory that creates the socket
+implementation, can configure itself to create sockets appropriate to the
+local firewall.
+*/
+class LOG4CXX_EXPORT Socket : public helpers::ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(Socket)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(Socket)
+ END_LOG4CXX_CAST_MAP()
- /** Creates a stream socket and connects it to the specified port
- number at the specified IP address.
- */
- Socket(InetAddressPtr& address, int port);
- Socket(apr_socket_t* socket, apr_pool_t* pool);
- ~Socket();
+ /** Creates a stream socket and connects it to the specified port
+ number at the specified IP address.
+ */
+ Socket(InetAddressPtr& address, int port);
+ Socket(apr_socket_t* socket, apr_pool_t* pool);
+ ~Socket();
- size_t write(ByteBuffer&);
+ size_t write(ByteBuffer&);
- /** Closes this socket. */
- void close();
+ /** Closes this socket. */
+ void close();
- /** Returns the value of this socket's address field. */
- InetAddressPtr getInetAddress() const;
+ /** Returns the value of this socket's address field. */
+ InetAddressPtr getInetAddress() const;
- /** Returns the value of this socket's port field. */
- int getPort() const;
- private:
- Socket(const Socket&);
- Socket& operator=(const Socket&);
+ /** Returns the value of this socket's port field. */
+ int getPort() const;
+ private:
+ Socket(const Socket&);
+ Socket& operator=(const Socket&);
- Pool pool;
+ Pool pool;
- apr_socket_t* socket;
+ apr_socket_t* socket;
- /** The IP address of the remote end of this socket. */
- InetAddressPtr address;
+ /** The IP address of the remote end of this socket. */
+ InetAddressPtr address;
- /** The port number on the remote host to which
- this socket is connected. */
- int port;
- };
+ /** The port number on the remote host to which
+ this socket is connected. */
+ int port;
+};
- LOG4CXX_PTR_DEF(Socket);
+LOG4CXX_PTR_DEF(Socket);
- } // namespace helpers
+} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_SOCKET_H
diff --git a/src/main/include/log4cxx/helpers/socketoutputstream.h b/src/main/include/log4cxx/helpers/socketoutputstream.h
index 94d9895..476fc50 100644
--- a/src/main/include/log4cxx/helpers/socketoutputstream.h
+++ b/src/main/include/log4cxx/helpers/socketoutputstream.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_HELPERS_SOCKET_OUTPUT_STREAM_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
@@ -30,43 +30,43 @@
namespace log4cxx
{
- namespace helpers
- {
- LOG4CXX_LIST_DEF(ByteList, unsigned char);
+namespace helpers
+{
+LOG4CXX_LIST_DEF(ByteList, unsigned char);
- class LOG4CXX_EXPORT SocketOutputStream : public OutputStream
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(SocketOutputStream)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(SocketOutputStream)
- LOG4CXX_CAST_ENTRY_CHAIN(OutputStream)
- END_LOG4CXX_CAST_MAP()
+class LOG4CXX_EXPORT SocketOutputStream : public OutputStream
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(SocketOutputStream)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(SocketOutputStream)
+ LOG4CXX_CAST_ENTRY_CHAIN(OutputStream)
+ END_LOG4CXX_CAST_MAP()
- SocketOutputStream(const SocketPtr& socket);
- ~SocketOutputStream();
+ SocketOutputStream(const SocketPtr& socket);
+ ~SocketOutputStream();
- virtual void close(Pool& p);
- virtual void flush(Pool& p);
- virtual void write(ByteBuffer& buf, Pool& p);
+ virtual void close(Pool& p);
+ virtual void flush(Pool& p);
+ virtual void write(ByteBuffer& buf, Pool& p);
- private:
- ByteList array;
- SocketPtr socket;
- //
- // prevent copy and assignment statements
- SocketOutputStream(const SocketOutputStream&);
- SocketOutputStream& operator=(const SocketOutputStream&);
+ private:
+ ByteList array;
+ SocketPtr socket;
+ //
+ // prevent copy and assignment statements
+ SocketOutputStream(const SocketOutputStream&);
+ SocketOutputStream& operator=(const SocketOutputStream&);
- };
+};
- LOG4CXX_PTR_DEF(SocketOutputStream);
+LOG4CXX_PTR_DEF(SocketOutputStream);
- } // namespace helpers
+} // namespace helpers
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
diff --git a/src/main/include/log4cxx/helpers/strftimedateformat.h b/src/main/include/log4cxx/helpers/strftimedateformat.h
index 043205b..ecacd89 100644
--- a/src/main/include/log4cxx/helpers/strftimedateformat.h
+++ b/src/main/include/log4cxx/helpers/strftimedateformat.h
@@ -22,47 +22,47 @@
namespace log4cxx
{
- namespace helpers
- {
+namespace helpers
+{
- /**
- Concrete class for formatting and parsing dates in a
- locale-sensitive manner.
+/**
+Concrete class for formatting and parsing dates in a
+locale-sensitive manner.
- */
- class LOG4CXX_EXPORT StrftimeDateFormat : public DateFormat
- {
- public:
- /**
- Constructs a DateFormat using the given pattern and the default
- time zone.
+*/
+class LOG4CXX_EXPORT StrftimeDateFormat : public DateFormat
+{
+ public:
+ /**
+ Constructs a DateFormat using the given pattern and the default
+ time zone.
- @param pattern the pattern describing the date and time format
- */
- StrftimeDateFormat(const LogString& pattern);
- ~StrftimeDateFormat();
+ @param pattern the pattern describing the date and time format
+ */
+ StrftimeDateFormat(const LogString& pattern);
+ ~StrftimeDateFormat();
- virtual void format(LogString& s,
- log4cxx_time_t tm,
- log4cxx::helpers::Pool& p) const;
+ virtual void format(LogString& s,
+ log4cxx_time_t tm,
+ log4cxx::helpers::Pool& p) const;
- /**
- * Set time zone.
- * @param zone new time zone.
- */
- void setTimeZone(const TimeZonePtr& zone);
+ /**
+ * Set time zone.
+ * @param zone new time zone.
+ */
+ void setTimeZone(const TimeZonePtr& zone);
- private:
- /**
- * Time zone.
- */
- TimeZonePtr timeZone;
- std::string pattern;
- };
+ private:
+ /**
+ * Time zone.
+ */
+ TimeZonePtr timeZone;
+ std::string pattern;
+};
- } // namespace helpers
+} // namespace helpers
} // namespace log4cxx
#endif // _LOG4CXX_HELPERS_STRFTIME_DATE_FORMAT_H
diff --git a/src/main/include/log4cxx/helpers/strictmath.h b/src/main/include/log4cxx/helpers/strictmath.h
index 8c4194b..8eff4d3 100644
--- a/src/main/include/log4cxx/helpers/strictmath.h
+++ b/src/main/include/log4cxx/helpers/strictmath.h
@@ -22,28 +22,28 @@
namespace log4cxx
{
- namespace helpers
+namespace helpers
+{
+/**
+The class StrictMath contains methods for performing basic numeric
+operations
+*/
+class StrictMath
+{
+ public:
+ template<typename _type> static inline const _type&
+ minimum(const _type& a, const _type& b)
{
- /**
- The class StrictMath contains methods for performing basic numeric
- operations
- */
- class StrictMath
- {
- public:
- template<typename _type> static inline const _type&
- minimum(const _type& a, const _type& b)
- {
- return (a < b) ? a : b;
- }
+ return (a < b) ? a : b;
+ }
- template<typename _type> static inline const _type&
- maximum(const _type& a, const _type& b)
- {
- return (a > b) ? a : b;
- }
- }; // class StrictMath
- } // namespace helpers
+ template<typename _type> static inline const _type&
+ maximum(const _type& a, const _type& b)
+ {
+ return (a > b) ? a : b;
+ }
+}; // class StrictMath
+} // namespace helpers
} // namespace log4cx
#endif //_LOG4CXX_HELPERS_STRICTMATH_H
diff --git a/src/main/include/log4cxx/helpers/stringhelper.h b/src/main/include/log4cxx/helpers/stringhelper.h
index e8e170d..82ffb18 100644
--- a/src/main/include/log4cxx/helpers/stringhelper.h
+++ b/src/main/include/log4cxx/helpers/stringhelper.h
@@ -24,38 +24,38 @@
namespace log4cxx
{
- namespace helpers
- {
- class Pool;
- /**
- String manipulation routines
- */
- class LOG4CXX_EXPORT StringHelper
- {
- public:
- static LogString trim(const LogString& s);
- static bool startsWith(const LogString& s, const LogString& suffix);
- static bool endsWith(const LogString& s, const LogString& suffix);
- static bool equalsIgnoreCase(const LogString& s1,
- const logchar* upper, const logchar* lower);
- static bool equalsIgnoreCase(const LogString& s1,
- const LogString& upper, const LogString& lower);
+namespace helpers
+{
+class Pool;
+/**
+String manipulation routines
+*/
+class LOG4CXX_EXPORT StringHelper
+{
+ public:
+ static LogString trim(const LogString& s);
+ static bool startsWith(const LogString& s, const LogString& suffix);
+ static bool endsWith(const LogString& s, const LogString& suffix);
+ static bool equalsIgnoreCase(const LogString& s1,
+ const logchar* upper, const logchar* lower);
+ static bool equalsIgnoreCase(const LogString& s1,
+ const LogString& upper, const LogString& lower);
- static int toInt(const LogString& s);
- static log4cxx_int64_t toInt64(const LogString& s);
+ static int toInt(const LogString& s);
+ static log4cxx_int64_t toInt64(const LogString& s);
- static void toString(int i, log4cxx::helpers::Pool& pool, LogString& dst);
- static void toString(log4cxx_int64_t i, log4cxx::helpers::Pool& pool, LogString& dst);
- static void toString(size_t i, log4cxx::helpers::Pool& pool, LogString& dst);
+ static void toString(int i, log4cxx::helpers::Pool& pool, LogString& dst);
+ static void toString(log4cxx_int64_t i, log4cxx::helpers::Pool& pool, LogString& dst);
+ static void toString(size_t i, log4cxx::helpers::Pool& pool, LogString& dst);
- static void toString(bool val, LogString& dst);
+ static void toString(bool val, LogString& dst);
- static LogString toLowerCase(const LogString& s);
+ static LogString toLowerCase(const LogString& s);
- static LogString format(const LogString& pattern, const std::vector<LogString>& params);
- };
- }
+ static LogString format(const LogString& pattern, const std::vector<LogString>& params);
+};
+}
}
#endif //_LOG4CXX_HELPERS_STRING_HELPER_H
diff --git a/src/main/include/log4cxx/helpers/stringtokenizer.h b/src/main/include/log4cxx/helpers/stringtokenizer.h
index 18320c4..692467b 100644
--- a/src/main/include/log4cxx/helpers/stringtokenizer.h
+++ b/src/main/include/log4cxx/helpers/stringtokenizer.h
@@ -23,27 +23,27 @@
namespace log4cxx
{
- namespace helpers
- {
- class LOG4CXX_EXPORT StringTokenizer
- {
- public:
- StringTokenizer(const LogString& str, const LogString& delim);
- ~StringTokenizer();
- bool hasMoreTokens() const;
- LogString nextToken();
+namespace helpers
+{
+class LOG4CXX_EXPORT StringTokenizer
+{
+ public:
+ StringTokenizer(const LogString& str, const LogString& delim);
+ ~StringTokenizer();
+ bool hasMoreTokens() const;
+ LogString nextToken();
- protected:
- LogString src;
- LogString delim;
- size_t pos;
+ protected:
+ LogString src;
+ LogString delim;
+ size_t pos;
- private:
- // prevent copy and assignment statements
- StringTokenizer(const StringTokenizer&);
- StringTokenizer& operator=(const StringTokenizer&);
- }; // class StringTokenizer
- } // namespace helpers;
+ private:
+ // prevent copy and assignment statements
+ StringTokenizer(const StringTokenizer&);
+ StringTokenizer& operator=(const StringTokenizer&);
+}; // class StringTokenizer
+} // namespace helpers;
} // namespace log4cxx;
#endif //_LOG4CXX_HELPERS_STRING_TOKENIZER_H
diff --git a/src/main/include/log4cxx/helpers/synchronized.h b/src/main/include/log4cxx/helpers/synchronized.h
index 741b24e..18963ae 100644
--- a/src/main/include/log4cxx/helpers/synchronized.h
+++ b/src/main/include/log4cxx/helpers/synchronized.h
@@ -25,71 +25,74 @@
namespace log4cxx
{
- namespace helpers {
- class Mutex;
+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();
+/** 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&);
- };
- }
+ 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;
+namespace helpers
+{
+class RWMutex;
- // utility class for objects multi-thread synchronization.
- class LOG4CXX_EXPORT synchronized_read
- {
- public:
- synchronized_read(const RWMutex& mutex);
- ~synchronized_read();
+// 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&);
- };
- }
+ 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;
+namespace helpers
+{
+class RWMutex;
- // utility class for objects multi-thread synchronization.
- class LOG4CXX_EXPORT synchronized_write
- {
- public:
- synchronized_write(const RWMutex& mutex);
- ~synchronized_write();
+// 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&);
- };
- }
+ 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
diff --git a/src/main/include/log4cxx/helpers/syslogwriter.h b/src/main/include/log4cxx/helpers/syslogwriter.h
index f62c0cf..ada08fb 100644
--- a/src/main/include/log4cxx/helpers/syslogwriter.h
+++ b/src/main/include/log4cxx/helpers/syslogwriter.h
@@ -23,28 +23,28 @@
#include <log4cxx/helpers/inetaddress.h>
#include <log4cxx/helpers/datagramsocket.h>
- namespace log4cxx
+namespace log4cxx
{
- namespace helpers
- {
- /**
- SyslogWriter is a wrapper around the DatagramSocket class
- it writes text to the specified host on the port 514 (UNIX syslog)
- */
- class LOG4CXX_EXPORT SyslogWriter
- {
- public:
- #define SYSLOG_PORT 514
- SyslogWriter(const LogString& syslogHost, int syslogHostPort = SYSLOG_PORT);
- void write(const LogString& string);
+namespace helpers
+{
+/**
+SyslogWriter is a wrapper around the DatagramSocket class
+it writes text to the specified host on the port 514 (UNIX syslog)
+*/
+class LOG4CXX_EXPORT SyslogWriter
+{
+ public:
+#define SYSLOG_PORT 514
+ SyslogWriter(const LogString& syslogHost, int syslogHostPort = SYSLOG_PORT);
+ void write(const LogString& string);
- private:
- LogString syslogHost;
- int syslogHostPort;
- InetAddressPtr address;
- DatagramSocketPtr ds;
- };
- } // namespace helpers
+ private:
+ LogString syslogHost;
+ int syslogHostPort;
+ InetAddressPtr address;
+ DatagramSocketPtr ds;
+};
+} // namespace helpers
} // namespace log4cxx
#endif
diff --git a/src/main/include/log4cxx/helpers/system.h b/src/main/include/log4cxx/helpers/system.h
index 3885687..2641adf 100644
--- a/src/main/include/log4cxx/helpers/system.h
+++ b/src/main/include/log4cxx/helpers/system.h
@@ -15,39 +15,39 @@
* limitations under the License.
*/
- #ifndef _LOG4CXX_HELPERS_SYSTEM_H
- #define _LOG4CXX_HELPERS_SYSTEM_H
+#ifndef _LOG4CXX_HELPERS_SYSTEM_H
+#define _LOG4CXX_HELPERS_SYSTEM_H
#include <log4cxx/logstring.h>
#include <log4cxx/helpers/exception.h>
- namespace log4cxx
- {
- namespace helpers
- {
- class Properties;
+namespace log4cxx
+{
+namespace helpers
+{
+class Properties;
- /** The System class contains several useful class fields and methods.
- It cannot be instantiated.
- */
- class LOG4CXX_EXPORT System
- {
- public:
+/** The System class contains several useful class fields and methods.
+It cannot be instantiated.
+*/
+class LOG4CXX_EXPORT System
+{
+ public:
- /**
- Gets the system property indicated by the specified key.
+ /**
+ Gets the system property indicated by the specified key.
- @param key the name of the system property.
+ @param key the name of the system property.
- @return the string value of the system property, or the default value if
- there is no property with that key.
+ @return the string value of the system property, or the default value if
+ there is no property with that key.
- @throws IllegalArgumentException if key is empty.
- */
- static LogString getProperty(const LogString& key);
+ @throws IllegalArgumentException if key is empty.
+ */
+ static LogString getProperty(const LogString& key);
- };
- } // namespace helpers
- } // namespace log4cxx
+};
+} // namespace helpers
+} // namespace log4cxx
- #endif //_LOG4CXX_HELPERS_SYSTEM_H
+#endif //_LOG4CXX_HELPERS_SYSTEM_H
diff --git a/src/main/include/log4cxx/helpers/systemerrwriter.h b/src/main/include/log4cxx/helpers/systemerrwriter.h
index 7fda472..eab756f 100644
--- a/src/main/include/log4cxx/helpers/systemerrwriter.h
+++ b/src/main/include/log4cxx/helpers/systemerrwriter.h
@@ -22,37 +22,38 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
- /**
- * Abstract class for writing to character streams.
- */
- class LOG4CXX_EXPORT SystemErrWriter : public Writer
- {
- public:
- DECLARE_LOG4CXX_OBJECT(SystemErrWriter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(SystemErrWriter)
- LOG4CXX_CAST_ENTRY_CHAIN(Writer)
- END_LOG4CXX_CAST_MAP()
+/**
+* Abstract class for writing to character streams.
+*/
+class LOG4CXX_EXPORT SystemErrWriter : public Writer
+{
+ public:
+ DECLARE_LOG4CXX_OBJECT(SystemErrWriter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(SystemErrWriter)
+ LOG4CXX_CAST_ENTRY_CHAIN(Writer)
+ END_LOG4CXX_CAST_MAP()
- SystemErrWriter();
- virtual ~SystemErrWriter();
+ SystemErrWriter();
+ virtual ~SystemErrWriter();
- virtual void close(Pool& p);
- virtual void flush(Pool& p);
- virtual void write(const LogString& str, Pool& p);
+ virtual void close(Pool& p);
+ virtual void flush(Pool& p);
+ virtual void write(const LogString& str, Pool& p);
- static void write(const LogString& str);
- static void flush();
+ static void write(const LogString& str);
+ static void flush();
- private:
- SystemErrWriter(const SystemErrWriter&);
- SystemErrWriter& operator=(const SystemErrWriter&);
- static bool isWide();
- };
+ private:
+ SystemErrWriter(const SystemErrWriter&);
+ SystemErrWriter& operator=(const SystemErrWriter&);
+ static bool isWide();
+};
- } // namespace helpers
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/systemoutwriter.h b/src/main/include/log4cxx/helpers/systemoutwriter.h
index 9838e71..9d942e4 100644
--- a/src/main/include/log4cxx/helpers/systemoutwriter.h
+++ b/src/main/include/log4cxx/helpers/systemoutwriter.h
@@ -22,36 +22,37 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
- /**
- * Abstract class for writing to character streams.
- */
- class LOG4CXX_EXPORT SystemOutWriter : public Writer
- {
- public:
- DECLARE_LOG4CXX_OBJECT(SystemOutWriter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(SystemOutWriter)
- LOG4CXX_CAST_ENTRY_CHAIN(Writer)
- END_LOG4CXX_CAST_MAP()
+/**
+* Abstract class for writing to character streams.
+*/
+class LOG4CXX_EXPORT SystemOutWriter : public Writer
+{
+ public:
+ DECLARE_LOG4CXX_OBJECT(SystemOutWriter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(SystemOutWriter)
+ LOG4CXX_CAST_ENTRY_CHAIN(Writer)
+ END_LOG4CXX_CAST_MAP()
- SystemOutWriter();
- ~SystemOutWriter();
+ SystemOutWriter();
+ ~SystemOutWriter();
- virtual void close(Pool& p);
- virtual void flush(Pool& p);
- virtual void write(const LogString& str, Pool& p);
+ virtual void close(Pool& p);
+ virtual void flush(Pool& p);
+ virtual void write(const LogString& str, Pool& p);
- static void write(const LogString& str);
- static void flush();
- private:
- SystemOutWriter(const SystemOutWriter&);
- SystemOutWriter& operator=(const SystemOutWriter&);
- static bool isWide();
- };
+ static void write(const LogString& str);
+ static void flush();
+ private:
+ SystemOutWriter(const SystemOutWriter&);
+ SystemOutWriter& operator=(const SystemOutWriter&);
+ static bool isWide();
+};
- } // namespace helpers
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/thread.h b/src/main/include/log4cxx/helpers/thread.h
index 880e07d..10806a5 100644
--- a/src/main/include/log4cxx/helpers/thread.h
+++ b/src/main/include/log4cxx/helpers/thread.h
@@ -22,15 +22,15 @@
#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
+ #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" {
@@ -42,77 +42,81 @@
namespace log4cxx
{
- namespace helpers
+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()
{
- class Pool;
- class ThreadLocal;
+ return thread != 0;
+ }
- 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);
- }
+ /**
+ * 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();
- /**
- * 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();
+ 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
+ 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/helpers/threadlocal.h b/src/main/include/log4cxx/helpers/threadlocal.h
index c4985af..a0f2917 100644
--- a/src/main/include/log4cxx/helpers/threadlocal.h
+++ b/src/main/include/log4cxx/helpers/threadlocal.h
@@ -22,11 +22,11 @@
#include <log4cxx/helpers/pool.h>
#if !defined(LOG4CXX_THREAD_FUNC)
-#if defined(_WIN32)
-#define LOG4CXX_THREAD_FUNC __stdcall
-#else
-#define LOG4CXX_THREAD_FUNC
-#endif
+ #if defined(_WIN32)
+ #define LOG4CXX_THREAD_FUNC __stdcall
+ #else
+ #define LOG4CXX_THREAD_FUNC
+ #endif
#endif
@@ -36,50 +36,51 @@
namespace log4cxx
{
- namespace helpers
- {
+namespace helpers
+{
- /**
- * This class provides thread-local variables. This class is similar in function
- * to java.lang.ThreadLocal.
- */
- class LOG4CXX_EXPORT ThreadLocal {
- public:
- /**
- * Create new instance.
- */
- ThreadLocal();
- /**
- * Destructor.
- */
- ~ThreadLocal();
- /**
- * Sets the value in the current thread's copy of this thread-local variable.
- * @param priv new value.
- */
- void set(void* priv);
- /**
- * Returns the value in the current thread's copy of this thread-local variable.
- * @return value of thread-local variable for the current thread.
- */
- void* get();
+/**
+ * This class provides thread-local variables. This class is similar in function
+ * to java.lang.ThreadLocal.
+ */
+class LOG4CXX_EXPORT ThreadLocal
+{
+ public:
+ /**
+ * Create new instance.
+ */
+ ThreadLocal();
+ /**
+ * Destructor.
+ */
+ ~ThreadLocal();
+ /**
+ * Sets the value in the current thread's copy of this thread-local variable.
+ * @param priv new value.
+ */
+ void set(void* priv);
+ /**
+ * Returns the value in the current thread's copy of this thread-local variable.
+ * @return value of thread-local variable for the current thread.
+ */
+ void* get();
- private:
- /**
- * Prevent use of default copy constructor.
- */
- ThreadLocal(const ThreadLocal&);
- /**
- * Prevent use of default assignment operator.
- */
- ThreadLocal& operator=(const ThreadLocal&);
+ private:
+ /**
+ * Prevent use of default copy constructor.
+ */
+ ThreadLocal(const ThreadLocal&);
+ /**
+ * Prevent use of default assignment operator.
+ */
+ ThreadLocal& operator=(const ThreadLocal&);
- static apr_threadkey_t* create(Pool& p);
+ static apr_threadkey_t* create(Pool& p);
- Pool p;
- apr_threadkey_t* key;
- };
- } // namespace helpers
+ Pool p;
+ apr_threadkey_t* key;
+};
+} // namespace helpers
} // namespace log4cxx
#endif //_LOG4CXX_HELPERS_THREAD_LOCAL_H
diff --git a/src/main/include/log4cxx/helpers/threadspecificdata.h b/src/main/include/log4cxx/helpers/threadspecificdata.h
index 04fe098..a76bb90 100644
--- a/src/main/include/log4cxx/helpers/threadspecificdata.h
+++ b/src/main/include/log4cxx/helpers/threadspecificdata.h
@@ -24,44 +24,44 @@
namespace log4cxx
{
- namespace helpers
- {
- /**
- * This class contains all the thread-specific
- * data in use by log4cxx.
- */
- class LOG4CXX_EXPORT ThreadSpecificData
- {
- public:
- ThreadSpecificData();
- ~ThreadSpecificData();
+namespace helpers
+{
+/**
+ * This class contains all the thread-specific
+ * data in use by log4cxx.
+ */
+class LOG4CXX_EXPORT ThreadSpecificData
+{
+ public:
+ ThreadSpecificData();
+ ~ThreadSpecificData();
- /**
- * Gets current thread specific data.
- * @return thread specific data, may be null.
- */
- static ThreadSpecificData* getCurrentData();
- /**
- * Release this ThreadSpecficData if empty.
- */
- void recycle();
+ /**
+ * Gets current thread specific data.
+ * @return thread specific data, may be null.
+ */
+ static ThreadSpecificData* getCurrentData();
+ /**
+ * Release this ThreadSpecficData if empty.
+ */
+ void recycle();
- static void put(const LogString& key, const LogString& val);
- static void push(const LogString& val);
- static void inherit(const log4cxx::NDC::Stack& stack);
+ static void put(const LogString& key, const LogString& val);
+ static void push(const LogString& val);
+ static void inherit(const log4cxx::NDC::Stack& stack);
- log4cxx::NDC::Stack& getStack();
- log4cxx::MDC::Map& getMap();
+ log4cxx::NDC::Stack& getStack();
+ log4cxx::MDC::Map& getMap();
- private:
- static ThreadSpecificData& getDataNoThreads();
- static ThreadSpecificData* createCurrentData();
- log4cxx::NDC::Stack ndcStack;
- log4cxx::MDC::Map mdcMap;
- };
+ private:
+ static ThreadSpecificData& getDataNoThreads();
+ static ThreadSpecificData* createCurrentData();
+ log4cxx::NDC::Stack ndcStack;
+ log4cxx::MDC::Map mdcMap;
+};
- } // namespace helpers
+} // namespace helpers
} // namespace log4cxx
#endif
diff --git a/src/main/include/log4cxx/helpers/timezone.h b/src/main/include/log4cxx/helpers/timezone.h
index 67c0626..3086669 100644
--- a/src/main/include/log4cxx/helpers/timezone.h
+++ b/src/main/include/log4cxx/helpers/timezone.h
@@ -26,45 +26,46 @@
namespace log4cxx
{
- namespace helpers
- {
- class TimeZone;
- LOG4CXX_PTR_DEF(TimeZone);
+namespace helpers
+{
+class TimeZone;
+LOG4CXX_PTR_DEF(TimeZone);
- class LOG4CXX_EXPORT TimeZone : public helpers::ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(TimeZone)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(TimeZone)
- END_LOG4CXX_CAST_MAP()
+class LOG4CXX_EXPORT TimeZone : public helpers::ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(TimeZone)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(TimeZone)
+ END_LOG4CXX_CAST_MAP()
- static const TimeZonePtr& getDefault();
- static const TimeZonePtr& getGMT();
- static const TimeZonePtr getTimeZone(const LogString& ID);
+ static const TimeZonePtr& getDefault();
+ static const TimeZonePtr& getGMT();
+ static const TimeZonePtr getTimeZone(const LogString& ID);
- const LogString getID() const {
- return id;
- }
+ const LogString getID() const
+ {
+ return id;
+ }
- /**
- * Expand an APR time into the human readable
- * components for this timezone.
- */
- virtual log4cxx_status_t explode(apr_time_exp_t* result,
- log4cxx_time_t input) const = 0;
+ /**
+ * Expand an APR time into the human readable
+ * components for this timezone.
+ */
+ virtual log4cxx_status_t explode(apr_time_exp_t* result,
+ log4cxx_time_t input) const = 0;
- protected:
- TimeZone(const LogString& ID);
- virtual ~TimeZone();
+ protected:
+ TimeZone(const LogString& ID);
+ virtual ~TimeZone();
- const LogString id;
- };
+ const LogString id;
+};
- }
+}
}
#endif //_LOG4CXX_HELPERS_TIMEZONE_H
diff --git a/src/main/include/log4cxx/helpers/transcoder.h b/src/main/include/log4cxx/helpers/transcoder.h
index 4336518..5f73b32 100644
--- a/src/main/include/log4cxx/helpers/transcoder.h
+++ b/src/main/include/log4cxx/helpers/transcoder.h
@@ -19,238 +19,241 @@
#define _LOG4CXX_HELPERS_TRANSCODER_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/logstring.h>
-namespace log4cxx {
- namespace helpers {
- class ByteBuffer;
- class Pool;
- /**
- * Simple transcoder for converting between
- * external char and wchar_t strings and
- * internal strings.
- *
- */
- class LOG4CXX_EXPORT Transcoder {
- public:
+namespace log4cxx
+{
+namespace helpers
+{
+class ByteBuffer;
+class Pool;
+/**
+* Simple transcoder for converting between
+* external char and wchar_t strings and
+* internal strings.
+*
+*/
+class LOG4CXX_EXPORT Transcoder
+{
+ public:
- /**
- * Appends this specified string of UTF-8 characters to LogString.
- */
- static void decodeUTF8(const std::string& src, LogString& dst);
- /**
- * Converts the LogString to a UTF-8 string.
- */
- static void encodeUTF8(const LogString& src, std::string& dst);
- /**
- * Converts the LogString to a UTF-8 string.
- */
- static char* encodeUTF8(const LogString& src, log4cxx::helpers::Pool& p);
- /**
- * Append UCS-4 code point to a byte buffer as UTF-8.
- */
- static void encodeUTF8(unsigned int sv, ByteBuffer& dst);
- /**
- * Append UCS-4 code point to a byte buffer as UTF-16LE.
- */
- static void encodeUTF16LE(unsigned int sv, ByteBuffer& dst);
- /**
- * Append UCS-4 code point to a byte buffer as UTF-16BE.
- */
- static void encodeUTF16BE(unsigned int sv, ByteBuffer& dst);
+ /**
+ * Appends this specified string of UTF-8 characters to LogString.
+ */
+ static void decodeUTF8(const std::string& src, LogString& dst);
+ /**
+ * Converts the LogString to a UTF-8 string.
+ */
+ static void encodeUTF8(const LogString& src, std::string& dst);
+ /**
+ * Converts the LogString to a UTF-8 string.
+ */
+ static char* encodeUTF8(const LogString& src, log4cxx::helpers::Pool& p);
+ /**
+ * Append UCS-4 code point to a byte buffer as UTF-8.
+ */
+ static void encodeUTF8(unsigned int sv, ByteBuffer& dst);
+ /**
+ * Append UCS-4 code point to a byte buffer as UTF-16LE.
+ */
+ static void encodeUTF16LE(unsigned int sv, ByteBuffer& dst);
+ /**
+ * Append UCS-4 code point to a byte buffer as UTF-16BE.
+ */
+ static void encodeUTF16BE(unsigned int sv, ByteBuffer& dst);
- /**
- * Decodes next character from a UTF-8 string.
- * @param in string from which the character is extracted.
- * @param iter iterator addressing start of character, will be
- * advanced to next character if successful.
- * @return scalar value (UCS-4) or 0xFFFF if invalid sequence.
- */
- static unsigned int decode(const std::string& in,
- std::string::const_iterator& iter);
+ /**
+ * Decodes next character from a UTF-8 string.
+ * @param in string from which the character is extracted.
+ * @param iter iterator addressing start of character, will be
+ * advanced to next character if successful.
+ * @return scalar value (UCS-4) or 0xFFFF if invalid sequence.
+ */
+ static unsigned int decode(const std::string& in,
+ std::string::const_iterator& iter);
- /**
- * Appends UCS-4 value to a UTF-8 string.
- * @param ch UCS-4 value.
- * @param dst destination.
+ /**
+ * Appends UCS-4 value to a UTF-8 string.
+ * @param ch UCS-4 value.
+ * @param dst destination.
+ */
+ static void encode(unsigned int ch, std::string& dst);
+
+ /**
+ * Appends string in the current code-page
+ * to a LogString.
+ */
+ static void decode(const std::string& src, LogString& dst);
+ /**
+ * Appends a LogString to a string in the current
+ * code-page. Unrepresentable characters may be
+ * replaced with loss characters.
*/
- static void encode(unsigned int ch, std::string& dst);
+ static void encode(const LogString& src, std::string& dst);
- /**
- * Appends string in the current code-page
- * to a LogString.
- */
- static void decode(const std::string& src, LogString& dst);
- /**
- * Appends a LogString to a string in the current
- * code-page. Unrepresentable characters may be
- * replaced with loss characters.
- */
- static void encode(const LogString& src, std::string& dst);
-
- /**
- * Encodes the specified LogString to the current
- * character set.
- * @param src string to encode.
- * @param p pool from which to allocate return value.
- * @return pool allocated string.
- */
- static char* encode(const LogString& src, log4cxx::helpers::Pool& p);
+ /**
+ * Encodes the specified LogString to the current
+ * character set.
+ * @param src string to encode.
+ * @param p pool from which to allocate return value.
+ * @return pool allocated string.
+ */
+ static char* encode(const LogString& src, log4cxx::helpers::Pool& p);
#if LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR_T || defined(WIN32) || defined(_WIN32)
- static void decode(const std::wstring& src, LogString& dst);
- static void encode(const LogString& src, std::wstring& dst);
- static wchar_t* wencode(const LogString& src, log4cxx::helpers::Pool& p);
+ static void decode(const std::wstring& src, LogString& dst);
+ static void encode(const LogString& src, std::wstring& dst);
+ static wchar_t* wencode(const LogString& src, log4cxx::helpers::Pool& p);
- /**
- * Decodes next character from a wstring.
- * @param in string from which the character is extracted.
- * @param iter iterator addressing start of character, will be
- * advanced to next character if successful.
- * @return scalar value (UCS-4) or 0xFFFF if invalid sequence.
- */
- static unsigned int decode(const std::wstring& in,
- std::wstring::const_iterator& iter);
+ /**
+ * Decodes next character from a wstring.
+ * @param in string from which the character is extracted.
+ * @param iter iterator addressing start of character, will be
+ * advanced to next character if successful.
+ * @return scalar value (UCS-4) or 0xFFFF if invalid sequence.
+ */
+ static unsigned int decode(const std::wstring& in,
+ std::wstring::const_iterator& iter);
- /**
- * Appends UCS-4 value to a UTF-8 string.
- * @param ch UCS-4 value.
- * @param dst destination.
- */
- static void encode(unsigned int ch, std::wstring& dst);
+ /**
+ * Appends UCS-4 value to a UTF-8 string.
+ * @param ch UCS-4 value.
+ * @param dst destination.
+ */
+ static void encode(unsigned int ch, std::wstring& dst);
#endif
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API || LOG4CXX_LOGCHAR_IS_UNICHAR
- static void decode(const std::basic_string<UniChar>& src, LogString& dst);
- static void encode(const LogString& src, std::basic_string<UniChar>& dst);
+ static void decode(const std::basic_string<UniChar>& src, LogString& dst);
+ static void encode(const LogString& src, std::basic_string<UniChar>& dst);
- /**
- * Decodes next character from a UniChar string.
- * @param in string from which the character is extracted.
- * @param iter iterator addressing start of character, will be
- * advanced to next character if successful.
- * @return scalar value (UCS-4) or 0xFFFF if invalid sequence.
- */
- static unsigned int decode(const std::basic_string<UniChar>& in,
- std::basic_string<UniChar>::const_iterator& iter);
+ /**
+ * Decodes next character from a UniChar string.
+ * @param in string from which the character is extracted.
+ * @param iter iterator addressing start of character, will be
+ * advanced to next character if successful.
+ * @return scalar value (UCS-4) or 0xFFFF if invalid sequence.
+ */
+ static unsigned int decode(const std::basic_string<UniChar>& in,
+ std::basic_string<UniChar>::const_iterator& iter);
- /**
- * Appends UCS-4 value to a UTF-8 string.
- * @param ch UCS-4 value.
- * @param dst destination.
- */
- static void encode(unsigned int ch, std::basic_string<UniChar>& dst);
+ /**
+ * Appends UCS-4 value to a UTF-8 string.
+ * @param ch UCS-4 value.
+ * @param dst destination.
+ */
+ static void encode(unsigned int ch, std::basic_string<UniChar>& dst);
#endif
#if LOG4CXX_CFSTRING_API
- static void decode(const CFStringRef& src, LogString& dst);
- static CFStringRef encode(const LogString& src);
+ static void decode(const CFStringRef& src, LogString& dst);
+ static CFStringRef encode(const LogString& src);
#endif
- enum { LOSSCHAR = 0x3F };
+ enum { LOSSCHAR = 0x3F };
- /**
- * Returns a logchar value given a character literal in the ASCII charset.
- * Used to implement the LOG4CXX_STR macro for EBCDIC and UNICHAR.
- */
- static logchar decode(char v);
- /**
- * Returns a LogString given a string literal in the ASCII charset.
- * Used to implement the LOG4CXX_STR macro for EBCDIC and UNICHAR.
- */
- static LogString decode(const char* v);
+ /**
+ * Returns a logchar value given a character literal in the ASCII charset.
+ * Used to implement the LOG4CXX_STR macro for EBCDIC and UNICHAR.
+ */
+ static logchar decode(char v);
+ /**
+ * Returns a LogString given a string literal in the ASCII charset.
+ * Used to implement the LOG4CXX_STR macro for EBCDIC and UNICHAR.
+ */
+ static LogString decode(const char* v);
- /**
- * Encodes a charset name in the default encoding
- * without using a CharsetEncoder (which could trigger recursion).
- */
- static std::string encodeCharsetName(const LogString& charsetName);
+ /**
+ * Encodes a charset name in the default encoding
+ * without using a CharsetEncoder (which could trigger recursion).
+ */
+ static std::string encodeCharsetName(const LogString& charsetName);
- private:
+ private:
- private:
- Transcoder();
- Transcoder(const Transcoder&);
- Transcoder& operator=(const Transcoder&);
- enum { BUFSIZE = 256 };
- static size_t encodeUTF8(unsigned int ch, char* dst);
- static size_t encodeUTF16BE(unsigned int ch, char* dst);
- static size_t encodeUTF16LE(unsigned int ch, char* dst);
+ private:
+ Transcoder();
+ Transcoder(const Transcoder&);
+ Transcoder& operator=(const Transcoder&);
+ enum { BUFSIZE = 256 };
+ static size_t encodeUTF8(unsigned int ch, char* dst);
+ static size_t encodeUTF16BE(unsigned int ch, char* dst);
+ static size_t encodeUTF16LE(unsigned int ch, char* dst);
- };
- }
+};
+}
}
#define LOG4CXX_ENCODE_CHAR(var, src) \
-std::string var; \
-log4cxx::helpers::Transcoder::encode(src, var)
+ std::string var; \
+ log4cxx::helpers::Transcoder::encode(src, var)
#define LOG4CXX_DECODE_CHAR(var, src) \
-log4cxx::LogString var; \
-log4cxx::helpers::Transcoder::decode(src, var)
+ log4cxx::LogString var; \
+ log4cxx::helpers::Transcoder::decode(src, var)
#define LOG4CXX_DECODE_CFSTRING(var, src) \
-log4cxx::LogString var; \
-log4cxx::helpers::Transcoder::decode(src, var)
+ log4cxx::LogString var; \
+ log4cxx::helpers::Transcoder::decode(src, var)
#define LOG4CXX_ENCODE_CFSTRING(var, src) \
-CFStringRef var = log4cxx::helpers::Transcoder::encode(src)
+ CFStringRef var = log4cxx::helpers::Transcoder::encode(src)
#if LOG4CXX_LOGCHAR_IS_WCHAR
#define LOG4CXX_ENCODE_WCHAR(var, src) \
-const std::wstring& var = src
+ const std::wstring& var = src
#define LOG4CXX_DECODE_WCHAR(var, src) \
-const log4cxx::LogString& var = src
+ const log4cxx::LogString& var = src
#else
#define LOG4CXX_ENCODE_WCHAR(var, src) \
-std::wstring var; \
-log4cxx::helpers::Transcoder::encode(src, var)
+ std::wstring var; \
+ log4cxx::helpers::Transcoder::encode(src, var)
#define LOG4CXX_DECODE_WCHAR(var, src) \
-log4cxx::LogString var; \
-log4cxx::helpers::Transcoder::decode(src, var)
+ log4cxx::LogString var; \
+ log4cxx::helpers::Transcoder::decode(src, var)
#endif
#if LOG4CXX_LOGCHAR_IS_UNICHAR
#define LOG4CXX_ENCODE_UNICHAR(var, src) \
-const std::basic_string<UniChar>& var = src
+ const std::basic_string<UniChar>& var = src
#define LOG4CXX_DECODE_UNICHAR(var, src) \
-const log4cxx::LogString& var = src
+ const log4cxx::LogString& var = src
#else
#define LOG4CXX_ENCODE_UNICHAR(var, src) \
-std::basic_string<UniChar> var; \
-log4cxx::helpers::Transcoder::encode(src, var)
+ std::basic_string<UniChar> var; \
+ log4cxx::helpers::Transcoder::encode(src, var)
#define LOG4CXX_DECODE_UNICHAR(var, src) \
-log4cxx::LogString var; \
-log4cxx::helpers::Transcoder::decode(src, var)
+ log4cxx::LogString var; \
+ log4cxx::helpers::Transcoder::decode(src, var)
#endif
#if defined(_MSC_VER)
-#pragma warning (pop)
+ #pragma warning (pop)
#endif
#endif //_LOG4CXX_HELPERS_TRANSCODER_H
diff --git a/src/main/include/log4cxx/helpers/transform.h b/src/main/include/log4cxx/helpers/transform.h
index 08be797..f866b35 100644
--- a/src/main/include/log4cxx/helpers/transform.h
+++ b/src/main/include/log4cxx/helpers/transform.h
@@ -22,41 +22,41 @@
namespace log4cxx
{
- namespace helpers
- {
- /**
- Utility class for transforming strings.
- */
- class LOG4CXX_EXPORT Transform
- {
- public:
- /**
- * This method takes a string which may contain HTML tags (ie,
- * <b>, <table>, etc) and replaces any '<' and '>'
- * characters with respective predefined entity references.
- *
- * @param buf output stream where to write the modified string.
- * @param input The text to be converted.
- * @return The input string with the characters '<' and '>' replaced with
- * &lt; and &gt; respectively.
- * */
- static void appendEscapingTags(
- LogString& buf, const LogString& input);
+namespace helpers
+{
+/**
+Utility class for transforming strings.
+*/
+class LOG4CXX_EXPORT Transform
+{
+ public:
+ /**
+ * This method takes a string which may contain HTML tags (ie,
+ * <b>, <table>, etc) and replaces any '<' and '>'
+ * characters with respective predefined entity references.
+ *
+ * @param buf output stream where to write the modified string.
+ * @param input The text to be converted.
+ * @return The input string with the characters '<' and '>' replaced with
+ * &lt; and &gt; respectively.
+ * */
+ static void appendEscapingTags(
+ LogString& buf, const LogString& input);
- /**
- * Ensures that embeded CDEnd strings (]]>) are handled properly
- * within message, NDC and throwable tag text.
- *
- * @param buf output stream holding the XML data to this point. The
- * initial CDStart (<![CDATA[) and final CDEnd (]]>) of the CDATA
- * section are the responsibility of the calling method.
- * @param input The String that is inserted into an existing CDATA
- * Section within buf.
- */
- static void appendEscapingCDATA(
- LogString& buf, const LogString& input);
- }; // class Transform
- } // namespace helpers
+ /**
+ * Ensures that embeded CDEnd strings (]]>) are handled properly
+ * within message, NDC and throwable tag text.
+ *
+ * @param buf output stream holding the XML data to this point. The
+ * initial CDStart (<![CDATA[) and final CDEnd (]]>) of the CDATA
+ * section are the responsibility of the calling method.
+ * @param input The String that is inserted into an existing CDATA
+ * Section within buf.
+ */
+ static void appendEscapingCDATA(
+ LogString& buf, const LogString& input);
+}; // class Transform
+} // namespace helpers
} //namespace log4cxx
#endif // _LOG4CXX_HELPERS_TRANSFORM_H
diff --git a/src/main/include/log4cxx/helpers/writer.h b/src/main/include/log4cxx/helpers/writer.h
index 1d4941a..d396b36 100644
--- a/src/main/include/log4cxx/helpers/writer.h
+++ b/src/main/include/log4cxx/helpers/writer.h
@@ -24,38 +24,39 @@
namespace log4cxx
{
- namespace helpers {
+namespace helpers
+{
- /**
- * Abstract class for writing to character streams.
- */
- class LOG4CXX_EXPORT Writer : public ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(Writer)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(Writer)
- END_LOG4CXX_CAST_MAP()
+/**
+* Abstract class for writing to character streams.
+*/
+class LOG4CXX_EXPORT Writer : public ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(Writer)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(Writer)
+ END_LOG4CXX_CAST_MAP()
- protected:
- Writer();
- virtual ~Writer();
+ protected:
+ Writer();
+ virtual ~Writer();
- public:
- virtual void close(Pool& p) = 0;
- virtual void flush(Pool& p) = 0;
- virtual void write(const LogString& str, Pool& p) = 0;
+ public:
+ virtual void close(Pool& p) = 0;
+ virtual void flush(Pool& p) = 0;
+ virtual void write(const LogString& str, Pool& p) = 0;
#ifdef LOG4CXX_MULTI_PROCESS
- virtual OutputStreamPtr getOutPutStreamPtr();
+ virtual OutputStreamPtr getOutPutStreamPtr();
#endif
- private:
- Writer(const Writer&);
- Writer& operator=(const Writer&);
- };
+ private:
+ Writer(const Writer&);
+ Writer& operator=(const Writer&);
+};
- LOG4CXX_PTR_DEF(Writer);
- } // namespace helpers
+LOG4CXX_PTR_DEF(Writer);
+} // namespace helpers
} //namespace log4cxx
diff --git a/src/main/include/log4cxx/helpers/xml.h b/src/main/include/log4cxx/helpers/xml.h
index a6b212b..965e460 100644
--- a/src/main/include/log4cxx/helpers/xml.h
+++ b/src/main/include/log4cxx/helpers/xml.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_HELPERS_XML_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
@@ -31,100 +31,100 @@
namespace log4cxx
{
- class File;
- namespace helpers
+class File;
+namespace helpers
+{
+class XMLDOMNode;
+typedef helpers::ObjectPtrT<XMLDOMNode> XMLDOMNodePtr;
+
+class XMLDOMDocument;
+typedef helpers::ObjectPtrT<XMLDOMDocument> XMLDOMDocumentPtr;
+
+class XMLDOMNodeList;
+typedef helpers::ObjectPtrT<XMLDOMNodeList> XMLDOMNodeListPtr;
+
+class LOG4CXX_EXPORT DOMException : public RuntimeException
+{
+ public:
+ DOMException() : RuntimeException(LOG4CXX_STR("DOM exception")) {}
+};
+
+
+/**
+The XMLDOMNode interface is the primary datatype for the entire Document
+Object Model.
+*/
+class LOG4CXX_EXPORT XMLDOMNode : virtual public Object
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMNode)
+ enum XMLDOMNodeType
{
- class XMLDOMNode;
- typedef helpers::ObjectPtrT<XMLDOMNode> XMLDOMNodePtr;
+ NOT_IMPLEMENTED_NODE = 0,
+ ELEMENT_NODE = 1,
+ DOCUMENT_NODE = 9
+ };
- class XMLDOMDocument;
- typedef helpers::ObjectPtrT<XMLDOMDocument> XMLDOMDocumentPtr;
-
- class XMLDOMNodeList;
- typedef helpers::ObjectPtrT<XMLDOMNodeList> XMLDOMNodeListPtr;
-
- class LOG4CXX_EXPORT DOMException : public RuntimeException
- {
- public:
- DOMException() : RuntimeException(LOG4CXX_STR("DOM exception")) {}
- };
+ virtual XMLDOMNodeListPtr getChildNodes() = 0;
+ virtual XMLDOMNodeType getNodeType() = 0;
+ virtual XMLDOMDocumentPtr getOwnerDocument() = 0;
+};
+LOG4CXX_PTR_DEF(XMLDOMNode);
- /**
- The XMLDOMNode interface is the primary datatype for the entire Document
- Object Model.
- */
- class LOG4CXX_EXPORT XMLDOMNode : virtual public Object
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMNode)
- enum XMLDOMNodeType
- {
- NOT_IMPLEMENTED_NODE = 0,
- ELEMENT_NODE = 1,
- DOCUMENT_NODE = 9
- };
+/**
+The XMLDOMElement interface represents an element in an XML document
+*/
+class LOG4CXX_EXPORT XMLDOMElement : virtual public XMLDOMNode
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMElement)
+ virtual LogString getTagName() = 0;
+ virtual LogString getAttribute(const LogString& name) = 0;
+};
+LOG4CXX_PTR_DEF(XMLDOMElement);
- virtual XMLDOMNodeListPtr getChildNodes() = 0;
- virtual XMLDOMNodeType getNodeType() = 0;
- virtual XMLDOMDocumentPtr getOwnerDocument() = 0;
- };
- LOG4CXX_PTR_DEF(XMLDOMNode);
+/**
+The XMLDOMDocument interface represents an entire XML document.
+Conceptually, it is the root of the document tree, and provides the
+primary access to the document's data.
+*/
+class LOG4CXX_EXPORT XMLDOMDocument : virtual public XMLDOMNode
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMDocument)
+ virtual void load(const File& fileName) = 0;
+ virtual XMLDOMElementPtr getDocumentElement() = 0;
+ virtual XMLDOMElementPtr getElementById(const LogString& tagName,
+ const LogString& elementId) = 0;
+};
+LOG4CXX_PTR_DEF(XMLDOMDocument);
- /**
- The XMLDOMElement interface represents an element in an XML document
- */
- class LOG4CXX_EXPORT XMLDOMElement : virtual public XMLDOMNode
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMElement)
- virtual LogString getTagName() = 0;
- virtual LogString getAttribute(const LogString& name) = 0;
- };
- LOG4CXX_PTR_DEF(XMLDOMElement);
+/**
+The XMLDOMNodeList interface provides the abstraction of an ordered
+collection of nodes, without defining or constraining how this
+collection is implemented.
- /**
- The XMLDOMDocument interface represents an entire XML document.
+XMLDOMNodeList objects in the DOM are live.
- Conceptually, it is the root of the document tree, and provides the
- primary access to the document's data.
- */
- class LOG4CXX_EXPORT XMLDOMDocument : virtual public XMLDOMNode
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMDocument)
- virtual void load(const File& fileName) = 0;
- virtual XMLDOMElementPtr getDocumentElement() = 0;
- virtual XMLDOMElementPtr getElementById(const LogString& tagName,
- const LogString& elementId) = 0;
- };
- LOG4CXX_PTR_DEF(XMLDOMDocument);
-
- /**
- The XMLDOMNodeList interface provides the abstraction of an ordered
- collection of nodes, without defining or constraining how this
- collection is implemented.
-
- XMLDOMNodeList objects in the DOM are live.
-
- The items in the XMLDOMNodeList are accessible via an integral index,
- starting from 0.
- */
- class LOG4CXX_EXPORT XMLDOMNodeList : virtual public Object
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMNodeList)
- virtual int getLength() = 0;
- virtual XMLDOMNodePtr item(int index) = 0;
- };
- LOG4CXX_PTR_DEF(XMLDOMNodeList);
- } // namespace helpers
+The items in the XMLDOMNodeList are accessible via an integral index,
+starting from 0.
+*/
+class LOG4CXX_EXPORT XMLDOMNodeList : virtual public Object
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(XMLDOMNodeList)
+ virtual int getLength() = 0;
+ virtual XMLDOMNodePtr item(int index) = 0;
+};
+LOG4CXX_PTR_DEF(XMLDOMNodeList);
+} // namespace helpers
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif // _LOG4CXX_HELPERS_XML_H
diff --git a/src/main/include/log4cxx/hierarchy.h b/src/main/include/log4cxx/hierarchy.h
index ff6854d..89a0be1 100644
--- a/src/main/include/log4cxx/hierarchy.h
+++ b/src/main/include/log4cxx/hierarchy.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_HIERARCHY_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/spi/loggerrepository.h>
@@ -34,250 +34,250 @@
namespace log4cxx
{
+/**
+This class is specialized in retrieving loggers by name and also
+maintaining the logger hierarchy.
+
+<p><em>The casual user does not have to deal with this class
+directly.</em>
+
+<p>The structure of the logger hierarchy is maintained by the
+#getLogger method. The hierarchy is such that children link
+to their parent but parents do not have any pointers to their
+children. Moreover, loggers can be instantiated in any order, in
+particular descendant before ancestor.
+
+<p>In case a descendant is created before a particular ancestor,
+then it creates a provision node for the ancestor and adds itself
+to the provision node. Other descendants of the same ancestor add
+themselves to the previously created provision node.
+*/
+class LOG4CXX_EXPORT Hierarchy :
+ public virtual spi::LoggerRepository,
+ public virtual helpers::ObjectImpl
+{
+ private:
+ log4cxx::helpers::Pool pool;
+ log4cxx::helpers::Mutex mutex;
+ bool configured;
+
+ spi::LoggerFactoryPtr defaultFactory;
+ spi::HierarchyEventListenerList listeners;
+
+ typedef std::map<LogString, LoggerPtr> LoggerMap;
+ LoggerMap* loggers;
+
+ typedef std::map<LogString, ProvisionNode> ProvisionNodeMap;
+ ProvisionNodeMap* provisionNodes;
+
+ LoggerPtr root;
+
+ int thresholdInt;
+ LevelPtr threshold;
+
+ bool emittedNoAppenderWarning;
+ bool emittedNoResourceBundleWarning;
+
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(Hierarchy)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(spi::LoggerRepository)
+ END_LOG4CXX_CAST_MAP()
+
/**
- This class is specialized in retrieving loggers by name and also
- maintaining the logger hierarchy.
-
- <p><em>The casual user does not have to deal with this class
- directly.</em>
-
- <p>The structure of the logger hierarchy is maintained by the
- #getLogger method. The hierarchy is such that children link
- to their parent but parents do not have any pointers to their
- children. Moreover, loggers can be instantiated in any order, in
- particular descendant before ancestor.
-
- <p>In case a descendant is created before a particular ancestor,
- then it creates a provision node for the ancestor and adds itself
- to the provision node. Other descendants of the same ancestor add
- themselves to the previously created provision node.
+ Create a new logger hierarchy.
*/
- class LOG4CXX_EXPORT Hierarchy :
- public virtual spi::LoggerRepository,
- public virtual helpers::ObjectImpl
- {
- private:
- log4cxx::helpers::Pool pool;
- log4cxx::helpers::Mutex mutex;
- bool configured;
+ Hierarchy();
- spi::LoggerFactoryPtr defaultFactory;
- spi::HierarchyEventListenerList listeners;
+ ~Hierarchy();
- typedef std::map<LogString, LoggerPtr> LoggerMap;
- LoggerMap* loggers;
+ void addRef() const;
+ void releaseRef() const;
- typedef std::map<LogString, ProvisionNode> ProvisionNodeMap;
- ProvisionNodeMap* provisionNodes;
+ void addHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener);
- LoggerPtr root;
+ /**
+ This call will clear all logger definitions from the internal
+ hashtable. Invoking this method will irrevocably mess up the
+ logger hierarchy.
- int thresholdInt;
- LevelPtr threshold;
+ <p>You should <em>really</em> know what you are doing before
+ invoking this method.
+ */
+ void clear();
- bool emittedNoAppenderWarning;
- bool emittedNoResourceBundleWarning;
+ void emitNoAppenderWarning(const LoggerPtr& logger);
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(Hierarchy)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(spi::LoggerRepository)
- END_LOG4CXX_CAST_MAP()
+ /**
+ Check if the named logger exists in the hierarchy. If so return
+ its reference, otherwise returns <code>null</code>.
- /**
- Create a new logger hierarchy.
- */
- Hierarchy();
+ @param name The name of the logger to search for.
- ~Hierarchy();
+ */
+ LoggerPtr exists(const LogString& name);
- void addRef() const;
- void releaseRef() const;
+ /**
+ The string form of {@link #setThreshold(const LevelPtr&) setThreshold}.
+ */
+ void setThreshold(const LogString& levelStr);
- void addHierarchyEventListener(const spi::HierarchyEventListenerPtr& listener);
+ /**
+ Enable logging for logging requests with level <code>l</code> or
+ higher. By default all levels are enabled.
- /**
- This call will clear all logger definitions from the internal
- hashtable. Invoking this method will irrevocably mess up the
- logger hierarchy.
+ @param l The minimum level for which logging requests are sent to
+ their appenders. */
+ void setThreshold(const LevelPtr& l);
- <p>You should <em>really</em> know what you are doing before
- invoking this method.
- */
- void clear();
+ void fireAddAppenderEvent(const LoggerPtr& logger, const AppenderPtr& appender);
- void emitNoAppenderWarning(const LoggerPtr& logger);
+ void fireRemoveAppenderEvent(const LoggerPtr& logger,
+ const AppenderPtr& appender);
- /**
- Check if the named logger exists in the hierarchy. If so return
- its reference, otherwise returns <code>null</code>.
+ /**
+ Returns a Level representation of the <code>enable</code>
+ state.
+ */
+ const LevelPtr& getThreshold() const;
- @param name The name of the logger to search for.
+ /**
+ Return a new logger instance named as the first parameter using
+ the default factory.
- */
- LoggerPtr exists(const LogString& name);
+ <p>If a logger of that name already exists, then it will be
+ returned. Otherwise, a new logger will be instantiated and
+ then linked with its existing ancestors as well as children.
- /**
- The string form of {@link #setThreshold(const LevelPtr&) setThreshold}.
- */
- void setThreshold(const LogString& levelStr);
+ @param name The name of the logger to retrieve.
- /**
- Enable logging for logging requests with level <code>l</code> or
- higher. By default all levels are enabled.
+ */
+ LoggerPtr getLogger(const LogString& name);
- @param l The minimum level for which logging requests are sent to
- their appenders. */
- void setThreshold(const LevelPtr& l);
+ /**
+ Return a new logger instance named as the first parameter using
+ <code>factory</code>.
- void fireAddAppenderEvent(const LoggerPtr& logger, const AppenderPtr& appender);
+ <p>If a logger of that name already exists, then it will be
+ returned. Otherwise, a new logger will be instantiated by the
+ <code>factory</code> parameter and linked with its existing
+ ancestors as well as children.
- void fireRemoveAppenderEvent(const LoggerPtr& logger,
- const AppenderPtr& appender);
+ @param name The name of the logger to retrieve.
+ @param factory The factory that will make the new logger instance.
- /**
- Returns a Level representation of the <code>enable</code>
- state.
- */
- const LevelPtr& getThreshold() const;
+ */
+ LoggerPtr getLogger(const LogString& name,
+ const spi::LoggerFactoryPtr& factory);
- /**
- Return a new logger instance named as the first parameter using
- the default factory.
+ /**
+ Returns all the currently defined loggers in this hierarchy as
+ a LoggerList.
- <p>If a logger of that name already exists, then it will be
- returned. Otherwise, a new logger will be instantiated and
- then linked with its existing ancestors as well as children.
+ <p>The root logger is <em>not</em> included in the returned
+ LoggerList. */
+ LoggerList getCurrentLoggers() const;
- @param name The name of the logger to retrieve.
+ /**
+ Get the root of this hierarchy.
+ */
+ LoggerPtr getRootLogger() const;
- */
- LoggerPtr getLogger(const LogString& name);
+ /**
+ This method will return <code>true</code> if this repository is
+ disabled for <code>level</code> object passed as parameter and
+ <code>false</code> otherwise. See also the
+ {@link #setThreshold(const LevelPtr&) setThreshold} method. */
+ bool isDisabled(int level) const;
- /**
- Return a new logger instance named as the first parameter using
- <code>factory</code>.
+ /**
+ Reset all values contained in this hierarchy instance to their
+ default. This removes all appenders from all categories, sets
+ the level of all non-root categories to <code>null</code>,
+ sets their additivity flag to <code>true</code> and sets the level
+ of the root logger to DEBUG. Moreover,
+ message disabling is set its default "off" value.
- <p>If a logger of that name already exists, then it will be
- returned. Otherwise, a new logger will be instantiated by the
- <code>factory</code> parameter and linked with its existing
- ancestors as well as children.
+ <p>Existing categories are not removed. They are just reset.
- @param name The name of the logger to retrieve.
- @param factory The factory that will make the new logger instance.
+ <p>This method should be used sparingly and with care as it will
+ block all logging until it is completed.</p>
+ */
+ void resetConfiguration();
- */
- LoggerPtr getLogger(const LogString& name,
- const spi::LoggerFactoryPtr& factory);
+ /**
+ Used by subclasses to add a renderer to the hierarchy passed as parameter.
+ */
+ /**
+ Shutting down a hierarchy will <em>safely</em> close and remove
+ all appenders in all categories including the root logger.
- /**
- Returns all the currently defined loggers in this hierarchy as
- a LoggerList.
+ <p>Some appenders such as {@link net::SocketAppender SocketAppender}
+ and AsyncAppender need to be closed before the
+ application exists. Otherwise, pending logging events might be
+ lost.
- <p>The root logger is <em>not</em> included in the returned
- LoggerList. */
- LoggerList getCurrentLoggers() const;
-
- /**
- Get the root of this hierarchy.
- */
- LoggerPtr getRootLogger() const;
-
- /**
- This method will return <code>true</code> if this repository is
- disabled for <code>level</code> object passed as parameter and
- <code>false</code> otherwise. See also the
- {@link #setThreshold(const LevelPtr&) setThreshold} method. */
- bool isDisabled(int level) const;
-
- /**
- Reset all values contained in this hierarchy instance to their
- default. This removes all appenders from all categories, sets
- the level of all non-root categories to <code>null</code>,
- sets their additivity flag to <code>true</code> and sets the level
- of the root logger to DEBUG. Moreover,
- message disabling is set its default "off" value.
-
- <p>Existing categories are not removed. They are just reset.
-
- <p>This method should be used sparingly and with care as it will
- block all logging until it is completed.</p>
- */
- void resetConfiguration();
-
- /**
- Used by subclasses to add a renderer to the hierarchy passed as parameter.
- */
- /**
- Shutting down a hierarchy will <em>safely</em> close and remove
- all appenders in all categories including the root logger.
-
- <p>Some appenders such as {@link net::SocketAppender SocketAppender}
- and AsyncAppender need to be closed before the
- application exists. Otherwise, pending logging events might be
- lost.
-
- <p>The <code>shutdown</code> method is careful to close nested
- appenders before closing regular appenders. This is allows
- configurations where a regular appender is attached to a logger
- and again to a nested appender.
- */
- void shutdown();
+ <p>The <code>shutdown</code> method is careful to close nested
+ appenders before closing regular appenders. This is allows
+ configurations where a regular appender is attached to a logger
+ and again to a nested appender.
+ */
+ void shutdown();
- virtual bool isConfigured();
- virtual void setConfigured(bool configured);
+ virtual bool isConfigured();
+ virtual void setConfigured(bool configured);
- private:
+ private:
- /**
- This method loops through all the *potential* parents of
- 'cat'. There 3 possible cases:
+ /**
+ This method loops through all the *potential* parents of
+ 'cat'. There 3 possible cases:
- 1) No entry for the potential parent of 'cat' exists
+ 1) No entry for the potential parent of 'cat' exists
- We create a ProvisionNode for this potential parent and insert
- 'cat' in that provision node.
+ We create a ProvisionNode for this potential parent and insert
+ 'cat' in that provision node.
- 2) There entry is of type Logger for the potential parent.
+ 2) There entry is of type Logger for the potential parent.
- The entry is 'cat's nearest existing parent. We update cat's
- parent field with this entry. We also break from the loop
- because updating our parent's parent is our parent's
- responsibility.
+ The entry is 'cat's nearest existing parent. We update cat's
+ parent field with this entry. We also break from the loop
+ because updating our parent's parent is our parent's
+ responsibility.
- 3) There entry is of type ProvisionNode for this potential parent.
+ 3) There entry is of type ProvisionNode for this potential parent.
- We add 'cat' to the list of children for this potential parent.
- */
- void updateParents(LoggerPtr logger);
+ We add 'cat' to the list of children for this potential parent.
+ */
+ void updateParents(LoggerPtr logger);
- /**
- We update the links for all the children that placed themselves
- in the provision node 'pn'. The second argument 'cat' is a
- reference for the newly created Logger, parent of all the
- children in 'pn'
+ /**
+ We update the links for all the children that placed themselves
+ in the provision node 'pn'. The second argument 'cat' is a
+ reference for the newly created Logger, parent of all the
+ children in 'pn'
- We loop on all the children 'c' in 'pn':
+ We loop on all the children 'c' in 'pn':
- If the child 'c' has been already linked to a child of
- 'cat' then there is no need to update 'c'.
+ If the child 'c' has been already linked to a child of
+ 'cat' then there is no need to update 'c'.
- Otherwise, we set cat's parent field to c's parent and set
- c's parent field to cat.
- */
- Hierarchy(const Hierarchy&);
- Hierarchy& operator=(const Hierarchy&);
+ Otherwise, we set cat's parent field to c's parent and set
+ c's parent field to cat.
+ */
+ Hierarchy(const Hierarchy&);
+ Hierarchy& operator=(const Hierarchy&);
- void updateChildren(ProvisionNode& pn, LoggerPtr logger);
- };
+ void updateChildren(ProvisionNode& pn, LoggerPtr logger);
+};
} //namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning (pop)
+ #pragma warning (pop)
#endif
#endif //_LOG4CXX_HIERARCHY_H
diff --git a/src/main/include/log4cxx/htmllayout.h b/src/main/include/log4cxx/htmllayout.h
index 8c0c6a7..27d62a7 100644
--- a/src/main/include/log4cxx/htmllayout.h
+++ b/src/main/include/log4cxx/htmllayout.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_HTML_LAYOUT_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
@@ -31,102 +31,115 @@
namespace log4cxx
{
+/**
+This layout outputs events in a HTML table.
+*/
+class LOG4CXX_EXPORT HTMLLayout : public Layout
+{
+ private:
+ // Print no location info by default
+ bool locationInfo; //= false
+
+ LogString title;
+
+ helpers::ISO8601DateFormat dateFormat;
+
+ public:
+ DECLARE_LOG4CXX_OBJECT(HTMLLayout)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(HTMLLayout)
+ LOG4CXX_CAST_ENTRY_CHAIN(Layout)
+ END_LOG4CXX_CAST_MAP()
+
+ HTMLLayout();
+
/**
- This layout outputs events in a HTML table.
+ The <b>LocationInfo</b> option takes a boolean value. By
+ default, it is set to false which means there will be no location
+ information output by this layout. If the the option is set to
+ true, then the file name and line number of the statement
+ at the origin of the log statement will be output.
+
+ <p>If you are embedding this layout within an
+ {@link net::SMTPAppender SMTPAppender} then make sure
+ to set the <b>LocationInfo</b> option of that appender as well.
*/
- class LOG4CXX_EXPORT HTMLLayout : public Layout
+ inline void setLocationInfo(bool locationInfoFlag)
{
- private:
- // Print no location info by default
- bool locationInfo; //= false
+ this->locationInfo = locationInfoFlag;
+ }
- LogString title;
+ /**
+ Returns the current value of the <b>LocationInfo</b> option.
+ */
+ inline bool getLocationInfo() const
+ {
+ return locationInfo;
+ }
- helpers::ISO8601DateFormat dateFormat;
+ /**
+ The <b>Title</b> option takes a String value. This option sets the
+ document title of the generated HTML document.
+ <p>Defaults to 'Log4cxx Log Messages'.
+ */
+ inline void setTitle(const LogString& title1)
+ {
+ this->title.assign(title1);
+ }
- public:
- DECLARE_LOG4CXX_OBJECT(HTMLLayout)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(HTMLLayout)
- LOG4CXX_CAST_ENTRY_CHAIN(Layout)
- END_LOG4CXX_CAST_MAP()
+ /**
+ Returns the current value of the <b>Title</b> option.
+ */
+ inline const LogString& getTitle() const
+ {
+ return title;
+ }
- HTMLLayout();
+ /**
+ Returns the content type output by this layout, i.e "text/html".
+ */
+ virtual LogString getContentType() const
+ {
+ return LOG4CXX_STR("text/html");
+ }
- /**
- The <b>LocationInfo</b> option takes a boolean value. By
- default, it is set to false which means there will be no location
- information output by this layout. If the the option is set to
- true, then the file name and line number of the statement
- at the origin of the log statement will be output.
+ /**
+ No options to activate.
+ */
+ virtual void activateOptions(log4cxx::helpers::Pool& /* p */) {}
- <p>If you are embedding this layout within an
- {@link net::SMTPAppender SMTPAppender} then make sure
- to set the <b>LocationInfo</b> option of that appender as well.
- */
- inline void setLocationInfo(bool locationInfoFlag)
- { this->locationInfo = locationInfoFlag; }
+ /**
+ Set options
+ */
+ virtual void setOption(const LogString& option, const LogString& value);
- /**
- Returns the current value of the <b>LocationInfo</b> option.
- */
- inline bool getLocationInfo() const
- { return locationInfo; }
+ virtual void format(LogString& output,
+ const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool) const;
- /**
- The <b>Title</b> option takes a String value. This option sets the
- document title of the generated HTML document.
- <p>Defaults to 'Log4cxx Log Messages'.
- */
- inline void setTitle(const LogString& title1)
- { this->title.assign(title1); }
+ /**
+ Append appropriate HTML headers.
+ */
+ virtual void appendHeader(LogString& output, log4cxx::helpers::Pool& pool);
- /**
- Returns the current value of the <b>Title</b> option.
- */
- inline const LogString& getTitle() const
- { return title; }
+ /**
+ Append the appropriate HTML footers.
+ */
+ virtual void appendFooter(LogString& output, log4cxx::helpers::Pool& pool);
- /**
- Returns the content type output by this layout, i.e "text/html".
- */
- virtual LogString getContentType() const { return LOG4CXX_STR("text/html"); }
+ /**
+ The HTML layout handles the throwable contained in logging
+ events. Hence, this method return <code>false</code>. */
+ virtual bool ignoresThrowable() const
+ {
+ return false;
+ }
- /**
- No options to activate.
- */
- virtual void activateOptions(log4cxx::helpers::Pool& /* p */) {}
-
- /**
- Set options
- */
- virtual void setOption(const LogString& option, const LogString& value);
-
- virtual void format(LogString& output,
- const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool) const;
-
- /**
- Append appropriate HTML headers.
- */
- virtual void appendHeader(LogString& output, log4cxx::helpers::Pool& pool);
-
- /**
- Append the appropriate HTML footers.
- */
- virtual void appendFooter(LogString& output, log4cxx::helpers::Pool& pool);
-
- /**
- The HTML layout handles the throwable contained in logging
- events. Hence, this method return <code>false</code>. */
- virtual bool ignoresThrowable() const
- { return false; }
-
- }; // class HtmlLayout
- LOG4CXX_PTR_DEF(HTMLLayout);
+}; // class HtmlLayout
+LOG4CXX_PTR_DEF(HTMLLayout);
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
diff --git a/src/main/include/log4cxx/layout.h b/src/main/include/log4cxx/layout.h
index 22ca17e..0942b77 100644
--- a/src/main/include/log4cxx/layout.h
+++ b/src/main/include/log4cxx/layout.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_LAYOUT_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
@@ -32,66 +32,66 @@
namespace log4cxx
{
+/**
+Extend this abstract class to create your own log layout format.
+*/
+class LOG4CXX_EXPORT Layout :
+ public virtual spi::OptionHandler,
+ public virtual helpers::ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(Layout)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(Layout)
+ LOG4CXX_CAST_ENTRY(spi::OptionHandler)
+ END_LOG4CXX_CAST_MAP()
+
+ virtual ~Layout();
+ void addRef() const;
+ void releaseRef() const;
+
+
/**
- Extend this abstract class to create your own log layout format.
+ Implement this method to create your own layout format.
*/
- class LOG4CXX_EXPORT Layout :
- public virtual spi::OptionHandler,
- public virtual helpers::ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(Layout)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(Layout)
- LOG4CXX_CAST_ENTRY(spi::OptionHandler)
- END_LOG4CXX_CAST_MAP()
+ virtual void format(LogString& output,
+ const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool) const = 0;
- virtual ~Layout();
- void addRef() const;
- void releaseRef() const;
+ /**
+ Returns the content type output by this layout. The base class
+ returns "text/plain".
+ */
+ virtual LogString getContentType() const;
+ /**
+ Append the header for the layout format. The base class does
+ nothing.
+ */
+ virtual void appendHeader(LogString& output, log4cxx::helpers::Pool& p);
- /**
- Implement this method to create your own layout format.
- */
- virtual void format(LogString& output,
- const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool) const = 0;
+ /**
+ Append the footer for the layout format. The base class does
+ nothing.
+ */
+ virtual void appendFooter(LogString& output, log4cxx::helpers::Pool& p);
- /**
- Returns the content type output by this layout. The base class
- returns "text/plain".
- */
- virtual LogString getContentType() const;
+ /**
+ If the layout handles the throwable object contained within
+ {@link spi::LoggingEvent LoggingEvent}, then the layout should return
+ <code>false</code>. Otherwise, if the layout ignores throwable
+ object, then the layout should return <code>true</code>.
- /**
- Append the header for the layout format. The base class does
- nothing.
- */
- virtual void appendHeader(LogString& output, log4cxx::helpers::Pool& p);
-
- /**
- Append the footer for the layout format. The base class does
- nothing.
- */
- virtual void appendFooter(LogString& output, log4cxx::helpers::Pool& p);
-
- /**
- If the layout handles the throwable object contained within
- {@link spi::LoggingEvent LoggingEvent}, then the layout should return
- <code>false</code>. Otherwise, if the layout ignores throwable
- object, then the layout should return <code>true</code>.
-
- <p>The SimpleLayout, TTCCLayout,
- PatternLayout all return <code>true</code>. The {@link
- xml::XMLLayout XMLLayout} returns <code>false</code>.
- */
- virtual bool ignoresThrowable() const = 0;
- };
- LOG4CXX_PTR_DEF(Layout);
+ <p>The SimpleLayout, TTCCLayout,
+ PatternLayout all return <code>true</code>. The {@link
+ xml::XMLLayout XMLLayout} returns <code>false</code>.
+ */
+ virtual bool ignoresThrowable() const = 0;
+};
+LOG4CXX_PTR_DEF(Layout);
}
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif // _LOG4CXX_LAYOUT_H
diff --git a/src/main/include/log4cxx/level.h b/src/main/include/log4cxx/level.h
index 332e19b..e59b904 100644
--- a/src/main/include/log4cxx/level.h
+++ b/src/main/include/log4cxx/level.h
@@ -27,291 +27,308 @@
namespace log4cxx
{
- /**
- * LOG4CXX_PTR_DEF can't be used to get a smart pointer for Level because we need to override
- * the comparison operator and this doesn't work if the template has alread been initialized,
- * which is what the macro does on some platforms. The overriding takes place underneath the
- * definition of Level because we need one of it's methods.
- *
- * https://issues.apache.org/jira/browse/LOGCXX-394
- */
- class Level;
- typedef log4cxx::helpers::ObjectPtrT<Level> LevelPtr;
+/**
+ * LOG4CXX_PTR_DEF can't be used to get a smart pointer for Level because we need to override
+ * the comparison operator and this doesn't work if the template has alread been initialized,
+ * which is what the macro does on some platforms. The overriding takes place underneath the
+ * definition of Level because we need one of it's methods.
+ *
+ * https://issues.apache.org/jira/browse/LOGCXX-394
+ */
+class Level;
+typedef log4cxx::helpers::ObjectPtrT<Level> LevelPtr;
- /**
- Defines the minimum set of levels recognized by the system, that is
- <code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
- <code>WARN</code>, <code>INFO</code>, <code>DEBUG</code> and
- <code>ALL</code>.
- <p>The <code>Level</code> class may be subclassed to define a larger
- level set.
- */
- class LOG4CXX_EXPORT Level : public helpers::ObjectImpl
+/**
+Defines the minimum set of levels recognized by the system, that is
+<code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
+<code>WARN</code>, <code>INFO</code>, <code>DEBUG</code> and
+<code>ALL</code>.
+<p>The <code>Level</code> class may be subclassed to define a larger
+level set.
+*/
+class LOG4CXX_EXPORT Level : public helpers::ObjectImpl
+{
+ public:
+ class LOG4CXX_EXPORT LevelClass : public helpers::Class
{
- public:
- class LOG4CXX_EXPORT LevelClass : public helpers::Class
+ public:
+ LevelClass() : helpers::Class() {}
+
+ virtual LogString getName() const
{
- public:
- LevelClass() : helpers::Class() {}
-
- virtual LogString getName() const {
- return LOG4CXX_STR("Level");
- }
-
- virtual LevelPtr toLevel(const LogString& sArg) const
- { return Level::toLevelLS(sArg); }
-
- virtual LevelPtr toLevel(int val) const
- { return Level::toLevel(val); }
- };
-
- DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(Level, LevelClass)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(Level)
- END_LOG4CXX_CAST_MAP()
-
- /**
- Instantiate a Level object.
- */
- Level(int level,
- const LogString& name,
- int syslogEquivalent);
-
- /**
- Convert the string passed as argument to a level. If the
- conversion fails, then this method returns DEBUG.
- * @param sArg level name.
- */
- static LevelPtr toLevel(const std::string& sArg);
- /**
- Convert the string passed as argument to a level. If the
- conversion fails, then this method returns the value of
- <code>defaultLevel</code>.
- * @param sArg level name.
- * @param defaultLevel level to return if no match.
- * @return
- */
- static LevelPtr toLevel(const std::string& sArg,
- const LevelPtr& defaultLevel);
- /**
- * Get the name of the level in the current encoding.
- * @param name buffer to which name is appended.
- */
- void toString(std::string& name) const;
-
-#if LOG4CXX_WCHAR_T_API
- /**
- Convert the string passed as argument to a level. If the
- conversion fails, then this method returns DEBUG.
- * @param sArg level name.
- */
- static LevelPtr toLevel(const std::wstring& sArg);
- /**
- Convert the string passed as argument to a level. If the
- conversion fails, then this method returns the value of
- <code>defaultLevel</code>.
- * @param sArg level name.
- * @param defaultLevel level to return if no match.
- * @return
- */
- static LevelPtr toLevel(const std::wstring& sArg,
- const LevelPtr& defaultLevel);
- /**
- * Get the name of the level.
- * @param name buffer to which name is appended.
- */
- void toString(std::wstring& name) const;
-#endif
-#if LOG4CXX_UNICHAR_API
- /**
- Convert the string passed as argument to a level. If the
- conversion fails, then this method returns DEBUG.
- * @param sArg level name.
- */
- static LevelPtr toLevel(const std::basic_string<UniChar>& sArg);
- /**
- Convert the string passed as argument to a level. If the
- conversion fails, then this method returns the value of
- <code>defaultLevel</code>.
- * @param sArg level name.
- * @param defaultLevel level to return if no match.
- * @return
- */
- static LevelPtr toLevel(const std::basic_string<UniChar>& sArg,
- const LevelPtr& defaultLevel);
- /**
- * Get the name of the level.
- * @param name buffer to which name is appended.
- */
- void toString(std::basic_string<UniChar>& name) const;
-#endif
-#if LOG4CXX_CFSTRING_API
- /**
- Convert the string passed as argument to a level. If the
- conversion fails, then this method returns DEBUG.
- * @param sArg level name.
- */
- static LevelPtr toLevel(const CFStringRef& sArg);
- /**
- Convert the string passed as argument to a level. If the
- conversion fails, then this method returns the value of
- <code>defaultLevel</code>.
- * @param sArg level name.
- * @param defaultLevel level to return if no match.
- * @return
- */
- static LevelPtr toLevel(const CFStringRef& sArg,
- const LevelPtr& defaultLevel);
- /**
- * Get the name of the level.
- * @param name buffer to which name is appended.
- */
- void toString(CFStringRef& name) const;
-#endif
- /**
- Convert the string passed as argument to a level. If the
- conversion fails, then this method returns DEBUG.
- * @param sArg level name.
- */
- static LevelPtr toLevelLS(const LogString& sArg);
- /**
- Convert the string passed as argument to a level. If the
- conversion fails, then this method returns the value of
- <code>defaultLevel</code>.
- * @param sArg level name.
- * @param defaultLevel level to return if no match.
- * @return
- */
- static LevelPtr toLevelLS(const LogString& sArg,
- const LevelPtr& defaultLevel);
- /**
- Returns the string representation of this level.
- * @return level name.
- */
- LogString toString() const;
-
- /**
- Convert an integer passed as argument to a level. If the
- conversion fails, then this method returns DEBUG.
- */
- static LevelPtr toLevel(int val);
-
- /**
- Convert an integer passed as argument to a level. If the
- conversion fails, then this method returns the specified default.
- */
- static LevelPtr toLevel(int val, const LevelPtr& defaultLevel);
-
- enum {
- OFF_INT = INT_MAX,
- FATAL_INT = 50000,
- ERROR_INT = 40000,
- WARN_INT = 30000,
- INFO_INT = 20000,
- DEBUG_INT = 10000,
- TRACE_INT = 5000,
- ALL_INT = INT_MIN
- };
-
-
- static LevelPtr getAll();
- static LevelPtr getFatal();
- static LevelPtr getError();
- static LevelPtr getWarn();
- static LevelPtr getInfo();
- static LevelPtr getDebug();
- static LevelPtr getTrace();
- static LevelPtr getOff();
-
-
- /**
- Two levels are equal if their level fields are equal.
- */
- virtual bool equals(const LevelPtr& level) const;
-
- inline bool operator==(const Level& level1) const
- { return (this->level == level1.level); }
-
- inline bool operator!=(const Level& level1) const
- { return (this->level != level1.level); }
-
- /**
- Return the syslog equivalent of this level as an integer.
- */
- inline int getSyslogEquivalent() const {
- return syslogEquivalent;
+ return LOG4CXX_STR("Level");
}
-
- /**
- Returns <code>true</code> if this level has a higher or equal
- level than the level passed as argument, <code>false</code>
- otherwise.
-
- <p>You should think twice before overriding the default
- implementation of <code>isGreaterOrEqual</code> method.
-
- */
- virtual bool isGreaterOrEqual(const LevelPtr& level) const;
-
-
- /**
- Returns the integer representation of this level.
- */
- inline int toInt() const {
- return level;
+ virtual LevelPtr toLevel(const LogString& sArg) const
+ {
+ return Level::toLevelLS(sArg);
}
- private:
- int level;
- LogString name;
- int syslogEquivalent;
- Level(const Level&);
- Level& operator=(const Level&);
+ virtual LevelPtr toLevel(int val) const
+ {
+ return Level::toLevel(val);
+ }
};
- /**
- * We need to double some logic from LOG4CXX_PTR_DEF or else we are unable to override the
- * comparison operator, which we need to properly fix LOGCXX-394.
- *
- * https://issues.apache.org/jira/browse/LOGCXX-394
- */
- namespace helpers {
+ DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(Level, LevelClass)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(Level)
+ END_LOG4CXX_CAST_MAP()
- /** @class log4cxx::helpers::ObjectPtr */
- template<> inline bool LevelPtr::operator==(const LevelPtr& rhs) const
- { return (*this)->equals(rhs); }
- template<> inline bool LevelPtr::operator!=(const LevelPtr& rhs) const
- { return !(*this == rhs); }
- #if defined(_MSC_VER) && !defined(LOG4CXX_STATIC) && defined(LOG4CXX)
- template class LOG4CXX_EXPORT log4cxx::helpers::ObjectPtrT<Level>;
- #elif defined(_MSC_VER) && !defined(LOG4CXX_STATIC)
- #pragma warning(push)
- #pragma warning(disable: 4231)
- extern template class LOG4CXX_EXPORT log4cxx::helpers::ObjectPtrT<Level>;
- #pragma warning(pop)
- #endif
+ /**
+ Instantiate a Level object.
+ */
+ Level(int level,
+ const LogString& name,
+ int syslogEquivalent);
- }
+ /**
+ Convert the string passed as argument to a level. If the
+ conversion fails, then this method returns DEBUG.
+ * @param sArg level name.
+ */
+ static LevelPtr toLevel(const std::string& sArg);
+ /**
+ Convert the string passed as argument to a level. If the
+ conversion fails, then this method returns the value of
+ <code>defaultLevel</code>.
+ * @param sArg level name.
+ * @param defaultLevel level to return if no match.
+ * @return
+ */
+ static LevelPtr toLevel(const std::string& sArg,
+ const LevelPtr& defaultLevel);
+ /**
+ * Get the name of the level in the current encoding.
+ * @param name buffer to which name is appended.
+ */
+ void toString(std::string& name) const;
+
+#if LOG4CXX_WCHAR_T_API
+ /**
+ Convert the string passed as argument to a level. If the
+ conversion fails, then this method returns DEBUG.
+ * @param sArg level name.
+ */
+ static LevelPtr toLevel(const std::wstring& sArg);
+ /**
+ Convert the string passed as argument to a level. If the
+ conversion fails, then this method returns the value of
+ <code>defaultLevel</code>.
+ * @param sArg level name.
+ * @param defaultLevel level to return if no match.
+ * @return
+ */
+ static LevelPtr toLevel(const std::wstring& sArg,
+ const LevelPtr& defaultLevel);
+ /**
+ * Get the name of the level.
+ * @param name buffer to which name is appended.
+ */
+ void toString(std::wstring& name) const;
+#endif
+#if LOG4CXX_UNICHAR_API
+ /**
+ Convert the string passed as argument to a level. If the
+ conversion fails, then this method returns DEBUG.
+ * @param sArg level name.
+ */
+ static LevelPtr toLevel(const std::basic_string<UniChar>& sArg);
+ /**
+ Convert the string passed as argument to a level. If the
+ conversion fails, then this method returns the value of
+ <code>defaultLevel</code>.
+ * @param sArg level name.
+ * @param defaultLevel level to return if no match.
+ * @return
+ */
+ static LevelPtr toLevel(const std::basic_string<UniChar>& sArg,
+ const LevelPtr& defaultLevel);
+ /**
+ * Get the name of the level.
+ * @param name buffer to which name is appended.
+ */
+ void toString(std::basic_string<UniChar>& name) const;
+#endif
+#if LOG4CXX_CFSTRING_API
+ /**
+ Convert the string passed as argument to a level. If the
+ conversion fails, then this method returns DEBUG.
+ * @param sArg level name.
+ */
+ static LevelPtr toLevel(const CFStringRef& sArg);
+ /**
+ Convert the string passed as argument to a level. If the
+ conversion fails, then this method returns the value of
+ <code>defaultLevel</code>.
+ * @param sArg level name.
+ * @param defaultLevel level to return if no match.
+ * @return
+ */
+ static LevelPtr toLevel(const CFStringRef& sArg,
+ const LevelPtr& defaultLevel);
+ /**
+ * Get the name of the level.
+ * @param name buffer to which name is appended.
+ */
+ void toString(CFStringRef& name) const;
+#endif
+ /**
+ Convert the string passed as argument to a level. If the
+ conversion fails, then this method returns DEBUG.
+ * @param sArg level name.
+ */
+ static LevelPtr toLevelLS(const LogString& sArg);
+ /**
+ Convert the string passed as argument to a level. If the
+ conversion fails, then this method returns the value of
+ <code>defaultLevel</code>.
+ * @param sArg level name.
+ * @param defaultLevel level to return if no match.
+ * @return
+ */
+ static LevelPtr toLevelLS(const LogString& sArg,
+ const LevelPtr& defaultLevel);
+ /**
+ Returns the string representation of this level.
+ * @return level name.
+ */
+ LogString toString() const;
+
+ /**
+ Convert an integer passed as argument to a level. If the
+ conversion fails, then this method returns DEBUG.
+ */
+ static LevelPtr toLevel(int val);
+
+ /**
+ Convert an integer passed as argument to a level. If the
+ conversion fails, then this method returns the specified default.
+ */
+ static LevelPtr toLevel(int val, const LevelPtr& defaultLevel);
+
+ enum
+ {
+ OFF_INT = INT_MAX,
+ FATAL_INT = 50000,
+ ERROR_INT = 40000,
+ WARN_INT = 30000,
+ INFO_INT = 20000,
+ DEBUG_INT = 10000,
+ TRACE_INT = 5000,
+ ALL_INT = INT_MIN
+ };
+
+
+ static LevelPtr getAll();
+ static LevelPtr getFatal();
+ static LevelPtr getError();
+ static LevelPtr getWarn();
+ static LevelPtr getInfo();
+ static LevelPtr getDebug();
+ static LevelPtr getTrace();
+ static LevelPtr getOff();
+
+
+ /**
+ Two levels are equal if their level fields are equal.
+ */
+ virtual bool equals(const LevelPtr& level) const;
+
+ inline bool operator==(const Level& level1) const
+ {
+ return (this->level == level1.level);
+ }
+
+ inline bool operator!=(const Level& level1) const
+ {
+ return (this->level != level1.level);
+ }
+
+ /**
+ Return the syslog equivalent of this level as an integer.
+ */
+ inline int getSyslogEquivalent() const
+ {
+ return syslogEquivalent;
+ }
+
+
+ /**
+ Returns <code>true</code> if this level has a higher or equal
+ level than the level passed as argument, <code>false</code>
+ otherwise.
+
+ <p>You should think twice before overriding the default
+ implementation of <code>isGreaterOrEqual</code> method.
+
+ */
+ virtual bool isGreaterOrEqual(const LevelPtr& level) const;
+
+
+ /**
+ Returns the integer representation of this level.
+ */
+ inline int toInt() const
+ {
+ return level;
+ }
+
+ private:
+ int level;
+ LogString name;
+ int syslogEquivalent;
+ Level(const Level&);
+ Level& operator=(const Level&);
+};
+
+/**
+ * We need to double some logic from LOG4CXX_PTR_DEF or else we are unable to override the
+ * comparison operator, which we need to properly fix LOGCXX-394.
+ *
+ * https://issues.apache.org/jira/browse/LOGCXX-394
+ */
+namespace helpers
+{
+
+/** @class log4cxx::helpers::ObjectPtr */
+template<> inline bool LevelPtr::operator==(const LevelPtr& rhs) const
+{
+ return (*this)->equals(rhs);
+}
+template<> inline bool LevelPtr::operator!=(const LevelPtr& rhs) const
+{
+ return !(*this == rhs);
+}
+#if defined(_MSC_VER) && !defined(LOG4CXX_STATIC) && defined(LOG4CXX)
+ template class LOG4CXX_EXPORT log4cxx::helpers::ObjectPtrT<Level>;
+#elif defined(_MSC_VER) && !defined(LOG4CXX_STATIC)
+ #pragma warning(push)
+ #pragma warning(disable: 4231)
+ extern template class LOG4CXX_EXPORT log4cxx::helpers::ObjectPtrT<Level>;
+ #pragma warning(pop)
+#endif
+
+}
}
#define DECLARE_LOG4CXX_LEVEL(level)\
-public:\
- class Class##level : public Level::LevelClass\
-{\
-public:\
- Class##level() : Level::LevelClass() {}\
- virtual LogString getName() const { return LOG4CXX_STR(#level); } \
- virtual LevelPtr toLevel(const LogString& sArg) const\
- { return level::toLevelLS(sArg); }\
- virtual LevelPtr toLevel(int val) const\
- { return level::toLevel(val); }\
-};\
-DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(level, Class##level)
+ public:\
+ class Class##level : public Level::LevelClass\
+ {\
+ public:\
+ Class##level() : Level::LevelClass() {}\
+ virtual LogString getName() const { return LOG4CXX_STR(#level); } \
+ virtual LevelPtr toLevel(const LogString& sArg) const\
+ { return level::toLevelLS(sArg); }\
+ virtual LevelPtr toLevel(int val) const\
+ { return level::toLevel(val); }\
+ };\
+ DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(level, Class##level)
#define IMPLEMENT_LOG4CXX_LEVEL(level) \
-IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(level, Class##level)
+ IMPLEMENT_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS(level, Class##level)
#endif //_LOG4CXX_LEVEL_H
diff --git a/src/main/include/log4cxx/logger.h b/src/main/include/log4cxx/logger.h
index bece458..62b6ed9 100644
--- a/src/main/include/log4cxx/logger.h
+++ b/src/main/include/log4cxx/logger.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_LOGGER_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/helpers/appenderattachableimpl.h>
@@ -35,36 +35,38 @@
namespace log4cxx
{
- namespace helpers {
- class synchronized;
- }
+namespace helpers
+{
+class synchronized;
+}
- namespace spi {
- class LoggerRepository;
- LOG4CXX_PTR_DEF(LoggerRepository);
- class LoggerFactory;
- LOG4CXX_PTR_DEF(LoggerFactory);
- }
+namespace spi
+{
+class LoggerRepository;
+LOG4CXX_PTR_DEF(LoggerRepository);
+class LoggerFactory;
+LOG4CXX_PTR_DEF(LoggerFactory);
+}
- class Logger;
- /** smart pointer to a Logger class */
- LOG4CXX_PTR_DEF(Logger);
- LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
+class Logger;
+/** smart pointer to a Logger class */
+LOG4CXX_PTR_DEF(Logger);
+LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
- /**
- This is the central class in the log4cxx package. Most logging
- operations, except configuration, are done through this class.
- */
- class LOG4CXX_EXPORT Logger :
- public virtual log4cxx::spi::AppenderAttachable,
- public virtual helpers::ObjectImpl
- {
+/**
+This is the central class in the log4cxx package. Most logging
+operations, except configuration, are done through this class.
+*/
+class LOG4CXX_EXPORT Logger :
+ 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)
+ LOG4CXX_CAST_ENTRY(Logger)
+ LOG4CXX_CAST_ENTRY(spi::AppenderAttachable)
END_LOG4CXX_CAST_MAP()
private:
@@ -98,18 +100,18 @@
// Loggers need to know what Hierarchy they are in
- log4cxx::spi::LoggerRepository * repository;
+ log4cxx::spi::LoggerRepository* repository;
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;
@@ -143,7 +145,7 @@
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.
@@ -516,7 +518,7 @@
@param location location of source of logging request.
*/
void forcedLog(const LevelPtr& level, const std::string& message,
- const log4cxx::spi::LocationInfo& location) const;
+ const log4cxx::spi::LocationInfo& location) const;
/**
This method creates a new logging event and logs the event
without further checks.
@@ -534,7 +536,7 @@
@param location location of source of logging request.
*/
void forcedLog(const LevelPtr& level, const std::wstring& message,
- const log4cxx::spi::LocationInfo& location) const;
+ const log4cxx::spi::LocationInfo& location) const;
/**
This method creates a new logging event and logs the event
without further checks.
@@ -552,7 +554,7 @@
@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;
+ const log4cxx::spi::LocationInfo& location) const;
/**
This method creates a new logging event and logs the event
without further checks.
@@ -570,7 +572,7 @@
@param location location of source of logging request.
*/
void forcedLog(const LevelPtr& level, const CFStringRef& message,
- const log4cxx::spi::LocationInfo& location) const;
+ const log4cxx::spi::LocationInfo& location) const;
/**
This method creates a new logging event and logs the event
without further checks.
@@ -587,7 +589,7 @@
@param location location of the logging statement.
*/
void forcedLogLS(const LevelPtr& level, const LogString& message,
- const log4cxx::spi::LocationInfo& location) const;
+ const log4cxx::spi::LocationInfo& location) const;
/**
Get the additivity flag for this Logger instance.
@@ -629,7 +631,10 @@
* Get the logger name.
* @return logger name as LogString.
*/
- const LogString& getName() const { return name; }
+ const LogString& getName() const
+ {
+ return name;
+ }
/**
* Get logger name in current encoding.
* @param name buffer to which name is appended.
@@ -734,7 +739,7 @@
actually create a new Instance.
*/
static LoggerPtr getLoggerLS(const LogString& name,
- const log4cxx::spi::LoggerFactoryPtr& factory);
+ const log4cxx::spi::LoggerFactoryPtr& factory);
/**
Like #getLogger except that the type of logger
instantiated depends on the type returned by the
@@ -749,7 +754,7 @@
actually create a new Instance.
*/
static LoggerPtr getLogger(const std::string& name,
- const log4cxx::spi::LoggerFactoryPtr& factory);
+ const log4cxx::spi::LoggerFactoryPtr& factory);
#if LOG4CXX_WCHAR_T_API
/**
Like #getLogger except that the type of logger
@@ -765,7 +770,7 @@
actually create a new Instance.
*/
static LoggerPtr getLogger(const std::wstring& name,
- const log4cxx::spi::LoggerFactoryPtr& factory);
+ const log4cxx::spi::LoggerFactoryPtr& factory);
#endif
#if LOG4CXX_UNICHAR_API
/**
@@ -782,7 +787,7 @@
actually create a new Instance.
*/
static LoggerPtr getLogger(const std::basic_string<UniChar>& name,
- const log4cxx::spi::LoggerFactoryPtr& factory);
+ const log4cxx::spi::LoggerFactoryPtr& factory);
#endif
#if LOG4CXX_CFSTRING_API
/**
@@ -799,7 +804,7 @@
actually create a new Instance.
*/
static LoggerPtr getLogger(const CFStringRef& name,
- const log4cxx::spi::LoggerFactoryPtr& factory);
+ const log4cxx::spi::LoggerFactoryPtr& factory);
#endif
/**
@@ -813,7 +818,7 @@
*/
helpers::ResourceBundlePtr getResourceBundle() const;
- protected:
+ protected:
/**
Returns the string resource coresponding to <code>key</code> in this
logger's inherited resource bundle.
@@ -825,7 +830,7 @@
*/
LogString getResourceBundleString(const LogString& key) const;
- public:
+ public:
/**
Log a message string with the INFO level.
@@ -839,8 +844,8 @@
@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;
+ 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.
@@ -855,7 +860,7 @@
@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;
+ void info(const std::wstring& msg, const log4cxx::spi::LocationInfo& location) const;
/**
Log a message string with the INFO level.
@@ -868,7 +873,7 @@
@param msg the message string to log.
*/
- void info(const std::wstring& msg) const;
+ void info(const std::wstring& msg) const;
#endif
#if LOG4CXX_UNICHAR_API
/**
@@ -934,40 +939,40 @@
*/
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.
- * */
+ /**
+ * 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;
/**
@@ -990,7 +995,7 @@
*/
bool isInfoEnabled() const;
- /**
+ /**
Check whether this logger is enabled for the warn Level.
See also #isDebugEnabled.
@@ -999,7 +1004,7 @@
*/
bool isWarnEnabled() const;
- /**
+ /**
Check whether this logger is enabled for the error Level.
See also #isDebugEnabled.
@@ -1008,7 +1013,7 @@
*/
bool isErrorEnabled() const;
- /**
+ /**
Check whether this logger is enabled for the fatal Level.
See also #isDebugEnabled.
@@ -1347,7 +1352,7 @@
const CFStringRef& val3) const;
#endif
- /**
+ /**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
@@ -1355,8 +1360,8 @@
@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;
- /**
+ const log4cxx::spi::LocationInfo& location) const;
+ /**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
@@ -1365,7 +1370,7 @@
*/
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.
@@ -1373,8 +1378,8 @@
@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;
- /**
+ const log4cxx::spi::LocationInfo& location) const;
+ /**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
@@ -1384,7 +1389,7 @@
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.
@@ -1392,8 +1397,8 @@
@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;
- /**
+ const log4cxx::spi::LocationInfo& location) const;
+ /**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
@@ -1403,7 +1408,7 @@
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.
@@ -1411,8 +1416,8 @@
@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;
- /**
+ const log4cxx::spi::LocationInfo& location) const;
+ /**
This is the most generic printing method. It is intended to be
invoked by <b>wrapper</b> classes.
@@ -1421,7 +1426,7 @@
*/
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.
@@ -1429,7 +1434,7 @@
@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;
+ const log4cxx::spi::LocationInfo& location) const;
@@ -1451,18 +1456,18 @@
*/
void removeAppender(const LogString& name);
- /**
- Set the additivity flag for this Logger instance.
- */
+ /**
+ 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);
+ void setHierarchy(spi::LoggerRepository* repository);
- public:
+ public:
/**
Set the level of this Logger.
@@ -1475,7 +1480,9 @@
Set the resource bundle to be used with localized logging methods.
*/
inline void setResourceBundle(const helpers::ResourceBundlePtr& bundle)
- { resourceBundle = bundle; }
+ {
+ resourceBundle = bundle;
+ }
#if LOG4CXX_WCHAR_T_API
/**
@@ -1707,17 +1714,20 @@
*/
void trace(const std::string& msg) const;
- inline SHARED_MUTEX & getMutex() { return mutex; }
+ inline SHARED_MUTEX& getMutex()
+ {
+ return mutex;
+ }
- private:
- //
+ private:
+ //
// prevent copy and assignment
Logger(const Logger&);
Logger& operator=(const Logger&);
mutable SHARED_MUTEX mutex;
friend class log4cxx::helpers::synchronized;
- };
- LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
+};
+LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
}
@@ -1726,23 +1736,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
@@ -1755,8 +1765,8 @@
*/
#define LOG4CXX_LOG(logger, level, message) do { \
if (logger->isEnabledFor(level)) {\
- ::log4cxx::helpers::MessageBuffer oss_; \
- logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+ ::log4cxx::helpers::MessageBuffer oss_; \
+ logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
/**
Logs a message to a specified logger with a specified level.
@@ -1767,8 +1777,8 @@
*/
#define LOG4CXX_LOGLS(logger, level, message) do { \
if (logger->isEnabledFor(level)) {\
- ::log4cxx::helpers::LogCharMessageBuffer oss_; \
- logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+ ::log4cxx::helpers::LogCharMessageBuffer oss_; \
+ logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
#if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 10000
/**
@@ -1779,8 +1789,8 @@
*/
#define LOG4CXX_DEBUG(logger, message) do { \
if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {\
- ::log4cxx::helpers::MessageBuffer oss_; \
- logger->forcedLog(::log4cxx::Level::getDebug(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+ ::log4cxx::helpers::MessageBuffer oss_; \
+ logger->forcedLog(::log4cxx::Level::getDebug(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
#else
#define LOG4CXX_DEBUG(logger, message)
#endif
@@ -1794,8 +1804,8 @@
*/
#define LOG4CXX_TRACE(logger, message) do { \
if (LOG4CXX_UNLIKELY(logger->isTraceEnabled())) {\
- ::log4cxx::helpers::MessageBuffer oss_; \
- logger->forcedLog(::log4cxx::Level::getTrace(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+ ::log4cxx::helpers::MessageBuffer oss_; \
+ logger->forcedLog(::log4cxx::Level::getTrace(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
#else
#define LOG4CXX_TRACE(logger, message)
#endif
@@ -1809,8 +1819,8 @@
*/
#define LOG4CXX_INFO(logger, message) do { \
if (logger->isInfoEnabled()) {\
- ::log4cxx::helpers::MessageBuffer oss_; \
- logger->forcedLog(::log4cxx::Level::getInfo(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+ ::log4cxx::helpers::MessageBuffer oss_; \
+ logger->forcedLog(::log4cxx::Level::getInfo(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
#else
#define LOG4CXX_INFO(logger, message)
#endif
@@ -1824,8 +1834,8 @@
*/
#define LOG4CXX_WARN(logger, message) do { \
if (logger->isWarnEnabled()) {\
- ::log4cxx::helpers::MessageBuffer oss_; \
- logger->forcedLog(::log4cxx::Level::getWarn(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+ ::log4cxx::helpers::MessageBuffer oss_; \
+ logger->forcedLog(::log4cxx::Level::getWarn(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
#else
#define LOG4CXX_WARN(logger, message)
#endif
@@ -1839,8 +1849,8 @@
*/
#define LOG4CXX_ERROR(logger, message) do { \
if (logger->isErrorEnabled()) {\
- ::log4cxx::helpers::MessageBuffer oss_; \
- logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+ ::log4cxx::helpers::MessageBuffer oss_; \
+ logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
/**
Logs a error if the condition is not true.
@@ -1851,8 +1861,8 @@
*/
#define LOG4CXX_ASSERT(logger, condition, message) do { \
if (!(condition) && logger->isErrorEnabled()) {\
- ::log4cxx::helpers::MessageBuffer oss_; \
- logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+ ::log4cxx::helpers::MessageBuffer oss_; \
+ logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
#else
#define LOG4CXX_ERROR(logger, message)
@@ -1868,8 +1878,8 @@
*/
#define LOG4CXX_FATAL(logger, message) do { \
if (logger->isFatalEnabled()) {\
- ::log4cxx::helpers::MessageBuffer oss_; \
- logger->forcedLog(::log4cxx::Level::getFatal(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+ ::log4cxx::helpers::MessageBuffer oss_; \
+ logger->forcedLog(::log4cxx::Level::getFatal(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
#else
#define LOG4CXX_FATAL(logger, message)
#endif
@@ -1883,7 +1893,7 @@
*/
#define LOG4CXX_L7DLOG(logger, level, key) do { \
if (logger->isEnabledFor(level)) {\
- logger->l7dlog(level, key, LOG4CXX_LOCATION); }} while (0)
+ logger->l7dlog(level, key, LOG4CXX_LOCATION); }} while (0)
/**
Logs a localized message with one parameter.
@@ -1895,7 +1905,7 @@
*/
#define LOG4CXX_L7DLOG1(logger, level, key, p1) do { \
if (logger->isEnabledFor(level)) {\
- logger->l7dlog(level, key, LOG4CXX_LOCATION, p1); }} while (0)
+ logger->l7dlog(level, key, LOG4CXX_LOCATION, p1); }} while (0)
/**
Logs a localized message with two parameters.
@@ -1908,7 +1918,7 @@
*/
#define LOG4CXX_L7DLOG2(logger, level, key, p1, p2) do { \
if (logger->isEnabledFor(level)) {\
- logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2); }} while (0)
+ logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2); }} while (0)
/**
Logs a localized message with three parameters.
@@ -1922,12 +1932,12 @@
*/
#define LOG4CXX_L7DLOG3(logger, level, key, p1, p2, p3) do { \
if (logger->isEnabledFor(level)) {\
- logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2, p3); }} while (0)
+ logger->l7dlog(level, key, LOG4CXX_LOCATION, p1, p2, p3); }} while (0)
/**@}*/
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#include <log4cxx/spi/loggerrepository.h>
diff --git a/src/main/include/log4cxx/logmanager.h b/src/main/include/log4cxx/logmanager.h
index a1e2448..6201b44 100644
--- a/src/main/include/log4cxx/logmanager.h
+++ b/src/main/include/log4cxx/logmanager.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_LOG_MANAGER_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/logstring.h>
@@ -29,26 +29,27 @@
namespace log4cxx
{
- class Logger;
- typedef helpers::ObjectPtrT<Logger> LoggerPtr;
- typedef std::vector<LoggerPtr> LoggerList;
+class Logger;
+typedef helpers::ObjectPtrT<Logger> LoggerPtr;
+typedef std::vector<LoggerPtr> LoggerList;
- namespace spi {
- class LoggerFactory;
- typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
- }
+namespace spi
+{
+class LoggerFactory;
+typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
+}
- /**
- * Use the <code>LogManager</code> class to retreive Logger
- * instances or to operate on the current
- * {@link log4cxx::spi::LoggerRepository LoggerRepository}.
- * When the <code>LogManager</code> class is loaded
- * into memory the default initialization procedure is inititated.
- */
- class LOG4CXX_EXPORT LogManager
- {
+/**
+* Use the <code>LogManager</code> class to retreive Logger
+* instances or to operate on the current
+* {@link log4cxx::spi::LoggerRepository LoggerRepository}.
+* When the <code>LogManager</code> class is loaded
+* into memory the default initialization procedure is inititated.
+ */
+class LOG4CXX_EXPORT LogManager
+{
private:
- static void * guard;
+ static void* guard;
static spi::RepositorySelectorPtr& getRepositorySelector();
public:
@@ -69,7 +70,7 @@
*/
static void setRepositorySelector(spi::RepositorySelectorPtr selector,
- void * guard);
+ void* guard);
static spi::LoggerRepositoryPtr& getLoggerRepository();
@@ -91,7 +92,7 @@
* @return logger.
*/
static LoggerPtr getLogger(const std::string& name,
- const spi::LoggerFactoryPtr& factory);
+ const spi::LoggerFactoryPtr& factory);
/**
* Determines if logger name exists in the hierarchy.
* @param name logger name.
@@ -112,7 +113,7 @@
* @return logger.
*/
static LoggerPtr getLogger(const std::wstring& name,
- const spi::LoggerFactoryPtr& factory);
+ const spi::LoggerFactoryPtr& factory);
/**
* Determines if logger name exists in the hierarchy.
* @param name logger name.
@@ -134,7 +135,7 @@
* @return logger.
*/
static LoggerPtr getLogger(const std::basic_string<UniChar>& name,
- const spi::LoggerFactoryPtr& factory);
+ const spi::LoggerFactoryPtr& factory);
/**
* Determines if logger name exists in the hierarchy.
* @param name logger name.
@@ -156,7 +157,7 @@
* @return logger.
*/
static LoggerPtr getLogger(const CFStringRef& name,
- const spi::LoggerFactoryPtr& factory);
+ const spi::LoggerFactoryPtr& factory);
/**
* Determines if logger name exists in the hierarchy.
* @param name logger name.
@@ -179,7 +180,7 @@
* @return logger.
*/
static LoggerPtr getLoggerLS(const LogString& name,
- const spi::LoggerFactoryPtr& factory);
+ const spi::LoggerFactoryPtr& factory);
/**
* Determines if logger name exists in the hierarchy.
@@ -201,11 +202,11 @@
spi::LoggerRepository LoggerRepository} to their default.
*/
static void resetConfiguration();
- }; // class LogManager
+}; // class LogManager
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
diff --git a/src/main/include/log4cxx/logstring.h b/src/main/include/log4cxx/logstring.h
index 297b76d..661ccaa 100644
--- a/src/main/include/log4cxx/logstring.h
+++ b/src/main/include/log4cxx/logstring.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_STRING_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
@@ -28,63 +28,64 @@
#include <log4cxx/log4cxx.h>
#if (LOG4CXX_LOGCHAR_IS_WCHAR + LOG4CXX_LOGCHAR_IS_UTF8 + LOG4CXX_LOGCHAR_IS_UNICHAR)>1
-#error only one of LOG4CXX_LOGCHAR_IS_WCHAR, LOG4CXX_LOGCHAR_IS_UTF8 or LOG4CXX_LOGCHAR_IS_UNICHAR may be true
+ #error only one of LOG4CXX_LOGCHAR_IS_WCHAR, LOG4CXX_LOGCHAR_IS_UTF8 or LOG4CXX_LOGCHAR_IS_UNICHAR may be true
#endif
#if LOG4CXX_CFSTRING_API
extern "C" {
-typedef const struct __CFString* CFStringRef;
+ typedef const struct __CFString* CFStringRef;
}
#endif
-namespace log4cxx {
+namespace log4cxx
+{
#if LOG4CXX_LOGCHAR_IS_UNICHAR || LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
-typedef unsigned short UniChar;
+ typedef unsigned short UniChar;
#endif
#if LOG4CXX_LOGCHAR_IS_WCHAR
- typedef wchar_t logchar;
-#define LOG4CXX_STR(str) L ## str
+ typedef wchar_t logchar;
+ #define LOG4CXX_STR(str) L ## str
#endif
#if LOG4CXX_LOGCHAR_IS_UTF8
- typedef char logchar;
-#if LOG4CXX_CHARSET_EBCDIC
-#define LOG4CXX_STR(str) log4cxx::helpers::Transcoder::decode(str)
-#else
-#define LOG4CXX_STR(str) str
-#endif
+ typedef char logchar;
+ #if LOG4CXX_CHARSET_EBCDIC
+ #define LOG4CXX_STR(str) log4cxx::helpers::Transcoder::decode(str)
+ #else
+ #define LOG4CXX_STR(str) str
+ #endif
#endif
#if LOG4CXX_LOGCHAR_IS_UNICHAR
- typedef UniChar logchar;
-#define LOG4CXX_STR(str) log4cxx::helpers::Transcoder::decode(str)
+ typedef UniChar logchar;
+ #define LOG4CXX_STR(str) log4cxx::helpers::Transcoder::decode(str)
#endif
- typedef std::basic_string<logchar> LogString;
+typedef std::basic_string<logchar> LogString;
}
#if !defined(LOG4CXX_EOL)
-#if defined(_WIN32)
-#define LOG4CXX_EOL LOG4CXX_STR("\x0D\x0A")
-#else
-#define LOG4CXX_EOL LOG4CXX_STR("\x0A")
-#endif
+ #if defined(_WIN32)
+ #define LOG4CXX_EOL LOG4CXX_STR("\x0D\x0A")
+ #else
+ #define LOG4CXX_EOL LOG4CXX_STR("\x0A")
+ #endif
#endif
#if LOG4CXX_LOGCHAR_IS_UNICHAR || (LOG4CXX_LOGCHAR_IS_UTF8 || LOG4CXX_CHARSET_EBCDIC)
-#include <log4cxx/helpers/transcoder.h>
+ #include <log4cxx/helpers/transcoder.h>
#endif
#if defined(_MSC_VER)
-#pragma warning (pop)
+ #pragma warning (pop)
#endif
#endif //_LOG4CXX_STRING_H
diff --git a/src/main/include/log4cxx/mdc.h b/src/main/include/log4cxx/mdc.h
index 69711a7..dbd8793 100644
--- a/src/main/include/log4cxx/mdc.h
+++ b/src/main/include/log4cxx/mdc.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_MDC_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/log4cxx.h>
@@ -29,206 +29,206 @@
namespace log4cxx
{
- /**
- The MDC class is similar to the {@link log4cxx::NDC NDC} class except that it is
- based on a map instead of a stack. It provides <em>mapped
- diagnostic contexts</em>. A <em>Mapped Diagnostic Context</em>, or
- MDC in short, is an instrument for distinguishing interleaved log
- output from different sources. Log output is typically interleaved
- when a server handles multiple clients near-simultaneously.
+/**
+The MDC class is similar to the {@link log4cxx::NDC NDC} class except that it is
+based on a map instead of a stack. It provides <em>mapped
+diagnostic contexts</em>. A <em>Mapped Diagnostic Context</em>, or
+MDC in short, is an instrument for distinguishing interleaved log
+output from different sources. Log output is typically interleaved
+when a server handles multiple clients near-simultaneously.
+*/
+class LOG4CXX_EXPORT MDC
+{
+ public:
+ /** String to string stl map.
*/
- class LOG4CXX_EXPORT MDC
- {
- public:
- /** String to string stl map.
- */
- typedef std::map<LogString, LogString> Map;
+ typedef std::map<LogString, LogString> Map;
- /**
- * Places a key/value pair in the MDC for the current thread
- * which will be removed during the corresponding destructor. Both
- * construction and destruction are expected to be on the same thread.
- * @param key key
- * @param value value.
- */
- MDC(const std::string& key, const std::string& value);
- ~MDC();
+ /**
+ * Places a key/value pair in the MDC for the current thread
+ * which will be removed during the corresponding destructor. Both
+ * construction and destruction are expected to be on the same thread.
+ * @param key key
+ * @param value value.
+ */
+ MDC(const std::string& key, const std::string& value);
+ ~MDC();
- /**
- * Put a context value (the <code>o</code> parameter) as identified
- * with the <code>key</code> parameter into the current thread's
- * context map.
- *
- * <p>If the current thread does not have a context map it is
- * created as a side effect.
- * @param key key
- * @param value value.
- */
- static void put(const std::string& key, const std::string& value);
- /**
- * Put a context value (the <code>o</code> parameter) as identified
- * with the <code>key</code> parameter into the current thread's
- * context map.
- *
- * <p>If the current thread does not have a context map it is
- * created as a side effect.
- * */
- static void putLS(const LogString& key, const LogString& value);
+ /**
+ * Put a context value (the <code>o</code> parameter) as identified
+ * with the <code>key</code> parameter into the current thread's
+ * context map.
+ *
+ * <p>If the current thread does not have a context map it is
+ * created as a side effect.
+ * @param key key
+ * @param value value.
+ */
+ static void put(const std::string& key, const std::string& value);
+ /**
+ * Put a context value (the <code>o</code> parameter) as identified
+ * with the <code>key</code> parameter into the current thread's
+ * context map.
+ *
+ * <p>If the current thread does not have a context map it is
+ * created as a side effect.
+ * */
+ static void putLS(const LogString& key, const LogString& value);
- /**
- * Get the context identified by the <code>key</code> parameter.
- *
- * <p>This method has no side effects.
- * @param key key.
- * @return value for key, empty if not set.
- * */
- static std::string get(const std::string& key);
- /**
- * Gets the context identified by the <code>key</code> parameter.
- * @param key context key.
- * @param dest destination to which value is appended.
- * @return true if key has associated value.
- */
- static bool get(const LogString& key, LogString& dest);
+ /**
+ * Get the context identified by the <code>key</code> parameter.
+ *
+ * <p>This method has no side effects.
+ * @param key key.
+ * @return value for key, empty if not set.
+ * */
+ static std::string get(const std::string& key);
+ /**
+ * Gets the context identified by the <code>key</code> parameter.
+ * @param key context key.
+ * @param dest destination to which value is appended.
+ * @return true if key has associated value.
+ */
+ static bool get(const LogString& key, LogString& dest);
- /**
- * Remove the the context identified by the <code>key</code>
- * parameter.
- * @param key key.
- * @return value if key had been set, empty if not.
- */
- static std::string remove(const std::string& key);
+ /**
+ * Remove the the context identified by the <code>key</code>
+ * parameter.
+ * @param key key.
+ * @return value if key had been set, empty if not.
+ */
+ static std::string remove(const std::string& key);
#if LOG4CXX_WCHAR_T_API
- /**
- * Places a key/value pair in the MDC for the current thread
- * which will be removed during the corresponding destructor. Both
- * construction and destruction are expected to be on the same thread.
- * @param key key
- * @param value value.
- */
- MDC(const std::wstring& key, const std::wstring& value);
- /**
- * Put a context value (the <code>o</code> parameter) as identified
- * with the <code>key</code> parameter into the current thread's
- * context map.
- *
- * <p>If the current thread does not have a context map it is
- * created as a side effect.
- * @param key key
- * @param value value.
- */
- static void put(const std::wstring& key, const std::wstring& value);
- /**
- * Get the context identified by the <code>key</code> parameter.
- *
- * <p>This method has no side effects.
- * @param key key.
- * @return value for key, empty if not set.
- * */
- static std::wstring get(const std::wstring& key);
- /**
- * Remove the the context identified by the <code>key</code>
- * parameter.
- * @param key key.
- * @return value if key had been set, empty if not.
- */
- static std::wstring remove(const std::wstring& key);
+ /**
+ * Places a key/value pair in the MDC for the current thread
+ * which will be removed during the corresponding destructor. Both
+ * construction and destruction are expected to be on the same thread.
+ * @param key key
+ * @param value value.
+ */
+ MDC(const std::wstring& key, const std::wstring& value);
+ /**
+ * Put a context value (the <code>o</code> parameter) as identified
+ * with the <code>key</code> parameter into the current thread's
+ * context map.
+ *
+ * <p>If the current thread does not have a context map it is
+ * created as a side effect.
+ * @param key key
+ * @param value value.
+ */
+ static void put(const std::wstring& key, const std::wstring& value);
+ /**
+ * Get the context identified by the <code>key</code> parameter.
+ *
+ * <p>This method has no side effects.
+ * @param key key.
+ * @return value for key, empty if not set.
+ * */
+ static std::wstring get(const std::wstring& key);
+ /**
+ * Remove the the context identified by the <code>key</code>
+ * parameter.
+ * @param key key.
+ * @return value if key had been set, empty if not.
+ */
+ static std::wstring remove(const std::wstring& key);
#endif
#if LOG4CXX_UNICHAR_API
- /**
- * Places a key/value pair in the MDC for the current thread
- * which will be removed during the corresponding destructor. Both
- * construction and destruction are expected to be on the same thread.
- * @param key key
- * @param value value.
- */
- MDC(const std::basic_string<UniChar>& key, const std::basic_string<UniChar>& value);
- /**
- * Put a context value (the <code>o</code> parameter) as identified
- * with the <code>key</code> parameter into the current thread's
- * context map.
- *
- * <p>If the current thread does not have a context map it is
- * created as a side effect.
- * @param key key
- * @param value value.
- */
- static void put(const std::basic_string<UniChar>& key, const std::basic_string<UniChar>& value);
- /**
- * Get the context identified by the <code>key</code> parameter.
- *
- * <p>This method has no side effects.
- * @param key key.
- * @return value for key, empty if not set.
- * */
- static std::basic_string<UniChar> get(const std::basic_string<UniChar>& key);
- /**
- * Remove the the context identified by the <code>key</code>
- * parameter.
- * @param key key.
- * @return value if key had been set, empty if not.
- */
- static std::basic_string<UniChar> remove(const std::basic_string<UniChar>& key);
+ /**
+ * Places a key/value pair in the MDC for the current thread
+ * which will be removed during the corresponding destructor. Both
+ * construction and destruction are expected to be on the same thread.
+ * @param key key
+ * @param value value.
+ */
+ MDC(const std::basic_string<UniChar>& key, const std::basic_string<UniChar>& value);
+ /**
+ * Put a context value (the <code>o</code> parameter) as identified
+ * with the <code>key</code> parameter into the current thread's
+ * context map.
+ *
+ * <p>If the current thread does not have a context map it is
+ * created as a side effect.
+ * @param key key
+ * @param value value.
+ */
+ static void put(const std::basic_string<UniChar>& key, const std::basic_string<UniChar>& value);
+ /**
+ * Get the context identified by the <code>key</code> parameter.
+ *
+ * <p>This method has no side effects.
+ * @param key key.
+ * @return value for key, empty if not set.
+ * */
+ static std::basic_string<UniChar> get(const std::basic_string<UniChar>& key);
+ /**
+ * Remove the the context identified by the <code>key</code>
+ * parameter.
+ * @param key key.
+ * @return value if key had been set, empty if not.
+ */
+ static std::basic_string<UniChar> remove(const std::basic_string<UniChar>& key);
#endif
#if LOG4CXX_CFSTRING_API
- /**
- * Places a key/value pair in the MDC for the current thread
- * which will be removed during the corresponding destructor. Both
- * construction and destruction are expected to be on the same thread.
- * @param key key
- * @param value value.
- */
- MDC(const CFStringRef& key, const CFStringRef& value);
- /**
- * Put a context value (the <code>o</code> parameter) as identified
- * with the <code>key</code> parameter into the current thread's
- * context map.
- *
- * <p>If the current thread does not have a context map it is
- * created as a side effect.
- * @param key key
- * @param value value.
- */
- static void put(const CFStringRef& key, const CFStringRef& value);
- /**
- * Get the context identified by the <code>key</code> parameter.
- *
- * <p>This method has no side effects.
- * @param key key.
- * @return value for key, empty if not set.
- * */
- static CFStringRef get(const CFStringRef& key);
- /**
- * Remove the the context identified by the <code>key</code>
- * parameter.
- * @param key key.
- * @return value if key had been set, empty if not.
- */
- static CFStringRef remove(const CFStringRef& key);
+ /**
+ * Places a key/value pair in the MDC for the current thread
+ * which will be removed during the corresponding destructor. Both
+ * construction and destruction are expected to be on the same thread.
+ * @param key key
+ * @param value value.
+ */
+ MDC(const CFStringRef& key, const CFStringRef& value);
+ /**
+ * Put a context value (the <code>o</code> parameter) as identified
+ * with the <code>key</code> parameter into the current thread's
+ * context map.
+ *
+ * <p>If the current thread does not have a context map it is
+ * created as a side effect.
+ * @param key key
+ * @param value value.
+ */
+ static void put(const CFStringRef& key, const CFStringRef& value);
+ /**
+ * Get the context identified by the <code>key</code> parameter.
+ *
+ * <p>This method has no side effects.
+ * @param key key.
+ * @return value for key, empty if not set.
+ * */
+ static CFStringRef get(const CFStringRef& key);
+ /**
+ * Remove the the context identified by the <code>key</code>
+ * parameter.
+ * @param key key.
+ * @return value if key had been set, empty if not.
+ */
+ static CFStringRef remove(const CFStringRef& key);
#endif
- /**
- * Remove the the context identified by the <code>key</code>
- * parameter.
- * @param key key.
- * @param prevValue buffer to which previous value is appended.
- * @return true if key existed in MDC.
- */
- static bool remove(const LogString& key, LogString& prevValue);
+ /**
+ * Remove the the context identified by the <code>key</code>
+ * parameter.
+ * @param key key.
+ * @param prevValue buffer to which previous value is appended.
+ * @return true if key existed in MDC.
+ */
+ static bool remove(const LogString& key, LogString& prevValue);
- /**
- * Clear all entries in the MDC.
- */
- static void clear();
+ /**
+ * Clear all entries in the MDC.
+ */
+ static void clear();
- private:
- MDC(const MDC&);
- MDC& operator=(const MDC&);
- LogString key;
- }; // class MDC;
+ private:
+ MDC(const MDC&);
+ MDC& operator=(const MDC&);
+ LogString key;
+}; // class MDC;
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning (pop)
+ #pragma warning (pop)
#endif
diff --git a/src/main/include/log4cxx/ndc.h b/src/main/include/log4cxx/ndc.h
index 0791d03..8cd12ae 100644
--- a/src/main/include/log4cxx/ndc.h
+++ b/src/main/include/log4cxx/ndc.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_NDC_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/log4cxx.h>
@@ -29,324 +29,324 @@
namespace log4cxx
{
+/**
+the ndc class implements <i>nested diagnostic contexts</i> as
+defined by neil harrison in the article "patterns for logging
+diagnostic messages" part of the book "<i>pattern languages of
+program design 3</i>" edited by martin et al.
+
+<p>a nested diagnostic context, or ndc in short, is an instrument
+to distinguish interleaved log output from different sources. log
+output is typically interleaved when a server handles multiple
+clients near-simultaneously.
+
+<p>interleaved log output can still be meaningful if each log entry
+from different contexts had a distinctive stamp. this is where ndcs
+come into play.
+
+<p><em><b>note that ndcs are managed on a per thread
+basis</b></em>. ndc operations such as #push,
+#pop, #clear and #getDepth
+affect the ndc of the <em>current</em> thread only. ndcs of other
+threads remain unaffected.
+
+<p>for example, a servlet can build a per client request ndc
+consisting the clients host name and other information contained in
+the the request. <em>cookies</em> are another source of distinctive
+information. to build an ndc one uses the #push
+operation. simply put,
+
+<p><ul>
+ <li>contexts can be nested.
+
+ <p><li>when entering a context, call <code>ndc.push</code>. as a
+ side effect, if there is no nested diagnostic context for the
+ current thread, this method will create it.
+
+ <p><li>when leaving a context, call <code>ndc.pop</code>.
+
+ <p><li><b>when exiting a thread make sure to call #remove
+ </b>.
+</ul>
+
+<p>there is no penalty for forgetting to match each
+<code>push</code> operation with a corresponding <code>pop</code>,
+except the obvious mismatch between the real application context
+and the context set in the ndc.
+
+<p>if configured to do so, PatternLayout and
+TTCCLayout instances automatically retrieve the nested diagnostic
+context for the current thread without any user intervention.
+hence, even if a servlet is serving multiple clients
+simultaneously, the logs emanating from the same code (belonging to
+the same logger) can still be distinguished because each client
+request will have a different ndc tag.
+
+<p>heavy duty systems should call the #remove method when
+leaving the run method of a thread. this ensures that the memory
+used by the thread can be freed by the java garbage
+collector. there is a mechanism to lazily remove references to dead
+threads. in practice, this means that you can be a little sloppy
+and sometimes forget to call #remove before exiting a
+thread.
+
+*/
+class LOG4CXX_EXPORT NDC
+{
+ public:
/**
- the ndc class implements <i>nested diagnostic contexts</i> as
- defined by neil harrison in the article "patterns for logging
- diagnostic messages" part of the book "<i>pattern languages of
- program design 3</i>" edited by martin et al.
+ * Pair of Message and FullMessage.
+ */
+ typedef std::pair<LogString, LogString> DiagnosticContext;
+ typedef std::stack<DiagnosticContext> Stack;
- <p>a nested diagnostic context, or ndc in short, is an instrument
- to distinguish interleaved log output from different sources. log
- output is typically interleaved when a server handles multiple
- clients near-simultaneously.
+ /**
+ Creates a nested diagnostic context.
+ Since java performs no automatic cleanup of objects when a
+ scope is left, in log4j push() and pop() must be used
+ to manage the NDC. For convenience, log4cxx provides
+ an NDC constructor and destructor which simply call the push() and
+ pop() methods, allowing for automatic cleanup when the current
+ scope ends.
- <p>interleaved log output can still be meaningful if each log entry
- from different contexts had a distinctive stamp. this is where ndcs
- come into play.
+ @param message The new diagnostic context information.
+ @see The #push method.
+ */
+ NDC(const std::string& message);
- <p><em><b>note that ndcs are managed on a per thread
- basis</b></em>. ndc operations such as #push,
- #pop, #clear and #getDepth
- affect the ndc of the <em>current</em> thread only. ndcs of other
- threads remain unaffected.
+ /**
+ Removes the topmost element from the NDC stack.
- <p>for example, a servlet can build a per client request ndc
- consisting the clients host name and other information contained in
- the the request. <em>cookies</em> are another source of distinctive
- information. to build an ndc one uses the #push
- operation. simply put,
-
- <p><ul>
- <li>contexts can be nested.
-
- <p><li>when entering a context, call <code>ndc.push</code>. as a
- side effect, if there is no nested diagnostic context for the
- current thread, this method will create it.
-
- <p><li>when leaving a context, call <code>ndc.pop</code>.
-
- <p><li><b>when exiting a thread make sure to call #remove
- </b>.
- </ul>
-
- <p>there is no penalty for forgetting to match each
- <code>push</code> operation with a corresponding <code>pop</code>,
- except the obvious mismatch between the real application context
- and the context set in the ndc.
-
- <p>if configured to do so, PatternLayout and
- TTCCLayout instances automatically retrieve the nested diagnostic
- context for the current thread without any user intervention.
- hence, even if a servlet is serving multiple clients
- simultaneously, the logs emanating from the same code (belonging to
- the same logger) can still be distinguished because each client
- request will have a different ndc tag.
-
- <p>heavy duty systems should call the #remove method when
- leaving the run method of a thread. this ensures that the memory
- used by the thread can be freed by the java garbage
- collector. there is a mechanism to lazily remove references to dead
- threads. in practice, this means that you can be a little sloppy
- and sometimes forget to call #remove before exiting a
- thread.
-
+ @see The #pop method.
*/
- class LOG4CXX_EXPORT NDC
- {
- public:
- /**
- * Pair of Message and FullMessage.
- */
- typedef std::pair<LogString, LogString> DiagnosticContext;
- typedef std::stack<DiagnosticContext> Stack;
+ ~NDC();
- /**
- Creates a nested diagnostic context.
- Since java performs no automatic cleanup of objects when a
- scope is left, in log4j push() and pop() must be used
- to manage the NDC. For convenience, log4cxx provides
- an NDC constructor and destructor which simply call the push() and
- pop() methods, allowing for automatic cleanup when the current
- scope ends.
+ /**
+ Clear any nested diagnostic information if any. This method is
+ useful in cases where the same thread can be potentially used
+ over and over in different unrelated contexts.
+ */
+ static void clear();
- @param message The new diagnostic context information.
- @see The #push method.
- */
- NDC(const std::string& message);
+ /**
+ Clone the diagnostic context for the current thread.
+ <p>Internally a diagnostic context is represented as a stack. A
+ given thread can supply the stack (i.e. diagnostic context) to a
+ child thread so that the child can inherit the parent thread's
+ diagnostic context.
+ <p>The child thread uses the #inherit method to
+ inherit the parent's diagnostic context.
+ <p>If not passed to #inherit, returned stack should be deleted by caller.
+ @return Stack A clone of the current thread's diagnostic context, will not be null.
+ */
+ static Stack* cloneStack();
- /**
- Removes the topmost element from the NDC stack.
+ /**
+ Inherit the diagnostic context of another thread.
+ <p>The parent thread can obtain a reference to its diagnostic
+ context using the #cloneStack method. It should
+ communicate this information to its child so that it may inherit
+ the parent's diagnostic context.
+ <p>The parent's diagnostic context is cloned before being
+ inherited. In other words, once inherited, the two diagnostic
+ contexts can be managed independently.
+ @param stack The diagnostic context of the parent thread,
+ will be deleted during call. If NULL, NDC will not be modified.
+ */
+ static void inherit(Stack* stack);
- @see The #pop method.
- */
- ~NDC();
+ /**
+ * Get the current value of the NDC of the
+ * currrent thread.
+ * @param dest destination to which to append content of NDC.
+ * @return true if NDC is set.
+ */
+ static bool get(LogString& dest);
- /**
- Clear any nested diagnostic information if any. This method is
- useful in cases where the same thread can be potentially used
- over and over in different unrelated contexts.
- */
- static void clear();
-
- /**
- Clone the diagnostic context for the current thread.
- <p>Internally a diagnostic context is represented as a stack. A
- given thread can supply the stack (i.e. diagnostic context) to a
- child thread so that the child can inherit the parent thread's
- diagnostic context.
- <p>The child thread uses the #inherit method to
- inherit the parent's diagnostic context.
- <p>If not passed to #inherit, returned stack should be deleted by caller.
- @return Stack A clone of the current thread's diagnostic context, will not be null.
- */
- static Stack * cloneStack();
-
- /**
- Inherit the diagnostic context of another thread.
- <p>The parent thread can obtain a reference to its diagnostic
- context using the #cloneStack method. It should
- communicate this information to its child so that it may inherit
- the parent's diagnostic context.
- <p>The parent's diagnostic context is cloned before being
- inherited. In other words, once inherited, the two diagnostic
- contexts can be managed independently.
- @param stack The diagnostic context of the parent thread,
- will be deleted during call. If NULL, NDC will not be modified.
- */
- static void inherit(Stack * stack);
-
- /**
- * Get the current value of the NDC of the
- * currrent thread.
- * @param dest destination to which to append content of NDC.
- * @return true if NDC is set.
- */
- static bool get(LogString& dest);
-
- /**
- Get the current nesting depth of this diagnostic context.
- */
- static int getDepth();
+ /**
+ Get the current nesting depth of this diagnostic context.
+ */
+ static int getDepth();
- /**
- * Tests if the NDC is empty.
- */
- static bool empty();
+ /**
+ * Tests if the NDC is empty.
+ */
+ static bool empty();
- /**
- Pop top value off stack.
- @return top value.
- */
- static LogString pop();
- /**
- Pop top value off stack.
- @param buf to which top value is appended.
- @return true if NDC contained at least one value.
- */
- static bool pop(std::string& buf);
+ /**
+ Pop top value off stack.
+ @return top value.
+ */
+ static LogString pop();
+ /**
+ Pop top value off stack.
+ @param buf to which top value is appended.
+ @return true if NDC contained at least one value.
+ */
+ static bool pop(std::string& buf);
- /**
- Looks at the last diagnostic context at the top of this NDC
- without removing it.
- <p>The returned value is the value that was pushed last. If no
- context is available, then the empty string "" is returned.
- @return String The innermost diagnostic context.
- */
- static LogString peek();
- /**
- Get top value without removing value.
- @param buf to which top value is appended.
- @return true if NDC contained at least one value.
- */
- static bool peek(std::string& buf);
+ /**
+ Looks at the last diagnostic context at the top of this NDC
+ without removing it.
+ <p>The returned value is the value that was pushed last. If no
+ context is available, then the empty string "" is returned.
+ @return String The innermost diagnostic context.
+ */
+ static LogString peek();
+ /**
+ Get top value without removing value.
+ @param buf to which top value is appended.
+ @return true if NDC contained at least one value.
+ */
+ static bool peek(std::string& buf);
- /**
- Push new diagnostic context information for the current thread.
- <p>The contents of the <code>message</code> parameter is
- determined solely by the client.
- @param message The new diagnostic context information.
- */
- static void push(const std::string& message);
- /**
- Push new diagnostic context information for the current thread.
- <p>The contents of the <code>message</code> parameter is
- determined solely by the client.
- @param message The new diagnostic context information.
- */
- static void pushLS(const LogString& message);
+ /**
+ Push new diagnostic context information for the current thread.
+ <p>The contents of the <code>message</code> parameter is
+ determined solely by the client.
+ @param message The new diagnostic context information.
+ */
+ static void push(const std::string& message);
+ /**
+ Push new diagnostic context information for the current thread.
+ <p>The contents of the <code>message</code> parameter is
+ determined solely by the client.
+ @param message The new diagnostic context information.
+ */
+ static void pushLS(const LogString& message);
- /**
- Remove the diagnostic context for this thread.
- <p>Each thread that created a diagnostic context by calling
- #push should call this method before exiting. Otherwise,
- the memory used by the <b>thread</b> cannot be reclaimed by the
- VM.
- <p>As this is such an important problem in heavy duty systems and
- because it is difficult to always guarantee that the remove
- method is called before exiting a thread, this method has been
- augmented to lazily remove references to dead threads. In
- practice, this means that you can be a little sloppy and
- occasionally forget to call #remove before exiting a
- thread. However, you must call <code>remove</code> sometime. If
- you never call it, then your application is sure to run out of
- memory.
- */
- static void remove();
+ /**
+ Remove the diagnostic context for this thread.
+ <p>Each thread that created a diagnostic context by calling
+ #push should call this method before exiting. Otherwise,
+ the memory used by the <b>thread</b> cannot be reclaimed by the
+ VM.
+ <p>As this is such an important problem in heavy duty systems and
+ because it is difficult to always guarantee that the remove
+ method is called before exiting a thread, this method has been
+ augmented to lazily remove references to dead threads. In
+ practice, this means that you can be a little sloppy and
+ occasionally forget to call #remove before exiting a
+ thread. However, you must call <code>remove</code> sometime. If
+ you never call it, then your application is sure to run out of
+ memory.
+ */
+ static void remove();
#if LOG4CXX_WCHAR_T_API
- /**
- Creates a nested diagnostic context.
- Since java performs no automatic cleanup of objects when a
- scope is left, in log4j push() and pop() must be used
- to manage the NDC. For convenience, log4cxx provides
- an NDC constructor and destructor which simply call the push() and
- pop() methods, allowing for automatic cleanup when the current
- scope ends.
+ /**
+ Creates a nested diagnostic context.
+ Since java performs no automatic cleanup of objects when a
+ scope is left, in log4j push() and pop() must be used
+ to manage the NDC. For convenience, log4cxx provides
+ an NDC constructor and destructor which simply call the push() and
+ pop() methods, allowing for automatic cleanup when the current
+ scope ends.
- @param message The new diagnostic context information.
- @see The #push method.
- */
- NDC(const std::wstring& message);
- /**
- Push new diagnostic context information for the current thread.
- <p>The contents of the <code>message</code> parameter is
- determined solely by the client.
- @param message The new diagnostic context information.
- */
- static void push(const std::wstring& message);
- /**
- * Appends the current NDC content to the provided string.
- * @param dst destination.
- * @return true if NDC value set.
- */
- static bool peek(std::wstring& dst);
- /**
- * Appends the current NDC content to the provided string and removes the value from the NDC.
- * @param dst destination.
- * @return true if NDC value set.
- */
- static bool pop(std::wstring& dst);
+ @param message The new diagnostic context information.
+ @see The #push method.
+ */
+ NDC(const std::wstring& message);
+ /**
+ Push new diagnostic context information for the current thread.
+ <p>The contents of the <code>message</code> parameter is
+ determined solely by the client.
+ @param message The new diagnostic context information.
+ */
+ static void push(const std::wstring& message);
+ /**
+ * Appends the current NDC content to the provided string.
+ * @param dst destination.
+ * @return true if NDC value set.
+ */
+ static bool peek(std::wstring& dst);
+ /**
+ * Appends the current NDC content to the provided string and removes the value from the NDC.
+ * @param dst destination.
+ * @return true if NDC value set.
+ */
+ static bool pop(std::wstring& dst);
#endif
#if LOG4CXX_UNICHAR_API
- /**
- Creates a nested diagnostic context.
- Since java performs no automatic cleanup of objects when a
- scope is left, in log4j push() and pop() must be used
- to manage the NDC. For convenience, log4cxx provides
- an NDC constructor and destructor which simply call the push() and
- pop() methods, allowing for automatic cleanup when the current
- scope ends.
+ /**
+ Creates a nested diagnostic context.
+ Since java performs no automatic cleanup of objects when a
+ scope is left, in log4j push() and pop() must be used
+ to manage the NDC. For convenience, log4cxx provides
+ an NDC constructor and destructor which simply call the push() and
+ pop() methods, allowing for automatic cleanup when the current
+ scope ends.
- @param message The new diagnostic context information.
- @see The #push method.
- */
- NDC(const std::basic_string<UniChar>& message);
- /**
- Push new diagnostic context information for the current thread.
- <p>The contents of the <code>message</code> parameter is
- determined solely by the client.
- @param message The new diagnostic context information.
- */
- static void push(const std::basic_string<UniChar>& message);
- /**
- * Appends the current NDC content to the provided string.
- * @param dst destination.
- * @return true if NDC value set.
- */
- static bool peek(std::basic_string<UniChar>& dst);
- /**
- * Appends the current NDC content to the provided string and removes the value from the NDC.
- * @param dst destination.
- * @return true if NDC value set.
- */
- static bool pop(std::basic_string<UniChar>& dst);
+ @param message The new diagnostic context information.
+ @see The #push method.
+ */
+ NDC(const std::basic_string<UniChar>& message);
+ /**
+ Push new diagnostic context information for the current thread.
+ <p>The contents of the <code>message</code> parameter is
+ determined solely by the client.
+ @param message The new diagnostic context information.
+ */
+ static void push(const std::basic_string<UniChar>& message);
+ /**
+ * Appends the current NDC content to the provided string.
+ * @param dst destination.
+ * @return true if NDC value set.
+ */
+ static bool peek(std::basic_string<UniChar>& dst);
+ /**
+ * Appends the current NDC content to the provided string and removes the value from the NDC.
+ * @param dst destination.
+ * @return true if NDC value set.
+ */
+ static bool pop(std::basic_string<UniChar>& dst);
#endif
#if LOG4CXX_CFSTRING_API
- /**
- Creates a nested diagnostic context.
- Since java performs no automatic cleanup of objects when a
- scope is left, in log4j push() and pop() must be used
- to manage the NDC. For convenience, log4cxx provides
- an NDC constructor and destructor which simply call the push() and
- pop() methods, allowing for automatic cleanup when the current
- scope ends.
+ /**
+ Creates a nested diagnostic context.
+ Since java performs no automatic cleanup of objects when a
+ scope is left, in log4j push() and pop() must be used
+ to manage the NDC. For convenience, log4cxx provides
+ an NDC constructor and destructor which simply call the push() and
+ pop() methods, allowing for automatic cleanup when the current
+ scope ends.
- @param message The new diagnostic context information.
- @see The #push method.
- */
- NDC(const CFStringRef& message);
- /**
- Push new diagnostic context information for the current thread.
- <p>The contents of the <code>message</code> parameter is
- determined solely by the client.
- @param message The new diagnostic context information.
- */
- static void push(const CFStringRef& message);
- /**
- * Gets the current NDC value.
- * @param dst destination.
- * @return true if NDC value set.
- */
- static bool peek(CFStringRef& dst);
- /**
- * Gets and removes the current NDC value.
- * @param dst destination.
- * @return true if NDC value set.
- */
- static bool pop(CFStringRef& dst);
+ @param message The new diagnostic context information.
+ @see The #push method.
+ */
+ NDC(const CFStringRef& message);
+ /**
+ Push new diagnostic context information for the current thread.
+ <p>The contents of the <code>message</code> parameter is
+ determined solely by the client.
+ @param message The new diagnostic context information.
+ */
+ static void push(const CFStringRef& message);
+ /**
+ * Gets the current NDC value.
+ * @param dst destination.
+ * @return true if NDC value set.
+ */
+ static bool peek(CFStringRef& dst);
+ /**
+ * Gets and removes the current NDC value.
+ * @param dst destination.
+ * @return true if NDC value set.
+ */
+ static bool pop(CFStringRef& dst);
#endif
- private:
- NDC(const NDC&);
- NDC& operator=(const NDC&);
- static LogString& getMessage(DiagnosticContext& ctx);
- static LogString& getFullMessage(DiagnosticContext& ctx);
- }; // class NDC;
+ private:
+ NDC(const NDC&);
+ NDC& operator=(const NDC&);
+ static LogString& getMessage(DiagnosticContext& ctx);
+ static LogString& getFullMessage(DiagnosticContext& ctx);
+}; // class NDC;
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning (pop)
+ #pragma warning (pop)
#endif
diff --git a/src/main/include/log4cxx/net/smtpappender.h b/src/main/include/log4cxx/net/smtpappender.h
index adac446..a2fceff 100644
--- a/src/main/include/log4cxx/net/smtpappender.h
+++ b/src/main/include/log4cxx/net/smtpappender.h
@@ -25,259 +25,261 @@
namespace log4cxx
{
- namespace net
+namespace net
+{
+/**
+Send an e-mail when a specific logging event occurs, typically on
+errors or fatal errors.
+<p>The number of logging events delivered in this e-mail depend on
+the value of <b>BufferSize</b> option. The
+<code>SMTPAppender</code> keeps only the last
+<code>BufferSize</code> logging events in its cyclic buffer. This
+keeps memory requirements at a reasonable level while still
+delivering useful application context.
+*/
+class LOG4CXX_EXPORT SMTPAppender : public AppenderSkeleton
+{
+ private:
+
+ private:
+ SMTPAppender(const SMTPAppender&);
+ SMTPAppender& operator=(const SMTPAppender&);
+ static bool asciiCheck(const LogString& value, const LogString& label);
+ /**
+ 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. */
+ bool checkEntryConditions();
+
+ LogString to;
+ LogString cc;
+ LogString bcc;
+ LogString from;
+ LogString subject;
+ LogString smtpHost;
+ LogString smtpUsername;
+ LogString smtpPassword;
+ int smtpPort;
+ int bufferSize; // 512
+ bool locationInfo;
+ helpers::CyclicBuffer cb;
+ spi::TriggeringEventEvaluatorPtr evaluator;
+
+ public:
+ DECLARE_LOG4CXX_OBJECT(SMTPAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(SMTPAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
+
+ SMTPAppender();
+ /**
+ The default constructor will instantiate the appender with a
+ spi::TriggeringEventEvaluator that will trigger on events with
+ level ERROR or higher.*/
+ SMTPAppender(log4cxx::helpers::Pool& p);
+
+ /**
+ Use <code>evaluator</code> passed as parameter as the
+ spi::TriggeringEventEvaluator for this net::SMTPAppender.
+ */
+ SMTPAppender(spi::TriggeringEventEvaluatorPtr evaluator);
+
+ ~SMTPAppender();
+
+ /**
+ Set options
+ */
+ virtual void setOption(const LogString& option, const LogString& value);
+
+ /**
+ Activate the specified options, such as the smtp host, the
+ recipient, from, etc.
+ */
+ virtual void activateOptions(log4cxx::helpers::Pool& p);
+
+ /**
+ Perform SMTPAppender specific appending actions, mainly adding
+ the event to a cyclic buffer and checking if the event triggers
+ an e-mail to be sent. */
+ virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+
+
+ virtual void close();
+
+ /**
+ Returns value of the <b>To</b> option.
+ */
+ LogString getTo() const;
+
+ /**
+ Returns value of the <b>cc</b> option.
+ */
+ LogString getCc() const;
+
+ /**
+ Returns value of the <b>bcc</b> option.
+ */
+ LogString getBcc() const;
+
+
+ /**
+ The <code>SMTPAppender</code> requires a {@link
+ Layout layout}. */
+ virtual bool requiresLayout() const;
+
+ /**
+ Send the contents of the cyclic buffer as an e-mail message.
+ */
+ void sendBuffer(log4cxx::helpers::Pool& p);
+
+
+ /**
+ Returns value of the <b>EvaluatorClass</b> option.
+ */
+ LogString getEvaluatorClass();
+
+ /**
+ Returns value of the <b>From</b> option.
+ */
+ LogString getFrom() const;
+
+ /**
+ Returns value of the <b>Subject</b> option.
+ */
+ LogString getSubject() const;
+
+
+ /**
+ The <b>From</b> option takes a string value which should be a
+ e-mail address of the sender.
+ */
+ void setFrom(const LogString& from);
+
+ /**
+ The <b>Subject</b> option takes a string value which should be a
+ the subject of the e-mail message.
+ */
+ void setSubject(const LogString& subject);
+
+ /**
+ The <b>BufferSize</b> option takes a positive integer
+ representing the maximum number of logging events to collect in a
+ cyclic buffer. When the <code>BufferSize</code> is reached,
+ oldest events are deleted as new events are added to the
+ buffer. By default the size of the cyclic buffer is 512 events.
+ */
+ void setBufferSize(int bufferSize);
+
+ /**
+ The <b>SMTPHost</b> option takes a string value which should be a
+ the host name of the SMTP server that will send the e-mail message.
+ */
+ void setSMTPHost(const LogString& smtpHost);
+
+ /**
+ Returns value of the <b>SMTPHost</b> option.
+ */
+ LogString getSMTPHost() const;
+
+ /**
+ The <b>SMTPPort</b> option takes a string value which should be a
+ the port of the SMTP server that will send the e-mail message.
+ */
+ void setSMTPPort(int port);
+
+ /**
+ Returns value of the <b>SMTPHost</b> option.
+ */
+ int getSMTPPort() const;
+
+ /**
+ The <b>To</b> option takes a string value which should be a
+ comma separated list of e-mail address of the recipients.
+ */
+ void setTo(const LogString& to);
+
+ /**
+ The <b>Cc</b> option takes a string value which should be a
+ comma separated list of e-mail address of the cc'd recipients.
+ */
+ void setCc(const LogString& to);
+
+ /**
+ The <b>Bcc</b> option takes a string value which should be a
+ comma separated list of e-mail address of the bcc'd recipients.
+ */
+ void setBcc(const LogString& to);
+
+
+ /**
+ The <b>SMTPUsername</b> option takes a string value which should be a
+ the user name for the SMTP server.
+ */
+ void setSMTPUsername(const LogString& newVal);
+
+ /**
+ Returns value of the <b>SMTPUsername</b> option.
+ */
+ LogString getSMTPUsername() const;
+
+ /**
+ The <b>SMTPPassword</b> option takes a string value which should be a
+ the password for the SMTP server.
+ */
+ void setSMTPPassword(const LogString& newVal);
+
+ /**
+ Returns value of the <b>SMTPPassword</b> option.
+ */
+ LogString getSMTPPassword() const;
+
+ /**
+ Returns value of the <b>BufferSize</b> option.
+ */
+ inline int getBufferSize() const
{
- /**
- Send an e-mail when a specific logging event occurs, typically on
- errors or fatal errors.
- <p>The number of logging events delivered in this e-mail depend on
- the value of <b>BufferSize</b> option. The
- <code>SMTPAppender</code> keeps only the last
- <code>BufferSize</code> logging events in its cyclic buffer. This
- keeps memory requirements at a reasonable level while still
- delivering useful application context.
- */
- class LOG4CXX_EXPORT SMTPAppender : public AppenderSkeleton
- {
- private:
-
- private:
- SMTPAppender(const SMTPAppender&);
- SMTPAppender& operator=(const SMTPAppender&);
- static bool asciiCheck(const LogString& value, const LogString& label);
- /**
- 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. */
- bool checkEntryConditions();
-
- LogString to;
- LogString cc;
- LogString bcc;
- LogString from;
- LogString subject;
- LogString smtpHost;
- LogString smtpUsername;
- LogString smtpPassword;
- int smtpPort;
- int bufferSize; // 512
- bool locationInfo;
- helpers::CyclicBuffer cb;
- spi::TriggeringEventEvaluatorPtr evaluator;
-
- public:
- DECLARE_LOG4CXX_OBJECT(SMTPAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(SMTPAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
-
- SMTPAppender();
- /**
- The default constructor will instantiate the appender with a
- spi::TriggeringEventEvaluator that will trigger on events with
- level ERROR or higher.*/
- SMTPAppender(log4cxx::helpers::Pool& p);
-
- /**
- Use <code>evaluator</code> passed as parameter as the
- spi::TriggeringEventEvaluator for this net::SMTPAppender.
- */
- SMTPAppender(spi::TriggeringEventEvaluatorPtr evaluator);
-
- ~SMTPAppender();
-
- /**
- Set options
- */
- virtual void setOption(const LogString& option, const LogString& value);
-
- /**
- Activate the specified options, such as the smtp host, the
- recipient, from, etc.
- */
- virtual void activateOptions(log4cxx::helpers::Pool& p);
-
- /**
- Perform SMTPAppender specific appending actions, mainly adding
- the event to a cyclic buffer and checking if the event triggers
- an e-mail to be sent. */
- virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+ return bufferSize;
+ }
- virtual void close();
+ /**
+ * Gets the current triggering evaluator.
+ * @return triggering evaluator.
+ */
+ log4cxx::spi::TriggeringEventEvaluatorPtr getEvaluator() const;
- /**
- Returns value of the <b>To</b> option.
- */
- LogString getTo() const;
+ /**
+ * Sets the triggering evaluator.
+ * @param trigger triggering evaluator.
+ */
+ void setEvaluator(log4cxx::spi::TriggeringEventEvaluatorPtr& trigger);
- /**
- Returns value of the <b>cc</b> option.
- */
- LogString getCc() const;
+ /**
+ The <b>EvaluatorClass</b> option takes a string value
+ representing the name of the class implementing the
+ spi::TriggeringEventEvaluator interface. A corresponding object will
+ be instantiated and assigned as the triggering event evaluator
+ for the SMTPAppender.
+ */
+ void setEvaluatorClass(const LogString& value);
- /**
- Returns value of the <b>bcc</b> option.
- */
- LogString getBcc() const;
+ /**
+ The <b>LocationInfo</b> option is provided for compatibility with log4j
+ and has no effect in log4cxx.
+ */
+ void setLocationInfo(bool locationInfo);
+ /**
+ Returns value of the <b>LocationInfo</b> option.
+ */
+ bool getLocationInfo() const;
+}; // class SMTPAppender
- /**
- The <code>SMTPAppender</code> requires a {@link
- Layout layout}. */
- virtual bool requiresLayout() const;
+LOG4CXX_PTR_DEF(SMTPAppender);
- /**
- Send the contents of the cyclic buffer as an e-mail message.
- */
- void sendBuffer(log4cxx::helpers::Pool& p);
-
-
- /**
- Returns value of the <b>EvaluatorClass</b> option.
- */
- LogString getEvaluatorClass();
-
- /**
- Returns value of the <b>From</b> option.
- */
- LogString getFrom() const;
-
- /**
- Returns value of the <b>Subject</b> option.
- */
- LogString getSubject() const;
-
-
- /**
- The <b>From</b> option takes a string value which should be a
- e-mail address of the sender.
- */
- void setFrom(const LogString& from);
-
- /**
- The <b>Subject</b> option takes a string value which should be a
- the subject of the e-mail message.
- */
- void setSubject(const LogString& subject);
-
- /**
- The <b>BufferSize</b> option takes a positive integer
- representing the maximum number of logging events to collect in a
- cyclic buffer. When the <code>BufferSize</code> is reached,
- oldest events are deleted as new events are added to the
- buffer. By default the size of the cyclic buffer is 512 events.
- */
- void setBufferSize(int bufferSize);
-
- /**
- The <b>SMTPHost</b> option takes a string value which should be a
- the host name of the SMTP server that will send the e-mail message.
- */
- void setSMTPHost(const LogString& smtpHost);
-
- /**
- Returns value of the <b>SMTPHost</b> option.
- */
- LogString getSMTPHost() const;
-
- /**
- The <b>SMTPPort</b> option takes a string value which should be a
- the port of the SMTP server that will send the e-mail message.
- */
- void setSMTPPort(int port);
-
- /**
- Returns value of the <b>SMTPHost</b> option.
- */
- int getSMTPPort() const;
-
- /**
- The <b>To</b> option takes a string value which should be a
- comma separated list of e-mail address of the recipients.
- */
- void setTo(const LogString& to);
-
- /**
- The <b>Cc</b> option takes a string value which should be a
- comma separated list of e-mail address of the cc'd recipients.
- */
- void setCc(const LogString& to);
-
- /**
- The <b>Bcc</b> option takes a string value which should be a
- comma separated list of e-mail address of the bcc'd recipients.
- */
- void setBcc(const LogString& to);
-
-
- /**
- The <b>SMTPUsername</b> option takes a string value which should be a
- the user name for the SMTP server.
- */
- void setSMTPUsername(const LogString& newVal);
-
- /**
- Returns value of the <b>SMTPUsername</b> option.
- */
- LogString getSMTPUsername() const;
-
- /**
- The <b>SMTPPassword</b> option takes a string value which should be a
- the password for the SMTP server.
- */
- void setSMTPPassword(const LogString& newVal);
-
- /**
- Returns value of the <b>SMTPPassword</b> option.
- */
- LogString getSMTPPassword() const;
-
- /**
- Returns value of the <b>BufferSize</b> option.
- */
- inline int getBufferSize() const
- { return bufferSize; }
-
-
- /**
- * Gets the current triggering evaluator.
- * @return triggering evaluator.
- */
- log4cxx::spi::TriggeringEventEvaluatorPtr getEvaluator() const;
-
- /**
- * Sets the triggering evaluator.
- * @param trigger triggering evaluator.
- */
- void setEvaluator(log4cxx::spi::TriggeringEventEvaluatorPtr& trigger);
-
- /**
- The <b>EvaluatorClass</b> option takes a string value
- representing the name of the class implementing the
- spi::TriggeringEventEvaluator interface. A corresponding object will
- be instantiated and assigned as the triggering event evaluator
- for the SMTPAppender.
- */
- void setEvaluatorClass(const LogString& value);
-
- /**
- The <b>LocationInfo</b> option is provided for compatibility with log4j
- and has no effect in log4cxx.
- */
- void setLocationInfo(bool locationInfo);
-
- /**
- Returns value of the <b>LocationInfo</b> option.
- */
- bool getLocationInfo() const;
- }; // class SMTPAppender
-
- LOG4CXX_PTR_DEF(SMTPAppender);
-
- } // namespace net
+} // namespace net
} // namespace log4cxx
#endif // _LOG4CXX_NET_SMTP_H
diff --git a/src/main/include/log4cxx/net/socketappender.h b/src/main/include/log4cxx/net/socketappender.h
index cb88d30..7f46907 100644
--- a/src/main/include/log4cxx/net/socketappender.h
+++ b/src/main/include/log4cxx/net/socketappender.h
@@ -23,112 +23,112 @@
namespace log4cxx
{
- namespace net
- {
- /**
- Sends {@link log4cxx::spi::LoggingEvent LoggingEvent} objects to a remote a log server,
- usually Apache Chainsaw.
+namespace net
+{
+/**
+Sends {@link log4cxx::spi::LoggingEvent LoggingEvent} objects to a remote a log server,
+usually Apache Chainsaw.
- <p>The SocketAppender has the following properties:
+<p>The SocketAppender has the following properties:
- - If sent to Apache Chainsaw, remote logging
- is non-intrusive as far as the log event is concerned. In other
- words, the event will be logged with the same time stamp, {@link
- NDC NDC}, location info as if it were logged locally by
- the client.
+- If sent to Apache Chainsaw, remote logging
+ is non-intrusive as far as the log event is concerned. In other
+words, the event will be logged with the same time stamp, {@link
+NDC NDC}, location info as if it were logged locally by
+the client.
- - SocketAppenders do not use a layout. They ship a
- serialized {@link log4cxx::spi::LoggingEvent LoggingEvent} object
- to the server side.
+- SocketAppenders do not use a layout. They ship a
+serialized {@link log4cxx::spi::LoggingEvent LoggingEvent} object
+ to the server side.
- - Remote logging uses the TCP protocol. Consequently, if
- the server is reachable, then log events will eventually arrive
- at the server.
+- Remote logging uses the TCP protocol. Consequently, if
+the server is reachable, then log events will eventually arrive
+at the server.
- - If the remote server is down, the logging requests are
- simply dropped. However, if and when the server comes back up,
- then event transmission is resumed transparently. This
- transparent reconneciton is performed by a <em>connector</em>
- thread which periodically attempts to connect to the server.
+- If the remote server is down, the logging requests are
+simply dropped. However, if and when the server comes back up,
+then event transmission is resumed transparently. This
+transparent reconneciton is performed by a <em>connector</em>
+thread which periodically attempts to connect to the server.
- - Logging events are automatically <em>buffered</em> by the
- native TCP implementation. This means that if the link to server
- is slow but still faster than the rate of (log) event production
- by the client, the client will not be affected by the slow
- network connection. However, if the network connection is slower
- then the rate of event production, then the client can only
- progress at the network rate. In particular, if the network link
- to the the server is down, the client will be blocked.
- @n @n On the other hand, if the network link is up, but the server
- is down, the client will not be blocked when making log requests
- but the log events will be lost due to server unavailability.
+- Logging events are automatically <em>buffered</em> by the
+native TCP implementation. This means that if the link to server
+is slow but still faster than the rate of (log) event production
+by the client, the client will not be affected by the slow
+network connection. However, if the network connection is slower
+then the rate of event production, then the client can only
+progress at the network rate. In particular, if the network link
+to the the server is down, the client will be blocked.
+@n @n On the other hand, if the network link is up, but the server
+is down, the client will not be blocked when making log requests
+but the log events will be lost due to server unavailability.
- - Even if a <code>SocketAppender</code> is no longer
- attached to any logger, it will not be destroyed in
- the presence of a connector thread. A connector thread exists
- only if the connection to the server is down. To avoid this
- destruction problem, you should #close the the
- <code>SocketAppender</code> explicitly. See also next item.
- @n @n Long lived applications which create/destroy many
- <code>SocketAppender</code> instances should be aware of this
- destruction problem. Most other applications can safely
- ignore it.
+- Even if a <code>SocketAppender</code> is no longer
+attached to any logger, it will not be destroyed in
+the presence of a connector thread. A connector thread exists
+only if the connection to the server is down. To avoid this
+destruction problem, you should #close the the
+<code>SocketAppender</code> explicitly. See also next item.
+@n @n Long lived applications which create/destroy many
+<code>SocketAppender</code> instances should be aware of this
+destruction problem. Most other applications can safely
+ignore it.
- - If the application hosting the <code>SocketAppender</code>
- exits before the <code>SocketAppender</code> is closed either
- explicitly or subsequent to destruction, then there might
- be untransmitted data in the pipe which might be lost.
- @n @n To avoid lost data, it is usually sufficient to
- #close the <code>SocketAppender</code> either explicitly or by
- calling the LogManager#shutdown method
- before exiting the application.
- */
- class LOG4CXX_EXPORT SocketAppender : public SocketAppenderSkeleton
- {
- public:
- /**
- The default port number of remote logging server (4560).
- */
- static int DEFAULT_PORT;
+- If the application hosting the <code>SocketAppender</code>
+ exits before the <code>SocketAppender</code> is closed either
+explicitly or subsequent to destruction, then there might
+be untransmitted data in the pipe which might be lost.
+@n @n To avoid lost data, it is usually sufficient to
+#close the <code>SocketAppender</code> either explicitly or by
+calling the LogManager#shutdown method
+before exiting the application.
+*/
+class LOG4CXX_EXPORT SocketAppender : public SocketAppenderSkeleton
+{
+ public:
+ /**
+ The default port number of remote logging server (4560).
+ */
+ static int DEFAULT_PORT;
- /**
- The default reconnection delay (30000 milliseconds or 30 seconds).
- */
- static int DEFAULT_RECONNECTION_DELAY;
+ /**
+ The default reconnection delay (30000 milliseconds or 30 seconds).
+ */
+ static int DEFAULT_RECONNECTION_DELAY;
- DECLARE_LOG4CXX_OBJECT(SocketAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(SocketAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
+ DECLARE_LOG4CXX_OBJECT(SocketAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(SocketAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
- SocketAppender();
- ~SocketAppender();
+ SocketAppender();
+ ~SocketAppender();
- /**
- Connects to remote server at <code>address</code> and <code>port</code>.
- */
- SocketAppender(helpers::InetAddressPtr& address, int port);
+ /**
+ Connects to remote server at <code>address</code> and <code>port</code>.
+ */
+ SocketAppender(helpers::InetAddressPtr& address, int port);
- /**
- Connects to remote server at <code>host</code> and <code>port</code>.
- */
- SocketAppender(const LogString& host, int port);
+ /**
+ Connects to remote server at <code>host</code> and <code>port</code>.
+ */
+ SocketAppender(const LogString& host, int port);
- protected:
- virtual void setSocket(log4cxx::helpers::SocketPtr& socket, log4cxx::helpers::Pool& p);
- virtual void cleanUp(log4cxx::helpers::Pool& p);
- virtual int getDefaultDelay() const;
- virtual int getDefaultPort() const;
- void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool);
+ protected:
+ virtual void setSocket(log4cxx::helpers::SocketPtr& socket, log4cxx::helpers::Pool& p);
+ virtual void cleanUp(log4cxx::helpers::Pool& p);
+ virtual int getDefaultDelay() const;
+ virtual int getDefaultPort() const;
+ void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool);
- private:
- log4cxx::helpers::ObjectOutputStreamPtr oos;
+ private:
+ log4cxx::helpers::ObjectOutputStreamPtr oos;
- }; // class SocketAppender
+}; // class SocketAppender
- LOG4CXX_PTR_DEF(SocketAppender);
- } // namespace net
+LOG4CXX_PTR_DEF(SocketAppender);
+} // namespace net
} // namespace log4cxx
#endif // _LOG4CXX_NET_SOCKET_APPENDER_H
diff --git a/src/main/include/log4cxx/net/socketappenderskeleton.h b/src/main/include/log4cxx/net/socketappenderskeleton.h
index 0f6a896..36c535d 100644
--- a/src/main/include/log4cxx/net/socketappenderskeleton.h
+++ b/src/main/include/log4cxx/net/socketappenderskeleton.h
@@ -26,153 +26,171 @@
namespace log4cxx
{
- namespace net
+namespace net
+{
+
+/**
+ * Abstract base class for SocketAppender and XMLSocketAppender
+ */
+class LOG4CXX_EXPORT SocketAppenderSkeleton : public AppenderSkeleton
+{
+ private:
+ /**
+ host name
+ */
+ LogString remoteHost;
+
+ /**
+ IP address
+ */
+ helpers::InetAddressPtr address;
+
+ int port;
+ int reconnectionDelay;
+ bool locationInfo;
+
+ public:
+ SocketAppenderSkeleton(int defaultPort, int reconnectionDelay);
+ ~SocketAppenderSkeleton();
+
+ /**
+ Connects to remote server at <code>address</code> and <code>port</code>.
+ */
+ SocketAppenderSkeleton(helpers::InetAddressPtr address, int port, int reconnectionDelay);
+
+ /**
+ Connects to remote server at <code>host</code> and <code>port</code>.
+ */
+ SocketAppenderSkeleton(const LogString& host, int port, int reconnectionDelay);
+
+ /**
+ Connect to the specified <b>RemoteHost</b> and <b>Port</b>.
+ */
+ void activateOptions(log4cxx::helpers::Pool& p);
+
+ void close();
+
+
+ /**
+ * This appender does not use a layout. Hence, this method
+ * returns <code>false</code>.
+ *
+ */
+ bool requiresLayout() const
{
+ return false;
+ }
- /**
- * Abstract base class for SocketAppender and XMLSocketAppender
- */
- class LOG4CXX_EXPORT SocketAppenderSkeleton : public AppenderSkeleton
+ /**
+ * The <b>RemoteHost</b> option takes a string value which should be
+ * the host name of the server where a
+ * Apache Chainsaw or compatible is running.
+ * */
+ inline void setRemoteHost(const LogString& host)
{
- private:
- /**
- host name
- */
- LogString remoteHost;
+ address = helpers::InetAddress::getByName(host);
+ remoteHost.assign(host);
+ }
- /**
- IP address
- */
- helpers::InetAddressPtr address;
+ /**
+ Returns value of the <b>RemoteHost</b> option.
+ */
+ inline const LogString& getRemoteHost() const
+ {
+ return remoteHost;
+ }
- int port;
- int reconnectionDelay;
- bool locationInfo;
+ /**
+ The <b>Port</b> option takes a positive integer representing
+ the port where the server is waiting for connections.
+ */
+ void setPort(int port1)
+ {
+ this->port = port1;
+ }
- public:
- SocketAppenderSkeleton(int defaultPort, int reconnectionDelay);
- ~SocketAppenderSkeleton();
+ /**
+ Returns value of the <b>Port</b> option.
+ */
+ int getPort() const
+ {
+ return port;
+ }
- /**
- Connects to remote server at <code>address</code> and <code>port</code>.
- */
- SocketAppenderSkeleton(helpers::InetAddressPtr address, int port, int reconnectionDelay);
+ /**
+ The <b>LocationInfo</b> option takes a boolean value. If true,
+ the information sent to the remote host will include location
+ information. By default no location information is sent to the server.
+ */
+ void setLocationInfo(bool locationInfo1)
+ {
+ this->locationInfo = locationInfo1;
+ }
- /**
- Connects to remote server at <code>host</code> and <code>port</code>.
- */
- SocketAppenderSkeleton(const LogString& host, int port, int reconnectionDelay);
+ /**
+ Returns value of the <b>LocationInfo</b> option.
+ */
+ bool getLocationInfo() const
+ {
+ return locationInfo;
+ }
- /**
- Connect to the specified <b>RemoteHost</b> and <b>Port</b>.
- */
- void activateOptions(log4cxx::helpers::Pool& p);
+ /**
+ The <b>ReconnectionDelay</b> option takes a positive integer
+ representing the number of milliseconds to wait between each
+ failed connection attempt to the server. The default value of
+ this option is 30000 which corresponds to 30 seconds.
- void close();
+ <p>Setting this option to zero turns off reconnection
+ capability.
+ */
+ void setReconnectionDelay(int reconnectionDelay1)
+ {
+ this->reconnectionDelay = reconnectionDelay1;
+ }
+ /**
+ Returns value of the <b>ReconnectionDelay</b> option.
+ */
+ int getReconnectionDelay() const
+ {
+ return reconnectionDelay;
+ }
- /**
- * This appender does not use a layout. Hence, this method
- * returns <code>false</code>.
- *
- */
- bool requiresLayout() const
- { return false; }
+ void fireConnector();
- /**
- * The <b>RemoteHost</b> option takes a string value which should be
- * the host name of the server where a
- * Apache Chainsaw or compatible is running.
- * */
- inline void setRemoteHost(const LogString& host)
- { address = helpers::InetAddress::getByName(host);
- remoteHost.assign(host); }
+ void setOption(const LogString& option,
+ const LogString& value);
- /**
- Returns value of the <b>RemoteHost</b> option.
- */
- inline const LogString& getRemoteHost() const
- { return remoteHost; }
+ protected:
- /**
- The <b>Port</b> option takes a positive integer representing
- the port where the server is waiting for connections.
- */
- void setPort(int port1)
- { this->port = port1; }
+ virtual void setSocket(log4cxx::helpers::SocketPtr& socket, log4cxx::helpers::Pool& p) = 0;
- /**
- Returns value of the <b>Port</b> option.
- */
- int getPort() const
- { return port; }
+ virtual void cleanUp(log4cxx::helpers::Pool& p) = 0;
- /**
- The <b>LocationInfo</b> option takes a boolean value. If true,
- the information sent to the remote host will include location
- information. By default no location information is sent to the server.
- */
- void setLocationInfo(bool locationInfo1)
- { this->locationInfo = locationInfo1; }
+ virtual int getDefaultDelay() const = 0;
- /**
- Returns value of the <b>LocationInfo</b> option.
- */
- bool getLocationInfo() const
- { return locationInfo; }
+ virtual int getDefaultPort() const = 0;
- /**
- The <b>ReconnectionDelay</b> option takes a positive integer
- representing the number of milliseconds to wait between each
- failed connection attempt to the server. The default value of
- this option is 30000 which corresponds to 30 seconds.
+ private:
+ void connect(log4cxx::helpers::Pool& p);
+ /**
+ The Connector will reconnect when the server becomes available
+ again. It does this by attempting to open a new connection every
+ <code>reconnectionDelay</code> milliseconds.
- <p>Setting this option to zero turns off reconnection
- capability.
- */
- void setReconnectionDelay(int reconnectionDelay1)
- { this->reconnectionDelay = reconnectionDelay1; }
+ <p>It stops trying whenever a connection is established. It will
+ restart to try reconnect to the server when previously open
+ connection is droppped.
+ */
- /**
- Returns value of the <b>ReconnectionDelay</b> option.
- */
- int getReconnectionDelay() const
- { return reconnectionDelay; }
+ helpers::Thread thread;
+ static void* LOG4CXX_THREAD_FUNC monitor(apr_thread_t* thread, void* data);
+ SocketAppenderSkeleton(const SocketAppenderSkeleton&);
+ SocketAppenderSkeleton& operator=(const SocketAppenderSkeleton&);
- void fireConnector();
-
- void setOption(const LogString& option,
- const LogString& value);
-
- protected:
-
- virtual void setSocket(log4cxx::helpers::SocketPtr& socket, log4cxx::helpers::Pool& p) = 0;
-
- virtual void cleanUp(log4cxx::helpers::Pool& p) = 0;
-
- virtual int getDefaultDelay() const = 0;
-
- virtual int getDefaultPort() const = 0;
-
- private:
- void connect(log4cxx::helpers::Pool& p);
- /**
- The Connector will reconnect when the server becomes available
- again. It does this by attempting to open a new connection every
- <code>reconnectionDelay</code> milliseconds.
-
- <p>It stops trying whenever a connection is established. It will
- restart to try reconnect to the server when previously open
- connection is droppped.
- */
-
- helpers::Thread thread;
- static void* LOG4CXX_THREAD_FUNC monitor(apr_thread_t* thread, void* data);
- SocketAppenderSkeleton(const SocketAppenderSkeleton&);
- SocketAppenderSkeleton& operator=(const SocketAppenderSkeleton&);
-
- }; // class SocketAppenderSkeleton
- } // namespace net
+}; // class SocketAppenderSkeleton
+} // namespace net
} // namespace log4cxx
#endif // _LOG4CXX_NET_SOCKET_APPENDER_SKELETON_H
diff --git a/src/main/include/log4cxx/net/sockethubappender.h b/src/main/include/log4cxx/net/sockethubappender.h
index b426994..47a64bd 100644
--- a/src/main/include/log4cxx/net/sockethubappender.h
+++ b/src/main/include/log4cxx/net/sockethubappender.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_NET_SOCKET_HUB_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
@@ -32,167 +32,178 @@
namespace log4cxx
{
- namespace helpers {
- class ObjectOutputStream;
- typedef ObjectPtrT<ObjectOutputStream> ObjectOutputStreamPtr;
- }
- namespace net
+namespace helpers
+{
+class ObjectOutputStream;
+typedef ObjectPtrT<ObjectOutputStream> ObjectOutputStreamPtr;
+}
+namespace net
+{
+LOG4CXX_LIST_DEF(ObjectOutputStreamList, log4cxx::helpers::ObjectOutputStreamPtr);
+
+/**
+Sends {@link log4cxx::spi::LoggingEvent LoggingEvent} objects to a set of remote log
+servers, usually a SocketNode.
+
+<p>Acts just like SocketAppender except that instead of
+connecting to a given remote log server,
+<code>SocketHubAppender</code> accepts connections from the remote
+log servers as clients. It can accept more than one connection.
+When a log event is received, the event is sent to the set of
+currently connected remote log servers. Implemented this way it does
+not require any update to the configuration file to send data to
+another remote log server. The remote log server simply connects to
+the host and port the <code>SocketHubAppender</code> is running on.
+
+<p>The <code>SocketHubAppender</code> does not store events such
+that the remote side will events that arrived after the
+establishment of its connection. Once connected, events arrive in
+order as guaranteed by the TCP protocol.
+
+<p>This implementation borrows heavily from the SocketAppender.
+
+<p>The SocketHubAppender has the following characteristics:
+
+- If sent to a SocketNode, logging is non-intrusive as
+far as the log event is concerned. In other words, the event will be
+logged with the same time stamp, NDC,
+location info as if it were logged locally.
+
+- <code>SocketHubAppender</code> does not use a layout. It
+ships a serialized spi::LoggingEvent object to the remote side.
+
+- <code>SocketHubAppender</code> relies on the TCP
+protocol. Consequently, if the remote side is reachable, then log
+events will eventually arrive at remote client.
+
+- If no remote clients are attached, the logging requests are
+simply dropped.
+
+- Logging events are automatically <em>buffered</em> by the
+native TCP implementation. This means that if the link to remote
+client is slow but still faster than the rate of (log) event
+production, the application will not be affected by the slow network
+connection. However, if the network connection is slower then the
+rate of event production, then the local application can only
+progress at the network rate. In particular, if the network link to
+the the remote client is down, the application will be blocked.
+@n @n On the other hand, if the network link is up, but the remote
+client is down, the client will not be blocked when making log
+requests but the log events will be lost due to client
+unavailability.
+@n @n The single remote client case extends to multiple clients
+connections. The rate of logging will be determined by the slowest
+link.
+
+- If the application hosting the <code>SocketHubAppender</code>
+exits before the <code>SocketHubAppender</code> is closed either
+explicitly or subsequent to garbage collection, then there might
+be untransmitted data in the pipe which might be lost. This is a
+common problem on Windows based systems.
+@n @n To avoid lost data, it is usually sufficient to #close
+the <code>SocketHubAppender</code> either explicitly or by calling
+the LogManager#shutdown method before
+exiting the application.
+*/
+
+class LOG4CXX_EXPORT SocketHubAppender : public AppenderSkeleton
+{
+ private:
+ /**
+ The default port number of the ServerSocket will be created on.
+ */
+ static int DEFAULT_PORT;
+
+ int port;
+ ObjectOutputStreamList streams;
+ bool locationInfo;
+
+ public:
+ DECLARE_LOG4CXX_OBJECT(SocketHubAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(SocketHubAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
+
+ SocketHubAppender();
+ ~SocketHubAppender();
+
+ /**
+ Connects to remote server at <code>address</code> and <code>port</code>.
+ */
+ SocketHubAppender(int port) ;
+
+ /**
+ Set up the socket server on the specified port.
+ */
+ virtual void activateOptions(log4cxx::helpers::Pool& p);
+
+ /**
+ Set options
+ */
+ virtual void setOption(const LogString& option, const LogString& value);
+
+ virtual void close();
+
+ /**
+ Append an event to all of current connections. */
+ virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+
+ /**
+ The SocketHubAppender does not use a layout. Hence, this method returns
+ <code>false</code>. */
+ virtual bool requiresLayout() const
{
- LOG4CXX_LIST_DEF(ObjectOutputStreamList, log4cxx::helpers::ObjectOutputStreamPtr);
+ return false;
+ }
- /**
- Sends {@link log4cxx::spi::LoggingEvent LoggingEvent} objects to a set of remote log
- servers, usually a SocketNode.
+ /**
+ The <b>Port</b> option takes a positive integer representing
+ the port where the server is waiting for connections. */
+ inline void setPort(int port1)
+ {
+ this->port = port1;
+ }
- <p>Acts just like SocketAppender except that instead of
- connecting to a given remote log server,
- <code>SocketHubAppender</code> accepts connections from the remote
- log servers as clients. It can accept more than one connection.
- When a log event is received, the event is sent to the set of
- currently connected remote log servers. Implemented this way it does
- not require any update to the configuration file to send data to
- another remote log server. The remote log server simply connects to
- the host and port the <code>SocketHubAppender</code> is running on.
+ /**
+ Returns value of the <b>Port</b> option. */
+ inline int getPort() const
+ {
+ return port;
+ }
- <p>The <code>SocketHubAppender</code> does not store events such
- that the remote side will events that arrived after the
- establishment of its connection. Once connected, events arrive in
- order as guaranteed by the TCP protocol.
+ /**
+ The <b>LocationInfo</b> option takes a boolean value. If true,
+ the information sent to the remote host will include location
+ information. By default no location information is sent to the server. */
+ inline void setLocationInfo(bool locationInfo1)
+ {
+ this->locationInfo = locationInfo1;
+ }
- <p>This implementation borrows heavily from the SocketAppender.
+ /**
+ Returns value of the <b>LocationInfo</b> option. */
+ inline bool getLocationInfo() const
+ {
+ return locationInfo;
+ }
- <p>The SocketHubAppender has the following characteristics:
+ /**
+ Start the ServerMonitor thread. */
+ private:
+ void startServer();
- - If sent to a SocketNode, logging is non-intrusive as
- far as the log event is concerned. In other words, the event will be
- logged with the same time stamp, NDC,
- location info as if it were logged locally.
+ helpers::Thread thread;
+ static void* LOG4CXX_THREAD_FUNC monitor(apr_thread_t* thread, void* data);
- - <code>SocketHubAppender</code> does not use a layout. It
- ships a serialized spi::LoggingEvent object to the remote side.
-
- - <code>SocketHubAppender</code> relies on the TCP
- protocol. Consequently, if the remote side is reachable, then log
- events will eventually arrive at remote client.
-
- - If no remote clients are attached, the logging requests are
- simply dropped.
-
- - Logging events are automatically <em>buffered</em> by the
- native TCP implementation. This means that if the link to remote
- client is slow but still faster than the rate of (log) event
- production, the application will not be affected by the slow network
- connection. However, if the network connection is slower then the
- rate of event production, then the local application can only
- progress at the network rate. In particular, if the network link to
- the the remote client is down, the application will be blocked.
- @n @n On the other hand, if the network link is up, but the remote
- client is down, the client will not be blocked when making log
- requests but the log events will be lost due to client
- unavailability.
- @n @n The single remote client case extends to multiple clients
- connections. The rate of logging will be determined by the slowest
- link.
-
- - If the application hosting the <code>SocketHubAppender</code>
- exits before the <code>SocketHubAppender</code> is closed either
- explicitly or subsequent to garbage collection, then there might
- be untransmitted data in the pipe which might be lost. This is a
- common problem on Windows based systems.
- @n @n To avoid lost data, it is usually sufficient to #close
- the <code>SocketHubAppender</code> either explicitly or by calling
- the LogManager#shutdown method before
- exiting the application.
- */
-
- class LOG4CXX_EXPORT SocketHubAppender : public AppenderSkeleton
- {
- private:
- /**
- The default port number of the ServerSocket will be created on.
- */
- static int DEFAULT_PORT;
-
- int port;
- ObjectOutputStreamList streams;
- bool locationInfo;
-
- public:
- DECLARE_LOG4CXX_OBJECT(SocketHubAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(SocketHubAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
-
- SocketHubAppender();
- ~SocketHubAppender();
-
- /**
- Connects to remote server at <code>address</code> and <code>port</code>.
- */
- SocketHubAppender(int port) ;
-
- /**
- Set up the socket server on the specified port.
- */
- virtual void activateOptions(log4cxx::helpers::Pool& p);
-
- /**
- Set options
- */
- virtual void setOption(const LogString& option, const LogString& value);
-
- virtual void close();
-
- /**
- Append an event to all of current connections. */
- virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
-
- /**
- The SocketHubAppender does not use a layout. Hence, this method returns
- <code>false</code>. */
- virtual bool requiresLayout() const
- { return false; }
-
- /**
- The <b>Port</b> option takes a positive integer representing
- the port where the server is waiting for connections. */
- inline void setPort(int port1)
- { this->port = port1; }
-
- /**
- Returns value of the <b>Port</b> option. */
- inline int getPort() const
- { return port; }
-
- /**
- The <b>LocationInfo</b> option takes a boolean value. If true,
- the information sent to the remote host will include location
- information. By default no location information is sent to the server. */
- inline void setLocationInfo(bool locationInfo1)
- { this->locationInfo = locationInfo1; }
-
- /**
- Returns value of the <b>LocationInfo</b> option. */
- inline bool getLocationInfo() const
- { return locationInfo; }
-
- /**
- Start the ServerMonitor thread. */
- private:
- void startServer();
-
- helpers::Thread thread;
- static void* LOG4CXX_THREAD_FUNC monitor(apr_thread_t* thread, void* data);
-
- }; // class SocketHubAppender
- LOG4CXX_PTR_DEF(SocketHubAppender);
- } // namespace net
+}; // class SocketHubAppender
+LOG4CXX_PTR_DEF(SocketHubAppender);
+} // namespace net
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif // _LOG4CXX_NET_SOCKET_HUB_APPENDER_H
diff --git a/src/main/include/log4cxx/net/syslogappender.h b/src/main/include/log4cxx/net/syslogappender.h
index 53faffa..e2a49e0 100644
--- a/src/main/include/log4cxx/net/syslogappender.h
+++ b/src/main/include/log4cxx/net/syslogappender.h
@@ -23,119 +23,129 @@
namespace log4cxx
{
- namespace net
+namespace net
+{
+/** Use SyslogAppender to send log messages to a remote syslog daemon.*/
+class LOG4CXX_EXPORT SyslogAppender : public AppenderSkeleton
+{
+ public:
+ DECLARE_LOG4CXX_OBJECT(SyslogAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(SyslogAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
+
+
+
+ SyslogAppender();
+ SyslogAppender(const LayoutPtr& layout, int syslogFacility);
+ SyslogAppender(const LayoutPtr& layout,
+ const LogString& syslogHost, int syslogFacility);
+ ~SyslogAppender();
+ /** Release any resources held by this SyslogAppender.*/
+ void close();
+
+ /**
+ Returns the specified syslog facility as a lower-case String,
+ e.g. "kern", "user", etc.
+ */
+ static LogString getFacilityString(int syslogFacility);
+
+ /**
+ Returns the integer value corresponding to the named syslog
+ facility, or -1 if it couldn't be recognized.
+ @param facilityName one of the strings KERN, USER, MAIL, DAEMON,
+ AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, LOCAL0,
+ LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
+ The matching is case-insensitive.
+ */
+ static int getFacility(const LogString& facilityName);
+
+ void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+
+ /**
+ This method returns immediately as options are activated when they
+ are set.
+ */
+ void activateOptions(log4cxx::helpers::Pool& p);
+ void setOption(const LogString& option, const LogString& value);
+
+ /**
+ The SyslogAppender requires a layout. Hence, this method returns
+ <code>true</code>.
+ */
+ virtual bool requiresLayout() const
{
- /** Use SyslogAppender to send log messages to a remote syslog daemon.*/
- class LOG4CXX_EXPORT SyslogAppender : public AppenderSkeleton
- {
- public:
- DECLARE_LOG4CXX_OBJECT(SyslogAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(SyslogAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
+ return true;
+ }
+ /**
+ The <b>SyslogHost</b> option is the name of the the syslog host
+ where log output should go.
+ <b>WARNING</b> If the SyslogHost is not set, then this appender
+ will fail.
+ */
+ void setSyslogHost(const LogString& syslogHost);
+ /**
+ Returns the value of the <b>SyslogHost</b> option.
+ */
+ inline const LogString& getSyslogHost() const
+ {
+ return syslogHost;
+ }
- SyslogAppender();
- SyslogAppender(const LayoutPtr& layout, int syslogFacility);
- SyslogAppender(const LayoutPtr& layout,
- const LogString& syslogHost, int syslogFacility);
- ~SyslogAppender();
- /** Release any resources held by this SyslogAppender.*/
- void close();
+ /**
+ Set the syslog facility. This is the <b>Facility</b> option.
- /**
- Returns the specified syslog facility as a lower-case String,
- e.g. "kern", "user", etc.
- */
- static LogString getFacilityString(int syslogFacility);
+ <p>The <code>facilityName</code> parameter must be one of the
+ strings KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP,
+ CRON, AUTHPRIV, FTP, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4,
+ LOCAL5, LOCAL6, LOCAL7. Case is unimportant.
+ */
+ void setFacility(const LogString& facilityName);
- /**
- Returns the integer value corresponding to the named syslog
- facility, or -1 if it couldn't be recognized.
- @param facilityName one of the strings KERN, USER, MAIL, DAEMON,
- AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, LOCAL0,
- LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
- The matching is case-insensitive.
- */
- static int getFacility(const LogString &facilityName);
+ /**
+ Returns the value of the <b>Facility</b> option.
+ */
+ inline LogString getFacility() const
+ {
+ return getFacilityString(syslogFacility);
+ }
- void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+ /**
+ If the <b>FacilityPrinting</b> option is set to true, the printed
+ message will include the facility name of the application. It is
+ <em>false</em> by default.
+ */
+ inline void setFacilityPrinting(bool facilityPrinting1)
+ {
+ this->facilityPrinting = facilityPrinting1;
+ }
- /**
- This method returns immediately as options are activated when they
- are set.
- */
- void activateOptions(log4cxx::helpers::Pool& p);
- void setOption(const LogString& option, const LogString& value);
+ /**
+ Returns the value of the <b>FacilityPrinting</b> option.
+ */
+ inline bool getFacilityPrinting() const
+ {
+ return facilityPrinting;
+ }
- /**
- The SyslogAppender requires a layout. Hence, this method returns
- <code>true</code>.
- */
- virtual bool requiresLayout() const
- { return true; }
+ protected:
+ void initSyslogFacilityStr();
- /**
- The <b>SyslogHost</b> option is the name of the the syslog host
- where log output should go.
- <b>WARNING</b> If the SyslogHost is not set, then this appender
- will fail.
- */
- void setSyslogHost(const LogString& syslogHost);
-
- /**
- Returns the value of the <b>SyslogHost</b> option.
- */
- inline const LogString& getSyslogHost() const
- { return syslogHost; }
-
- /**
- Set the syslog facility. This is the <b>Facility</b> option.
-
- <p>The <code>facilityName</code> parameter must be one of the
- strings KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP,
- CRON, AUTHPRIV, FTP, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4,
- LOCAL5, LOCAL6, LOCAL7. Case is unimportant.
- */
- void setFacility(const LogString& facilityName);
-
- /**
- Returns the value of the <b>Facility</b> option.
- */
- inline LogString getFacility() const
- { return getFacilityString(syslogFacility); }
-
- /**
- If the <b>FacilityPrinting</b> option is set to true, the printed
- message will include the facility name of the application. It is
- <em>false</em> by default.
- */
- inline void setFacilityPrinting(bool facilityPrinting1)
- { this->facilityPrinting = facilityPrinting1; }
-
- /**
- Returns the value of the <b>FacilityPrinting</b> option.
- */
- inline bool getFacilityPrinting() const
- { return facilityPrinting; }
-
- protected:
- void initSyslogFacilityStr();
-
- int syslogFacility; // Have LOG_USER as default
- LogString facilityStr;
- bool facilityPrinting;
- helpers::SyslogWriter * sw;
- LogString syslogHost;
- int syslogHostPort;
- private:
- SyslogAppender(const SyslogAppender&);
- SyslogAppender& operator=(const SyslogAppender&);
- }; // class SyslogAppender
- LOG4CXX_PTR_DEF(SyslogAppender);
- } // namespace net
+ int syslogFacility; // Have LOG_USER as default
+ LogString facilityStr;
+ bool facilityPrinting;
+ helpers::SyslogWriter* sw;
+ LogString syslogHost;
+ int syslogHostPort;
+ private:
+ SyslogAppender(const SyslogAppender&);
+ SyslogAppender& operator=(const SyslogAppender&);
+}; // class SyslogAppender
+LOG4CXX_PTR_DEF(SyslogAppender);
+} // namespace net
} // namespace log4cxx
#endif // _LOG4CXX_NET_SYSLOG_APPENDER_H
diff --git a/src/main/include/log4cxx/net/telnetappender.h b/src/main/include/log4cxx/net/telnetappender.h
index fbc00e0..e531555 100644
--- a/src/main/include/log4cxx/net/telnetappender.h
+++ b/src/main/include/log4cxx/net/telnetappender.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_NET_TELNET_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
@@ -34,13 +34,14 @@
namespace log4cxx
{
- namespace helpers {
- class ByteBuffer;
- }
- namespace net
- {
- typedef log4cxx::helpers::SocketPtr Connection;
- LOG4CXX_LIST_DEF(ConnectionList, Connection);
+namespace helpers
+{
+class ByteBuffer;
+}
+namespace net
+{
+typedef log4cxx::helpers::SocketPtr Connection;
+LOG4CXX_LIST_DEF(ConnectionList, Connection);
/**
<p>The TelnetAppender is a log4cxx appender that specializes in
@@ -67,91 +68,97 @@
<td>5875</td>
</table>
*/
- class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton
- {
- class SocketHandler;
- friend class SocketHandler;
- private:
- static const int DEFAULT_PORT;
- static const int MAX_CONNECTIONS;
- int port;
+class LOG4CXX_EXPORT TelnetAppender : public AppenderSkeleton
+{
+ class SocketHandler;
+ friend class SocketHandler;
+ private:
+ static const int DEFAULT_PORT;
+ static const int MAX_CONNECTIONS;
+ int port;
- public:
- DECLARE_LOG4CXX_OBJECT(TelnetAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(TelnetAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_OBJECT(TelnetAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(TelnetAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
- TelnetAppender();
- ~TelnetAppender();
+ TelnetAppender();
+ ~TelnetAppender();
- /**
- This appender requires a layout to format the text to the
- attached client(s). */
- virtual bool requiresLayout() const
- { return true; }
+ /**
+ This appender requires a layout to format the text to the
+ attached client(s). */
+ virtual bool requiresLayout() const
+ {
+ return true;
+ }
- LogString getEncoding() const;
- void setEncoding(const LogString& value);
+ LogString getEncoding() const;
+ void setEncoding(const LogString& value);
- /** all of the options have been set, create the socket handler and
- wait for connections. */
- void activateOptions(log4cxx::helpers::Pool& p);
+ /** all of the options have been set, create the socket handler and
+ wait for connections. */
+ void activateOptions(log4cxx::helpers::Pool& p);
- /**
- Set options
- */
- virtual void setOption(const LogString& option, const LogString& value);
+ /**
+ Set options
+ */
+ virtual void setOption(const LogString& option, const LogString& value);
- /**
- Returns value of the <b>Port</b> option.
- */
- int getPort() const
- { return port; }
+ /**
+ Returns value of the <b>Port</b> option.
+ */
+ int getPort() const
+ {
+ return port;
+ }
- /**
- The <b>Port</b> option takes a positive integer representing
- the port where the server is waiting for connections.
- */
- void setPort(int port1)
- { this->port = port1; }
+ /**
+ The <b>Port</b> option takes a positive integer representing
+ the port where the server is waiting for connections.
+ */
+ void setPort(int port1)
+ {
+ this->port = port1;
+ }
- /** shuts down the appender. */
- void close();
+ /** shuts down the appender. */
+ void close();
- protected:
- /** Handles a log event. For this appender, that means writing the
- message to each connected client. */
- virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) ;
+ protected:
+ /** Handles a log event. For this appender, that means writing the
+ message to each connected client. */
+ virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) ;
- //---------------------------------------------------------- SocketHandler:
+ //---------------------------------------------------------- SocketHandler:
- private:
- // prevent copy and assignment statements
- TelnetAppender(const TelnetAppender&);
- TelnetAppender& operator=(const TelnetAppender&);
+ private:
+ // prevent copy and assignment statements
+ TelnetAppender(const TelnetAppender&);
+ TelnetAppender& operator=(const TelnetAppender&);
- void write(log4cxx::helpers::ByteBuffer&);
- void writeStatus(const log4cxx::helpers::SocketPtr& socket, const LogString& msg, log4cxx::helpers::Pool& p);
- ConnectionList connections;
- LogString encoding;
- log4cxx::helpers::CharsetEncoderPtr encoder;
- helpers::ServerSocket* serverSocket;
- helpers::Thread sh;
- size_t activeConnections;
- static void* LOG4CXX_THREAD_FUNC acceptConnections(apr_thread_t* thread, void* data);
- }; // class TelnetAppender
+ void write(log4cxx::helpers::ByteBuffer&);
+ void writeStatus(const log4cxx::helpers::SocketPtr& socket, const LogString& msg, log4cxx::helpers::Pool& p);
+ ConnectionList connections;
+ LogString encoding;
+ log4cxx::helpers::CharsetEncoderPtr encoder;
+ helpers::ServerSocket* serverSocket;
+ helpers::Thread sh;
+ size_t activeConnections;
+ static void* LOG4CXX_THREAD_FUNC acceptConnections(apr_thread_t* thread, void* data);
+}; // class TelnetAppender
- LOG4CXX_PTR_DEF(TelnetAppender);
- } // namespace net
+LOG4CXX_PTR_DEF(TelnetAppender);
+} // namespace net
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif // _LOG4CXX_NET_TELNET_APPENDER_H
diff --git a/src/main/include/log4cxx/net/xmlsocketappender.h b/src/main/include/log4cxx/net/xmlsocketappender.h
index a308f5e..a65356b 100644
--- a/src/main/include/log4cxx/net/xmlsocketappender.h
+++ b/src/main/include/log4cxx/net/xmlsocketappender.h
@@ -23,127 +23,127 @@
namespace log4cxx
{
- namespace net
- {
+namespace net
+{
+
+/**
+Sends {@link log4cxx::spi::LoggingEvent LoggingEvent} objects in XML format
+ to a remote a log server, usually a XMLSocketNode.
+
+<p>The XMLSocketAppender has the following properties:
+
+- If sent to a XMLSocketNode, remote logging
+ is non-intrusive as far as the log event is concerned. In other
+words, the event will be logged with the same time stamp, {@link
+NDC NDC}, location info as if it were logged locally by
+the client.
+
+- XMLSocketAppenders use exclusively an XMLLayout. They ship an
+XML stream representing a {@link spi::LoggingEvent LoggingEvent} object
+ to the server side.
+
+- Remote logging uses the TCP protocol. Consequently, if
+the server is reachable, then log events will eventually arrive
+at the server.
+
+- If the remote server is down, the logging requests are
+simply dropped. However, if and when the server comes back up,
+then event transmission is resumed transparently. This
+transparent reconneciton is performed by a <em>connector</em>
+thread which periodically attempts to connect to the server.
+
+- Logging events are automatically <em>buffered</em> by the
+native TCP implementation. This means that if the link to server
+is slow but still faster than the rate of (log) event production
+by the client, the client will not be affected by the slow
+network connection. However, if the network connection is slower
+then the rate of event production, then the client can only
+progress at the network rate. In particular, if the network link
+to the the server is down, the client will be blocked.
+@n @n On the other hand, if the network link is up, but the server
+is down, the client will not be blocked when making log requests
+but the log events will be lost due to server unavailability.
+
+- Even if an <code>XMLSocketAppender</code> is no longer
+attached to any logger, it will not be destroyed in
+the presence of a connector thread. A connector thread exists
+only if the connection to the server is down. To avoid this
+destruction problem, you should #close the the
+<code>XMLSocketAppender</code> explicitly. See also next item.
+@n @n Long lived applications which create/destroy many
+<code>XMLSocketAppender</code> instances should be aware of this
+destruction problem. Most other applications can safely
+ignore it.
+
+- If the application hosting the <code>XMLSocketAppender</code>
+ exits before the <code>XMLSocketAppender</code> is closed either
+explicitly or subsequent to destruction, then there might
+be untransmitted data in the pipe which might be lost.
+@n @n To avoid lost data, it is usually sufficient to
+#close the <code>XMLSocketAppender</code> either explicitly or by
+calling the LogManager#shutdown method
+before exiting the application.
+*/
+
+class LOG4CXX_EXPORT XMLSocketAppender : public SocketAppenderSkeleton
+{
+ public:
+ /**
+ The default port number of remote logging server (4560).
+ */
+ static int DEFAULT_PORT;
/**
- Sends {@link log4cxx::spi::LoggingEvent LoggingEvent} objects in XML format
- to a remote a log server, usually a XMLSocketNode.
+ The default reconnection delay (30000 milliseconds or 30 seconds).
+ */
+ static int DEFAULT_RECONNECTION_DELAY;
- <p>The XMLSocketAppender has the following properties:
+ /**
+ An event XML stream cannot exceed 1024 bytes.
+ */
+ static const int MAX_EVENT_LEN;
- - If sent to a XMLSocketNode, remote logging
- is non-intrusive as far as the log event is concerned. In other
- words, the event will be logged with the same time stamp, {@link
- NDC NDC}, location info as if it were logged locally by
- the client.
+ DECLARE_LOG4CXX_OBJECT(XMLSocketAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(XMLSocketAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
- - XMLSocketAppenders use exclusively an XMLLayout. They ship an
- XML stream representing a {@link spi::LoggingEvent LoggingEvent} object
- to the server side.
+ XMLSocketAppender();
+ ~XMLSocketAppender();
- - Remote logging uses the TCP protocol. Consequently, if
- the server is reachable, then log events will eventually arrive
- at the server.
+ /**
+ Connects to remote server at <code>address</code> and <code>port</code>.
+ */
+ XMLSocketAppender(helpers::InetAddressPtr address, int port);
- - If the remote server is down, the logging requests are
- simply dropped. However, if and when the server comes back up,
- then event transmission is resumed transparently. This
- transparent reconneciton is performed by a <em>connector</em>
- thread which periodically attempts to connect to the server.
-
- - Logging events are automatically <em>buffered</em> by the
- native TCP implementation. This means that if the link to server
- is slow but still faster than the rate of (log) event production
- by the client, the client will not be affected by the slow
- network connection. However, if the network connection is slower
- then the rate of event production, then the client can only
- progress at the network rate. In particular, if the network link
- to the the server is down, the client will be blocked.
- @n @n On the other hand, if the network link is up, but the server
- is down, the client will not be blocked when making log requests
- but the log events will be lost due to server unavailability.
-
- - Even if an <code>XMLSocketAppender</code> is no longer
- attached to any logger, it will not be destroyed in
- the presence of a connector thread. A connector thread exists
- only if the connection to the server is down. To avoid this
- destruction problem, you should #close the the
- <code>XMLSocketAppender</code> explicitly. See also next item.
- @n @n Long lived applications which create/destroy many
- <code>XMLSocketAppender</code> instances should be aware of this
- destruction problem. Most other applications can safely
- ignore it.
-
- - If the application hosting the <code>XMLSocketAppender</code>
- exits before the <code>XMLSocketAppender</code> is closed either
- explicitly or subsequent to destruction, then there might
- be untransmitted data in the pipe which might be lost.
- @n @n To avoid lost data, it is usually sufficient to
- #close the <code>XMLSocketAppender</code> either explicitly or by
- calling the LogManager#shutdown method
- before exiting the application.
- */
-
- class LOG4CXX_EXPORT XMLSocketAppender : public SocketAppenderSkeleton
- {
- public:
- /**
- The default port number of remote logging server (4560).
- */
- static int DEFAULT_PORT;
-
- /**
- The default reconnection delay (30000 milliseconds or 30 seconds).
- */
- static int DEFAULT_RECONNECTION_DELAY;
-
- /**
- An event XML stream cannot exceed 1024 bytes.
- */
- static const int MAX_EVENT_LEN;
-
- DECLARE_LOG4CXX_OBJECT(XMLSocketAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(XMLSocketAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
-
- XMLSocketAppender();
- ~XMLSocketAppender();
-
- /**
- Connects to remote server at <code>address</code> and <code>port</code>.
- */
- XMLSocketAppender(helpers::InetAddressPtr address, int port);
-
- /**
- Connects to remote server at <code>host</code> and <code>port</code>.
- */
- XMLSocketAppender(const LogString& host, int port);
+ /**
+ Connects to remote server at <code>host</code> and <code>port</code>.
+ */
+ XMLSocketAppender(const LogString& host, int port);
- protected:
- virtual void setSocket(log4cxx::helpers::SocketPtr& socket, log4cxx::helpers::Pool& p);
+ protected:
+ virtual void setSocket(log4cxx::helpers::SocketPtr& socket, log4cxx::helpers::Pool& p);
- virtual void cleanUp(log4cxx::helpers::Pool& p);
+ virtual void cleanUp(log4cxx::helpers::Pool& p);
- virtual int getDefaultDelay() const;
+ virtual int getDefaultDelay() const;
- virtual int getDefaultPort() const;
+ virtual int getDefaultPort() const;
- void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool);
+ void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool);
- private:
- log4cxx::helpers::WriterPtr writer;
- // prevent copy and assignment statements
- XMLSocketAppender(const XMLSocketAppender&);
- XMLSocketAppender& operator=(const XMLSocketAppender&);
- }; // class XMLSocketAppender
+ private:
+ log4cxx::helpers::WriterPtr writer;
+ // prevent copy and assignment statements
+ XMLSocketAppender(const XMLSocketAppender&);
+ XMLSocketAppender& operator=(const XMLSocketAppender&);
+}; // class XMLSocketAppender
- LOG4CXX_PTR_DEF(XMLSocketAppender);
+LOG4CXX_PTR_DEF(XMLSocketAppender);
- } // namespace net
+} // namespace net
} // namespace log4cxx
#endif // _LOG4CXX_NET_XML_SOCKET_APPENDER_H
diff --git a/src/main/include/log4cxx/nt/nteventlogappender.h b/src/main/include/log4cxx/nt/nteventlogappender.h
index 4951bcc..8d4d05f 100644
--- a/src/main/include/log4cxx/nt/nteventlogappender.h
+++ b/src/main/include/log4cxx/nt/nteventlogappender.h
@@ -23,89 +23,103 @@
namespace log4cxx
{
- namespace nt
+namespace nt
+{
+/**
+ * Appends log events to NT EventLog.
+ */
+class LOG4CXX_EXPORT NTEventLogAppender : public AppenderSkeleton
+{
+ public:
+ DECLARE_LOG4CXX_OBJECT(NTEventLogAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(NTEventLogAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
+
+ NTEventLogAppender();
+ NTEventLogAppender(const LogString& server, const LogString& log,
+ const LogString& source, const LayoutPtr& layout);
+
+ virtual ~NTEventLogAppender();
+
+ virtual void activateOptions(log4cxx::helpers::Pool& p);
+ virtual void close();
+ virtual void setOption(const LogString& option, const LogString& value);
+
+ /**
+ * The SocketAppender does not use a layout. Hence, this method
+ * returns <code>false</code>.
+ *
+ */
+ bool requiresLayout() const
{
- /**
- * Appends log events to NT EventLog.
- */
- class LOG4CXX_EXPORT NTEventLogAppender : public AppenderSkeleton
- {
- public:
- DECLARE_LOG4CXX_OBJECT(NTEventLogAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(NTEventLogAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
+ return true;
+ }
- NTEventLogAppender();
- NTEventLogAppender(const LogString& server, const LogString& log,
- const LogString& source, const LayoutPtr& layout);
+ void setSource(const LogString& source)
+ {
+ this->source.assign(source);
+ }
- virtual ~NTEventLogAppender();
+ const LogString& getSource() const
+ {
+ return source;
+ }
- virtual void activateOptions(log4cxx::helpers::Pool& p);
- virtual void close();
- virtual void setOption(const LogString& option, const LogString& value);
+ void setLog(const LogString& log)
+ {
+ this->log.assign(log);
+ }
- /**
- * The SocketAppender does not use a layout. Hence, this method
- * returns <code>false</code>.
- *
- */
- bool requiresLayout() const
- { return true; }
+ const LogString& getLog() const
+ {
+ return log;
+ }
- void setSource(const LogString& source)
- { this->source.assign(source); }
+ void setServer(const LogString& server)
+ {
+ this->server.assign(server);
+ }
- const LogString& getSource() const
- { return source; }
-
- void setLog(const LogString& log)
- { this->log.assign(log); }
-
- const LogString& getLog() const
- { return log; }
-
- void setServer(const LogString& server)
- { this->server.assign(server); }
-
- const LogString& getServer() const
- { return server; }
+ const LogString& getServer() const
+ {
+ return server;
+ }
- protected:
- //
- // these typedef are proxies for the real Win32 definitions
- // and need to be cast to the global definitions before
- // use with a Win32 API call
- typedef void SID;
- typedef void* HANDLE;
+ protected:
+ //
+ // these typedef are proxies for the real Win32 definitions
+ // and need to be cast to the global definitions before
+ // use with a Win32 API call
+ typedef void SID;
+ typedef void* HANDLE;
- virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
- static unsigned short getEventType(const spi::LoggingEventPtr& event);
- static unsigned short getEventCategory(const spi::LoggingEventPtr& event);
- /*
- * Add this source with appropriate configuration keys to the registry.
- */
- void addRegistryInfo();
+ virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+ static unsigned short getEventType(const spi::LoggingEventPtr& event);
+ static unsigned short getEventCategory(const spi::LoggingEventPtr& event);
+ /*
+ * Add this source with appropriate configuration keys to the registry.
+ */
+ void addRegistryInfo();
- // Data
- LogString server;
- LogString log;
- LogString source;
- HANDLE hEventLog;
- SID * pCurrentUserSID;
- static LogString getErrorString(const LogString& function);
+ // Data
+ LogString server;
+ LogString log;
+ LogString source;
+ HANDLE hEventLog;
+ SID* pCurrentUserSID;
+ static LogString getErrorString(const LogString& function);
- private:
- NTEventLogAppender(const NTEventLogAppender&);
- NTEventLogAppender& operator=(const NTEventLogAppender&);
- }; // class NTEventLogAppender
+ private:
+ NTEventLogAppender(const NTEventLogAppender&);
+ NTEventLogAppender& operator=(const NTEventLogAppender&);
+}; // class NTEventLogAppender
- LOG4CXX_PTR_DEF(NTEventLogAppender);
+LOG4CXX_PTR_DEF(NTEventLogAppender);
- } // namespace nt
+} // namespace nt
} // namespace log4cxx
#endif //_LOG4CXX_NT_EVENT_LOG_APPENDER_HEADER_
diff --git a/src/main/include/log4cxx/nt/outputdebugstringappender.h b/src/main/include/log4cxx/nt/outputdebugstringappender.h
index b9cc7d9..f4082c3 100644
--- a/src/main/include/log4cxx/nt/outputdebugstringappender.h
+++ b/src/main/include/log4cxx/nt/outputdebugstringappender.h
@@ -22,27 +22,29 @@
namespace log4cxx
{
- namespace nt
+namespace nt
+{
+class LOG4CXX_EXPORT OutputDebugStringAppender : public AppenderSkeleton
+{
+ public:
+ DECLARE_LOG4CXX_OBJECT(OutputDebugStringAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(OutputDebugStringAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
+
+ OutputDebugStringAppender();
+
+ bool requiresLayout() const
{
- class LOG4CXX_EXPORT OutputDebugStringAppender : public AppenderSkeleton
- {
- public:
- DECLARE_LOG4CXX_OBJECT(OutputDebugStringAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(OutputDebugStringAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
-
- OutputDebugStringAppender();
-
- bool requiresLayout() const
- { return true; }
-
- virtual void close() {}
-
- virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
- };
+ return true;
}
+
+ virtual void close() {}
+
+ virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+};
+}
}
#endif //_LOG4CXX_NT_OUTPUTDEBUGSTRING_APPENDER_HEADER_
diff --git a/src/main/include/log4cxx/pattern/classnamepatternconverter.h b/src/main/include/log4cxx/pattern/classnamepatternconverter.h
index 8c3b2f2..918c3d1 100644
--- a/src/main/include/log4cxx/pattern/classnamepatternconverter.h
+++ b/src/main/include/log4cxx/pattern/classnamepatternconverter.h
@@ -21,8 +21,10 @@
#include <log4cxx/pattern/namepatternconverter.h>
-namespace log4cxx {
- namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -31,37 +33,38 @@
*
*
*/
-class LOG4CXX_EXPORT ClassNamePatternConverter : public NamePatternConverter {
- /**
- * Private constructor.
- * @param options options, may be null.
- * @param logger logger for diagnostic messages, may be null.
- */
- ClassNamePatternConverter(
- const std::vector<LogString>& options);
+class LOG4CXX_EXPORT ClassNamePatternConverter : public NamePatternConverter
+{
+ /**
+ * Private constructor.
+ * @param options options, may be null.
+ * @param logger logger for diagnostic messages, may be null.
+ */
+ ClassNamePatternConverter(
+ const std::vector<LogString>& options);
-public:
- DECLARE_LOG4CXX_PATTERN(ClassNamePatternConverter)
- BEGIN_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(ClassNamePatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(ClassNamePatternConverter)
LOG4CXX_CAST_ENTRY_CHAIN(NamePatternConverter)
- END_LOG4CXX_CAST_MAP()
+ END_LOG4CXX_CAST_MAP()
- /**
- * Gets an instance of ClassNamePatternConverter.
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Gets an instance of ClassNamePatternConverter.
+ * @param options options, may be null.
+ * @return instance of pattern converter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using NamePatternConverter::format;
+ using NamePatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr&event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/pattern/datepatternconverter.h b/src/main/include/log4cxx/pattern/datepatternconverter.h
index 978ee8e..737599a 100644
--- a/src/main/include/log4cxx/pattern/datepatternconverter.h
+++ b/src/main/include/log4cxx/pattern/datepatternconverter.h
@@ -23,8 +23,10 @@
#include <log4cxx/helpers/date.h>
#include <vector>
-namespace log4cxx {
- namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -33,55 +35,56 @@
*
*
*/
-class LOG4CXX_EXPORT DatePatternConverter : public LoggingEventPatternConverter {
- /**
- * Date format.
- */
- log4cxx::helpers::DateFormatPtr df;
+class LOG4CXX_EXPORT DatePatternConverter : public LoggingEventPatternConverter
+{
+ /**
+ * Date format.
+ */
+ log4cxx::helpers::DateFormatPtr df;
- /**
- * Private constructor.
- * @param options options, may be null.
- * @param logger logger for diagnostic messages, may be null.
- */
- DatePatternConverter(const OptionsList& options);
+ /**
+ * Private constructor.
+ * @param options options, may be null.
+ * @param logger logger for diagnostic messages, may be null.
+ */
+ DatePatternConverter(const OptionsList& options);
- /**
- * Obtains an instance of pattern converter.
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- static log4cxx::helpers::DateFormatPtr getDateFormat(const OptionsList& options);
- public:
- DECLARE_LOG4CXX_PATTERN(DatePatternConverter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(DatePatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
- END_LOG4CXX_CAST_MAP()
+ /**
+ * Obtains an instance of pattern converter.
+ * @param options options, may be null.
+ * @return instance of pattern converter.
+ */
+ static log4cxx::helpers::DateFormatPtr getDateFormat(const OptionsList& options);
+ public:
+ DECLARE_LOG4CXX_PATTERN(DatePatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(DatePatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& output,
- log4cxx::helpers::Pool& p) const;
- void format(const log4cxx::helpers::ObjectPtr& obj,
- LogString& output,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& output,
+ log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::helpers::ObjectPtr& obj,
+ LogString& output,
+ log4cxx::helpers::Pool& p) const;
- void format(const log4cxx::helpers::DatePtr& date,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::helpers::DatePtr& date,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
LOG4CXX_PTR_DEF(DatePatternConverter);
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/pattern/filedatepatternconverter.h b/src/main/include/log4cxx/pattern/filedatepatternconverter.h
index 30893ec..8fef9cb 100644
--- a/src/main/include/log4cxx/pattern/filedatepatternconverter.h
+++ b/src/main/include/log4cxx/pattern/filedatepatternconverter.h
@@ -20,7 +20,10 @@
#include <log4cxx/pattern/patternconverter.h>
-namespace log4cxx { namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -31,20 +34,21 @@
*
*
*/
-class LOG4CXX_EXPORT FileDatePatternConverter {
- /**
- * Private constructor.
- */
- FileDatePatternConverter();
+class LOG4CXX_EXPORT FileDatePatternConverter
+{
+ /**
+ * Private constructor.
+ */
+ FileDatePatternConverter();
-public:
- /**
- * Obtains an instance of pattern converter.
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ public:
+ /**
+ * Obtains an instance of pattern converter.
+ * @param options options, may be null.
+ * @return instance of pattern converter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
};
}
}
diff --git a/src/main/include/log4cxx/pattern/filelocationpatternconverter.h b/src/main/include/log4cxx/pattern/filelocationpatternconverter.h
index b2d14d6..09a67ed 100644
--- a/src/main/include/log4cxx/pattern/filelocationpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/filelocationpatternconverter.h
@@ -20,8 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx {
- namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -31,34 +33,35 @@
*
*/
class LOG4CXX_EXPORT FileLocationPatternConverter
- : public LoggingEventPatternConverter {
- /**
- * Private constructor.
- */
- FileLocationPatternConverter();
+ : public LoggingEventPatternConverter
+{
+ /**
+ * Private constructor.
+ */
+ FileLocationPatternConverter();
-public:
- DECLARE_LOG4CXX_PATTERN(FileLocationPatternConverter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(FileLocationPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(FileLocationPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(FileLocationPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Obtains an instance of pattern converter.
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of pattern converter.
+ * @param options options, may be null.
+ * @return instance of pattern converter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/pattern/formattinginfo.h b/src/main/include/log4cxx/pattern/formattinginfo.h
index 8b1ab1d..9816e96 100644
--- a/src/main/include/log4cxx/pattern/formattinginfo.h
+++ b/src/main/include/log4cxx/pattern/formattinginfo.h
@@ -22,8 +22,10 @@
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/logstring.h>
-namespace log4cxx {
- namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
class FormattingInfo;
@@ -38,79 +40,83 @@
*
*
*/
-class LOG4CXX_EXPORT FormattingInfo : public virtual log4cxx::helpers::ObjectImpl {
+class LOG4CXX_EXPORT FormattingInfo : public virtual log4cxx::helpers::ObjectImpl
+{
- /**
- * Minimum length.
- */
- const int minLength;
+ /**
+ * Minimum length.
+ */
+ const int minLength;
- /**
- * Maximum length.
- */
- const int maxLength;
+ /**
+ * Maximum length.
+ */
+ const int maxLength;
- /**
- * Alignment.
- */
- const bool leftAlign;
+ /**
+ * Alignment.
+ */
+ const bool leftAlign;
-public:
-DECLARE_ABSTRACT_LOG4CXX_OBJECT(FormattingInfo)
-BEGIN_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(FormattingInfo)
+ BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(FormattingInfo)
-END_LOG4CXX_CAST_MAP()
+ END_LOG4CXX_CAST_MAP()
- /**
- * Creates new instance.
- * @param leftAlign left align if true.
- * @param minLength minimum length.
- * @param maxLength maximum length.
- */
-FormattingInfo(
- const bool leftAlign, const int minLength, const int maxLength);
+ /**
+ * Creates new instance.
+ * @param leftAlign left align if true.
+ * @param minLength minimum length.
+ * @param maxLength maximum length.
+ */
+ FormattingInfo(
+ const bool leftAlign, const int minLength, const int maxLength);
- /**
- * Gets default instance.
- * @return default instance.
- */
-static FormattingInfoPtr getDefault();
+ /**
+ * Gets default instance.
+ * @return default instance.
+ */
+ static FormattingInfoPtr getDefault();
- /**
- * Determine if left aligned.
- * @return true if left aligned.
- */
-inline bool isLeftAligned() const {
- return leftAlign;
-}
+ /**
+ * Determine if left aligned.
+ * @return true if left aligned.
+ */
+ inline bool isLeftAligned() const
+ {
+ return leftAlign;
+ }
- /**
- * Get minimum length.
- * @return minimum length.
- */
-inline int getMinLength() const {
- return minLength;
-}
+ /**
+ * Get minimum length.
+ * @return minimum length.
+ */
+ inline int getMinLength() const
+ {
+ return minLength;
+ }
- /**
- * Get maximum length.
- * @return maximum length.
- */
-inline int getMaxLength() const {
- return maxLength;
-}
+ /**
+ * Get maximum length.
+ * @return maximum length.
+ */
+ inline int getMaxLength() const
+ {
+ return maxLength;
+ }
- /**
- * Adjust the content of the buffer based on the specified lengths and alignment.
- *
- * @param fieldStart start of field in buffer.
- * @param buffer buffer to be modified.
- */
-void format(const int fieldStart, LogString& buffer) const;
+ /**
+ * Adjust the content of the buffer based on the specified lengths and alignment.
+ *
+ * @param fieldStart start of field in buffer.
+ * @param buffer buffer to be modified.
+ */
+ void format(const int fieldStart, LogString& buffer) const;
};
LOG4CXX_PTR_DEF(FormattingInfo);
- }
+}
}
diff --git a/src/main/include/log4cxx/pattern/fulllocationpatternconverter.h b/src/main/include/log4cxx/pattern/fulllocationpatternconverter.h
index 1b54fa9..d478b6e 100644
--- a/src/main/include/log4cxx/pattern/fulllocationpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/fulllocationpatternconverter.h
@@ -20,8 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx {
-namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -31,32 +33,33 @@
*
*/
class LOG4CXX_EXPORT FullLocationPatternConverter
- : public LoggingEventPatternConverter {
- /**
- * Private constructor.
- */
- FullLocationPatternConverter();
+ : public LoggingEventPatternConverter
+{
+ /**
+ * Private constructor.
+ */
+ FullLocationPatternConverter();
-public:
- DECLARE_LOG4CXX_PATTERN(FullLocationPatternConverter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(FullLocationPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(FullLocationPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(FullLocationPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Obtains an instance of pattern converter.
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of pattern converter.
+ * @param options options, may be null.
+ * @return instance of pattern converter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
}
diff --git a/src/main/include/log4cxx/pattern/integerpatternconverter.h b/src/main/include/log4cxx/pattern/integerpatternconverter.h
index c552632..db5c2f8 100644
--- a/src/main/include/log4cxx/pattern/integerpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/integerpatternconverter.h
@@ -20,7 +20,10 @@
#include <log4cxx/pattern/patternconverter.h>
-namespace log4cxx { namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -29,31 +32,32 @@
*
*
*/
-class LOG4CXX_EXPORT IntegerPatternConverter : public PatternConverter {
+class LOG4CXX_EXPORT IntegerPatternConverter : public PatternConverter
+{
- /**
- * Private constructor.
- */
- IntegerPatternConverter();
+ /**
+ * Private constructor.
+ */
+ IntegerPatternConverter();
-public:
- DECLARE_LOG4CXX_PATTERN(IntegerPatternConverter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(IntegerPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(PatternConverter)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(IntegerPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(IntegerPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(PatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Obtains an instance of pattern converter.
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of pattern converter.
+ * @param options options, may be null.
+ * @return instance of pattern converter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- void format(const log4cxx::helpers::ObjectPtr& obj,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::helpers::ObjectPtr& obj,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
LOG4CXX_PTR_DEF(IntegerPatternConverter);
diff --git a/src/main/include/log4cxx/pattern/levelpatternconverter.h b/src/main/include/log4cxx/pattern/levelpatternconverter.h
index 5ff198d..68fb38a 100644
--- a/src/main/include/log4cxx/pattern/levelpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/levelpatternconverter.h
@@ -20,7 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx { namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -29,34 +32,35 @@
*
*
*/
-class LOG4CXX_EXPORT LevelPatternConverter : public LoggingEventPatternConverter {
- /**
- * Private constructor.
- */
- LevelPatternConverter();
+class LOG4CXX_EXPORT LevelPatternConverter : public LoggingEventPatternConverter
+{
+ /**
+ * Private constructor.
+ */
+ LevelPatternConverter();
-public:
- DECLARE_LOG4CXX_PATTERN(LevelPatternConverter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(LevelPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(LevelPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(LevelPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Obtains an instance of pattern converter.
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of pattern converter.
+ * @param options options, may be null.
+ * @return instance of pattern converter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
- LogString getStyleClass(const log4cxx::helpers::ObjectPtr& e) const;
+ LogString getStyleClass(const log4cxx::helpers::ObjectPtr& e) const;
};
}
}
diff --git a/src/main/include/log4cxx/pattern/linelocationpatternconverter.h b/src/main/include/log4cxx/pattern/linelocationpatternconverter.h
index adacfdc..e37e65b 100644
--- a/src/main/include/log4cxx/pattern/linelocationpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/linelocationpatternconverter.h
@@ -20,8 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx {
-namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -31,32 +33,33 @@
*
*/
class LOG4CXX_EXPORT LineLocationPatternConverter
- : public LoggingEventPatternConverter {
- /**
- * Private constructor.
- */
- LineLocationPatternConverter();
+ : public LoggingEventPatternConverter
+{
+ /**
+ * Private constructor.
+ */
+ LineLocationPatternConverter();
-public:
- DECLARE_LOG4CXX_PATTERN(LineLocationPatternConverter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(LineLocationPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(LineLocationPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(LineLocationPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Obtains an instance of pattern converter.
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of pattern converter.
+ * @param options options, may be null.
+ * @return instance of pattern converter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
}
diff --git a/src/main/include/log4cxx/pattern/lineseparatorpatternconverter.h b/src/main/include/log4cxx/pattern/lineseparatorpatternconverter.h
index 85f5633..de7c47d 100644
--- a/src/main/include/log4cxx/pattern/lineseparatorpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/lineseparatorpatternconverter.h
@@ -20,8 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx {
-namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -31,38 +33,39 @@
*
*/
class LOG4CXX_EXPORT LineSeparatorPatternConverter
- : public LoggingEventPatternConverter {
+ : public LoggingEventPatternConverter
+{
- /**
- * Private constructor.
- */
- LineSeparatorPatternConverter();
+ /**
+ * Private constructor.
+ */
+ LineSeparatorPatternConverter();
-public:
-DECLARE_LOG4CXX_PATTERN(LineSeparatorPatternConverter)
-BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(LineSeparatorPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
-END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(LineSeparatorPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(LineSeparatorPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Obtains an instance of pattern converter.
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of pattern converter.
+ * @param options options, may be null.
+ * @return instance of pattern converter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
- void format(const log4cxx::helpers::ObjectPtr& obj,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::helpers::ObjectPtr& obj,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
}
diff --git a/src/main/include/log4cxx/pattern/literalpatternconverter.h b/src/main/include/log4cxx/pattern/literalpatternconverter.h
index 3717f43..2f96aea 100644
--- a/src/main/include/log4cxx/pattern/literalpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/literalpatternconverter.h
@@ -20,8 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx {
- namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
* Formats a string literal.
@@ -30,40 +32,41 @@
*
*
*/
-class LOG4CXX_EXPORT LiteralPatternConverter : public LoggingEventPatternConverter {
- /**
- * String literal.
- */
- const LogString literal;
+class LOG4CXX_EXPORT LiteralPatternConverter : public LoggingEventPatternConverter
+{
+ /**
+ * String literal.
+ */
+ const LogString literal;
- /**
- * Create a new instance.
- * @param literal string literal.
- */
- LiteralPatternConverter(const LogString& literal);
+ /**
+ * Create a new instance.
+ * @param literal string literal.
+ */
+ LiteralPatternConverter(const LogString& literal);
-public:
- DECLARE_LOG4CXX_PATTERN(LiteralPatternConverter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(LiteralPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(LiteralPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(LiteralPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- static PatternConverterPtr newInstance(const LogString& literal);
+ static PatternConverterPtr newInstance(const LogString& literal);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
- void format(const log4cxx::helpers::ObjectPtr& obj,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::helpers::ObjectPtr& obj,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/pattern/loggerpatternconverter.h b/src/main/include/log4cxx/pattern/loggerpatternconverter.h
index 76b8561..21c0abc 100644
--- a/src/main/include/log4cxx/pattern/loggerpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/loggerpatternconverter.h
@@ -14,14 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
- #ifndef _LOG4CXX_PATTERN_LOGGER_PATTERN_CONVERTER_H
- #define _LOG4CXX_PATTERN_LOGGER_PATTERN_CONVERTER_H
+#ifndef _LOG4CXX_PATTERN_LOGGER_PATTERN_CONVERTER_H
+#define _LOG4CXX_PATTERN_LOGGER_PATTERN_CONVERTER_H
#include <log4cxx/pattern/namepatternconverter.h>
-namespace log4cxx {
- namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -31,38 +33,39 @@
*
*
*/
-class LOG4CXX_EXPORT LoggerPatternConverter : public NamePatternConverter {
+class LOG4CXX_EXPORT LoggerPatternConverter : public NamePatternConverter
+{
- /**
- * Private constructor.
- * @param options options, may be null.
- * @param logger logger for diagnostic messages, may be null.
- */
- LoggerPatternConverter(const std::vector<LogString>& options);
+ /**
+ * Private constructor.
+ * @param options options, may be null.
+ * @param logger logger for diagnostic messages, may be null.
+ */
+ LoggerPatternConverter(const std::vector<LogString>& options);
-public:
- DECLARE_LOG4CXX_PATTERN(LoggerPatternConverter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(LoggerPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(NamePatternConverter)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(LoggerPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(LoggerPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(NamePatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Obtains an instance of pattern converter.
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of pattern converter.
+ * @param options options, may be null.
+ * @return instance of pattern converter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using NamePatternConverter::format;
+ using NamePatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/pattern/loggingeventpatternconverter.h b/src/main/include/log4cxx/pattern/loggingeventpatternconverter.h
index 048366c..e546d59 100644
--- a/src/main/include/log4cxx/pattern/loggingeventpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/loggingeventpatternconverter.h
@@ -21,64 +21,67 @@
#include <log4cxx/pattern/patternconverter.h>
#include <log4cxx/spi/loggingevent.h>
-namespace log4cxx {
+namespace log4cxx
+{
- namespace pattern {
- /**
- * LoggingEventPatternConverter is a base class for pattern converters
- * that can format information from instances of LoggingEvent.
- *
- *
- *
- *
- */
-class LOG4CXX_EXPORT LoggingEventPatternConverter : public PatternConverter {
-protected:
- /**
- * Constructs an instance of LoggingEventPatternConverter.
- * @param name name of converter.
- * @param style CSS style for output.
- */
- LoggingEventPatternConverter(
- const LogString& name, const LogString& style);
+namespace pattern
+{
+/**
+* LoggingEventPatternConverter is a base class for pattern converters
+* that can format information from instances of LoggingEvent.
+*
+*
+*
+*
+*/
+class LOG4CXX_EXPORT LoggingEventPatternConverter : public PatternConverter
+{
+ protected:
+ /**
+ * Constructs an instance of LoggingEventPatternConverter.
+ * @param name name of converter.
+ * @param style CSS style for output.
+ */
+ LoggingEventPatternConverter(
+ const LogString& name, const LogString& style);
-public:
-DECLARE_LOG4CXX_PATTERN(LoggingEventPatternConverter)
-BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(LoggingEventPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(PatternConverter)
-END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(LoggingEventPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(LoggingEventPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(PatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Formats an event into a string buffer.
- * @param event event to format, may not be null.
- * @param toAppendTo string buffer to which the formatted event will be appended. May not be null.
- * @param p pool for memory allocations needing during format.
- */
- virtual void format(
- const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const = 0;
+ /**
+ * Formats an event into a string buffer.
+ * @param event event to format, may not be null.
+ * @param toAppendTo string buffer to which the formatted event will be appended. May not be null.
+ * @param p pool for memory allocations needing during format.
+ */
+ virtual void format(
+ const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const = 0;
- void format(const log4cxx::helpers::ObjectPtr& obj,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::helpers::ObjectPtr& obj,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
- /**
- * Normally pattern converters are not meant to handle Exceptions although
- * few pattern converters might.
- *
- * By examining the return values for this method, the containing layout will
- * determine whether it handles throwables or not.
+ /**
+ * Normally pattern converters are not meant to handle Exceptions although
+ * few pattern converters might.
+ *
+ * By examining the return values for this method, the containing layout will
+ * determine whether it handles throwables or not.
- * @return true if this PatternConverter handles throwables
- */
- virtual bool handlesThrowable() const;
+ * @return true if this PatternConverter handles throwables
+ */
+ virtual bool handlesThrowable() const;
};
LOG4CXX_PTR_DEF(LoggingEventPatternConverter);
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/pattern/messagepatternconverter.h b/src/main/include/log4cxx/pattern/messagepatternconverter.h
index 4bb86ef..8535219 100644
--- a/src/main/include/log4cxx/pattern/messagepatternconverter.h
+++ b/src/main/include/log4cxx/pattern/messagepatternconverter.h
@@ -20,7 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx { namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -29,33 +32,34 @@
*
*
*/
-class LOG4CXX_EXPORT MessagePatternConverter : public LoggingEventPatternConverter {
+class LOG4CXX_EXPORT MessagePatternConverter : public LoggingEventPatternConverter
+{
- /**
- * Private constructor.
- */
- MessagePatternConverter();
+ /**
+ * Private constructor.
+ */
+ MessagePatternConverter();
-public:
-DECLARE_LOG4CXX_PATTERN(MessagePatternConverter)
-BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(MessagePatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
-END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(MessagePatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(MessagePatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Obtains an instance of pattern converter.
- * @param options options, may be null.
- * @return instance of pattern converter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of pattern converter.
+ * @param options options, may be null.
+ * @return instance of pattern converter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
}
}
diff --git a/src/main/include/log4cxx/pattern/methodlocationpatternconverter.h b/src/main/include/log4cxx/pattern/methodlocationpatternconverter.h
index 8cbc6b1..8eeb6c0 100644
--- a/src/main/include/log4cxx/pattern/methodlocationpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/methodlocationpatternconverter.h
@@ -20,7 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx { namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -30,33 +33,34 @@
*
*/
class LOG4CXX_EXPORT MethodLocationPatternConverter
- : public LoggingEventPatternConverter {
+ : public LoggingEventPatternConverter
+{
- /**
- * Private constructor.
- */
- MethodLocationPatternConverter();
+ /**
+ * Private constructor.
+ */
+ MethodLocationPatternConverter();
-public:
-DECLARE_LOG4CXX_PATTERN(MethodLocationPatternConverter)
-BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(MethodLocationPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
-END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(MethodLocationPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(MethodLocationPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Obtains an instance of MethodLocationPatternConverter.
- * @param options options, may be null.
- * @return instance of MethodLocationPatternConverter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of MethodLocationPatternConverter.
+ * @param options options, may be null.
+ * @return instance of MethodLocationPatternConverter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
}
}
diff --git a/src/main/include/log4cxx/pattern/nameabbreviator.h b/src/main/include/log4cxx/pattern/nameabbreviator.h
index 092ee12..f62c7c1 100644
--- a/src/main/include/log4cxx/pattern/nameabbreviator.h
+++ b/src/main/include/log4cxx/pattern/nameabbreviator.h
@@ -22,11 +22,13 @@
#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/objectimpl.h>
-namespace log4cxx {
- namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
- class NameAbbreviator;
- LOG4CXX_PTR_DEF(NameAbbreviator);
+class NameAbbreviator;
+LOG4CXX_PTR_DEF(NameAbbreviator);
/**
* NameAbbreviator generates abbreviated logger and class names.
@@ -34,48 +36,49 @@
*
*
*/
-class LOG4CXX_EXPORT NameAbbreviator : public log4cxx::helpers::ObjectImpl {
-public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(NameAbbreviator)
- BEGIN_LOG4CXX_CAST_MAP()
+class LOG4CXX_EXPORT NameAbbreviator : public log4cxx::helpers::ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(NameAbbreviator)
+ BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(NameAbbreviator)
- END_LOG4CXX_CAST_MAP()
+ END_LOG4CXX_CAST_MAP()
-protected:
- NameAbbreviator();
+ protected:
+ NameAbbreviator();
-public:
- virtual ~NameAbbreviator();
+ public:
+ virtual ~NameAbbreviator();
- /**
- * Gets an abbreviator.
- *
- * For example, "%logger{2}" will output only 2 elements of the logger name,
- * "%logger{1.}" will output only the first character of the non-final elements in the name,
- * "%logger(1~.2~} will output the first character of the first element, two characters of
- * the second and subsequent elements and will use a tilde to indicate abbreviated characters.
- *
- * @param pattern abbreviation pattern.
- * @return abbreviator, will not be null.
- */
- static NameAbbreviatorPtr getAbbreviator(const LogString& pattern);
+ /**
+ * Gets an abbreviator.
+ *
+ * For example, "%logger{2}" will output only 2 elements of the logger name,
+ * "%logger{1.}" will output only the first character of the non-final elements in the name,
+ * "%logger(1~.2~} will output the first character of the first element, two characters of
+ * the second and subsequent elements and will use a tilde to indicate abbreviated characters.
+ *
+ * @param pattern abbreviation pattern.
+ * @return abbreviator, will not be null.
+ */
+ static NameAbbreviatorPtr getAbbreviator(const LogString& pattern);
- /**
- * Gets default abbreviator.
- *
- * @return default abbreviator.
- */
- static NameAbbreviatorPtr getDefaultAbbreviator();
+ /**
+ * Gets default abbreviator.
+ *
+ * @return default abbreviator.
+ */
+ static NameAbbreviatorPtr getDefaultAbbreviator();
- /**
- * Abbreviates a name in a StringBuffer.
- *
- * @param nameStart starting position of name in buf.
- * @param buf buffer, may not be null.
- */
- virtual void abbreviate(LogString::size_type nameStart, LogString& buf) const = 0;
+ /**
+ * Abbreviates a name in a StringBuffer.
+ *
+ * @param nameStart starting position of name in buf.
+ * @param buf buffer, may not be null.
+ */
+ virtual void abbreviate(LogString::size_type nameStart, LogString& buf) const = 0;
};
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/pattern/namepatternconverter.h b/src/main/include/log4cxx/pattern/namepatternconverter.h
index 68c7e56..35b8b93 100644
--- a/src/main/include/log4cxx/pattern/namepatternconverter.h
+++ b/src/main/include/log4cxx/pattern/namepatternconverter.h
@@ -23,52 +23,55 @@
#include <vector>
-namespace log4cxx {
- namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
*
* Base class for other pattern converters which can return only parts of their name.
*
*/
-class LOG4CXX_EXPORT NamePatternConverter : public LoggingEventPatternConverter {
- /**
- * Abbreviator.
- */
- const NameAbbreviatorPtr abbreviator;
+class LOG4CXX_EXPORT NamePatternConverter : public LoggingEventPatternConverter
+{
+ /**
+ * Abbreviator.
+ */
+ const NameAbbreviatorPtr abbreviator;
-public:
-DECLARE_LOG4CXX_PATTERN(NamePatternConverter)
-BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(NamePatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
-END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(NamePatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(NamePatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
-protected:
- /**
- * Constructor.
- * @param name name of converter.
- * @param style style name for associated output.
- * @param options options, may be null, first element will be interpreted as an abbreviation pattern.
- */
- NamePatternConverter(
- const LogString& name,
- const LogString& style,
- const std::vector<LogString>& options);
+ protected:
+ /**
+ * Constructor.
+ * @param name name of converter.
+ * @param style style name for associated output.
+ * @param options options, may be null, first element will be interpreted as an abbreviation pattern.
+ */
+ NamePatternConverter(
+ const LogString& name,
+ const LogString& style,
+ const std::vector<LogString>& options);
- /**
- * Abbreviate name in string buffer.
- * @param nameStart starting position of name to abbreviate.
- * @param buf string buffer containing name.
- */
- void abbreviate(int nameStart, LogString& buf) const;
+ /**
+ * Abbreviate name in string buffer.
+ * @param nameStart starting position of name to abbreviate.
+ * @param buf string buffer containing name.
+ */
+ void abbreviate(int nameStart, LogString& buf) const;
-private:
- NameAbbreviatorPtr getAbbreviator(const std::vector<LogString>& options);
+ private:
+ NameAbbreviatorPtr getAbbreviator(const std::vector<LogString>& options);
};
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/pattern/ndcpatternconverter.h b/src/main/include/log4cxx/pattern/ndcpatternconverter.h
index ce026fd..279b31c 100644
--- a/src/main/include/log4cxx/pattern/ndcpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/ndcpatternconverter.h
@@ -20,7 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx { namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -29,33 +32,34 @@
*
*
*/
-class LOG4CXX_EXPORT NDCPatternConverter : public LoggingEventPatternConverter {
+class LOG4CXX_EXPORT NDCPatternConverter : public LoggingEventPatternConverter
+{
- /**
- * Private constructor.
- */
- NDCPatternConverter();
+ /**
+ * Private constructor.
+ */
+ NDCPatternConverter();
-public:
-DECLARE_LOG4CXX_PATTERN(NDCPatternConverter)
-BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(NDCPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
-END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(NDCPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(NDCPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Obtains an instance of NDCPatternConverter.
- * @param options options, may be null.
- * @return instance of NDCPatternConverter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of NDCPatternConverter.
+ * @param options options, may be null.
+ * @return instance of NDCPatternConverter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
}
}
diff --git a/src/main/include/log4cxx/pattern/patternconverter.h b/src/main/include/log4cxx/pattern/patternconverter.h
index c4e21db..d707c12 100644
--- a/src/main/include/log4cxx/pattern/patternconverter.h
+++ b/src/main/include/log4cxx/pattern/patternconverter.h
@@ -24,16 +24,18 @@
#include <vector>
#ifdef _MSC_VER
-// disable identifier too wide for debugging warning
-#pragma warning ( disable: 4231 4251 4275 4786 )
+ // disable identifier too wide for debugging warning
+ #pragma warning ( disable: 4231 4251 4275 4786 )
#endif
#define DECLARE_LOG4CXX_PATTERN(cls) DECLARE_ABSTRACT_LOG4CXX_OBJECT(cls)
-namespace log4cxx {
- namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
- typedef std::vector<LogString> OptionsList;
+typedef std::vector<LogString> OptionsList;
/**
@@ -45,79 +47,80 @@
converting an object in a converter specific manner.
*/
-class LOG4CXX_EXPORT PatternConverter : public virtual log4cxx::helpers::ObjectImpl {
+class LOG4CXX_EXPORT PatternConverter : public virtual log4cxx::helpers::ObjectImpl
+{
- /**
- * Converter name.
- */
- const LogString name;
+ /**
+ * Converter name.
+ */
+ const LogString name;
- /**
- * Converter style name.
- */
- const LogString style;
+ /**
+ * Converter style name.
+ */
+ const LogString style;
-protected:
- /**
- * Create a new pattern converter.
- * @param name name for pattern converter.
- * @param style CSS style for formatted output.
- */
- PatternConverter(const LogString& name,
- const LogString& style);
+ protected:
+ /**
+ * Create a new pattern converter.
+ * @param name name for pattern converter.
+ * @param style CSS style for formatted output.
+ */
+ PatternConverter(const LogString& name,
+ const LogString& style);
- virtual ~PatternConverter();
+ virtual ~PatternConverter();
-public:
- DECLARE_LOG4CXX_PATTERN(PatternConverter);
- BEGIN_LOG4CXX_CAST_MAP();
- LOG4CXX_CAST_ENTRY(PatternConverter);
- END_LOG4CXX_CAST_MAP();
+ public:
+ DECLARE_LOG4CXX_PATTERN(PatternConverter);
+ BEGIN_LOG4CXX_CAST_MAP();
+ LOG4CXX_CAST_ENTRY(PatternConverter);
+ END_LOG4CXX_CAST_MAP();
- /**
- * Formats an object into a string buffer.
- * @param obj event to format, may not be null.
- * @param toAppendTo string buffer to which the formatted event will be appended. May not be null.
- * @param p pool for any allocations necessary during formatting.
- */
- virtual void format(const log4cxx::helpers::ObjectPtr& obj,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const = 0;
+ /**
+ * Formats an object into a string buffer.
+ * @param obj event to format, may not be null.
+ * @param toAppendTo string buffer to which the formatted event will be appended. May not be null.
+ * @param p pool for any allocations necessary during formatting.
+ */
+ virtual void format(const log4cxx::helpers::ObjectPtr& obj,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const = 0;
- /**
- * This method returns the name of the conversion pattern.
- *
- * The name can be useful to certain Layouts such as HTMLLayout.
- *
- * @return the name of the conversion pattern
- */
- LogString getName() const;
+ /**
+ * This method returns the name of the conversion pattern.
+ *
+ * The name can be useful to certain Layouts such as HTMLLayout.
+ *
+ * @return the name of the conversion pattern
+ */
+ LogString getName() const;
- /**
- * This method returns the CSS style class that should be applied to
- * the LoggingEvent passed as parameter, which can be null.
- *
- * This information is currently used only by HTMLLayout.
- *
- * @param e null values are accepted
- * @return the name of the conversion pattern
- */
- virtual LogString getStyleClass(const log4cxx::helpers::ObjectPtr& e) const;
+ /**
+ * This method returns the CSS style class that should be applied to
+ * the LoggingEvent passed as parameter, which can be null.
+ *
+ * This information is currently used only by HTMLLayout.
+ *
+ * @param e null values are accepted
+ * @return the name of the conversion pattern
+ */
+ virtual LogString getStyleClass(const log4cxx::helpers::ObjectPtr& e) const;
-protected:
-/**
-* Appends content in the locale code page to a LogString.
-* @param toAppendTo string to which content is appended.
-* @param src content.
-*/
- static void append(LogString& toAppendTo, const std::string& src);
+ protected:
+ /**
+ * Appends content in the locale code page to a LogString.
+ * @param toAppendTo string to which content is appended.
+ * @param src content.
+ */
+ static void append(LogString& toAppendTo, const std::string& src);
};
LOG4CXX_PTR_DEF(PatternConverter);
- }
+}
}
diff --git a/src/main/include/log4cxx/pattern/patternparser.h b/src/main/include/log4cxx/pattern/patternparser.h
index eab174b..a7d043e 100644
--- a/src/main/include/log4cxx/pattern/patternparser.h
+++ b/src/main/include/log4cxx/pattern/patternparser.h
@@ -20,8 +20,8 @@
#define _LOG4CXX_HELPER_PATTERN_CONVERTER_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
@@ -32,8 +32,10 @@
#include <log4cxx/pattern/patternconverter.h>
#include <log4cxx/pattern/formattinginfo.h>
-namespace log4cxx {
- namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
typedef PatternConverterPtr (*PatternConstructor)(const std::vector<LogString>& options);
typedef std::map<LogString, PatternConstructor> PatternMap;
@@ -51,110 +53,112 @@
*
*
*/
-class LOG4CXX_EXPORT PatternParser {
- /**
- * Escape character for format specifier.
- */
- static const logchar ESCAPE_CHAR;
+class LOG4CXX_EXPORT PatternParser
+{
+ /**
+ * Escape character for format specifier.
+ */
+ static const logchar ESCAPE_CHAR;
- enum {
- LITERAL_STATE = 0,
- CONVERTER_STATE = 1,
- DOT_STATE = 3,
- MIN_STATE = 4,
- MAX_STATE = 5
- };
+ enum
+ {
+ LITERAL_STATE = 0,
+ CONVERTER_STATE = 1,
+ DOT_STATE = 3,
+ MIN_STATE = 4,
+ MAX_STATE = 5
+ };
- /**
- * Private constructor.
- */
- PatternParser();
+ /**
+ * Private constructor.
+ */
+ PatternParser();
-private:
- /** Extract the converter identifier found at position i.
- *
- * After this function returns, the variable i will point to the
- * first char after the end of the converter identifier.
- *
- * If i points to a char which is not a character acceptable at the
- * start of a unicode identifier, the value null is returned.
- *
- * @param lastChar last processed character.
- * @param pattern format string.
- * @param i current index into pattern format.
- * @param convBuf buffer to receive conversion specifier.
- * @param currentLiteral literal to be output in case format specifier in unrecognized.
- * @return position in pattern after converter.
- */
- static int extractConverter(
- logchar lastChar, const LogString& pattern,
- LogString::size_type i, LogString& convBuf,
- LogString& currentLiteral);
+ private:
+ /** Extract the converter identifier found at position i.
+ *
+ * After this function returns, the variable i will point to the
+ * first char after the end of the converter identifier.
+ *
+ * If i points to a char which is not a character acceptable at the
+ * start of a unicode identifier, the value null is returned.
+ *
+ * @param lastChar last processed character.
+ * @param pattern format string.
+ * @param i current index into pattern format.
+ * @param convBuf buffer to receive conversion specifier.
+ * @param currentLiteral literal to be output in case format specifier in unrecognized.
+ * @return position in pattern after converter.
+ */
+ static int extractConverter(
+ logchar lastChar, const LogString& pattern,
+ LogString::size_type i, LogString& convBuf,
+ LogString& currentLiteral);
- /**
- * Extract options.
- * @param pattern conversion pattern.
- * @param i start of options.
- * @param options array to receive extracted options
- * @return position in pattern after options.
- */
- static int extractOptions(const LogString& pattern, LogString::size_type i,
- std::vector<LogString>& options);
+ /**
+ * Extract options.
+ * @param pattern conversion pattern.
+ * @param i start of options.
+ * @param options array to receive extracted options
+ * @return position in pattern after options.
+ */
+ static int extractOptions(const LogString& pattern, LogString::size_type i,
+ std::vector<LogString>& options);
-public:
- /**
- * Parse a format specifier.
- * @param pattern pattern to parse.
- * @param patternConverters list to receive pattern converters.
- * @param formattingInfos list to receive field specifiers corresponding to pattern converters.
- * @param rules map of stock pattern converters keyed by format specifier.
- */
- static void parse(
- const LogString& pattern,
- std::vector<PatternConverterPtr>& patternConverters,
- std::vector<FormattingInfoPtr>& formattingInfos,
- const PatternMap& rules);
+ public:
+ /**
+ * Parse a format specifier.
+ * @param pattern pattern to parse.
+ * @param patternConverters list to receive pattern converters.
+ * @param formattingInfos list to receive field specifiers corresponding to pattern converters.
+ * @param rules map of stock pattern converters keyed by format specifier.
+ */
+ static void parse(
+ const LogString& pattern,
+ std::vector<PatternConverterPtr>& patternConverters,
+ std::vector<FormattingInfoPtr>& formattingInfos,
+ const PatternMap& rules);
-private:
- /**
- * Creates a new PatternConverter.
- *
- *
- * @param converterId converterId.
- * @param currentLiteral literal to be used if converter is unrecognized or following converter
- * if converterId contains extra characters.
- * @param rules map of stock pattern converters keyed by format specifier.
- * @param options converter options.
- * @return converter or null.
- */
- static PatternConverterPtr createConverter(
- const LogString& converterId,
- LogString& currentLiteral,
- const PatternMap& rules,
- std::vector<LogString>& options);
+ private:
+ /**
+ * Creates a new PatternConverter.
+ *
+ *
+ * @param converterId converterId.
+ * @param currentLiteral literal to be used if converter is unrecognized or following converter
+ * if converterId contains extra characters.
+ * @param rules map of stock pattern converters keyed by format specifier.
+ * @param options converter options.
+ * @return converter or null.
+ */
+ static PatternConverterPtr createConverter(
+ const LogString& converterId,
+ LogString& currentLiteral,
+ const PatternMap& rules,
+ std::vector<LogString>& options);
- /**
- * Processes a format specifier sequence.
- *
- * @param c initial character of format specifier.
- * @param pattern conversion pattern
- * @param i current position in conversion pattern.
- * @param currentLiteral current literal.
- * @param formattingInfo current field specifier.
- * @param rules map of stock pattern converters keyed by format specifier.
- * @param patternConverters list to receive parsed pattern converter.
- * @param formattingInfos list to receive corresponding field specifier.
- * @return position after format specifier sequence.
- */
- static int finalizeConverter(
- logchar c, const LogString& pattern, int i,
- LogString& currentLiteral, const FormattingInfoPtr& formattingInfo,
- const PatternMap& rules,
- std::vector<PatternConverterPtr>& patternConverters,
- std::vector<FormattingInfoPtr>& formattingInfos);
+ /**
+ * Processes a format specifier sequence.
+ *
+ * @param c initial character of format specifier.
+ * @param pattern conversion pattern
+ * @param i current position in conversion pattern.
+ * @param currentLiteral current literal.
+ * @param formattingInfo current field specifier.
+ * @param rules map of stock pattern converters keyed by format specifier.
+ * @param patternConverters list to receive parsed pattern converter.
+ * @param formattingInfos list to receive corresponding field specifier.
+ * @return position after format specifier sequence.
+ */
+ static int finalizeConverter(
+ logchar c, const LogString& pattern, int i,
+ LogString& currentLiteral, const FormattingInfoPtr& formattingInfo,
+ const PatternMap& rules,
+ std::vector<PatternConverterPtr>& patternConverters,
+ std::vector<FormattingInfoPtr>& formattingInfos);
- static bool isUnicodeIdentifierStart(logchar c);
- static bool isUnicodeIdentifierPart(logchar c);
+ static bool isUnicodeIdentifierStart(logchar c);
+ static bool isUnicodeIdentifierPart(logchar c);
};
@@ -164,7 +168,7 @@
#if defined(_MSC_VER)
-#pragma warning (pop)
+ #pragma warning (pop)
#endif
diff --git a/src/main/include/log4cxx/pattern/propertiespatternconverter.h b/src/main/include/log4cxx/pattern/propertiespatternconverter.h
index 9dcad0c..e6364da 100644
--- a/src/main/include/log4cxx/pattern/propertiespatternconverter.h
+++ b/src/main/include/log4cxx/pattern/propertiespatternconverter.h
@@ -20,7 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx { namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -34,39 +37,40 @@
*
*/
class LOG4CXX_EXPORT PropertiesPatternConverter
- : public LoggingEventPatternConverter {
- /**
- * Name of property to output.
- */
- const LogString option;
+ : public LoggingEventPatternConverter
+{
+ /**
+ * Name of property to output.
+ */
+ const LogString option;
- /**
- * Private constructor.
- * @param options options, may be null.
- * @param logger logger for diagnostic messages, may be null.
- */
- PropertiesPatternConverter(const LogString& name, const LogString& option);
+ /**
+ * Private constructor.
+ * @param options options, may be null.
+ * @param logger logger for diagnostic messages, may be null.
+ */
+ PropertiesPatternConverter(const LogString& name, const LogString& option);
- public:
- DECLARE_LOG4CXX_PATTERN(PropertiesPatternConverter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(PropertiesPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(PropertiesPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(PropertiesPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Obtains an instance of PropertiesPatternConverter.
- * @param options options, may be null or first element contains name of property to format.
- * @return instance of PropertiesPatternConverter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of PropertiesPatternConverter.
+ * @param options options, may be null or first element contains name of property to format.
+ * @return instance of PropertiesPatternConverter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
}
}
diff --git a/src/main/include/log4cxx/pattern/relativetimepatternconverter.h b/src/main/include/log4cxx/pattern/relativetimepatternconverter.h
index 708fe8f..b4313f2 100644
--- a/src/main/include/log4cxx/pattern/relativetimepatternconverter.h
+++ b/src/main/include/log4cxx/pattern/relativetimepatternconverter.h
@@ -20,7 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx { namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -29,33 +32,34 @@
*
*
*/
-class LOG4CXX_EXPORT RelativeTimePatternConverter : public LoggingEventPatternConverter {
-public:
-DECLARE_LOG4CXX_PATTERN(RelativeTimePatternConverter)
-BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(RelativeTimePatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
-END_LOG4CXX_CAST_MAP()
+class LOG4CXX_EXPORT RelativeTimePatternConverter : public LoggingEventPatternConverter
+{
+ public:
+ DECLARE_LOG4CXX_PATTERN(RelativeTimePatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(RelativeTimePatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Private constructor.
- */
- RelativeTimePatternConverter();
+ /**
+ * Private constructor.
+ */
+ RelativeTimePatternConverter();
- /**
- * Obtains an instance of RelativeTimePatternConverter.
- * @param options options, currently ignored, may be null.
- * @return instance of RelativeTimePatternConverter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of RelativeTimePatternConverter.
+ * @param options options, currently ignored, may be null.
+ * @return instance of RelativeTimePatternConverter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
}
}
diff --git a/src/main/include/log4cxx/pattern/threadpatternconverter.h b/src/main/include/log4cxx/pattern/threadpatternconverter.h
index 178f652..9e342b2 100644
--- a/src/main/include/log4cxx/pattern/threadpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/threadpatternconverter.h
@@ -20,7 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx { namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -29,32 +32,33 @@
*
*
*/
-class LOG4CXX_EXPORT ThreadPatternConverter : public LoggingEventPatternConverter {
- /**
- * Private constructor.
- */
- ThreadPatternConverter();
+class LOG4CXX_EXPORT ThreadPatternConverter : public LoggingEventPatternConverter
+{
+ /**
+ * Private constructor.
+ */
+ ThreadPatternConverter();
-public:
-DECLARE_LOG4CXX_PATTERN(ThreadPatternConverter)
-BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(ThreadPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
-END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(ThreadPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(ThreadPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Obtains an instance of ThreadPatternConverter.
- * @param options options, currently ignored, may be null.
- * @return instance of ThreadPatternConverter.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Obtains an instance of ThreadPatternConverter.
+ * @param options options, currently ignored, may be null.
+ * @return instance of ThreadPatternConverter.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
};
}
}
diff --git a/src/main/include/log4cxx/pattern/throwableinformationpatternconverter.h b/src/main/include/log4cxx/pattern/throwableinformationpatternconverter.h
index e3a4805..993b046 100644
--- a/src/main/include/log4cxx/pattern/throwableinformationpatternconverter.h
+++ b/src/main/include/log4cxx/pattern/throwableinformationpatternconverter.h
@@ -20,7 +20,10 @@
#include <log4cxx/pattern/loggingeventpatternconverter.h>
-namespace log4cxx { namespace pattern {
+namespace log4cxx
+{
+namespace pattern
+{
/**
@@ -32,45 +35,46 @@
*
*/
class LOG4CXX_EXPORT ThrowableInformationPatternConverter
- : public LoggingEventPatternConverter {
- /**
- * If "short", only first line of throwable report will be formatted.
- */
- const bool shortReport;
+ : public LoggingEventPatternConverter
+{
+ /**
+ * If "short", only first line of throwable report will be formatted.
+ */
+ const bool shortReport;
- /**
- * Private constructor.
- */
- ThrowableInformationPatternConverter(bool shortReport);
+ /**
+ * Private constructor.
+ */
+ ThrowableInformationPatternConverter(bool shortReport);
-public:
-DECLARE_LOG4CXX_PATTERN(ThrowableInformationPatternConverter)
-BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(ThrowableInformationPatternConverter)
- LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
-END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_PATTERN(ThrowableInformationPatternConverter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(ThrowableInformationPatternConverter)
+ LOG4CXX_CAST_ENTRY_CHAIN(LoggingEventPatternConverter)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Gets an instance of the class.
- * @param options pattern options, may be null. If first element is "short",
- * only the first line of the throwable will be formatted.
- * @return instance of class.
- */
- static PatternConverterPtr newInstance(
- const std::vector<LogString>& options);
+ /**
+ * Gets an instance of the class.
+ * @param options pattern options, may be null. If first element is "short",
+ * only the first line of the throwable will be formatted.
+ * @return instance of class.
+ */
+ static PatternConverterPtr newInstance(
+ const std::vector<LogString>& options);
- using LoggingEventPatternConverter::format;
+ using LoggingEventPatternConverter::format;
- void format(const log4cxx::spi::LoggingEventPtr& event,
- LogString& toAppendTo,
- log4cxx::helpers::Pool& p) const;
+ void format(const log4cxx::spi::LoggingEventPtr& event,
+ LogString& toAppendTo,
+ log4cxx::helpers::Pool& p) const;
- /**
- * This converter obviously handles throwables.
- * @return true.
- */
- bool handlesThrowable() const;
+ /**
+ * This converter obviously handles throwables.
+ * @return true.
+ */
+ bool handlesThrowable() const;
};
}
}
diff --git a/src/main/include/log4cxx/patternlayout.h b/src/main/include/log4cxx/patternlayout.h
index b0687b7..2cec7de 100644
--- a/src/main/include/log4cxx/patternlayout.h
+++ b/src/main/include/log4cxx/patternlayout.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_PATTERN_LAYOUT_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/layout.h>
@@ -30,384 +30,389 @@
namespace log4cxx
{
- LOG4CXX_LIST_DEF(LoggingEventPatternConverterList, log4cxx::pattern::LoggingEventPatternConverterPtr);
- LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
+LOG4CXX_LIST_DEF(LoggingEventPatternConverterList, log4cxx::pattern::LoggingEventPatternConverterPtr);
+LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
- /**
- * A flexible layout configurable with pattern string.
- *
- * <p>
- * The goal of this class is to #format a {@link spi::LoggingEvent LoggingEvent} and
- * return the results as a string. The results depend on the <em>conversion pattern</em>.
- * </p>
- *
- * <p>
- * The conversion pattern is closely related to the conversion pattern of the printf
- * function in C. A conversion pattern is composed of literal text and format control
- * expressions called <em>conversion specifiers</em>.
- * </p>
- *
- * <p>
- * <i>You are free to insert any literal text within the conversion pattern.</i>
- * </p>
- *
- * <p>
- * Each conversion specifier starts with a percent sign (%) and is followed by optional
- * <em>format modifiers</em> and a <em>conversion character</em>. The conversion character
- * specifies the type of data, e.g. logger, level, date, thread name. The format modifiers
- * control such things as field width, padding, left and right justification. The
- * following is a simple example.
- * </p>
- *
- * <p>
- * Let the conversion pattern be <strong>"%-5p [%t]: %m%n"</strong> and assume that the log4cxx
- * environment was set to use a PatternLayout. Then the statements
- * <pre>
- * LoggerPtr root = Logger::getRoot();
- * root->debug("Message 1");
- * root->warn("Message 2");</pre>
- * would yield the output
- * <pre>
- * DEBUG [main]: Message 1
- * WARN [main]: Message 2</pre>
- * </p>
- *
- * <p>
- * Note that there is no explicit separator between text and conversion specifiers. The
- * pattern parser knows when it has reached the end of a conversion specifier when it
- * reads a conversion character. In the example above the conversion specifier <strong>%-5p</strong>
- * means the level of the logging event should be left justified to a width of five
- * characters.
- * </p>
- *
- * <p>The recognized conversion characters are:</p>
- *
- * <table border="1" cellpadding="8">
- * <tr>
- * <th align="center"><strong>Conversion Character</strong></th>
- * <th align="center"><strong>Effect</strong></th>
- * </tr>
- * <tr>
- * <td align="center"><strong>c</strong></td>
- * <td>
- * Used to output the logger of the logging event. The logger conversion specifier
- * can be optionally followed by <em>precision specifier</em>, that is a decimal
- * constant in brackets.
- * <p>
- * If a precision specifier is given, then only the corresponding number of
- * right most components of the logger name will be printed. By default the
- * logger name is printed in full.
- * </p>
- * <p>
- * For example, for the logger name "a.b.c" the pattern <strong>%c{2}</strong> will
- * output "b.c".
- * </p>
- * </td>
- * </tr>
- * <tr>
- * <td align="center">
- * <p><strong>C</strong></p>
- * <p><strong>class</strong></p>
- * </td>
- * <td>
- * Used to output the class of the issuer of the logging event if the compiler
- * used supports a macro to retrieve the method of the currently compiled line and
- * if the LOG4CXX_TRACE-like macros are used to issue a logging request. In this
- * case the macro LOG4CXX_* is expanded at compile time to generate location info
- * of the logging event and adds the method name, besides file and line, if
- * available. In most cases the provided method contains the classname and can
- * therefore be retrieved form the location info as needed.
- * <p>
- * Currently supported compilers are those from Microsoft, GNU-C and Borland.
- * </p>
- * </td>
- * </tr>
- * <tr>
- * <td align="center"><strong>d</strong></td>
- * <td>
- * Used to output the date of the logging event. The date conversion specifier may
- * be followed by a set of braces containing a date and time pattern string
- * compatible with java.text.SimpleDateFormat, <em>ABSOLUTE</em>, <em>DATE</em> or
- * <em>ISO8601</em>. For example, <strong>%d{HH:mm:ss,SSS}</strong>,
- * <strong>%d{dd MMM yyyy HH:mm:ss,SSS}</strong> or <strong>%d{DATE}</strong>. If no
- * date format specifier is given then ISO8601 format is assumed.
- * </td>
- * </tr>
- * <tr>
- * <td align="center"><strong>F</strong></td>
- * <td>
- * Used to output the file name where the logging request was issued.
- * </td>
- * </tr>
- * <tr>
- * <td align="center"><strong>l</strong></td>
- * <td>
- * Used to output location information of the caller which generated the logging
- * event.
- * </td>
- * </tr>
- * <tr>
- * <td align="center"><strong>L</strong></td>
- * <td>
- * Used to output the line number from where the logging request was issued.
- * </td>
- * </tr>
- * <tr>
- * <td align="center"><strong>m</strong></td>
- * <td>
- * Used to output the application supplied message associated with the logging
- * event.
- * </td>
- * </tr>
- * <tr>
- * <td align="center">
- * <strong>M</strong>
- * <p><strong>method</strong></p>
- * </td>
- * <td>
- * Used to output the method of the issuer of the logging event if the compiler
- * used supports a macro to retrieve the method of the currently compiled line
- * and if the LOG4CXX_TRACE-like macros are used to issue a logging request. In
- * this case the macro LOG4CXX_* is expanded at compile time to generate location
- * info of the logging event and adds the method name, besides file and line, if
- * available. In most cases the provided method contains the classname which is
- * ignored in every attempt to retrieve the method from the location info.
- * <p>
- * Currently supported compilers are those from Microsoft, GNU-C and Borland.
- * </p>
- * </td>
- * </tr>
- * <tr>
- * <td align="center"><strong>n</strong></td>
- * <td>
- * Outputs the platform dependent line separator character or characters.
- * <p>
- * This conversion character offers practically the same performance as using
- * non-portable line separator strings such as "\n", or "\r\n". Thus, it is the
- * preferred way of specifying a line separator.
- * </p>
- * </td>
- * </tr>
- * <tr>
- * <td align="center"><strong>p</strong></td>
- * <td>Used to output the level of the logging event.</td>
- * </tr>
- * <tr>
- * <td align="center"><strong>r</strong></td>
- * <td>
- * Used to output the number of milliseconds elapsed since the start of the
- * application until the creation of the logging event.
- * </td>
- * </tr>
- * <tr>
- * <td align="center"><strong>t</strong></td>
- * <td>Used to output the name of the thread that generated the logging event.</td>
- * </tr>
- * <tr>
- * <td align="center"><strong>x</strong></td>
- * <td>
- * Used to output the NDC (nested diagnostic context) associated with the thread that
- * generated the logging event.
- * </td>
- * </tr>
- * <tr>
- * <td align="center"><strong>X</strong></td>
- * <td>
- * Used to output the MDC (mapped diagnostic context) associated with the thread that
- * generated the logging event. The <strong>X</strong> conversion character <em>must</em> be
- * followed by the key for the map placed between braces, as in <strong>%X{clientNumber}</strong>
- * where <code>clientNumber</code> is the key. The value in the MDC corresponding to
- * the key will be output.
- * <p>See MDC class for more details.</p>
- * </td>
- * </tr>
- * <tr>
- * <td align="center"><strong>%</strong></td>
- * <td>The sequence %% outputs a single percent sign.</td>
- * </tr>
- * </table>
- *
- * <p>
- * By default the relevant information is output as is. However, with the aid of format
- * modifiers it is possible to change the minimum field width, the maximum field width
- * and justification.
- * </p>
- *
- * <p>
- * The optional format modifier is placed between the percent sign and the conversion
- * character.
- * </p>
- *
- * <p>
- * The first optional format modifier is the <em>left justification flag</em> which is
- * just the minus (-) character. Then comes the optional <em>minimum field width</em>
- * modifier. This is a decimal constant that represents the minimum number of characters
- * to output. If the data item requires fewer characters, it is padded on either the left
- * or the right until the minimum width is reached. The default is to pad on the left
- * (right justify) but you can specify right padding with the left justification flag. The
- * padding character is space. If the data item is larger than the minimum field width,
- * the field is expanded to accommodate the data. The value is never truncated.
- * </p>
- *
- * <p>
- * This behavior can be changed using the <em>maximum field width</em> modifier which is
- * designated by a period followed by a decimal constant. If the data item is longer than
- * the maximum field, then the extra characters are removed from the <em>beginning</em> of
- * the data item and not from the end. For example, it the maximum field width is eight
- * and the data item is ten characters long, then the first two characters of the data
- * item are dropped. This behavior deviates from the printf function in C where truncation
- * is done from the end.
- * </p>
- *
- * <p>Below are various format modifier examples for the logger conversion specifier.</p>
- *
- * <table border="1" cellpadding="8">
- * <tr>
- * <th align="center"><strong>Format modifier</strong></th>
- * <th align="center"><strong>left justify</strong></th>
- * <th align="center"><strong>minimum width</strong></th>
- * <th align="center"><strong>maximum width</strong></th>
- * <th align="center"><strong>comment</strong></th>
- * </tr>
- * <tr>
- * <td align="center">%20c</td>
- * <td align="center">false</td>
- * <td align="center">20</td>
- * <td align="center">none</td>
- * <td>Left pad with spaces if the logger name is less than 20 characters long.</td>
- * </tr>
- * <tr>
- * <td align="center">%-20c</td>
- * <td align="center">true</td>
- * <td align="center">20</td>
- * <td align="center">none</td>
- * <td>Right pad with spaces if the logger name is less than 20 characters long.</td>
- * </tr>
- * <tr>
- * <td align="center">%.30c</td>
- * <td align="center">NA</td>
- * <td align="center">none</td>
- * <td align="center">30</td>
- * <td>Truncate from the beginning if the logger name is longer than 30 characters.</td>
- * </tr>
- * <tr>
- * <td align="center">%20.30c</td>
- * <td align="center">false</td>
- * <td align="center">20</td>
- * <td align="center">30</td>
- * <td>
- * Left pad with spaces if the logger name is shorter than 20 characters. However, if
- * logger name is longer than 30 characters, then truncate from the beginning.
- * </td>
- * </tr>
- * <tr>
- * <td align="center">%-20.30c</td>
- * <td align="center">true</td>
- * <td align="center">20</td>
- * <td align="center">30</td>
- * <td>
- * Right pad with spaces if the logger name is shorter than 20 characters. However, if
- * logger name is longer than 30 characters, then truncate from the beginning.
- * </td>
- * </tr>
- * </table>
- *
- * <p>Below are some examples of conversion patterns.</p>
- *
- * <p><strong>%r [%t] %-5p %c %x - %m\n</strong></p>
- * <p>This is essentially the TTCC layout.</p>
- *
- * <p><strong>%-6r [%15.15t] %-5p %30.30c %x - %m\n</strong></p>
- *
- * <p>
- * Similar to the TTCC layout except that the relative time is right padded if less than 6
- * digits, thread name is right padded if less than 15 characters and truncated if longer
- * and the logger name is left padded if shorter than 30 characters and truncated if
- * longer.
- * </p>
- *
- * <p>
- * The above text is largely inspired from Peter A. Darnell and Philip E. Margolis' highly
- * recommended book "C -- a Software Engineering Approach", ISBN 0-387-97389-3.
- * </p>
- */
- class LOG4CXX_EXPORT PatternLayout : public Layout
- {
- /**
- * Conversion pattern.
- */
- LogString conversionPattern;
+/**
+ * A flexible layout configurable with pattern string.
+ *
+ * <p>
+ * The goal of this class is to #format a {@link spi::LoggingEvent LoggingEvent} and
+ * return the results as a string. The results depend on the <em>conversion pattern</em>.
+ * </p>
+ *
+ * <p>
+ * The conversion pattern is closely related to the conversion pattern of the printf
+ * function in C. A conversion pattern is composed of literal text and format control
+ * expressions called <em>conversion specifiers</em>.
+ * </p>
+ *
+ * <p>
+ * <i>You are free to insert any literal text within the conversion pattern.</i>
+ * </p>
+ *
+ * <p>
+ * Each conversion specifier starts with a percent sign (%) and is followed by optional
+ * <em>format modifiers</em> and a <em>conversion character</em>. The conversion character
+ * specifies the type of data, e.g. logger, level, date, thread name. The format modifiers
+ * control such things as field width, padding, left and right justification. The
+ * following is a simple example.
+ * </p>
+ *
+ * <p>
+ * Let the conversion pattern be <strong>"%-5p [%t]: %m%n"</strong> and assume that the log4cxx
+ * environment was set to use a PatternLayout. Then the statements
+ * <pre>
+ * LoggerPtr root = Logger::getRoot();
+ * root->debug("Message 1");
+ * root->warn("Message 2");</pre>
+ * would yield the output
+ * <pre>
+ * DEBUG [main]: Message 1
+ * WARN [main]: Message 2</pre>
+ * </p>
+ *
+ * <p>
+ * Note that there is no explicit separator between text and conversion specifiers. The
+ * pattern parser knows when it has reached the end of a conversion specifier when it
+ * reads a conversion character. In the example above the conversion specifier <strong>%-5p</strong>
+ * means the level of the logging event should be left justified to a width of five
+ * characters.
+ * </p>
+ *
+ * <p>The recognized conversion characters are:</p>
+ *
+ * <table border="1" cellpadding="8">
+ * <tr>
+ * <th align="center"><strong>Conversion Character</strong></th>
+ * <th align="center"><strong>Effect</strong></th>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>c</strong></td>
+ * <td>
+ * Used to output the logger of the logging event. The logger conversion specifier
+ * can be optionally followed by <em>precision specifier</em>, that is a decimal
+ * constant in brackets.
+ * <p>
+ * If a precision specifier is given, then only the corresponding number of
+ * right most components of the logger name will be printed. By default the
+ * logger name is printed in full.
+ * </p>
+ * <p>
+ * For example, for the logger name "a.b.c" the pattern <strong>%c{2}</strong> will
+ * output "b.c".
+ * </p>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center">
+ * <p><strong>C</strong></p>
+ * <p><strong>class</strong></p>
+ * </td>
+ * <td>
+ * Used to output the class of the issuer of the logging event if the compiler
+ * used supports a macro to retrieve the method of the currently compiled line and
+ * if the LOG4CXX_TRACE-like macros are used to issue a logging request. In this
+ * case the macro LOG4CXX_* is expanded at compile time to generate location info
+ * of the logging event and adds the method name, besides file and line, if
+ * available. In most cases the provided method contains the classname and can
+ * therefore be retrieved form the location info as needed.
+ * <p>
+ * Currently supported compilers are those from Microsoft, GNU-C and Borland.
+ * </p>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>d</strong></td>
+ * <td>
+ * Used to output the date of the logging event. The date conversion specifier may
+ * be followed by a set of braces containing a date and time pattern string
+ * compatible with java.text.SimpleDateFormat, <em>ABSOLUTE</em>, <em>DATE</em> or
+ * <em>ISO8601</em>. For example, <strong>%d{HH:mm:ss,SSS}</strong>,
+ * <strong>%d{dd MMM yyyy HH:mm:ss,SSS}</strong> or <strong>%d{DATE}</strong>. If no
+ * date format specifier is given then ISO8601 format is assumed.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>F</strong></td>
+ * <td>
+ * Used to output the file name where the logging request was issued.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>l</strong></td>
+ * <td>
+ * Used to output location information of the caller which generated the logging
+ * event.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>L</strong></td>
+ * <td>
+ * Used to output the line number from where the logging request was issued.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>m</strong></td>
+ * <td>
+ * Used to output the application supplied message associated with the logging
+ * event.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center">
+ * <strong>M</strong>
+ * <p><strong>method</strong></p>
+ * </td>
+ * <td>
+ * Used to output the method of the issuer of the logging event if the compiler
+ * used supports a macro to retrieve the method of the currently compiled line
+ * and if the LOG4CXX_TRACE-like macros are used to issue a logging request. In
+ * this case the macro LOG4CXX_* is expanded at compile time to generate location
+ * info of the logging event and adds the method name, besides file and line, if
+ * available. In most cases the provided method contains the classname which is
+ * ignored in every attempt to retrieve the method from the location info.
+ * <p>
+ * Currently supported compilers are those from Microsoft, GNU-C and Borland.
+ * </p>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>n</strong></td>
+ * <td>
+ * Outputs the platform dependent line separator character or characters.
+ * <p>
+ * This conversion character offers practically the same performance as using
+ * non-portable line separator strings such as "\n", or "\r\n". Thus, it is the
+ * preferred way of specifying a line separator.
+ * </p>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>p</strong></td>
+ * <td>Used to output the level of the logging event.</td>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>r</strong></td>
+ * <td>
+ * Used to output the number of milliseconds elapsed since the start of the
+ * application until the creation of the logging event.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>t</strong></td>
+ * <td>Used to output the name of the thread that generated the logging event.</td>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>x</strong></td>
+ * <td>
+ * Used to output the NDC (nested diagnostic context) associated with the thread that
+ * generated the logging event.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>X</strong></td>
+ * <td>
+ * Used to output the MDC (mapped diagnostic context) associated with the thread that
+ * generated the logging event. The <strong>X</strong> conversion character <em>must</em> be
+ * followed by the key for the map placed between braces, as in <strong>%X{clientNumber}</strong>
+ * where <code>clientNumber</code> is the key. The value in the MDC corresponding to
+ * the key will be output.
+ * <p>See MDC class for more details.</p>
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center"><strong>%</strong></td>
+ * <td>The sequence %% outputs a single percent sign.</td>
+ * </tr>
+ * </table>
+ *
+ * <p>
+ * By default the relevant information is output as is. However, with the aid of format
+ * modifiers it is possible to change the minimum field width, the maximum field width
+ * and justification.
+ * </p>
+ *
+ * <p>
+ * The optional format modifier is placed between the percent sign and the conversion
+ * character.
+ * </p>
+ *
+ * <p>
+ * The first optional format modifier is the <em>left justification flag</em> which is
+ * just the minus (-) character. Then comes the optional <em>minimum field width</em>
+ * modifier. This is a decimal constant that represents the minimum number of characters
+ * to output. If the data item requires fewer characters, it is padded on either the left
+ * or the right until the minimum width is reached. The default is to pad on the left
+ * (right justify) but you can specify right padding with the left justification flag. The
+ * padding character is space. If the data item is larger than the minimum field width,
+ * the field is expanded to accommodate the data. The value is never truncated.
+ * </p>
+ *
+ * <p>
+ * This behavior can be changed using the <em>maximum field width</em> modifier which is
+ * designated by a period followed by a decimal constant. If the data item is longer than
+ * the maximum field, then the extra characters are removed from the <em>beginning</em> of
+ * the data item and not from the end. For example, it the maximum field width is eight
+ * and the data item is ten characters long, then the first two characters of the data
+ * item are dropped. This behavior deviates from the printf function in C where truncation
+ * is done from the end.
+ * </p>
+ *
+ * <p>Below are various format modifier examples for the logger conversion specifier.</p>
+ *
+ * <table border="1" cellpadding="8">
+ * <tr>
+ * <th align="center"><strong>Format modifier</strong></th>
+ * <th align="center"><strong>left justify</strong></th>
+ * <th align="center"><strong>minimum width</strong></th>
+ * <th align="center"><strong>maximum width</strong></th>
+ * <th align="center"><strong>comment</strong></th>
+ * </tr>
+ * <tr>
+ * <td align="center">%20c</td>
+ * <td align="center">false</td>
+ * <td align="center">20</td>
+ * <td align="center">none</td>
+ * <td>Left pad with spaces if the logger name is less than 20 characters long.</td>
+ * </tr>
+ * <tr>
+ * <td align="center">%-20c</td>
+ * <td align="center">true</td>
+ * <td align="center">20</td>
+ * <td align="center">none</td>
+ * <td>Right pad with spaces if the logger name is less than 20 characters long.</td>
+ * </tr>
+ * <tr>
+ * <td align="center">%.30c</td>
+ * <td align="center">NA</td>
+ * <td align="center">none</td>
+ * <td align="center">30</td>
+ * <td>Truncate from the beginning if the logger name is longer than 30 characters.</td>
+ * </tr>
+ * <tr>
+ * <td align="center">%20.30c</td>
+ * <td align="center">false</td>
+ * <td align="center">20</td>
+ * <td align="center">30</td>
+ * <td>
+ * Left pad with spaces if the logger name is shorter than 20 characters. However, if
+ * logger name is longer than 30 characters, then truncate from the beginning.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td align="center">%-20.30c</td>
+ * <td align="center">true</td>
+ * <td align="center">20</td>
+ * <td align="center">30</td>
+ * <td>
+ * Right pad with spaces if the logger name is shorter than 20 characters. However, if
+ * logger name is longer than 30 characters, then truncate from the beginning.
+ * </td>
+ * </tr>
+ * </table>
+ *
+ * <p>Below are some examples of conversion patterns.</p>
+ *
+ * <p><strong>%r [%t] %-5p %c %x - %m\n</strong></p>
+ * <p>This is essentially the TTCC layout.</p>
+ *
+ * <p><strong>%-6r [%15.15t] %-5p %30.30c %x - %m\n</strong></p>
+ *
+ * <p>
+ * Similar to the TTCC layout except that the relative time is right padded if less than 6
+ * digits, thread name is right padded if less than 15 characters and truncated if longer
+ * and the logger name is left padded if shorter than 30 characters and truncated if
+ * longer.
+ * </p>
+ *
+ * <p>
+ * The above text is largely inspired from Peter A. Darnell and Philip E. Margolis' highly
+ * recommended book "C -- a Software Engineering Approach", ISBN 0-387-97389-3.
+ * </p>
+ */
+class LOG4CXX_EXPORT PatternLayout : public Layout
+{
+ /**
+ * Conversion pattern.
+ */
+ LogString conversionPattern;
- /**
- * Pattern converters.
- */
- LoggingEventPatternConverterList patternConverters;
+ /**
+ * Pattern converters.
+ */
+ LoggingEventPatternConverterList patternConverters;
- /**
- * Field widths and alignment corresponding to pattern converters.
- */
- FormattingInfoList patternFields;
+ /**
+ * Field widths and alignment corresponding to pattern converters.
+ */
+ FormattingInfoList patternFields;
- public:
- DECLARE_LOG4CXX_OBJECT(PatternLayout)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(PatternLayout)
- LOG4CXX_CAST_ENTRY_CHAIN(Layout)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_OBJECT(PatternLayout)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(PatternLayout)
+ LOG4CXX_CAST_ENTRY_CHAIN(Layout)
+ END_LOG4CXX_CAST_MAP()
- /**
- * Does nothing
- */
- PatternLayout();
+ /**
+ * Does nothing
+ */
+ PatternLayout();
- /**
- * Constructs a PatternLayout using the supplied conversion pattern.
- */
- PatternLayout(const LogString& pattern);
+ /**
+ * Constructs a PatternLayout using the supplied conversion pattern.
+ */
+ PatternLayout(const LogString& pattern);
- /**
- * Set the <strong>ConversionPattern</strong> option. This is the string which
- * controls formatting and consists of a mix of literal content and
- * conversion specifiers.
- */
- void setConversionPattern(const LogString& conversionPattern);
+ /**
+ * Set the <strong>ConversionPattern</strong> option. This is the string which
+ * controls formatting and consists of a mix of literal content and
+ * conversion specifiers.
+ */
+ void setConversionPattern(const LogString& conversionPattern);
- /**
- * Returns the value of the <strong>ConversionPattern</strong> option.
- */
- inline LogString getConversionPattern() const
- { return conversionPattern; }
+ /**
+ * Returns the value of the <strong>ConversionPattern</strong> option.
+ */
+ inline LogString getConversionPattern() const
+ {
+ return conversionPattern;
+ }
- /**
- * Call createPatternParser
- */
- virtual void activateOptions(log4cxx::helpers::Pool& p);
+ /**
+ * Call createPatternParser
+ */
+ virtual void activateOptions(log4cxx::helpers::Pool& p);
- virtual void setOption(const LogString& option, const LogString& value);
+ virtual void setOption(const LogString& option, const LogString& value);
- /**
- * The PatternLayout does not handle the throwable contained within
- * {@link spi::LoggingEvent LoggingEvents}. Thus, it returns
- * <code>true</code>.
- */
- virtual bool ignoresThrowable() const { return true; }
+ /**
+ * The PatternLayout does not handle the throwable contained within
+ * {@link spi::LoggingEvent LoggingEvents}. Thus, it returns
+ * <code>true</code>.
+ */
+ virtual bool ignoresThrowable() const
+ {
+ return true;
+ }
- /**
- * Produces a formatted string as specified by the conversion pattern.
- */
- virtual void format( LogString& output,
- const spi::LoggingEventPtr& event,
- log4cxx::helpers::Pool& pool) const;
+ /**
+ * Produces a formatted string as specified by the conversion pattern.
+ */
+ virtual void format( LogString& output,
+ const spi::LoggingEventPtr& event,
+ log4cxx::helpers::Pool& pool) const;
- protected:
- virtual log4cxx::pattern::PatternMap getFormatSpecifiers();
- };
+ protected:
+ virtual log4cxx::pattern::PatternMap getFormatSpecifiers();
+};
- LOG4CXX_PTR_DEF(PatternLayout);
+LOG4CXX_PTR_DEF(PatternLayout);
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif //_LOG4CXX_PATTERN_LAYOUT_H
diff --git a/src/main/include/log4cxx/propertyconfigurator.h b/src/main/include/log4cxx/propertyconfigurator.h
index e9706ff..bc952cd 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
@@ -34,23 +34,24 @@
namespace log4cxx
{
- class Logger;
- typedef helpers::ObjectPtrT<Logger> LoggerPtr;
+class Logger;
+typedef helpers::ObjectPtrT<Logger> LoggerPtr;
- class Appender;
- typedef helpers::ObjectPtrT<Appender> AppenderPtr;
+class Appender;
+typedef helpers::ObjectPtrT<Appender> AppenderPtr;
- namespace helpers
- {
- class Properties;
- }
+namespace helpers
+{
+class Properties;
+}
- namespace spi {
- class LoggerFactory;
- }
+namespace spi
+{
+class LoggerFactory;
+}
- class PropertyWatchdog;
+class PropertyWatchdog;
/**
Allows the configuration of log4cxx from an external file. See
<b>{@link #doConfigure(const File&, log4cxx::spi::LoggerRepositoryPtr&)}</b>
@@ -89,308 +90,308 @@
<code>${java.home}</code> will be interpreted as
<code>/home/xyz</code>.
*/
- class LOG4CXX_EXPORT PropertyConfigurator :
- virtual public spi::Configurator,
- virtual public helpers::ObjectImpl
- {
- protected:
+class LOG4CXX_EXPORT PropertyConfigurator :
+ virtual public spi::Configurator,
+ virtual public helpers::ObjectImpl
+{
+ 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
- */
+ /**
+ 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.
+ */
+ void 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);
- 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;
- }; // class PropertyConfigurator
+ 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/provisionnode.h b/src/main/include/log4cxx/provisionnode.h
index c6ec36f..cc7dff2 100644
--- a/src/main/include/log4cxx/provisionnode.h
+++ b/src/main/include/log4cxx/provisionnode.h
@@ -24,11 +24,11 @@
namespace log4cxx
{
- class Logger;
- typedef helpers::ObjectPtrT<Logger> LoggerPtr;
+class Logger;
+typedef helpers::ObjectPtrT<Logger> LoggerPtr;
- typedef std::vector<LoggerPtr> ProvisionNode;
+typedef std::vector<LoggerPtr> ProvisionNode;
} // namespace log4cxx
diff --git a/src/main/include/log4cxx/rolling/action.h b/src/main/include/log4cxx/rolling/action.h
index 00595ff..0dec165 100644
--- a/src/main/include/log4cxx/rolling/action.h
+++ b/src/main/include/log4cxx/rolling/action.h
@@ -23,18 +23,21 @@
#include <log4cxx/helpers/mutex.h>
#include <log4cxx/helpers/pool.h>
-namespace log4cxx {
- namespace rolling {
+namespace log4cxx
+{
+namespace rolling
+{
- /**
- * A file system action performed as part of a rollover event.
- */
- class Action : public virtual log4cxx::helpers::ObjectImpl {
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(Action)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(Action)
- END_LOG4CXX_CAST_MAP()
+/**
+ * A file system action performed as part of a rollover event.
+ */
+class Action : public virtual log4cxx::helpers::ObjectImpl
+{
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(Action)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(Action)
+ END_LOG4CXX_CAST_MAP()
/**
* Is action complete.
*/
@@ -49,14 +52,14 @@
log4cxx::helpers::Mutex mutex;
- protected:
+ protected:
/**
* Constructor.
*/
Action();
virtual ~Action();
- public:
+ public:
/**
* Perform action.
*
@@ -68,20 +71,20 @@
void close();
- /**
- * Tests if the action is complete.
- * @return true if action is complete.
- */
+ /**
+ * Tests if the action is complete.
+ * @return true if action is complete.
+ */
bool isComplete() const;
void reportException(const std::exception&);
- };
+};
- LOG4CXX_PTR_DEF(Action);
+LOG4CXX_PTR_DEF(Action);
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/rolling/filerenameaction.h b/src/main/include/log4cxx/rolling/filerenameaction.h
index 46a284a..f0605dc 100644
--- a/src/main/include/log4cxx/rolling/filerenameaction.h
+++ b/src/main/include/log4cxx/rolling/filerenameaction.h
@@ -21,27 +21,30 @@
#include <log4cxx/rolling/action.h>
#include <log4cxx/file.h>
-namespace log4cxx {
- namespace rolling {
+namespace log4cxx
+{
+namespace rolling
+{
- class FileRenameAction : public Action {
- const File source;
- const File destination;
- bool renameEmptyFile;
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(FileRenameAction)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(FileRenameAction)
- LOG4CXX_CAST_ENTRY_CHAIN(Action)
- END_LOG4CXX_CAST_MAP()
+class FileRenameAction : public Action
+{
+ const File source;
+ const File destination;
+ bool renameEmptyFile;
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(FileRenameAction)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(FileRenameAction)
+ LOG4CXX_CAST_ENTRY_CHAIN(Action)
+ END_LOG4CXX_CAST_MAP()
/**
* Constructor.
*/
FileRenameAction(const File& toRename,
- const File& renameTo,
- bool renameEmptyFile);
+ const File& renameTo,
+ bool renameEmptyFile);
/**
* Perform action.
@@ -49,11 +52,11 @@
* @return true if successful.
*/
virtual bool execute(log4cxx::helpers::Pool& pool) const;
- };
+};
- LOG4CXX_PTR_DEF(FileRenameAction);
+LOG4CXX_PTR_DEF(FileRenameAction);
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/rolling/filterbasedtriggeringpolicy.h b/src/main/include/log4cxx/rolling/filterbasedtriggeringpolicy.h
index 310edd6..f8024b5 100644
--- a/src/main/include/log4cxx/rolling/filterbasedtriggeringpolicy.h
+++ b/src/main/include/log4cxx/rolling/filterbasedtriggeringpolicy.h
@@ -15,22 +15,25 @@
* limitations under the License.
*/
- #if !defined(_LOG4CXX_ROLLING_FILTER_BASED_TRIGGERING_POLICY_H)
- #define _LOG4CXX_ROLLING_FILTER_BASED_TRIGGERING_POLICY_H
+#if !defined(_LOG4CXX_ROLLING_FILTER_BASED_TRIGGERING_POLICY_H)
+#define _LOG4CXX_ROLLING_FILTER_BASED_TRIGGERING_POLICY_H
#include <log4cxx/rolling/triggeringpolicy.h>
#include <log4cxx/spi/filter.h>
- namespace log4cxx {
+namespace log4cxx
+{
- class File;
+class File;
- namespace helpers {
- class Pool;
- }
+namespace helpers
+{
+class Pool;
+}
- namespace rolling {
+namespace rolling
+{
/**
@@ -42,77 +45,78 @@
*
*
*/
-class LOG4CXX_EXPORT FilterBasedTriggeringPolicy : public TriggeringPolicy {
+class LOG4CXX_EXPORT FilterBasedTriggeringPolicy : public TriggeringPolicy
+{
- DECLARE_LOG4CXX_OBJECT(FilterBasedTriggeringPolicy)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(FilterBasedTriggeringPolicy)
- LOG4CXX_CAST_ENTRY_CHAIN(TriggeringPolicy)
- END_LOG4CXX_CAST_MAP()
+ DECLARE_LOG4CXX_OBJECT(FilterBasedTriggeringPolicy)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(FilterBasedTriggeringPolicy)
+ LOG4CXX_CAST_ENTRY_CHAIN(TriggeringPolicy)
+ END_LOG4CXX_CAST_MAP()
- /**
- * The first filter in the filter chain. Set to <code>null</code> initially.
- */
- log4cxx::spi::FilterPtr headFilter;
+ /**
+ * The first filter in the filter chain. Set to <code>null</code> initially.
+ */
+ log4cxx::spi::FilterPtr headFilter;
- /**
- * The last filter in the filter chain.
- */
- log4cxx::spi::FilterPtr tailFilter;
+ /**
+ * The last filter in the filter chain.
+ */
+ log4cxx::spi::FilterPtr tailFilter;
-public:
- /**
- * Creates a new FilterBasedTriggeringPolicy.
- */
- FilterBasedTriggeringPolicy();
- virtual ~FilterBasedTriggeringPolicy();
+ public:
+ /**
+ * Creates a new FilterBasedTriggeringPolicy.
+ */
+ FilterBasedTriggeringPolicy();
+ virtual ~FilterBasedTriggeringPolicy();
-/**
- * Determines if a rollover may be appropriate at this time. If
- * true is returned, RolloverPolicy.rollover will be called but it
- * can determine that a rollover is not warranted.
- *
- * @param appender A reference to the appender.
- * @param event A reference to the currently event.
- * @param filename The filename for the currently active log file.
- * @param fileLength Length of the file in bytes.
- * @return true if a rollover should occur.
- */
-virtual bool isTriggeringEvent(
- Appender* appender,
- const log4cxx::spi::LoggingEventPtr& event,
- const LogString& filename,
- size_t fileLength);
+ /**
+ * Determines if a rollover may be appropriate at this time. If
+ * true is returned, RolloverPolicy.rollover will be called but it
+ * can determine that a rollover is not warranted.
+ *
+ * @param appender A reference to the appender.
+ * @param event A reference to the currently event.
+ * @param filename The filename for the currently active log file.
+ * @param fileLength Length of the file in bytes.
+ * @return true if a rollover should occur.
+ */
+ virtual bool isTriggeringEvent(
+ Appender* appender,
+ const log4cxx::spi::LoggingEventPtr& event,
+ const LogString& filename,
+ size_t fileLength);
- /**
- * Add a filter to end of the filter list.
- * @param newFilter filter to add to end of list.
- */
- void addFilter(const log4cxx::spi::FilterPtr& newFilter);
+ /**
+ * Add a filter to end of the filter list.
+ * @param newFilter filter to add to end of list.
+ */
+ void addFilter(const log4cxx::spi::FilterPtr& newFilter);
- /**
- * Clear the filters chain.
- *
- */
- void clearFilters();
+ /**
+ * Clear the filters chain.
+ *
+ */
+ void clearFilters();
- /**
- * Returns the head Filter.
- *
- */
- log4cxx::spi::FilterPtr& getFilter();
+ /**
+ * Returns the head Filter.
+ *
+ */
+ log4cxx::spi::FilterPtr& getFilter();
- /**
- * Prepares the instance for use.
- */
- void activateOptions(log4cxx::helpers::Pool&);
+ /**
+ * Prepares the instance for use.
+ */
+ void activateOptions(log4cxx::helpers::Pool&);
- void setOption(const LogString& option, const LogString& value);
- };
+ void setOption(const LogString& option, const LogString& value);
+};
- LOG4CXX_PTR_DEF(FilterBasedTriggeringPolicy);
+LOG4CXX_PTR_DEF(FilterBasedTriggeringPolicy);
}
- }
+}
#endif
diff --git a/src/main/include/log4cxx/rolling/fixedwindowrollingpolicy.h b/src/main/include/log4cxx/rolling/fixedwindowrollingpolicy.h
index aeab8a3..e7d4936 100644
--- a/src/main/include/log4cxx/rolling/fixedwindowrollingpolicy.h
+++ b/src/main/include/log4cxx/rolling/fixedwindowrollingpolicy.h
@@ -23,13 +23,16 @@
-namespace log4cxx {
+namespace log4cxx
+{
- namespace helpers {
- class Pool;
- }
+namespace helpers
+{
+class Pool;
+}
- namespace rolling {
+namespace rolling
+{
/**
@@ -65,65 +68,66 @@
*
*
* */
- class LOG4CXX_EXPORT FixedWindowRollingPolicy : public RollingPolicyBase {
- DECLARE_LOG4CXX_OBJECT(FixedWindowRollingPolicy)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(FixedWindowRollingPolicy)
- LOG4CXX_CAST_ENTRY_CHAIN(RollingPolicyBase)
- END_LOG4CXX_CAST_MAP()
+class LOG4CXX_EXPORT FixedWindowRollingPolicy : public RollingPolicyBase
+{
+ DECLARE_LOG4CXX_OBJECT(FixedWindowRollingPolicy)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(FixedWindowRollingPolicy)
+ LOG4CXX_CAST_ENTRY_CHAIN(RollingPolicyBase)
+ END_LOG4CXX_CAST_MAP()
- int minIndex;
- int maxIndex;
- bool explicitActiveFile;
+ int minIndex;
+ int maxIndex;
+ bool explicitActiveFile;
- /**
- * It's almost always a bad idea to have a large window size, say over 12.
- */
- enum { MAX_WINDOW_SIZE = 12 };
+ /**
+ * It's almost always a bad idea to have a large window size, say over 12.
+ */
+ enum { MAX_WINDOW_SIZE = 12 };
- bool purge(int purgeStart, int maxIndex, log4cxx::helpers::Pool& p) const;
+ bool purge(int purgeStart, int maxIndex, log4cxx::helpers::Pool& p) const;
- public:
+ public:
- FixedWindowRollingPolicy();
+ FixedWindowRollingPolicy();
- void activateOptions(log4cxx::helpers::Pool& p);
- void setOption(const LogString& option,
- const LogString& value);
+ void activateOptions(log4cxx::helpers::Pool& p);
+ void setOption(const LogString& option,
+ const LogString& value);
- void rollover();
+ void rollover();
- int getMaxIndex() const;
+ int getMaxIndex() const;
- int getMinIndex() const;
+ int getMinIndex() const;
- void setMaxIndex(int newVal);
- void setMinIndex(int newVal);
+ void setMaxIndex(int newVal);
+ void setMinIndex(int newVal);
- /**
- * {@inheritDoc}
- */
- RolloverDescriptionPtr initialize(
- const LogString& currentActiveFile,
- const bool append,
- log4cxx::helpers::Pool& pool);
+ /**
+ * {@inheritDoc}
+ */
+ RolloverDescriptionPtr initialize(
+ const LogString& currentActiveFile,
+ const bool append,
+ log4cxx::helpers::Pool& pool);
- /**
- * {@inheritDoc}
- */
- RolloverDescriptionPtr rollover(
- const LogString& currentActiveFile,
- const bool append,
- log4cxx::helpers::Pool& pool);
+ /**
+ * {@inheritDoc}
+ */
+ RolloverDescriptionPtr rollover(
+ const LogString& currentActiveFile,
+ const bool append,
+ log4cxx::helpers::Pool& pool);
-protected:
- log4cxx::pattern::PatternMap getFormatSpecifiers() const;
+ protected:
+ log4cxx::pattern::PatternMap getFormatSpecifiers() const;
- };
+};
- LOG4CXX_PTR_DEF(FixedWindowRollingPolicy);
+LOG4CXX_PTR_DEF(FixedWindowRollingPolicy);
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/rolling/gzcompressaction.h b/src/main/include/log4cxx/rolling/gzcompressaction.h
index d94d4e8..38a9561 100644
--- a/src/main/include/log4cxx/rolling/gzcompressaction.h
+++ b/src/main/include/log4cxx/rolling/gzcompressaction.h
@@ -19,34 +19,37 @@
#define _LOG4CXX_ROLLING_GZ_COMPRESS_ACTION_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/rolling/action.h>
#include <log4cxx/file.h>
-namespace log4cxx {
- namespace rolling {
+namespace log4cxx
+{
+namespace rolling
+{
- class GZCompressAction : public Action {
- const File source;
- const File destination;
- bool deleteSource;
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(GZCompressAction)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(GZCompressAction)
- LOG4CXX_CAST_ENTRY_CHAIN(Action)
- END_LOG4CXX_CAST_MAP()
+class GZCompressAction : public Action
+{
+ const File source;
+ const File destination;
+ bool deleteSource;
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(GZCompressAction)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(GZCompressAction)
+ LOG4CXX_CAST_ENTRY_CHAIN(Action)
+ END_LOG4CXX_CAST_MAP()
/**
* Constructor.
*/
GZCompressAction(const File& source,
- const File& destination,
- bool deleteSource);
+ const File& destination,
+ bool deleteSource);
/**
* Perform action.
@@ -55,18 +58,18 @@
*/
virtual bool execute(log4cxx::helpers::Pool& pool) const;
- private:
+ private:
GZCompressAction(const GZCompressAction&);
GZCompressAction& operator=(const GZCompressAction&);
- };
+};
- LOG4CXX_PTR_DEF(GZCompressAction);
+LOG4CXX_PTR_DEF(GZCompressAction);
- }
+}
}
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif
diff --git a/src/main/include/log4cxx/rolling/manualtriggeringpolicy.h b/src/main/include/log4cxx/rolling/manualtriggeringpolicy.h
index cb29794..bdaf0ca 100644
--- a/src/main/include/log4cxx/rolling/manualtriggeringpolicy.h
+++ b/src/main/include/log4cxx/rolling/manualtriggeringpolicy.h
@@ -20,53 +20,57 @@
#include <log4cxx/rolling/triggeringpolicy.h>
-namespace log4cxx {
+namespace log4cxx
+{
- class File;
+class File;
- namespace helpers {
- class Pool;
- }
+namespace helpers
+{
+class Pool;
+}
- namespace rolling {
+namespace rolling
+{
+/**
+ * ManualTriggeringPolicy only rolls over on explicit calls to
+ * RollingFileAppender.rollover().
+ *
+ *
+ *
+ */
+class LOG4CXX_EXPORT ManualTriggeringPolicy : public TriggeringPolicy
+{
+ DECLARE_LOG4CXX_OBJECT(ManualTriggeringPolicy)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(ManualTriggeringPolicy)
+ LOG4CXX_CAST_ENTRY_CHAIN(TriggeringPolicy)
+ END_LOG4CXX_CAST_MAP()
+
+ public:
+ ManualTriggeringPolicy();
/**
- * ManualTriggeringPolicy only rolls over on explicit calls to
- * RollingFileAppender.rollover().
+ * Determines if a rollover may be appropriate at this time. If
+ * true is returned, RolloverPolicy.rollover will be called but it
+ * can determine that a rollover is not warranted.
*
- *
- *
+ * @param appender A reference to the appender.
+ * @param event A reference to the currently event.
+ * @param filename The filename for the currently active log file.
+ * @param fileLength Length of the file in bytes.
+ * @return true if a rollover should occur.
*/
- class LOG4CXX_EXPORT ManualTriggeringPolicy : public TriggeringPolicy {
- DECLARE_LOG4CXX_OBJECT(ManualTriggeringPolicy)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(ManualTriggeringPolicy)
- LOG4CXX_CAST_ENTRY_CHAIN(TriggeringPolicy)
- END_LOG4CXX_CAST_MAP()
+ virtual bool isTriggeringEvent(
+ Appender* appender,
+ const log4cxx::spi::LoggingEventPtr& event,
+ const LogString& filename,
+ size_t fileLength);
- public:
- ManualTriggeringPolicy();
- /**
- * Determines if a rollover may be appropriate at this time. If
- * true is returned, RolloverPolicy.rollover will be called but it
- * can determine that a rollover is not warranted.
- *
- * @param appender A reference to the appender.
- * @param event A reference to the currently event.
- * @param filename The filename for the currently active log file.
- * @param fileLength Length of the file in bytes.
- * @return true if a rollover should occur.
- */
- virtual bool isTriggeringEvent(
- Appender* appender,
- const log4cxx::spi::LoggingEventPtr& event,
- const LogString& filename,
- size_t fileLength);
-
- void activateOptions(log4cxx::helpers::Pool&);
- void setOption(const LogString& option, const LogString& value);
- };
- }
+ void activateOptions(log4cxx::helpers::Pool&);
+ void setOption(const LogString& option, const LogString& value);
+};
+}
}
#endif
diff --git a/src/main/include/log4cxx/rolling/rollingfileappender.h b/src/main/include/log4cxx/rolling/rollingfileappender.h
index 103e967..4ccd45a 100644
--- a/src/main/include/log4cxx/rolling/rollingfileappender.h
+++ b/src/main/include/log4cxx/rolling/rollingfileappender.h
@@ -21,84 +21,87 @@
#include <log4cxx/rolling/rollingfileappenderskeleton.h>
-namespace log4cxx {
- namespace rolling {
+namespace log4cxx
+{
+namespace rolling
+{
+/**
+ * <code>RollingFileAppender</code> extends {@link log4cxx::FileAppender} to backup the log files
+ * depending on {@link log4cxx::rolling::RollingPolicy RollingPolicy} and {@link log4cxx::rolling::TriggeringPolicy TriggeringPolicy}.
+ * <p>
+ * To be of any use, a <code>RollingFileAppender</code> instance must have both
+ * a <code>RollingPolicy</code> and a <code>TriggeringPolicy</code> set up.
+ * However, if its <code>RollingPolicy</code> also implements the
+ * <code>TriggeringPolicy</code> interface, then only the former needs to be
+ * set up. For example, {@link log4cxx::rolling::TimeBasedRollingPolicy TimeBasedRollingPolicy} acts both as a
+ * <code>RollingPolicy</code> and a <code>TriggeringPolicy</code>.
+ *
+ * <p><code>RollingFileAppender</code> can be configured programattically or
+ * using {@link log4cxx::xml::DOMConfigurator}. Here is a sample
+ * configration file:
+
+<pre><?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration>
+
+<log4j:configuration debug="true">
+
+ <appender name="ROLL" class="org.apache.log4j.rolling.RollingFileAppender">
+ <b><rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
+ <param name="FileNamePattern" value="/wombat/foo.%d{yyyy-MM}.gz"/>
+ </rollingPolicy></b>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <root">
+ <appender-ref ref="ROLL"/>
+ </root>
+
+</log4j:configuration>
+</pre>
+
+ *<p>This configuration file specifies a monthly rollover schedule including
+ * automatic compression of the archived files. See
+ * {@link TimeBasedRollingPolicy} for more details.
+ *
+ *
+ *
+ *
+ * */
+class LOG4CXX_EXPORT RollingFileAppender : public RollingFileAppenderSkeleton
+{
+ DECLARE_LOG4CXX_OBJECT(RollingFileAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(RollingFileAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(RollingFileAppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
+
+ public:
+ RollingFileAppender();
+
+ using RollingFileAppenderSkeleton::getRollingPolicy;
+
+ using RollingFileAppenderSkeleton::getTriggeringPolicy;
+
/**
- * <code>RollingFileAppender</code> extends {@link log4cxx::FileAppender} to backup the log files
- * depending on {@link log4cxx::rolling::RollingPolicy RollingPolicy} and {@link log4cxx::rolling::TriggeringPolicy TriggeringPolicy}.
- * <p>
- * To be of any use, a <code>RollingFileAppender</code> instance must have both
- * a <code>RollingPolicy</code> and a <code>TriggeringPolicy</code> set up.
- * However, if its <code>RollingPolicy</code> also implements the
- * <code>TriggeringPolicy</code> interface, then only the former needs to be
- * set up. For example, {@link log4cxx::rolling::TimeBasedRollingPolicy TimeBasedRollingPolicy} acts both as a
- * <code>RollingPolicy</code> and a <code>TriggeringPolicy</code>.
- *
- * <p><code>RollingFileAppender</code> can be configured programattically or
- * using {@link log4cxx::xml::DOMConfigurator}. Here is a sample
- * configration file:
+ * Sets the rolling policy. In case the 'policy' argument also implements
+ * {@link TriggeringPolicy}, then the triggering policy for this appender
+ * is automatically set to be the policy argument.
+ * @param policy
+ */
+ using RollingFileAppenderSkeleton::setRollingPolicy;
- <pre><?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE log4j:configuration>
+ using RollingFileAppenderSkeleton::setTriggeringPolicy;
- <log4j:configuration debug="true">
+};
- <appender name="ROLL" class="org.apache.log4j.rolling.RollingFileAppender">
- <b><rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
- <param name="FileNamePattern" value="/wombat/foo.%d{yyyy-MM}.gz"/>
- </rollingPolicy></b>
+LOG4CXX_PTR_DEF(RollingFileAppender);
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%c{1} - %m%n"/>
- </layout>
- </appender>
-
- <root">
- <appender-ref ref="ROLL"/>
- </root>
-
- </log4j:configuration>
- </pre>
-
- *<p>This configuration file specifies a monthly rollover schedule including
- * automatic compression of the archived files. See
- * {@link TimeBasedRollingPolicy} for more details.
- *
- *
- *
- *
- * */
- class LOG4CXX_EXPORT RollingFileAppender : public RollingFileAppenderSkeleton {
- DECLARE_LOG4CXX_OBJECT(RollingFileAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(RollingFileAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(RollingFileAppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
-
- public:
- RollingFileAppender();
-
- using RollingFileAppenderSkeleton::getRollingPolicy;
-
- using RollingFileAppenderSkeleton::getTriggeringPolicy;
-
- /**
- * Sets the rolling policy. In case the 'policy' argument also implements
- * {@link TriggeringPolicy}, then the triggering policy for this appender
- * is automatically set to be the policy argument.
- * @param policy
- */
- using RollingFileAppenderSkeleton::setRollingPolicy;
-
- using RollingFileAppenderSkeleton::setTriggeringPolicy;
-
- };
-
- LOG4CXX_PTR_DEF(RollingFileAppender);
-
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/rolling/rollingfileappenderskeleton.h b/src/main/include/log4cxx/rolling/rollingfileappenderskeleton.h
index 40568c7..1eb648f 100644
--- a/src/main/include/log4cxx/rolling/rollingfileappenderskeleton.h
+++ b/src/main/include/log4cxx/rolling/rollingfileappenderskeleton.h
@@ -25,150 +25,153 @@
#include <log4cxx/rolling/rollingpolicy.h>
#include <log4cxx/rolling/action.h>
-namespace log4cxx {
- namespace rolling {
+namespace log4cxx
+{
+namespace rolling
+{
+
+
+/**
+ * Base class for log4cxx::rolling::RollingFileAppender and log4cxx::RollingFileAppender
+ * (analogues of org.apache.log4j.rolling.RFA from extras companion and
+ * org.apache.log4j.RFA from log4j 1.2, respectively).
+ *
+ * */
+class LOG4CXX_EXPORT RollingFileAppenderSkeleton : public FileAppender
+{
+ DECLARE_LOG4CXX_OBJECT(RollingFileAppenderSkeleton)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(RollingFileAppenderSkeleton)
+ LOG4CXX_CAST_ENTRY_CHAIN(FileAppender)
+ END_LOG4CXX_CAST_MAP()
+
+ /**
+ * Triggering policy.
+ */
+ TriggeringPolicyPtr triggeringPolicy;
+
+ /**
+ * Rolling policy.
+ */
+ RollingPolicyPtr rollingPolicy;
+
+ /**
+ * Length of current active log file.
+ */
+ size_t fileLength;
+
+ /**
+ * save the loggingevent
+ */
+ spi::LoggingEventPtr* _event;
+ public:
+ /**
+ * The default constructor simply calls its {@link
+ * FileAppender#FileAppender parents constructor}.
+ * */
+ RollingFileAppenderSkeleton();
+
+ void activateOptions(log4cxx::helpers::Pool&);
/**
- * Base class for log4cxx::rolling::RollingFileAppender and log4cxx::RollingFileAppender
- * (analogues of org.apache.log4j.rolling.RFA from extras companion and
- * org.apache.log4j.RFA from log4j 1.2, respectively).
- *
- * */
- class LOG4CXX_EXPORT RollingFileAppenderSkeleton : public FileAppender {
- DECLARE_LOG4CXX_OBJECT(RollingFileAppenderSkeleton)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(RollingFileAppenderSkeleton)
- LOG4CXX_CAST_ENTRY_CHAIN(FileAppender)
- END_LOG4CXX_CAST_MAP()
+ Implements the usual roll over behaviour.
- /**
- * Triggering policy.
- */
- TriggeringPolicyPtr triggeringPolicy;
+ <p>If <code>MaxBackupIndex</code> is positive, then files
+ {<code>File.1</code>, ..., <code>File.MaxBackupIndex -1</code>}
+ are renamed to {<code>File.2</code>, ...,
+ <code>File.MaxBackupIndex</code>}. Moreover, <code>File</code> is
+ renamed <code>File.1</code> and closed. A new <code>File</code> is
+ created to receive further log output.
- /**
- * Rolling policy.
- */
- RollingPolicyPtr rollingPolicy;
+ <p>If <code>MaxBackupIndex</code> is equal to zero, then the
+ <code>File</code> is truncated with no backup files created.
- /**
- * Length of current active log file.
- */
- size_t fileLength;
+ */
+ bool rollover(log4cxx::helpers::Pool& p);
- /**
- * save the loggingevent
- */
- spi::LoggingEventPtr* _event;
- public:
- /**
- * The default constructor simply calls its {@link
- * FileAppender#FileAppender parents constructor}.
- * */
- RollingFileAppenderSkeleton();
-
- void activateOptions(log4cxx::helpers::Pool&);
-
-
- /**
- Implements the usual roll over behaviour.
-
- <p>If <code>MaxBackupIndex</code> is positive, then files
- {<code>File.1</code>, ..., <code>File.MaxBackupIndex -1</code>}
- are renamed to {<code>File.2</code>, ...,
- <code>File.MaxBackupIndex</code>}. Moreover, <code>File</code> is
- renamed <code>File.1</code> and closed. A new <code>File</code> is
- created to receive further log output.
-
- <p>If <code>MaxBackupIndex</code> is equal to zero, then the
- <code>File</code> is truncated with no backup files created.
-
- */
- bool rollover(log4cxx::helpers::Pool& p);
-
- protected:
+ protected:
/**
Actual writing occurs here.
*/
virtual void subAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
- protected:
+ protected:
- RollingPolicyPtr getRollingPolicy() const;
+ RollingPolicyPtr getRollingPolicy() const;
- TriggeringPolicyPtr getTriggeringPolicy() const;
+ TriggeringPolicyPtr getTriggeringPolicy() const;
- /**
- * Sets the rolling policy. In case the 'policy' argument also implements
- * {@link TriggeringPolicy}, then the triggering policy for this appender
- * is automatically set to be the policy argument.
- * @param policy
- */
- void setRollingPolicy(const RollingPolicyPtr& policy);
+ /**
+ * Sets the rolling policy. In case the 'policy' argument also implements
+ * {@link TriggeringPolicy}, then the triggering policy for this appender
+ * is automatically set to be the policy argument.
+ * @param policy
+ */
+ void setRollingPolicy(const RollingPolicyPtr& policy);
- void setTriggeringPolicy(const TriggeringPolicyPtr& policy);
+ void setTriggeringPolicy(const TriggeringPolicyPtr& policy);
- public:
- /**
- * Close appender. Waits for any asynchronous file compression actions to be completed.
- */
- void close();
+ public:
+ /**
+ * Close appender. Waits for any asynchronous file compression actions to be completed.
+ */
+ void close();
- protected:
- /**
- 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.
- @param os output stream, may not be null.
- @return new writer.
- */
- log4cxx::helpers::WriterPtr createWriter(log4cxx::helpers::OutputStreamPtr& os);
+ protected:
+ /**
+ 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.
+ @param os output stream, may not be null.
+ @return new writer.
+ */
+ log4cxx::helpers::WriterPtr createWriter(log4cxx::helpers::OutputStreamPtr& os);
- public:
+ public:
- /**
- * Get byte length of current active log file.
- * @return byte length of current active log file.
- */
- size_t getFileLength() const;
+ /**
+ * Get byte length of current active log file.
+ * @return byte length of current active log file.
+ */
+ size_t getFileLength() const;
#ifdef LOG4CXX_MULTI_PROCESS
- /**
- * Set byte length of current active log file.
- * @return void
- */
- void setFileLength(size_t length);
+ /**
+ * Set byte length of current active log file.
+ * @return void
+ */
+ void setFileLength(size_t length);
- /**
- * Release the file lock
- * @return void
- */
- void releaseFileLock(apr_file_t* lock_file);
- /**
- * re-open the latest file when its own handler has been renamed
- * @return void
- */
- void reopenLatestFile(log4cxx::helpers::Pool& p);
+ /**
+ * Release the file lock
+ * @return void
+ */
+ void releaseFileLock(apr_file_t* lock_file);
+ /**
+ * re-open the latest file when its own handler has been renamed
+ * @return void
+ */
+ void reopenLatestFile(log4cxx::helpers::Pool& p);
#endif
- /**
- * Increments estimated byte length of current active log file.
- * @param increment additional bytes written to log file.
- */
- void incrementFileLength(size_t increment);
+ /**
+ * Increments estimated byte length of current active log file.
+ * @param increment additional bytes written to log file.
+ */
+ void incrementFileLength(size_t increment);
- };
+};
- LOG4CXX_PTR_DEF(RollingFileAppenderSkeleton);
+LOG4CXX_PTR_DEF(RollingFileAppenderSkeleton);
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/rolling/rollingpolicy.h b/src/main/include/log4cxx/rolling/rollingpolicy.h
index 04a834d..dda944f 100644
--- a/src/main/include/log4cxx/rolling/rollingpolicy.h
+++ b/src/main/include/log4cxx/rolling/rollingpolicy.h
@@ -23,64 +23,67 @@
#include <log4cxx/rolling/rolloverdescription.h>
#include <log4cxx/file.h>
-namespace log4cxx {
- namespace rolling {
+namespace log4cxx
+{
+namespace rolling
+{
- /**
- * A <code>RollingPolicy</code> is responsible for performing the
- * rolling over of the active log file. The <code>RollingPolicy</code>
- * is also responsible for providing the <em>active log file</em>,
- * that is the live file where logging output will be directed.
- *
- *
- *
- *
- */
- class LOG4CXX_EXPORT RollingPolicy :
- public virtual spi::OptionHandler {
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(RollingPolicy)
+/**
+ * A <code>RollingPolicy</code> is responsible for performing the
+ * rolling over of the active log file. The <code>RollingPolicy</code>
+ * is also responsible for providing the <em>active log file</em>,
+ * that is the live file where logging output will be directed.
+ *
+ *
+ *
+ *
+*/
+class LOG4CXX_EXPORT RollingPolicy :
+ public virtual spi::OptionHandler
+{
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(RollingPolicy)
- public:
+ public:
virtual ~RollingPolicy() {}
- /**
- * Initialize the policy and return any initial actions for rolling file appender.
- *
- * @param currentActiveFile current value of RollingFileAppender.getFile().
- * @param append current value of RollingFileAppender.getAppend().
- * @param pool pool for memory allocations during call.
- * @return Description of the initialization, may be null to indicate
- * no initialization needed.
- * @throws SecurityException if denied access to log files.
- */
- virtual RolloverDescriptionPtr initialize(
- const LogString& currentActiveFile,
- const bool append,
- log4cxx::helpers::Pool& pool) = 0;
+ /**
+ * Initialize the policy and return any initial actions for rolling file appender.
+ *
+ * @param currentActiveFile current value of RollingFileAppender.getFile().
+ * @param append current value of RollingFileAppender.getAppend().
+ * @param pool pool for memory allocations during call.
+ * @return Description of the initialization, may be null to indicate
+ * no initialization needed.
+ * @throws SecurityException if denied access to log files.
+ */
+ virtual RolloverDescriptionPtr initialize(
+ const LogString& currentActiveFile,
+ const bool append,
+ log4cxx::helpers::Pool& pool) = 0;
- /**
- * Prepare for a rollover. This method is called prior to
- * closing the active log file, performs any necessary
- * preliminary actions and describes actions needed
- * after close of current log file.
- *
- * @param currentActiveFile file name for current active log file.
- * @param append current value of the parent FileAppender.getAppend().
- * @param pool pool for memory allocations during call.
- * @return Description of pending rollover, may be null to indicate no rollover
- * at this time.
- * @throws SecurityException if denied access to log files.
- */
- virtual RolloverDescriptionPtr rollover(
- const LogString& currentActiveFile,
- const bool append,
- log4cxx::helpers::Pool& pool) = 0;
- };
+ /**
+ * Prepare for a rollover. This method is called prior to
+ * closing the active log file, performs any necessary
+ * preliminary actions and describes actions needed
+ * after close of current log file.
+ *
+ * @param currentActiveFile file name for current active log file.
+ * @param append current value of the parent FileAppender.getAppend().
+ * @param pool pool for memory allocations during call.
+ * @return Description of pending rollover, may be null to indicate no rollover
+ * at this time.
+ * @throws SecurityException if denied access to log files.
+ */
+ virtual RolloverDescriptionPtr rollover(
+ const LogString& currentActiveFile,
+ const bool append,
+ log4cxx::helpers::Pool& pool) = 0;
+};
- LOG4CXX_PTR_DEF(RollingPolicy);
+LOG4CXX_PTR_DEF(RollingPolicy);
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/rolling/rollingpolicybase.h b/src/main/include/log4cxx/rolling/rollingpolicybase.h
index 4011a62..630bcd6 100644
--- a/src/main/include/log4cxx/rolling/rollingpolicybase.h
+++ b/src/main/include/log4cxx/rolling/rollingpolicybase.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_ROLLING_ROLLING_POLICY_BASE_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
@@ -32,100 +32,106 @@
#include <log4cxx/pattern/formattinginfo.h>
#include <log4cxx/pattern/patternparser.h>
-namespace log4cxx {
- namespace rolling {
- LOG4CXX_LIST_DEF(PatternConverterList, log4cxx::pattern::PatternConverterPtr);
- LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
+namespace log4cxx
+{
+namespace rolling
+{
+LOG4CXX_LIST_DEF(PatternConverterList, log4cxx::pattern::PatternConverterPtr);
+LOG4CXX_LIST_DEF(FormattingInfoList, log4cxx::pattern::FormattingInfoPtr);
+
+/**
+ * Implements methods common to most, it not all, rolling
+ * policies.
+ *
+ *
+ *
+ */
+class LOG4CXX_EXPORT RollingPolicyBase :
+ public virtual RollingPolicy,
+ public virtual helpers::ObjectImpl
+{
+ protected:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(RollingPolicyBase)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(RollingPolicy)
+ LOG4CXX_CAST_ENTRY(spi::OptionHandler)
+ END_LOG4CXX_CAST_MAP()
+
+
+ private:
+ /**
+ * File name pattern converters.
+ */
+ PatternConverterList patternConverters;
/**
- * Implements methods common to most, it not all, rolling
- * policies.
- *
- *
- *
+ * File name field specifiers.
*/
- class LOG4CXX_EXPORT RollingPolicyBase :
- public virtual RollingPolicy,
- public virtual helpers::ObjectImpl {
- protected:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(RollingPolicyBase)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(RollingPolicy)
- LOG4CXX_CAST_ENTRY(spi::OptionHandler)
- END_LOG4CXX_CAST_MAP()
+ FormattingInfoList patternFields;
+
+ /**
+ * File name pattern.
+ */
+ LogString fileNamePatternStr;
- private:
- /**
- * File name pattern converters.
- */
- PatternConverterList patternConverters;
+ public:
+ RollingPolicyBase();
+ virtual ~RollingPolicyBase();
+ void addRef() const;
+ void releaseRef() const;
+ virtual void activateOptions(log4cxx::helpers::Pool& p) = 0;
+ virtual log4cxx::pattern::PatternMap getFormatSpecifiers() const = 0;
- /**
- * File name field specifiers.
- */
- FormattingInfoList patternFields;
+ virtual void setOption(const LogString& option,
+ const LogString& value);
- /**
- * File name pattern.
- */
- LogString fileNamePatternStr;
+ /**
+ * Set file name pattern.
+ * @param fnp file name pattern.
+ */
+ void setFileNamePattern(const LogString& fnp);
-
- public:
- RollingPolicyBase();
- virtual ~RollingPolicyBase();
- void addRef() const;
- void releaseRef() const;
- virtual void activateOptions(log4cxx::helpers::Pool& p) = 0;
- virtual log4cxx::pattern::PatternMap getFormatSpecifiers() const = 0;
-
- virtual void setOption(const LogString& option,
- const LogString& value);
-
- /**
- * Set file name pattern.
- * @param fnp file name pattern.
- */
- void setFileNamePattern(const LogString& fnp);
-
- /**
- * Get file name pattern.
- * @return file name pattern.
- */
- LogString getFileNamePattern() const;
+ /**
+ * Get file name pattern.
+ * @return file name pattern.
+ */
+ LogString getFileNamePattern() const;
#ifdef LOG4CXX_MULTI_PROCESS
- PatternConverterList getPatternConverterList() { return patternConverters; }
+ PatternConverterList getPatternConverterList()
+ {
+ return patternConverters;
+ }
#endif
- protected:
- /**
- * Parse file name pattern.
- */
- void parseFileNamePattern();
+ protected:
+ /**
+ * Parse file name pattern.
+ */
+ void parseFileNamePattern();
- /**
- * Format file name.
- *
- * @param obj object to be evaluted in formatting, may not be null.
- * @param buf string buffer to which formatted file name is appended, may not be null.
- * @param p memory pool.
- */
- void formatFileName(log4cxx::helpers::ObjectPtr& obj,
- LogString& buf, log4cxx::helpers::Pool& p) const;
+ /**
+ * Format file name.
+ *
+ * @param obj object to be evaluted in formatting, may not be null.
+ * @param buf string buffer to which formatted file name is appended, may not be null.
+ * @param p memory pool.
+ */
+ void formatFileName(log4cxx::helpers::ObjectPtr& obj,
+ LogString& buf, log4cxx::helpers::Pool& p) const;
- log4cxx::pattern::PatternConverterPtr getIntegerPatternConverter() const;
- log4cxx::pattern::PatternConverterPtr getDatePatternConverter() const;
+ log4cxx::pattern::PatternConverterPtr getIntegerPatternConverter() const;
+ log4cxx::pattern::PatternConverterPtr getDatePatternConverter() const;
- };
- }
+};
+}
}
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif
diff --git a/src/main/include/log4cxx/rolling/rolloverdescription.h b/src/main/include/log4cxx/rolling/rolloverdescription.h
index 4e01fca..892e0ff 100644
--- a/src/main/include/log4cxx/rolling/rolloverdescription.h
+++ b/src/main/include/log4cxx/rolling/rolloverdescription.h
@@ -21,81 +21,84 @@
#include <log4cxx/portability.h>
#include <log4cxx/rolling/action.h>
-namespace log4cxx {
- namespace rolling {
+namespace log4cxx
+{
+namespace rolling
+{
- class RolloverDescription : public log4cxx::helpers::ObjectImpl {
- DECLARE_LOG4CXX_OBJECT(RolloverDescription)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(RolloverDescription)
- END_LOG4CXX_CAST_MAP()
- /**
- * Active log file name after rollover.
- */
- LogString activeFileName;
+class RolloverDescription : public log4cxx::helpers::ObjectImpl
+{
+ DECLARE_LOG4CXX_OBJECT(RolloverDescription)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(RolloverDescription)
+ END_LOG4CXX_CAST_MAP()
+ /**
+ * Active log file name after rollover.
+ */
+ LogString activeFileName;
- /**
- * Should active file be opened for appending.
- */
- bool append;
+ /**
+ * Should active file be opened for appending.
+ */
+ bool append;
- /**
- * Action to be completed after close of current active log file
- * before returning control to caller.
- */
- ActionPtr synchronous;
+ /**
+ * Action to be completed after close of current active log file
+ * before returning control to caller.
+ */
+ ActionPtr synchronous;
- /**
- * Action to be completed after close of current active log file
- * and before next rollover attempt, may be executed asynchronously.
- */
- ActionPtr asynchronous;
+ /**
+ * Action to be completed after close of current active log file
+ * and before next rollover attempt, may be executed asynchronously.
+ */
+ ActionPtr asynchronous;
- public:
- RolloverDescription();
- /**
- * Create new instance.
- * @param activeFileName active log file name after rollover, may not be null.
- * @param append true if active log file after rollover should be opened for appending.
- * @param synchronous action to be completed after close of current active log file, may be null.
- * @param asynchronous action to be completed after close of current active log file and
- * before next rollover attempt.
- */
- RolloverDescription(
+ public:
+ RolloverDescription();
+ /**
+ * Create new instance.
+ * @param activeFileName active log file name after rollover, may not be null.
+ * @param append true if active log file after rollover should be opened for appending.
+ * @param synchronous action to be completed after close of current active log file, may be null.
+ * @param asynchronous action to be completed after close of current active log file and
+ * before next rollover attempt.
+ */
+ RolloverDescription(
const LogString& activeFileName,
const bool append,
const ActionPtr& synchronous,
const ActionPtr& asynchronous);
- /**
- * Active log file name after rollover.
- * @return active log file name after rollover.
- */
- LogString getActiveFileName() const;
+ /**
+ * Active log file name after rollover.
+ * @return active log file name after rollover.
+ */
+ LogString getActiveFileName() const;
- bool getAppend() const;
+ bool getAppend() const;
- /**
- * Action to be completed after close of current active log file
- * before returning control to caller.
- *
- * @return action, may be null.
- */
- ActionPtr getSynchronous() const;
+ /**
+ * Action to be completed after close of current active log file
+ * before returning control to caller.
+ *
+ * @return action, may be null.
+ */
+ ActionPtr getSynchronous() const;
- /**
- * Action to be completed after close of current active log file
- * and before next rollover attempt, may be executed asynchronously.
- *
- * @return action, may be null.
- */
- ActionPtr getAsynchronous() const;
- };
+ /**
+ * Action to be completed after close of current active log file
+ * and before next rollover attempt, may be executed asynchronously.
+ *
+ * @return action, may be null.
+ */
+ ActionPtr getAsynchronous() const;
+};
- LOG4CXX_PTR_DEF(RolloverDescription);
+LOG4CXX_PTR_DEF(RolloverDescription);
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/rolling/sizebasedtriggeringpolicy.h b/src/main/include/log4cxx/rolling/sizebasedtriggeringpolicy.h
index 918d691..86b6083 100644
--- a/src/main/include/log4cxx/rolling/sizebasedtriggeringpolicy.h
+++ b/src/main/include/log4cxx/rolling/sizebasedtriggeringpolicy.h
@@ -20,63 +20,67 @@
#include <log4cxx/rolling/triggeringpolicy.h>
-namespace log4cxx {
+namespace log4cxx
+{
- class File;
+class File;
- namespace helpers {
- class Pool;
- }
+namespace helpers
+{
+class Pool;
+}
- namespace rolling {
+namespace rolling
+{
+/**
+ * SizeBasedTriggeringPolicy looks at size of the file being
+ * currently written to.
+ *
+ *
+ *
+ */
+class LOG4CXX_EXPORT SizeBasedTriggeringPolicy : public TriggeringPolicy
+{
+ DECLARE_LOG4CXX_OBJECT(SizeBasedTriggeringPolicy)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(SizeBasedTriggeringPolicy)
+ LOG4CXX_CAST_ENTRY_CHAIN(TriggeringPolicy)
+ END_LOG4CXX_CAST_MAP()
+
+ protected:
+ size_t maxFileSize;
+
+ public:
+ SizeBasedTriggeringPolicy();
/**
- * SizeBasedTriggeringPolicy looks at size of the file being
- * currently written to.
+ * Determines if a rollover may be appropriate at this time. If
+ * true is returned, RolloverPolicy.rollover will be called but it
+ * can determine that a rollover is not warranted.
*
- *
- *
+ * @param appender A reference to the appender.
+ * @param event A reference to the currently event.
+ * @param filename The filename for the currently active log file.
+ * @param fileLength Length of the file in bytes.
+ * @return true if a rollover should occur.
*/
- class LOG4CXX_EXPORT SizeBasedTriggeringPolicy : public TriggeringPolicy {
- DECLARE_LOG4CXX_OBJECT(SizeBasedTriggeringPolicy)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(SizeBasedTriggeringPolicy)
- LOG4CXX_CAST_ENTRY_CHAIN(TriggeringPolicy)
- END_LOG4CXX_CAST_MAP()
+ virtual bool isTriggeringEvent(
+ Appender* appender,
+ const log4cxx::spi::LoggingEventPtr& event,
+ const LogString& filename,
+ size_t fileLength);
- protected:
- size_t maxFileSize;
+ size_t getMaxFileSize();
- public:
- SizeBasedTriggeringPolicy();
- /**
- * Determines if a rollover may be appropriate at this time. If
- * true is returned, RolloverPolicy.rollover will be called but it
- * can determine that a rollover is not warranted.
- *
- * @param appender A reference to the appender.
- * @param event A reference to the currently event.
- * @param filename The filename for the currently active log file.
- * @param fileLength Length of the file in bytes.
- * @return true if a rollover should occur.
- */
- virtual bool isTriggeringEvent(
- Appender* appender,
- const log4cxx::spi::LoggingEventPtr& event,
- const LogString& filename,
- size_t fileLength);
+ void setMaxFileSize(size_t l);
- size_t getMaxFileSize();
+ void activateOptions(log4cxx::helpers::Pool&);
+ void setOption(const LogString& option, const LogString& value);
+};
- void setMaxFileSize(size_t l);
+LOG4CXX_PTR_DEF(SizeBasedTriggeringPolicy);
- void activateOptions(log4cxx::helpers::Pool&);
- void setOption(const LogString& option, const LogString& value);
- };
-
- LOG4CXX_PTR_DEF(SizeBasedTriggeringPolicy);
-
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
index 4491b0b..e3ced73 100755
--- a/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
+++ b/src/main/include/log4cxx/rolling/timebasedrollingpolicy.h
@@ -26,126 +26,129 @@
#include <log4cxx/helpers/outputstream.h>
#include <apr_mmap.h>
-namespace log4cxx {
+namespace log4cxx
+{
- namespace rolling {
+namespace rolling
+{
- /**
- * <code>TimeBasedRollingPolicy</code> is both easy to configure and quite
- * powerful.
- *
- * <p>In order to use <code>TimeBasedRollingPolicy</code>, the
- * <b>FileNamePattern</b> option must be set. It basically specifies the name of the
- * rolled log files. The value <code>FileNamePattern</code> should consist of
- * the name of the file, plus a suitably placed <code>%d</code> conversion
- * specifier. The <code>%d</code> conversion specifier may contain a date and
- * time pattern as specified by the {@link log4cxx::helpers::SimpleDateFormat} class. If
- * the date and time pattern is ommitted, then the default pattern of
- * "yyyy-MM-dd" is assumed. The following examples should clarify the point.
- *
- * <p>
- * <table cellspacing="5px" border="1">
- * <tr>
- * <th><code>FileNamePattern</code> value</th>
- * <th>Rollover schedule</th>
- * <th>Example</th>
- * </tr>
- * <tr>
- * <td nowrap="true"><code>/wombat/folder/foo.%d</code></td>
- * <td>Daily rollover (at midnight). Due to the omission of the optional
- * time and date pattern for the %d token specifier, the default pattern
- * of "yyyy-MM-dd" is assumed, which corresponds to daily rollover.
- * </td>
- * <td>During November 23rd, 2004, logging output will go to
- * the file <code>/wombat/foo.2004-11-23</code>. At midnight and for
- * the rest of the 24th, logging output will be directed to
- * <code>/wombat/foo.2004-11-24</code>.
- * </td>
- * </tr>
- * <tr>
- * <td nowrap="true"><code>/wombat/foo.%d{yyyy-MM}.log</code></td>
- * <td>Rollover at the beginning of each month.</td>
- * <td>During the month of October 2004, logging output will go to
- * <code>/wombat/foo.2004-10.log</code>. After midnight of October 31st
- * and for the rest of November, logging output will be directed to
- * <code>/wombat/foo.2004-11.log</code>.
- * </td>
- * </tr>
- * </table>
- * <h2>Automatic file compression</h2>
- * <code>TimeBasedRollingPolicy</code> supports automatic file compression.
- * This feature is enabled if the value of the <b>FileNamePattern</b> option
- * ends with <code>.gz</code> or <code>.zip</code>.
- * <p>
- * <table cellspacing="5px" border="1">
- * <tr>
- * <th><code>FileNamePattern</code> value</th>
- * <th>Rollover schedule</th>
- * <th>Example</th>
- * </tr>
- * <tr>
- * <td nowrap="true"><code>/wombat/foo.%d.gz</code></td>
- * <td>Daily rollover (at midnight) with automatic GZIP compression of the
- * arcived files.</td>
- * <td>During November 23rd, 2004, logging output will go to
- * the file <code>/wombat/foo.2004-11-23</code>. However, at midnight that
- * file will be compressed to become <code>/wombat/foo.2004-11-23.gz</code>.
- * For the 24th of November, logging output will be directed to
- * <code>/wombat/folder/foo.2004-11-24</code> until its rolled over at the
- * beginning of the next day.
- * </td>
- * </tr>
- * </table>
- *
- * <h2>Decoupling the location of the active log file and the archived log files</h2>
- * <p>The <em>active file</em> is defined as the log file for the current period
- * whereas <em>archived files</em> are thos files which have been rolled over
- * in previous periods.
- *
- * <p>By setting the <b>ActiveFileName</b> option you can decouple the location
- * of the active log file and the location of the archived log files.
- * <p>
- * <table cellspacing="5px" border="1">
- * <tr>
- * <th><code>FileNamePattern</code> value</th>
- * <th>ActiveFileName</th>
- * <th>Rollover schedule</th>
- * <th>Example</th>
- * </tr>
- * <tr>
- * <td nowrap="true"><code>/wombat/foo.log.%d</code></td>
- * <td nowrap="true"><code>/wombat/foo.log</code></td>
- * <td>Daily rollover.</td>
- *
- * <td>During November 23rd, 2004, logging output will go to
- * the file <code>/wombat/foo.log</code>. However, at midnight that file
- * will archived as <code>/wombat/foo.log.2004-11-23</code>. For the 24th
- * of November, logging output will be directed to
- * <code>/wombat/folder/foo.log</code> until its archived as
- * <code>/wombat/foo.log.2004-11-24</code> at the beginning of the next
- * day.
- * </td>
- * </tr>
- * </table>
- * <p>
- * If configuring programatically, do not forget to call {@link #activateOptions}
- * method before using this policy. Moreover, {@link #activateOptions} of
- * <code> TimeBasedRollingPolicy</code> must be called <em>before</em> calling
- * the {@link #activateOptions} method of the owning
- * <code>RollingFileAppender</code>.
- */
- class LOG4CXX_EXPORT TimeBasedRollingPolicy : public RollingPolicyBase,
- public TriggeringPolicy {
- DECLARE_LOG4CXX_OBJECT(TimeBasedRollingPolicy)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(TimeBasedRollingPolicy)
- LOG4CXX_CAST_ENTRY_CHAIN(RollingPolicyBase)
- LOG4CXX_CAST_ENTRY_CHAIN(TriggeringPolicy)
- END_LOG4CXX_CAST_MAP()
+/**
+ * <code>TimeBasedRollingPolicy</code> is both easy to configure and quite
+ * powerful.
+ *
+ * <p>In order to use <code>TimeBasedRollingPolicy</code>, the
+ * <b>FileNamePattern</b> option must be set. It basically specifies the name of the
+ * rolled log files. The value <code>FileNamePattern</code> should consist of
+ * the name of the file, plus a suitably placed <code>%d</code> conversion
+ * specifier. The <code>%d</code> conversion specifier may contain a date and
+ * time pattern as specified by the {@link log4cxx::helpers::SimpleDateFormat} class. If
+ * the date and time pattern is ommitted, then the default pattern of
+ * "yyyy-MM-dd" is assumed. The following examples should clarify the point.
+ *
+ * <p>
+ * <table cellspacing="5px" border="1">
+ * <tr>
+ * <th><code>FileNamePattern</code> value</th>
+ * <th>Rollover schedule</th>
+ * <th>Example</th>
+ * </tr>
+ * <tr>
+ * <td nowrap="true"><code>/wombat/folder/foo.%d</code></td>
+ * <td>Daily rollover (at midnight). Due to the omission of the optional
+ * time and date pattern for the %d token specifier, the default pattern
+ * of "yyyy-MM-dd" is assumed, which corresponds to daily rollover.
+ * </td>
+ * <td>During November 23rd, 2004, logging output will go to
+ * the file <code>/wombat/foo.2004-11-23</code>. At midnight and for
+ * the rest of the 24th, logging output will be directed to
+ * <code>/wombat/foo.2004-11-24</code>.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td nowrap="true"><code>/wombat/foo.%d{yyyy-MM}.log</code></td>
+ * <td>Rollover at the beginning of each month.</td>
+ * <td>During the month of October 2004, logging output will go to
+ * <code>/wombat/foo.2004-10.log</code>. After midnight of October 31st
+ * and for the rest of November, logging output will be directed to
+ * <code>/wombat/foo.2004-11.log</code>.
+ * </td>
+ * </tr>
+ * </table>
+ * <h2>Automatic file compression</h2>
+ * <code>TimeBasedRollingPolicy</code> supports automatic file compression.
+ * This feature is enabled if the value of the <b>FileNamePattern</b> option
+ * ends with <code>.gz</code> or <code>.zip</code>.
+ * <p>
+ * <table cellspacing="5px" border="1">
+ * <tr>
+ * <th><code>FileNamePattern</code> value</th>
+ * <th>Rollover schedule</th>
+ * <th>Example</th>
+ * </tr>
+ * <tr>
+ * <td nowrap="true"><code>/wombat/foo.%d.gz</code></td>
+ * <td>Daily rollover (at midnight) with automatic GZIP compression of the
+ * arcived files.</td>
+ * <td>During November 23rd, 2004, logging output will go to
+ * the file <code>/wombat/foo.2004-11-23</code>. However, at midnight that
+ * file will be compressed to become <code>/wombat/foo.2004-11-23.gz</code>.
+ * For the 24th of November, logging output will be directed to
+ * <code>/wombat/folder/foo.2004-11-24</code> until its rolled over at the
+ * beginning of the next day.
+ * </td>
+ * </tr>
+ * </table>
+ *
+ * <h2>Decoupling the location of the active log file and the archived log files</h2>
+ * <p>The <em>active file</em> is defined as the log file for the current period
+ * whereas <em>archived files</em> are thos files which have been rolled over
+ * in previous periods.
+ *
+ * <p>By setting the <b>ActiveFileName</b> option you can decouple the location
+ * of the active log file and the location of the archived log files.
+ * <p>
+ * <table cellspacing="5px" border="1">
+ * <tr>
+ * <th><code>FileNamePattern</code> value</th>
+ * <th>ActiveFileName</th>
+ * <th>Rollover schedule</th>
+ * <th>Example</th>
+ * </tr>
+ * <tr>
+ * <td nowrap="true"><code>/wombat/foo.log.%d</code></td>
+ * <td nowrap="true"><code>/wombat/foo.log</code></td>
+ * <td>Daily rollover.</td>
+ *
+ * <td>During November 23rd, 2004, logging output will go to
+ * the file <code>/wombat/foo.log</code>. However, at midnight that file
+ * will archived as <code>/wombat/foo.log.2004-11-23</code>. For the 24th
+ * of November, logging output will be directed to
+ * <code>/wombat/folder/foo.log</code> until its archived as
+ * <code>/wombat/foo.log.2004-11-24</code> at the beginning of the next
+ * day.
+ * </td>
+ * </tr>
+ * </table>
+ * <p>
+ * If configuring programatically, do not forget to call {@link #activateOptions}
+ * method before using this policy. Moreover, {@link #activateOptions} of
+ * <code> TimeBasedRollingPolicy</code> must be called <em>before</em> calling
+ * the {@link #activateOptions} method of the owning
+ * <code>RollingFileAppender</code>.
+ */
+class LOG4CXX_EXPORT TimeBasedRollingPolicy : public RollingPolicyBase,
+ public TriggeringPolicy
+{
+ DECLARE_LOG4CXX_OBJECT(TimeBasedRollingPolicy)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(TimeBasedRollingPolicy)
+ LOG4CXX_CAST_ENTRY_CHAIN(RollingPolicyBase)
+ LOG4CXX_CAST_ENTRY_CHAIN(TriggeringPolicy)
+ END_LOG4CXX_CAST_MAP()
- private:
+ private:
/**
* Time for next determination if time for rollover.
*/
@@ -206,87 +209,87 @@
*/
int suffixLength;
- public:
- TimeBasedRollingPolicy();
- void addRef() const;
- void releaseRef() const;
- void activateOptions(log4cxx::helpers::Pool& );
+ public:
+ TimeBasedRollingPolicy();
+ void addRef() const;
+ void releaseRef() const;
+ void activateOptions(log4cxx::helpers::Pool& );
#ifdef LOG4CXX_MULTI_PROCESS
- virtual ~TimeBasedRollingPolicy();
+ virtual ~TimeBasedRollingPolicy();
- /**
- * Generate mmap file
- */
- int createMMapFile(const std::string& lastfilename, log4cxx::helpers::Pool& pool);
+ /**
+ * Generate mmap file
+ */
+ int createMMapFile(const std::string& lastfilename, log4cxx::helpers::Pool& pool);
- /**
- * Detect if the mmap file is empty
- */
- bool isMapFileEmpty(log4cxx::helpers::Pool& pool);
+ /**
+ * Detect if the mmap file is empty
+ */
+ bool isMapFileEmpty(log4cxx::helpers::Pool& pool);
- /**
- * init MMapFile
- */
- void initMMapFile(const LogString& lastFileName, log4cxx::helpers::Pool& pool);
+ /**
+ * init MMapFile
+ */
+ void initMMapFile(const LogString& lastFileName, log4cxx::helpers::Pool& pool);
- /**
- * lock MMapFile
- */
- int lockMMapFile(int type);
+ /**
+ * lock MMapFile
+ */
+ int lockMMapFile(int type);
- /**
- * unlock MMapFile
- */
- int unLockMMapFile();
+ /**
+ * unlock MMapFile
+ */
+ int unLockMMapFile();
- /**
- * create MMapFile/lockFile
- */
- const std::string createFile(const std::string& filename, const std::string& suffix, log4cxx::helpers::Pool& pool);
+ /**
+ * create MMapFile/lockFile
+ */
+ const std::string createFile(const std::string& filename, const std::string& suffix, log4cxx::helpers::Pool& pool);
#endif
- /**
- * {@inheritDoc}
- */
- RolloverDescriptionPtr initialize(
- const LogString& currentActiveFile,
- const bool append,
- log4cxx::helpers::Pool& pool);
+ /**
+ * {@inheritDoc}
+ */
+ RolloverDescriptionPtr initialize(
+ const LogString& currentActiveFile,
+ const bool append,
+ log4cxx::helpers::Pool& pool);
- /**
- * {@inheritDoc}
- */
- RolloverDescriptionPtr rollover(
- const LogString& currentActiveFile,
- const bool append,
- log4cxx::helpers::Pool& pool);
+ /**
+ * {@inheritDoc}
+ */
+ RolloverDescriptionPtr rollover(
+ const LogString& currentActiveFile,
+ const bool append,
+ log4cxx::helpers::Pool& pool);
-/**
- * Determines if a rollover may be appropriate at this time. If
- * true is returned, RolloverPolicy.rollover will be called but it
- * can determine that a rollover is not warranted.
- *
- * @param appender A reference to the appender.
- * @param event A reference to the currently event.
- * @param filename The filename for the currently active log file.
- * @param fileLength Length of the file in bytes.
- * @return true if a rollover should occur.
- */
-virtual bool isTriggeringEvent(
- Appender* appender,
- const log4cxx::spi::LoggingEventPtr& event,
- const LogString& filename,
- size_t fileLength);
+ /**
+ * Determines if a rollover may be appropriate at this time. If
+ * true is returned, RolloverPolicy.rollover will be called but it
+ * can determine that a rollover is not warranted.
+ *
+ * @param appender A reference to the appender.
+ * @param event A reference to the currently event.
+ * @param filename The filename for the currently active log file.
+ * @param fileLength Length of the file in bytes.
+ * @return true if a rollover should occur.
+ */
+ virtual bool isTriggeringEvent(
+ Appender* appender,
+ const log4cxx::spi::LoggingEventPtr& event,
+ const LogString& filename,
+ size_t fileLength);
- protected:
- log4cxx::pattern::PatternMap getFormatSpecifiers() const;
+ protected:
+ log4cxx::pattern::PatternMap getFormatSpecifiers() const;
- };
+};
- LOG4CXX_PTR_DEF(TimeBasedRollingPolicy);
+LOG4CXX_PTR_DEF(TimeBasedRollingPolicy);
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/rolling/triggeringpolicy.h b/src/main/include/log4cxx/rolling/triggeringpolicy.h
index 7b53ef2..7c4c62b 100644
--- a/src/main/include/log4cxx/rolling/triggeringpolicy.h
+++ b/src/main/include/log4cxx/rolling/triggeringpolicy.h
@@ -25,56 +25,59 @@
#include <log4cxx/spi/loggingevent.h>
#include <log4cxx/appender.h>
-namespace log4cxx {
- class File;
+namespace log4cxx
+{
+class File;
- namespace rolling {
+namespace rolling
+{
+
+/**
+ * A <code>TriggeringPolicy</code> controls the conditions under which rollover
+ * occurs. Such conditions include time of day, file size, an
+ * external event or a combination thereof.
+ *
+ *
+ *
+ * */
+
+class LOG4CXX_EXPORT TriggeringPolicy :
+ public virtual spi::OptionHandler,
+ public virtual helpers::ObjectImpl
+{
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(TriggeringPolicy)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(TriggeringPolicy)
+ LOG4CXX_CAST_ENTRY(spi::OptionHandler)
+ END_LOG4CXX_CAST_MAP()
+ public:
+ virtual ~TriggeringPolicy();
+ void addRef() const;
+ void releaseRef() const;
/**
- * A <code>TriggeringPolicy</code> controls the conditions under which rollover
- * occurs. Such conditions include time of day, file size, an
- * external event or a combination thereof.
+ * Determines if a rollover may be appropriate at this time. If
+ * true is returned, RolloverPolicy.rollover will be called but it
+ * can determine that a rollover is not warranted.
*
- *
- *
- * */
+ * @param appender A reference to the appender.
+ * @param event A reference to the currently event.
+ * @param filename The filename for the currently active log file.
+ * @param fileLength Length of the file in bytes.
+ * @return true if a rollover should occur.
+ */
+ virtual bool isTriggeringEvent(
+ Appender* appender,
+ const log4cxx::spi::LoggingEventPtr& event,
+ const LogString& filename,
+ size_t fileLength) = 0;
- class LOG4CXX_EXPORT TriggeringPolicy :
- public virtual spi::OptionHandler,
- public virtual helpers::ObjectImpl {
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(TriggeringPolicy)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(TriggeringPolicy)
- LOG4CXX_CAST_ENTRY(spi::OptionHandler)
- END_LOG4CXX_CAST_MAP()
- public:
- virtual ~TriggeringPolicy();
- void addRef() const;
- void releaseRef() const;
+};
- /**
- * Determines if a rollover may be appropriate at this time. If
- * true is returned, RolloverPolicy.rollover will be called but it
- * can determine that a rollover is not warranted.
- *
- * @param appender A reference to the appender.
- * @param event A reference to the currently event.
- * @param filename The filename for the currently active log file.
- * @param fileLength Length of the file in bytes.
- * @return true if a rollover should occur.
- */
- virtual bool isTriggeringEvent(
- Appender* appender,
- const log4cxx::spi::LoggingEventPtr& event,
- const LogString& filename,
- size_t fileLength) = 0;
-
- };
-
- LOG4CXX_PTR_DEF(TriggeringPolicy);
+LOG4CXX_PTR_DEF(TriggeringPolicy);
- }
+}
}
#endif
diff --git a/src/main/include/log4cxx/rolling/zipcompressaction.h b/src/main/include/log4cxx/rolling/zipcompressaction.h
index 559326b..2e7b9fb 100644
--- a/src/main/include/log4cxx/rolling/zipcompressaction.h
+++ b/src/main/include/log4cxx/rolling/zipcompressaction.h
@@ -19,35 +19,38 @@
#define _LOG4CXX_ROLLING_ZIP_COMPRESS_ACTION_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/rolling/action.h>
#include <log4cxx/file.h>
-namespace log4cxx {
- namespace rolling {
+namespace log4cxx
+{
+namespace rolling
+{
- class ZipCompressAction : public Action {
- const File source;
- const File destination;
- bool deleteSource;
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(ZipCompressAction)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(ZipCompressAction)
- LOG4CXX_CAST_ENTRY_CHAIN(Action)
- END_LOG4CXX_CAST_MAP()
+class ZipCompressAction : public Action
+{
+ const File source;
+ const File destination;
+ bool deleteSource;
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(ZipCompressAction)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(ZipCompressAction)
+ LOG4CXX_CAST_ENTRY_CHAIN(Action)
+ END_LOG4CXX_CAST_MAP()
/**
* Constructor.
*/
ZipCompressAction(const File& source,
- const File& destination,
- bool deleteSource);
+ const File& destination,
+ bool deleteSource);
/**
* Perform action.
@@ -56,17 +59,17 @@
*/
virtual bool execute(log4cxx::helpers::Pool& pool) const;
- private:
+ private:
ZipCompressAction(const ZipCompressAction&);
ZipCompressAction& operator=(const ZipCompressAction&);
- };
+};
- LOG4CXX_PTR_DEF(ZipCompressAction);
+LOG4CXX_PTR_DEF(ZipCompressAction);
- }
+}
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
}
diff --git a/src/main/include/log4cxx/rollingfileappender.h b/src/main/include/log4cxx/rollingfileappender.h
index f8d519f..9d9ca79 100644
--- a/src/main/include/log4cxx/rollingfileappender.h
+++ b/src/main/include/log4cxx/rollingfileappender.h
@@ -18,8 +18,8 @@
#define _LOG4CXX_ROLLING_FILE_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/rolling/rollingfileappenderskeleton.h>
@@ -27,90 +27,90 @@
namespace log4cxx
{
- /** RollingFileAppender extends FileAppender to backup the log files when they reach a certain size. */
- class LOG4CXX_EXPORT RollingFileAppender : public log4cxx::rolling::RollingFileAppenderSkeleton
- {
- private:
- /** The default maximum file size is 10MB. */
- long maxFileSize;
+/** RollingFileAppender extends FileAppender to backup the log files when they reach a certain size. */
+class LOG4CXX_EXPORT RollingFileAppender : public log4cxx::rolling::RollingFileAppenderSkeleton
+{
+ private:
+ /** The default maximum file size is 10MB. */
+ long maxFileSize;
- /** There is one backup file by default. */
- int maxBackupIndex;
+ /** There is one backup file by default. */
+ int maxBackupIndex;
- public:
- //
- // Use custom class to use non-default name to avoid
- // conflict with log4cxx::rolling::RollingFileAppender
- DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS( RollingFileAppender, ClassRollingFileAppender )
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY( RollingFileAppender )
- LOG4CXX_CAST_ENTRY_CHAIN( FileAppender )
- END_LOG4CXX_CAST_MAP()
- /** The default constructor simply calls its {@link FileAppender#FileAppender parents constructor}. */
- RollingFileAppender();
+ public:
+ //
+ // Use custom class to use non-default name to avoid
+ // conflict with log4cxx::rolling::RollingFileAppender
+ DECLARE_LOG4CXX_OBJECT_WITH_CUSTOM_CLASS( RollingFileAppender, ClassRollingFileAppender )
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY( RollingFileAppender )
+ LOG4CXX_CAST_ENTRY_CHAIN( FileAppender )
+ END_LOG4CXX_CAST_MAP()
+ /** The default constructor simply calls its {@link FileAppender#FileAppender parents constructor}. */
+ RollingFileAppender();
- /**
- Instantiate a RollingFileAppender and open the file designated by
- <code>filename</code>. The opened filename will become the ouput destination for this appender.
+ /**
+ Instantiate a RollingFileAppender and open the file designated by
+ <code>filename</code>. The opened filename will become the ouput destination for this appender.
- <p>If the <code>append</code> parameter is true, the file will be appended to. Otherwise, the file desginated by
- <code>filename</code> will be truncated before being opened.
- */
- RollingFileAppender( const LayoutPtr & layout, const LogString & fileName, bool append );
+ <p>If the <code>append</code> parameter is true, the file will be appended to. Otherwise, the file desginated by
+ <code>filename</code> will be truncated before being opened.
+ */
+ RollingFileAppender( const LayoutPtr& layout, const LogString& fileName, bool append );
- /**
- Instantiate a FileAppender and open the file designated by
- <code>filename</code>. The opened filename will become the output destination for this appender.
- <p>The file will be appended to.
- */
- RollingFileAppender( const LayoutPtr & layout, const LogString & fileName );
+ /**
+ Instantiate a FileAppender and open the file designated by
+ <code>filename</code>. The opened filename will become the output destination for this appender.
+ <p>The file will be appended to.
+ */
+ RollingFileAppender( const LayoutPtr& layout, const LogString& fileName );
- virtual ~RollingFileAppender();
+ virtual ~RollingFileAppender();
- /** Returns the value of the <b>MaxBackupIndex</b> option. */
- int getMaxBackupIndex() const;
+ /** Returns the value of the <b>MaxBackupIndex</b> option. */
+ int getMaxBackupIndex() const;
- /** Get the maximum size that the output file is allowed to reach before being rolled over to backup files. */
- long getMaximumFileSize() const;
+ /** Get the maximum size that the output file is allowed to reach before being rolled over to backup files. */
+ long getMaximumFileSize() const;
- /**
- Set the maximum number of backup files to keep around.
+ /**
+ Set the maximum number of backup files to keep around.
- <p>The <b>MaxBackupIndex</b> option determines how many backup
- files are kept before the oldest is erased. This option takes
- a positive integer value. If set to zero, then there will be no
- backup files and the log file will be truncated when it reaches <code>MaxFileSize</code>.
- */
- void setMaxBackupIndex( int maxBackupIndex );
+ <p>The <b>MaxBackupIndex</b> option determines how many backup
+ files are kept before the oldest is erased. This option takes
+ a positive integer value. If set to zero, then there will be no
+ backup files and the log file will be truncated when it reaches <code>MaxFileSize</code>.
+ */
+ void setMaxBackupIndex( int maxBackupIndex );
- /**
- Set the maximum size that the output file is allowed to reach before being rolled over to backup files.
+ /**
+ Set the maximum size that the output file is allowed to reach before being rolled over to backup files.
- <p>In configuration files, the <b>MaxFileSize</b> option takes an
- long integer in the range 0 - 2^63. You can specify the value with the suffixes "KB", "MB" or "GB" so that the integer is
- interpreted being expressed respectively in kilobytes, megabytes
- or gigabytes. For example, the value "10KB" will be interpreted as 10240.
- */
- void setMaxFileSize( const LogString & value );
+ <p>In configuration files, the <b>MaxFileSize</b> option takes an
+ long integer in the range 0 - 2^63. You can specify the value with the suffixes "KB", "MB" or "GB" so that the integer is
+ interpreted being expressed respectively in kilobytes, megabytes
+ or gigabytes. For example, the value "10KB" will be interpreted as 10240.
+ */
+ void setMaxFileSize( const LogString& value );
- void setMaximumFileSize( int value );
+ void setMaximumFileSize( int value );
- virtual void setOption( const LogString & option, const LogString & value );
+ virtual void setOption( const LogString& option, const LogString& value );
- /** Prepares RollingFileAppender for use. */
- void activateOptions( log4cxx::helpers::Pool & pool );
+ /** Prepares RollingFileAppender for use. */
+ void activateOptions( log4cxx::helpers::Pool& pool );
- }; // class RollingFileAppender
- LOG4CXX_PTR_DEF(RollingFileAppender);
+}; // class RollingFileAppender
+LOG4CXX_PTR_DEF(RollingFileAppender);
- } // namespace log4cxx
+} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif //_LOG4CXX_ROLLING_FILE_APPENDER_H
diff --git a/src/main/include/log4cxx/simplelayout.h b/src/main/include/log4cxx/simplelayout.h
index 2dae784..fde9388 100644
--- a/src/main/include/log4cxx/simplelayout.h
+++ b/src/main/include/log4cxx/simplelayout.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_SIMPLE_LAYOUT_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
@@ -28,56 +28,59 @@
namespace log4cxx
{
- /**
- SimpleLayout consists of the level of the log statement,
- followed by " - " and then the log message itself. For example,
+/**
+SimpleLayout consists of the level of the log statement,
+followed by " - " and then the log message itself. For example,
- <pre>
- DEBUG - Hello world
+<pre>
+ DEBUG - Hello world
+</pre>
+
+<p>
+
+<p>PatternLayout offers a much more powerful alternative.
+*/
+class LOG4CXX_EXPORT SimpleLayout : public Layout
+{
+ public:
+ DECLARE_LOG4CXX_OBJECT(SimpleLayout)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(SimpleLayout)
+ LOG4CXX_CAST_ENTRY_CHAIN(Layout)
+ END_LOG4CXX_CAST_MAP()
+
+ /**
+ Returns the log statement in a format consisting of the
+ <code>level</code>, followed by " - " and then the
+ <code>message</code>. For example, <pre> INFO - "A message"
</pre>
- <p>
-
- <p>PatternLayout offers a much more powerful alternative.
+ @return A byte array in SimpleLayout format.
*/
- class LOG4CXX_EXPORT SimpleLayout : public Layout
+ virtual void format(LogString& output,
+ const spi::LoggingEventPtr& event,
+ log4cxx::helpers::Pool& pool) const;
+
+ /**
+ The SimpleLayout does not handle the throwable contained within
+ {@link spi::LoggingEvent LoggingEvents}. Thus, it returns
+ <code>true</code>.
+ */
+ bool ignoresThrowable() const
{
- public:
- DECLARE_LOG4CXX_OBJECT(SimpleLayout)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(SimpleLayout)
- LOG4CXX_CAST_ENTRY_CHAIN(Layout)
- END_LOG4CXX_CAST_MAP()
+ return true;
+ }
- /**
- Returns the log statement in a format consisting of the
- <code>level</code>, followed by " - " and then the
- <code>message</code>. For example, <pre> INFO - "A message"
- </pre>
-
- @return A byte array in SimpleLayout format.
- */
- virtual void format(LogString& output,
- const spi::LoggingEventPtr& event,
- log4cxx::helpers::Pool& pool) const;
-
- /**
- The SimpleLayout does not handle the throwable contained within
- {@link spi::LoggingEvent LoggingEvents}. Thus, it returns
- <code>true</code>.
- */
- bool ignoresThrowable() const { return true; }
-
- virtual void activateOptions(log4cxx::helpers::Pool& /* p */) {}
- virtual void setOption(const LogString& /* option */,
- const LogString& /* value */) {}
- };
- LOG4CXX_PTR_DEF(SimpleLayout);
+ virtual void activateOptions(log4cxx::helpers::Pool& /* p */) {}
+ virtual void setOption(const LogString& /* option */,
+ const LogString& /* value */) {}
+};
+LOG4CXX_PTR_DEF(SimpleLayout);
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif //_LOG4CXX_SIMPLE_LAYOUT_H
diff --git a/src/main/include/log4cxx/spi/appenderattachable.h b/src/main/include/log4cxx/spi/appenderattachable.h
index 490a23e..7b71f1c 100644
--- a/src/main/include/log4cxx/spi/appenderattachable.h
+++ b/src/main/include/log4cxx/spi/appenderattachable.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_SPI_APPENDER_ATTACHABLE_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/logstring.h>
@@ -31,64 +31,64 @@
namespace log4cxx
{
- namespace spi
- {
+namespace spi
+{
+/**
+ * This Interface is for attaching Appenders to objects.
+ */
+class LOG4CXX_EXPORT AppenderAttachable : public virtual helpers::Object
+{
+ public:
+ // Methods
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(AppenderAttachable)
+
/**
- * This Interface is for attaching Appenders to objects.
+ * Add an appender.
*/
- class LOG4CXX_EXPORT AppenderAttachable : public virtual helpers::Object
- {
- public:
- // Methods
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(AppenderAttachable)
+ virtual void addAppender(const AppenderPtr& newAppender) = 0;
- /**
- * Add an appender.
- */
- virtual void addAppender(const AppenderPtr& newAppender) = 0;
+ /**
+ * Get all previously added appenders as an AppenderList.
+ */
+ virtual AppenderList getAllAppenders() const = 0;
- /**
- * Get all previously added appenders as an AppenderList.
- */
- virtual AppenderList getAllAppenders() const = 0;
+ /**
+ * Get an appender by name.
+ */
+ virtual AppenderPtr getAppender(const LogString& name) const = 0;
- /**
- * Get an appender by name.
- */
- virtual AppenderPtr getAppender(const LogString& name) const = 0;
+ /**
+ * Returns <code>true</code> if the specified appender is in list of
+ * attached appenders, <code>false</code> otherwise.
+ */
+ virtual bool isAttached(const AppenderPtr& appender) const = 0;
- /**
- * Returns <code>true</code> if the specified appender is in list of
- * attached appenders, <code>false</code> otherwise.
- */
- virtual bool isAttached(const AppenderPtr& appender) const = 0;
+ /**
+ * Remove all previously added appenders.
+ */
+ virtual void removeAllAppenders() = 0;
- /**
- * Remove all previously added appenders.
- */
- virtual void removeAllAppenders() = 0;
+ /**
+ * Remove the appender passed as parameter from the list of appenders.
+ */
+ virtual void removeAppender(const AppenderPtr& appender) = 0;
- /**
- * Remove the appender passed as parameter from the list of appenders.
- */
- virtual void removeAppender(const AppenderPtr& appender) = 0;
+ /**
+ * Remove the appender with the name passed as parameter from the
+ * list of appenders.
+ */
+ virtual void removeAppender(const LogString& name) = 0;
- /**
- * Remove the appender with the name passed as parameter from the
- * list of appenders.
- */
- virtual void removeAppender(const LogString& name) = 0;
+ // Dtor
+ virtual ~AppenderAttachable() {}
+};
- // Dtor
- virtual ~AppenderAttachable() {}
- };
-
- LOG4CXX_PTR_DEF(AppenderAttachable);
- }
+LOG4CXX_PTR_DEF(AppenderAttachable);
+}
}
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif //_LOG4CXX_SPI_APPENDER_ATTACHABLE_H_
diff --git a/src/main/include/log4cxx/spi/configurator.h b/src/main/include/log4cxx/spi/configurator.h
index 7ded840..61ae313 100644
--- a/src/main/include/log4cxx/spi/configurator.h
+++ b/src/main/include/log4cxx/spi/configurator.h
@@ -22,40 +22,40 @@
namespace log4cxx
{
- class File;
+class File;
- namespace spi
- {
- /**
- Implemented by classes capable of configuring log4j using a URL.
- */
- class LOG4CXX_EXPORT Configurator : virtual public helpers::Object
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(Configurator)
- Configurator();
+namespace spi
+{
+/**
+Implemented by classes capable of configuring log4j using a URL.
+*/
+class LOG4CXX_EXPORT Configurator : virtual public helpers::Object
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(Configurator)
+ Configurator();
- /**
- Interpret a resource pointed by a URL and set up log4j accordingly.
+ /**
+ Interpret a resource pointed by a URL and set up log4j accordingly.
- The configuration is done relative to the <code>hierarchy</code>
- parameter.
+ The configuration is done relative to the <code>hierarchy</code>
+ parameter.
- @param configFileName The file to parse
- @param repository The hierarchy to operation upon.
- */
- virtual void doConfigure(const File& configFileName,
- spi::LoggerRepositoryPtr& repository) = 0;
+ @param configFileName The file to parse
+ @param repository The hierarchy to operation upon.
+ */
+ virtual void doConfigure(const File& configFileName,
+ spi::LoggerRepositoryPtr& repository) = 0;
- private:
- Configurator(const Configurator&);
- Configurator& operator=(const Configurator&);
- bool initialized;
- };
+ private:
+ Configurator(const Configurator&);
+ Configurator& operator=(const Configurator&);
+ bool initialized;
+};
- LOG4CXX_PTR_DEF(Configurator);
- }
+LOG4CXX_PTR_DEF(Configurator);
+}
}
#endif // _LOG4CXX_SPI_CONFIGURATOR_H
diff --git a/src/main/include/log4cxx/spi/defaultrepositoryselector.h b/src/main/include/log4cxx/spi/defaultrepositoryselector.h
index 9f09908..22835a6 100644
--- a/src/main/include/log4cxx/spi/defaultrepositoryselector.h
+++ b/src/main/include/log4cxx/spi/defaultrepositoryselector.h
@@ -24,27 +24,27 @@
namespace log4cxx
{
- namespace spi
- {
- class LOG4CXX_EXPORT DefaultRepositorySelector :
- public virtual RepositorySelector,
- public virtual helpers::ObjectImpl
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(DefaultRepositorySelector)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(RepositorySelector)
- END_LOG4CXX_CAST_MAP()
+namespace spi
+{
+class LOG4CXX_EXPORT DefaultRepositorySelector :
+ public virtual RepositorySelector,
+ public virtual helpers::ObjectImpl
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(DefaultRepositorySelector)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(RepositorySelector)
+ END_LOG4CXX_CAST_MAP()
- DefaultRepositorySelector(const LoggerRepositoryPtr& repository1);
- void addRef() const;
- void releaseRef() const;
- virtual LoggerRepositoryPtr& getLoggerRepository();
+ DefaultRepositorySelector(const LoggerRepositoryPtr& repository1);
+ void addRef() const;
+ void releaseRef() const;
+ virtual LoggerRepositoryPtr& getLoggerRepository();
- private:
- LoggerRepositoryPtr repository;
- };
- } // namespace spi
+ private:
+ LoggerRepositoryPtr repository;
+};
+} // namespace spi
} // namespace log4cxx
#endif //_LOG4CXX_SPI_DEFAULT_REPOSITORY_SELECTOR_H
diff --git a/src/main/include/log4cxx/spi/errorhandler.h b/src/main/include/log4cxx/spi/errorhandler.h
index 11faa90..5d6d1ae 100644
--- a/src/main/include/log4cxx/spi/errorhandler.h
+++ b/src/main/include/log4cxx/spi/errorhandler.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_SPI_ERROR_HANDLER_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
@@ -31,102 +31,102 @@
namespace log4cxx
{
- namespace spi
+namespace spi
+{
+class ErrorCode
+{
+ public:
+ enum
{
- class ErrorCode
- {
- public:
- enum
- {
- GENERIC_FAILURE = 0,
- WRITE_FAILURE = 1,
- FLUSH_FAILURE = 2,
- CLOSE_FAILURE = 3,
- FILE_OPEN_FAILURE = 4,
- MISSING_LAYOUT = 5,
- ADDRESS_PARSE_FAILURE = 6
- };
- };
+ GENERIC_FAILURE = 0,
+ WRITE_FAILURE = 1,
+ FLUSH_FAILURE = 2,
+ CLOSE_FAILURE = 3,
+ FILE_OPEN_FAILURE = 4,
+ MISSING_LAYOUT = 5,
+ ADDRESS_PARSE_FAILURE = 6
+ };
+};
- /**
- Appenders may delegate their error handling to
- <code>ErrorHandlers</code>.
+/**
+Appenders may delegate their error handling to
+<code>ErrorHandlers</code>.
- <p>Error handling is a particularly tedious to get right because by
- definition errors are hard to predict and to reproduce.
+<p>Error handling is a particularly tedious to get right because by
+definition errors are hard to predict and to reproduce.
- <p>Please take the time to contact the author in case you discover
- that errors are not properly handled. You are most welcome to
- suggest new error handling policies or criticize existing policies.
- */
- class LOG4CXX_EXPORT ErrorHandler : public virtual OptionHandler
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(ErrorHandler)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(ErrorHandler)
- LOG4CXX_CAST_ENTRY(OptionHandler)
- END_LOG4CXX_CAST_MAP()
+<p>Please take the time to contact the author in case you discover
+that errors are not properly handled. You are most welcome to
+suggest new error handling policies or criticize existing policies.
+*/
+class LOG4CXX_EXPORT ErrorHandler : public virtual OptionHandler
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(ErrorHandler)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(ErrorHandler)
+ LOG4CXX_CAST_ENTRY(OptionHandler)
+ END_LOG4CXX_CAST_MAP()
- virtual ~ErrorHandler() {}
+ virtual ~ErrorHandler() {}
- /**
- Add a reference to a logger to which the failing appender might
- be attached to. The failing appender will be searched and
- replaced only in the loggers you add through this method.
+ /**
+ Add a reference to a logger to which the failing appender might
+ be attached to. The failing appender will be searched and
+ replaced only in the loggers you add through this method.
- @param logger One of the loggers that will be searched for the failing
- appender in view of replacement.
- */
- virtual void setLogger(const LoggerPtr& logger) = 0;
+ @param logger One of the loggers that will be searched for the failing
+ appender in view of replacement.
+ */
+ virtual void setLogger(const LoggerPtr& logger) = 0;
- /**
- Equivalent to the error(const String&, helpers::Exception&, int,
- spi::LoggingEvent&) with the the event parameteter set to
- null.
- */
- virtual void error(const LogString& message, const std::exception& e,
- int errorCode) const = 0;
+ /**
+ Equivalent to the error(const String&, helpers::Exception&, int,
+ spi::LoggingEvent&) with the the event parameteter set to
+ null.
+ */
+ virtual void error(const LogString& message, const std::exception& e,
+ int errorCode) const = 0;
- /**
- This method is normally used to just print the error message
- passed as a parameter.
- */
- virtual void error(const LogString& message) const = 0;
+ /**
+ This method is normally used to just print the error message
+ passed as a parameter.
+ */
+ virtual void error(const LogString& message) const = 0;
- /**
- This method is invoked to handle the error.
+ /**
+ This method is invoked to handle the error.
- @param message The message assoicated with the error.
- @param e The Exption that was thrown when the error occured.
- @param errorCode The error code associated with the error.
- @param event The logging event that the failing appender is asked
- to log.
- */
- virtual void error(const LogString& message, const std::exception& e,
- int errorCode, const LoggingEventPtr& event) const = 0;
+ @param message The message assoicated with the error.
+ @param e The Exption that was thrown when the error occured.
+ @param errorCode The error code associated with the error.
+ @param event The logging event that the failing appender is asked
+ to log.
+ */
+ virtual void error(const LogString& message, const std::exception& e,
+ int errorCode, const LoggingEventPtr& event) const = 0;
- /**
- Set the appender for which errors are handled. This method is
- usually called when the error handler is configured.
- */
- virtual void setAppender(const AppenderPtr& appender) = 0;
+ /**
+ Set the appender for which errors are handled. This method is
+ usually called when the error handler is configured.
+ */
+ virtual void setAppender(const AppenderPtr& appender) = 0;
- /**
- Set the appender to fallback upon in case of failure.
- */
- virtual void setBackupAppender(const AppenderPtr& appender) = 0;
- };
+ /**
+ Set the appender to fallback upon in case of failure.
+ */
+ virtual void setBackupAppender(const AppenderPtr& appender) = 0;
+};
- LOG4CXX_PTR_DEF(ErrorHandler);
- } //namespace spi
+LOG4CXX_PTR_DEF(ErrorHandler);
+} //namespace spi
} //namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif //_LOG4CXX_SPI_ERROR_HANDLER_H
diff --git a/src/main/include/log4cxx/spi/filter.h b/src/main/include/log4cxx/spi/filter.h
index 80ce59b..bd8feaf 100644
--- a/src/main/include/log4cxx/spi/filter.h
+++ b/src/main/include/log4cxx/spi/filter.h
@@ -25,109 +25,109 @@
namespace log4cxx
{
- namespace spi
- {
- class Filter;
- LOG4CXX_PTR_DEF(Filter);
+namespace spi
+{
+class Filter;
+LOG4CXX_PTR_DEF(Filter);
+/**
+Users should extend this class to implement customized logging
+event filtering. Note that Logger and
+AppenderSkeleton, the parent class of all standard
+appenders, have built-in filtering rules. It is suggested that you
+first use and understand the built-in rules before rushing to write
+your own custom filters.
+
+<p>This abstract class assumes and also imposes that filters be
+organized in a linear chain. The {@link #decide
+decide(LoggingEvent)} method of each filter is called sequentially,
+in the order of their addition to the chain.
+
+<p>The {@link #decide decide(LoggingEvent)} method must return one
+of the integer constants #DENY, #NEUTRAL or
+#ACCEPT.
+
+<p>If the value #DENY is returned, then the log event is
+dropped immediately without consulting with the remaining
+filters.
+
+<p>If the value #NEUTRAL is returned, then the next filter
+in the chain is consulted. If there are no more filters in the
+chain, then the log event is logged. Thus, in the presence of no
+filters, the default behaviour is to log all logging events.
+
+<p>If the value #ACCEPT is returned, then the log
+event is logged without consulting the remaining filters.
+
+<p>The philosophy of log4cxx filters is largely inspired from the
+Linux ipchains.
+
+<p>Note that filtering is only supported by the {@link
+xml::DOMConfigurator DOMConfigurator}.
+*/
+class LOG4CXX_EXPORT Filter : public virtual OptionHandler,
+ public virtual helpers::ObjectImpl
+{
/**
- Users should extend this class to implement customized logging
- event filtering. Note that Logger and
- AppenderSkeleton, the parent class of all standard
- appenders, have built-in filtering rules. It is suggested that you
- first use and understand the built-in rules before rushing to write
- your own custom filters.
-
- <p>This abstract class assumes and also imposes that filters be
- organized in a linear chain. The {@link #decide
- decide(LoggingEvent)} method of each filter is called sequentially,
- in the order of their addition to the chain.
-
- <p>The {@link #decide decide(LoggingEvent)} method must return one
- of the integer constants #DENY, #NEUTRAL or
- #ACCEPT.
-
- <p>If the value #DENY is returned, then the log event is
- dropped immediately without consulting with the remaining
- filters.
-
- <p>If the value #NEUTRAL is returned, then the next filter
- in the chain is consulted. If there are no more filters in the
- chain, then the log event is logged. Thus, in the presence of no
- filters, the default behaviour is to log all logging events.
-
- <p>If the value #ACCEPT is returned, then the log
- event is logged without consulting the remaining filters.
-
- <p>The philosophy of log4cxx filters is largely inspired from the
- Linux ipchains.
-
- <p>Note that filtering is only supported by the {@link
- xml::DOMConfigurator DOMConfigurator}.
+ Points to the next filter in the filter chain.
*/
- class LOG4CXX_EXPORT Filter : public virtual OptionHandler,
- public virtual helpers::ObjectImpl
- {
- /**
- Points to the next filter in the filter chain.
- */
- FilterPtr next;
- public:
- Filter();
+ FilterPtr next;
+ public:
+ Filter();
- void addRef() const;
- void releaseRef() const;
+ void addRef() const;
+ void releaseRef() const;
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(Filter)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(Filter)
- LOG4CXX_CAST_ENTRY(spi::OptionHandler)
- END_LOG4CXX_CAST_MAP()
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(Filter)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(Filter)
+ LOG4CXX_CAST_ENTRY(spi::OptionHandler)
+ END_LOG4CXX_CAST_MAP()
- log4cxx::spi::FilterPtr getNext() const;
- void setNext(const log4cxx::spi::FilterPtr& newNext);
+ log4cxx::spi::FilterPtr getNext() const;
+ void setNext(const log4cxx::spi::FilterPtr& newNext);
- enum FilterDecision
- {
+ enum FilterDecision
+ {
/**
The log event must be dropped immediately without consulting
with the remaining filters, if any, in the chain. */
- DENY = -1,
+ DENY = -1,
/**
This filter is neutral with respect to the log event. The
remaining filters, if any, should be consulted for a final decision.
*/
- NEUTRAL = 0,
+ NEUTRAL = 0,
/**
The log event must be logged immediately without consulting with
the remaining filters, if any, in the chain.
*/
- ACCEPT = 1
+ ACCEPT = 1
- };
+ };
- /**
- Usually filters options become active when set. We provide a
+ /**
+ Usually filters options become active when set. We provide a
- default do-nothing implementation for convenience.
- */
- void activateOptions(log4cxx::helpers::Pool& p);
- void setOption(const LogString& option, const LogString& value);
+ default do-nothing implementation for convenience.
+ */
+ void activateOptions(log4cxx::helpers::Pool& p);
+ void setOption(const LogString& option, const LogString& value);
- /**
- <p>If the decision is <code>DENY</code>, then the event will be
- dropped. If the decision is <code>NEUTRAL</code>, then the next
- filter, if any, will be invoked. If the decision is ACCEPT then
- the event will be logged without consulting with other filters in
- the chain.
+ /**
+ <p>If the decision is <code>DENY</code>, then the event will be
+ dropped. If the decision is <code>NEUTRAL</code>, then the next
+ filter, if any, will be invoked. If the decision is ACCEPT then
+ the event will be logged without consulting with other filters in
+ the chain.
- @param event The LoggingEvent to decide upon.
- @return The decision of the filter. */
- virtual FilterDecision decide(const LoggingEventPtr& event) const = 0;
- };
- }
+ @param event The LoggingEvent to decide upon.
+ @return The decision of the filter. */
+ virtual FilterDecision decide(const LoggingEventPtr& event) const = 0;
+};
+}
}
#endif //_LOG4CXX_SPI_FILTER_H
diff --git a/src/main/include/log4cxx/spi/hierarchyeventlistener.h b/src/main/include/log4cxx/spi/hierarchyeventlistener.h
index 98e8f86..637f875 100644
--- a/src/main/include/log4cxx/spi/hierarchyeventlistener.h
+++ b/src/main/include/log4cxx/spi/hierarchyeventlistener.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_SPI_HIERARCHY_EVENT_LISTENER_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
@@ -30,36 +30,36 @@
namespace log4cxx
{
- class Logger;
- class Appender;
+class Logger;
+class Appender;
- namespace spi
- {
+namespace spi
+{
- /** Listen to events occuring within a Hierarchy.*/
- class LOG4CXX_EXPORT HierarchyEventListener :
- public virtual log4cxx::helpers::Object
- {
- public:
- virtual ~HierarchyEventListener() {}
+/** Listen to events occuring within a Hierarchy.*/
+class LOG4CXX_EXPORT HierarchyEventListener :
+ public virtual log4cxx::helpers::Object
+{
+ public:
+ virtual ~HierarchyEventListener() {}
- virtual void addAppenderEvent(
- const log4cxx::helpers::ObjectPtrT<Logger>& logger,
- const log4cxx::helpers::ObjectPtrT<Appender>& appender) = 0;
+ virtual void addAppenderEvent(
+ const log4cxx::helpers::ObjectPtrT<Logger>& logger,
+ const log4cxx::helpers::ObjectPtrT<Appender>& appender) = 0;
- virtual void removeAppenderEvent(
- const log4cxx::helpers::ObjectPtrT<Logger>& logger,
- const log4cxx::helpers::ObjectPtrT<Appender>& appender) = 0;
- };
- LOG4CXX_PTR_DEF(HierarchyEventListener);
- LOG4CXX_LIST_DEF(HierarchyEventListenerList, HierarchyEventListenerPtr);
+ virtual void removeAppenderEvent(
+ const log4cxx::helpers::ObjectPtrT<Logger>& logger,
+ const log4cxx::helpers::ObjectPtrT<Appender>& appender) = 0;
+};
+LOG4CXX_PTR_DEF(HierarchyEventListener);
+LOG4CXX_LIST_DEF(HierarchyEventListenerList, HierarchyEventListenerPtr);
- } // namespace spi
+} // namespace spi
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif //_LOG4CXX_SPI_HIERARCHY_EVENT_LISTENER_H
diff --git a/src/main/include/log4cxx/spi/location/locationinfo.h b/src/main/include/log4cxx/spi/location/locationinfo.h
index 67b260f..b8f4703 100644
--- a/src/main/include/log4cxx/spi/location/locationinfo.h
+++ b/src/main/include/log4cxx/spi/location/locationinfo.h
@@ -24,54 +24,54 @@
namespace log4cxx
{
- namespace spi
- {
- /**
- * This class represents the location of a logging statement.
- *
- */
- class LOG4CXX_EXPORT LocationInfo
- {
- public:
+namespace spi
+{
+/**
+ * This class represents the location of a logging statement.
+ *
+ */
+class LOG4CXX_EXPORT LocationInfo
+{
+ public:
- /**
- * When location information is not available the constant
- * <code>NA</code> is returned. Current value of this string constant is <b>?</b>.
- */
- static const char * const NA;
- static const char * const NA_METHOD;
+ /**
+ * When location information is not available the constant
+ * <code>NA</code> is returned. Current value of this string constant is <b>?</b>.
+ */
+ static const char* const NA;
+ static const char* const NA_METHOD;
static const LocationInfo& getLocationUnavailable();
- /**
- * Constructor.
- * @remarks Used by LOG4CXX_LOCATION to generate
- * location info for current code site
- */
- LocationInfo( const char * const fileName,
- const char * const functionName,
+ /**
+ * Constructor.
+ * @remarks Used by LOG4CXX_LOCATION to generate
+ * location info for current code site
+ */
+ LocationInfo( const char* const fileName,
+ const char* const functionName,
int lineNumber);
- /**
- * Default constructor.
- */
+ /**
+ * Default constructor.
+ */
LocationInfo();
- /**
- * Copy constructor.
- * @param src source location
- */
- LocationInfo( const LocationInfo & src );
+ /**
+ * Copy constructor.
+ * @param src source location
+ */
+ LocationInfo( const LocationInfo& src );
- /**
- * Assignment operator.
- * @param src source location
- */
- LocationInfo & operator = ( const LocationInfo & src );
+ /**
+ * Assignment operator.
+ * @param src source location
+ */
+ LocationInfo& operator = ( const LocationInfo& src );
/**
* Resets location info to default state.
@@ -86,7 +86,7 @@
* Return the file name of the caller.
* @returns file name, may be null.
*/
- const char * getFileName() const;
+ const char* getFileName() const;
/**
* Returns the line number of the caller.
@@ -100,41 +100,41 @@
void write(log4cxx::helpers::ObjectOutputStream& os, log4cxx::helpers::Pool& p) const;
- private:
+ private:
/** Caller's line number. */
int lineNumber;
/** Caller's file name. */
- const char * fileName;
+ const char* fileName;
/** Caller's method name. */
- const char * methodName;
+ const char* methodName;
- };
- }
+};
+}
}
#if !defined(LOG4CXX_LOCATION)
- #if defined(_MSC_VER)
+#if defined(_MSC_VER)
#if _MSC_VER >= 1300
- #define __LOG4CXX_FUNC__ __FUNCSIG__
+ #define __LOG4CXX_FUNC__ __FUNCSIG__
#endif
- #else
+#else
#if defined(__GNUC__)
- #define __LOG4CXX_FUNC__ __PRETTY_FUNCTION__
+ #define __LOG4CXX_FUNC__ __PRETTY_FUNCTION__
#else
- #if defined(__BORLANDC__)
- #define __LOG4CXX_FUNC__ __FUNC__
- #endif
+ #if defined(__BORLANDC__)
+ #define __LOG4CXX_FUNC__ __FUNC__
+ #endif
#endif
- #endif
- #if !defined(__LOG4CXX_FUNC__)
+#endif
+#if !defined(__LOG4CXX_FUNC__)
#define __LOG4CXX_FUNC__ ""
- #endif
- #define LOG4CXX_LOCATION ::log4cxx::spi::LocationInfo(__FILE__, \
- __LOG4CXX_FUNC__, \
- __LINE__)
+#endif
+#define LOG4CXX_LOCATION ::log4cxx::spi::LocationInfo(__FILE__, \
+ __LOG4CXX_FUNC__, \
+ __LINE__)
#endif
#endif //_LOG4CXX_SPI_LOCATION_LOCATIONINFO_H
diff --git a/src/main/include/log4cxx/spi/loggerfactory.h b/src/main/include/log4cxx/spi/loggerfactory.h
index ff9be2f..d1aff27 100644
--- a/src/main/include/log4cxx/spi/loggerfactory.h
+++ b/src/main/include/log4cxx/spi/loggerfactory.h
@@ -23,24 +23,24 @@
namespace log4cxx
{
- namespace spi
- {
- /**
- Implement this interface to create new instances of Logger or
- a sub-class of Logger.
- */
- class LOG4CXX_EXPORT LoggerFactory : public virtual helpers::Object
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerFactory)
- virtual ~LoggerFactory() {}
- virtual LoggerPtr makeNewLoggerInstance(
- log4cxx::helpers::Pool& pool,
- const LogString& name) const = 0;
- };
+namespace spi
+{
+/**
+Implement this interface to create new instances of Logger or
+a sub-class of Logger.
+*/
+class LOG4CXX_EXPORT LoggerFactory : public virtual helpers::Object
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerFactory)
+ virtual ~LoggerFactory() {}
+ virtual LoggerPtr makeNewLoggerInstance(
+ log4cxx::helpers::Pool& pool,
+ const LogString& name) const = 0;
+};
- } // namespace spi
+} // namespace spi
} // namesapce log4cxx
#endif //_LOG4CXX_SPI_LOGGERFACTORY_H
diff --git a/src/main/include/log4cxx/spi/loggerrepository.h b/src/main/include/log4cxx/spi/loggerrepository.h
index 1949d17..656163c 100644
--- a/src/main/include/log4cxx/spi/loggerrepository.h
+++ b/src/main/include/log4cxx/spi/loggerrepository.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_SPI_LOG_REPOSITORY_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
@@ -31,85 +31,85 @@
namespace log4cxx
{
- namespace spi
- {
+namespace spi
+{
- /**
- A <code>LoggerRepository</code> is used to create and retrieve
- <code>Loggers</code>. The relation between loggers in a repository
- depends on the repository but typically loggers are arranged in a
- named hierarchy.
+/**
+A <code>LoggerRepository</code> is used to create and retrieve
+<code>Loggers</code>. The relation between loggers in a repository
+depends on the repository but typically loggers are arranged in a
+named hierarchy.
- <p>In addition to the creational methods, a
- <code>LoggerRepository</code> can be queried for existing loggers,
- can act as a point of registry for events related to loggers.
- */
- class LOG4CXX_EXPORT LoggerRepository : public virtual helpers::Object
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerRepository)
- virtual ~LoggerRepository() {}
+<p>In addition to the creational methods, a
+<code>LoggerRepository</code> can be queried for existing loggers,
+can act as a point of registry for events related to loggers.
+*/
+class LOG4CXX_EXPORT LoggerRepository : public virtual helpers::Object
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerRepository)
+ virtual ~LoggerRepository() {}
- /**
- Add a {@link spi::HierarchyEventListener HierarchyEventListener}
- event to the repository.
- */
- virtual void addHierarchyEventListener(const HierarchyEventListenerPtr&
- listener) = 0;
- /**
- Is the repository disabled for a given level? The answer depends
- on the repository threshold and the <code>level</code>
- parameter. See also #setThreshold method. */
- virtual bool isDisabled(int level) const = 0;
+ /**
+ Add a {@link spi::HierarchyEventListener HierarchyEventListener}
+ event to the repository.
+ */
+ virtual void addHierarchyEventListener(const HierarchyEventListenerPtr&
+ listener) = 0;
+ /**
+ Is the repository disabled for a given level? The answer depends
+ on the repository threshold and the <code>level</code>
+ parameter. See also #setThreshold method. */
+ virtual bool isDisabled(int level) const = 0;
- /**
- Set the repository-wide threshold. All logging requests below the
- threshold are immediately dropped. By default, the threshold is
- set to <code>Level::getAll()</code> which has the lowest possible rank. */
- virtual void setThreshold(const LevelPtr& level) = 0;
+ /**
+ Set the repository-wide threshold. All logging requests below the
+ threshold are immediately dropped. By default, the threshold is
+ set to <code>Level::getAll()</code> which has the lowest possible rank. */
+ virtual void setThreshold(const LevelPtr& level) = 0;
- /**
- Another form of {@link #setThreshold(const LevelPtr&)
- setThreshold} accepting a string
- parameter instead of a <code>Level</code>. */
- virtual void setThreshold(const LogString& val) = 0;
+ /**
+ Another form of {@link #setThreshold(const LevelPtr&)
+ setThreshold} accepting a string
+ parameter instead of a <code>Level</code>. */
+ virtual void setThreshold(const LogString& val) = 0;
- virtual void emitNoAppenderWarning(const LoggerPtr& logger) = 0;
+ virtual void emitNoAppenderWarning(const LoggerPtr& logger) = 0;
- /**
- Get the repository-wide threshold. See {@link
- #setThreshold(const LevelPtr&) setThreshold}
- for an explanation. */
- virtual const LevelPtr& getThreshold() const = 0;
+ /**
+ Get the repository-wide threshold. See {@link
+ #setThreshold(const LevelPtr&) setThreshold}
+ for an explanation. */
+ virtual const LevelPtr& getThreshold() const = 0;
- virtual LoggerPtr getLogger(const LogString& name) = 0;
+ virtual LoggerPtr getLogger(const LogString& name) = 0;
- virtual LoggerPtr getLogger(const LogString& name,
- const spi::LoggerFactoryPtr& factory) = 0;
+ virtual LoggerPtr getLogger(const LogString& name,
+ const spi::LoggerFactoryPtr& factory) = 0;
- virtual LoggerPtr getRootLogger() const = 0;
+ virtual LoggerPtr getRootLogger() const = 0;
- virtual LoggerPtr exists(const LogString& name) = 0;
+ virtual LoggerPtr exists(const LogString& name) = 0;
- virtual void shutdown() = 0;
+ virtual void shutdown() = 0;
- virtual LoggerList getCurrentLoggers() const = 0;
+ virtual LoggerList getCurrentLoggers() const = 0;
- virtual void fireAddAppenderEvent(const LoggerPtr& logger,
- const AppenderPtr& appender) = 0;
+ virtual void fireAddAppenderEvent(const LoggerPtr& logger,
+ const AppenderPtr& appender) = 0;
- virtual void resetConfiguration() = 0;
+ virtual void resetConfiguration() = 0;
- virtual bool isConfigured() = 0;
- virtual void setConfigured(bool configured) = 0;
+ virtual bool isConfigured() = 0;
+ virtual void setConfigured(bool configured) = 0;
- }; // class LoggerRepository
+}; // class LoggerRepository
- } // namespace spi
+} // namespace spi
} // namespace log4cxx
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
diff --git a/src/main/include/log4cxx/spi/loggingevent.h b/src/main/include/log4cxx/spi/loggingevent.h
index 8f6dec0..c5af803 100644
--- a/src/main/include/log4cxx/spi/loggingevent.h
+++ b/src/main/include/log4cxx/spi/loggingevent.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_SPI_LOGGING_EVENT_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
@@ -36,230 +36,242 @@
namespace log4cxx
{
- namespace helpers
+namespace helpers
+{
+class ObjectOutputStream;
+}
+
+namespace spi
+{
+LOG4CXX_LIST_DEF(KeySet, LogString);
+
+/**
+The internal representation of logging events. When an affirmative
+decision is made to log then a <code>LoggingEvent</code> instance
+is created. This instance is passed around to the different log4cxx
+components.
+
+<p>This class is of concern to those wishing to extend log4cxx.
+*/
+class LOG4CXX_EXPORT LoggingEvent :
+ public virtual helpers::ObjectImpl
+{
+ public:
+ DECLARE_LOG4CXX_OBJECT(LoggingEvent)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(LoggingEvent)
+ END_LOG4CXX_CAST_MAP()
+
+ typedef spi::KeySet KeySet;
+
+ /** For serialization only
+ */
+ LoggingEvent();
+
+ /**
+ Instantiate a LoggingEvent from the supplied parameters.
+
+ <p>Except timeStamp all the other fields of
+ <code>LoggingEvent</code> are filled when actually needed.
+ <p>
+ @param logger The logger of this event.
+ @param level The level of this event.
+ @param message The message of this event.
+ @param location location of logging request.
+ */
+ LoggingEvent(const LogString& logger,
+ const LevelPtr& level, const LogString& message,
+ const log4cxx::spi::LocationInfo& location);
+
+ ~LoggingEvent();
+
+ /** Return the level of this event. */
+ inline const LevelPtr& getLevel() const
{
- class ObjectOutputStream;
+ return level;
}
- namespace spi
+ /** Return the name of the logger. */
+ inline const LogString& getLoggerName() const
{
- LOG4CXX_LIST_DEF(KeySet, LogString);
-
- /**
- The internal representation of logging events. When an affirmative
- decision is made to log then a <code>LoggingEvent</code> instance
- is created. This instance is passed around to the different log4cxx
- components.
-
- <p>This class is of concern to those wishing to extend log4cxx.
- */
- class LOG4CXX_EXPORT LoggingEvent :
- public virtual helpers::ObjectImpl
- {
- public:
- DECLARE_LOG4CXX_OBJECT(LoggingEvent)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(LoggingEvent)
- END_LOG4CXX_CAST_MAP()
-
- typedef spi::KeySet KeySet;
-
- /** For serialization only
- */
- LoggingEvent();
-
- /**
- Instantiate a LoggingEvent from the supplied parameters.
-
- <p>Except timeStamp all the other fields of
- <code>LoggingEvent</code> are filled when actually needed.
- <p>
- @param logger The logger of this event.
- @param level The level of this event.
- @param message The message of this event.
- @param location location of logging request.
- */
- LoggingEvent(const LogString& logger,
- const LevelPtr& level, const LogString& message,
- const log4cxx::spi::LocationInfo& location);
-
- ~LoggingEvent();
-
- /** Return the level of this event. */
- inline const LevelPtr& getLevel() const
- { return level; }
-
- /** Return the name of the logger. */
- inline const LogString& getLoggerName() const {
- return logger;
- }
-
- /** Return the message for this logging event. */
- inline const LogString& getMessage() const
- { return message; }
-
- /** Return the message for this logging event. */
- inline const LogString& getRenderedMessage() const
- { return message; }
-
- /**Returns the time when the application started,
- in microseconds elapsed since 01.01.1970.
- */
- static log4cxx_time_t getStartTime();
-
- /** Return the threadName of this event. */
- inline const LogString& getThreadName() const {
- return threadName;
- }
-
- /** The number of microseconds elapsed from 01.01.1970 until logging event
- was created. */
- inline log4cxx_time_t getTimeStamp() const
- { return timeStamp; }
-
- /* Return the file where this log statement was written. */
- inline const log4cxx::spi::LocationInfo& getLocationInformation() const
- { return locationInfo; }
-
- /**
- * This method appends the NDC for this event to passed string. It will return the
- * correct content even if the event was generated in a different
- * thread or even on a different machine. The NDC#get method
- * should <em>never</em> be called directly.
- *
- * @param dest destination for NDC, unchanged if NDC is not set.
- * @return true if NDC is set.
- */
- bool getNDC(LogString& dest) const;
-
- /**
- * Writes the content of the LoggingEvent
- * in a format compatible with log4j's serialized form.
- */
- void write(helpers::ObjectOutputStream& os, helpers::Pool& p) const;
-
- /**
- * Appends the the context corresponding to the <code>key</code> parameter.
- * If there is a local MDC copy, possibly because we are in a logging
- * server or running inside AsyncAppender, then we search for the key in
- * MDC copy, if a value is found it is returned. Otherwise, if the search
- * in MDC copy returns an empty result, then the current thread's
- * <code>MDC</code> is used.
- *
- * <p>
- * Note that <em>both</em> the local MDC copy and the current thread's MDC
- * are searched.
- * </p>
- * @param key key.
- * @param dest string to which value, if any, is appended.
- * @return true if key had a corresponding value.
- */
- bool getMDC(const LogString& key, LogString& dest) const;
-
- /**
- * Returns the set of of the key values in the MDC for the event.
- * The returned set is unmodifiable by the caller.
- *
- * @return Set an unmodifiable set of the MDC keys.
- *
- */
- KeySet getMDCKeySet() const;
-
- /**
- Obtain a copy of this thread's MDC prior to serialization
- or asynchronous logging.
- */
- void getMDCCopy() const;
-
- /**
- * Return a previously set property.
- * @param key key.
- * @param dest string to which value, if any, is appended.
- * @return true if key had a corresponding value.
- */
- bool getProperty(const LogString& key, LogString& dest) const;
- /**
- * Returns the set of of the key values in the properties
- * for the event. The returned set is unmodifiable by the caller.
- *
- * @return Set an unmodifiable set of the property keys.
- */
- KeySet getPropertyKeySet() const;
-
- /**
- * Set a string property using a key and a string value. since 1.3
- */
- void setProperty(const LogString& key, const LogString& value);
-
- private:
- /**
- * The logger of the logging event.
- **/
- LogString logger;
-
- /** level of logging event. */
- LevelPtr level;
-
- /** The nested diagnostic context (NDC) of logging event. */
- mutable LogString* ndc;
-
- /** The mapped diagnostic context (MDC) of logging event. */
- mutable MDC::Map* mdcCopy;
-
- /**
- * A map of String keys and String values.
- */
- std::map<LogString, LogString> * properties;
-
- /** Have we tried to do an NDC lookup? If we did, there is no need
- * to do it again. Note that its value is always false when
- * serialized. Thus, a receiving SocketNode will never use it's own
- * (incorrect) NDC. See also writeObject method.
- */
- mutable bool ndcLookupRequired;
-
- /**
- * Have we tried to do an MDC lookup? If we did, there is no need to do it
- * again. Note that its value is always false when serialized. See also
- * the getMDC and getMDCCopy methods.
- */
- mutable bool mdcCopyLookupRequired;
-
- /** The application supplied message of logging event. */
- LogString message;
-
-
- /** The number of microseconds elapsed from 01.01.1970 until logging event
- was created. */
- log4cxx_time_t timeStamp;
-
- /** The is the location where this log statement was written. */
- const log4cxx::spi::LocationInfo locationInfo;
-
-
- /** The identifier of thread in which this logging event
- was generated.
- */
- const LogString threadName;
-
- //
- // prevent copy and assignment
- //
- LoggingEvent(const LoggingEvent&);
- LoggingEvent& operator=(const LoggingEvent&);
- static const LogString getCurrentThreadName();
-
- static void writeProlog(log4cxx::helpers::ObjectOutputStream& os, log4cxx::helpers::Pool& p);
-
- };
-
- LOG4CXX_PTR_DEF(LoggingEvent);
- LOG4CXX_LIST_DEF(LoggingEventList, LoggingEventPtr);
+ return logger;
}
+
+ /** Return the message for this logging event. */
+ inline const LogString& getMessage() const
+ {
+ return message;
+ }
+
+ /** Return the message for this logging event. */
+ inline const LogString& getRenderedMessage() const
+ {
+ return message;
+ }
+
+ /**Returns the time when the application started,
+ in microseconds elapsed since 01.01.1970.
+ */
+ static log4cxx_time_t getStartTime();
+
+ /** Return the threadName of this event. */
+ inline const LogString& getThreadName() const
+ {
+ return threadName;
+ }
+
+ /** The number of microseconds elapsed from 01.01.1970 until logging event
+ was created. */
+ inline log4cxx_time_t getTimeStamp() const
+ {
+ return timeStamp;
+ }
+
+ /* Return the file where this log statement was written. */
+ inline const log4cxx::spi::LocationInfo& getLocationInformation() const
+ {
+ return locationInfo;
+ }
+
+ /**
+ * This method appends the NDC for this event to passed string. It will return the
+ * correct content even if the event was generated in a different
+ * thread or even on a different machine. The NDC#get method
+ * should <em>never</em> be called directly.
+ *
+ * @param dest destination for NDC, unchanged if NDC is not set.
+ * @return true if NDC is set.
+ */
+ bool getNDC(LogString& dest) const;
+
+ /**
+ * Writes the content of the LoggingEvent
+ * in a format compatible with log4j's serialized form.
+ */
+ void write(helpers::ObjectOutputStream& os, helpers::Pool& p) const;
+
+ /**
+ * Appends the the context corresponding to the <code>key</code> parameter.
+ * If there is a local MDC copy, possibly because we are in a logging
+ * server or running inside AsyncAppender, then we search for the key in
+ * MDC copy, if a value is found it is returned. Otherwise, if the search
+ * in MDC copy returns an empty result, then the current thread's
+ * <code>MDC</code> is used.
+ *
+ * <p>
+ * Note that <em>both</em> the local MDC copy and the current thread's MDC
+ * are searched.
+ * </p>
+ * @param key key.
+ * @param dest string to which value, if any, is appended.
+ * @return true if key had a corresponding value.
+ */
+ bool getMDC(const LogString& key, LogString& dest) const;
+
+ /**
+ * Returns the set of of the key values in the MDC for the event.
+ * The returned set is unmodifiable by the caller.
+ *
+ * @return Set an unmodifiable set of the MDC keys.
+ *
+ */
+ KeySet getMDCKeySet() const;
+
+ /**
+ Obtain a copy of this thread's MDC prior to serialization
+ or asynchronous logging.
+ */
+ void getMDCCopy() const;
+
+ /**
+ * Return a previously set property.
+ * @param key key.
+ * @param dest string to which value, if any, is appended.
+ * @return true if key had a corresponding value.
+ */
+ bool getProperty(const LogString& key, LogString& dest) const;
+ /**
+ * Returns the set of of the key values in the properties
+ * for the event. The returned set is unmodifiable by the caller.
+ *
+ * @return Set an unmodifiable set of the property keys.
+ */
+ KeySet getPropertyKeySet() const;
+
+ /**
+ * Set a string property using a key and a string value. since 1.3
+ */
+ void setProperty(const LogString& key, const LogString& value);
+
+ private:
+ /**
+ * The logger of the logging event.
+ **/
+ LogString logger;
+
+ /** level of logging event. */
+ LevelPtr level;
+
+ /** The nested diagnostic context (NDC) of logging event. */
+ mutable LogString* ndc;
+
+ /** The mapped diagnostic context (MDC) of logging event. */
+ mutable MDC::Map* mdcCopy;
+
+ /**
+ * A map of String keys and String values.
+ */
+ std::map<LogString, LogString>* properties;
+
+ /** Have we tried to do an NDC lookup? If we did, there is no need
+ * to do it again. Note that its value is always false when
+ * serialized. Thus, a receiving SocketNode will never use it's own
+ * (incorrect) NDC. See also writeObject method.
+ */
+ mutable bool ndcLookupRequired;
+
+ /**
+ * Have we tried to do an MDC lookup? If we did, there is no need to do it
+ * again. Note that its value is always false when serialized. See also
+ * the getMDC and getMDCCopy methods.
+ */
+ mutable bool mdcCopyLookupRequired;
+
+ /** The application supplied message of logging event. */
+ LogString message;
+
+
+ /** The number of microseconds elapsed from 01.01.1970 until logging event
+ was created. */
+ log4cxx_time_t timeStamp;
+
+ /** The is the location where this log statement was written. */
+ const log4cxx::spi::LocationInfo locationInfo;
+
+
+ /** The identifier of thread in which this logging event
+ was generated.
+ */
+ const LogString threadName;
+
+ //
+ // prevent copy and assignment
+ //
+ LoggingEvent(const LoggingEvent&);
+ LoggingEvent& operator=(const LoggingEvent&);
+ static const LogString getCurrentThreadName();
+
+ static void writeProlog(log4cxx::helpers::ObjectOutputStream& os, log4cxx::helpers::Pool& p);
+
+};
+
+LOG4CXX_PTR_DEF(LoggingEvent);
+LOG4CXX_LIST_DEF(LoggingEventList, LoggingEventPtr);
+}
}
#if defined(_MSC_VER)
-#pragma warning (pop)
+ #pragma warning (pop)
#endif
diff --git a/src/main/include/log4cxx/spi/optionhandler.h b/src/main/include/log4cxx/spi/optionhandler.h
index 88cd954..b86aa7a 100644
--- a/src/main/include/log4cxx/spi/optionhandler.h
+++ b/src/main/include/log4cxx/spi/optionhandler.h
@@ -24,48 +24,48 @@
namespace log4cxx
{
- namespace spi
- {
- class OptionHandler;
- typedef helpers::ObjectPtrT<OptionHandler> OptionHandlerPtr;
+namespace spi
+{
+class OptionHandler;
+typedef helpers::ObjectPtrT<OptionHandler> OptionHandlerPtr;
- /**
- A string based interface to configure package components.
- */
- class LOG4CXX_EXPORT OptionHandler : public virtual helpers::Object
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(OptionHandler)
- virtual ~OptionHandler() {}
+/**
+A string based interface to configure package components.
+*/
+class LOG4CXX_EXPORT OptionHandler : public virtual helpers::Object
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(OptionHandler)
+ virtual ~OptionHandler() {}
- /**
- Activate the options that were previously set with calls to option
- setters.
+ /**
+ Activate the options that were previously set with calls to option
+ setters.
- <p>This allows to defer activiation of the options until all
- options have been set. This is required for components which have
- related options that remain ambigous until all are set.
+ <p>This allows to defer activiation of the options until all
+ options have been set. This is required for components which have
+ related options that remain ambigous until all are set.
- <p>For example, the FileAppender has the {@link
- FileAppender#setFile File} and {@link
- FileAppender#setAppend Append} options both of
- which are ambigous until the other is also set. */
- virtual void activateOptions(log4cxx::helpers::Pool& p) = 0;
+ <p>For example, the FileAppender has the {@link
+ FileAppender#setFile File} and {@link
+ FileAppender#setAppend Append} options both of
+ which are ambigous until the other is also set. */
+ virtual void activateOptions(log4cxx::helpers::Pool& p) = 0;
- /**
- Set <code>option</code> to <code>value</code>.
+ /**
+ Set <code>option</code> to <code>value</code>.
- <p>The handling of each option depends on the OptionHandler
- instance. Some options may become active immediately whereas
- other may be activated only when #activateOptions is
- called.
- */
- virtual void setOption(const LogString& option,
- const LogString& value) = 0;
+ <p>The handling of each option depends on the OptionHandler
+ instance. Some options may become active immediately whereas
+ other may be activated only when #activateOptions is
+ called.
+ */
+ virtual void setOption(const LogString& option,
+ const LogString& value) = 0;
- }; // class OptionConverter
- } // namespace spi
+}; // class OptionConverter
+} // namespace spi
} // namespace log4cxx
diff --git a/src/main/include/log4cxx/spi/repositoryselector.h b/src/main/include/log4cxx/spi/repositoryselector.h
index 1d1bf0c..50131e8 100644
--- a/src/main/include/log4cxx/spi/repositoryselector.h
+++ b/src/main/include/log4cxx/spi/repositoryselector.h
@@ -23,32 +23,32 @@
namespace log4cxx
{
- namespace spi
- {
- class LoggerRepository;
- typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
+namespace spi
+{
+class LoggerRepository;
+typedef helpers::ObjectPtrT<LoggerRepository> LoggerRepositoryPtr;
- /**
- The <code>LogManager</code> uses one (and only one)
- <code>RepositorySelector</code> implementation to select the
- {@link log4cxx::spi::LoggerRepository LoggerRepository}
- for a particular application context.
+/**
+The <code>LogManager</code> uses one (and only one)
+<code>RepositorySelector</code> implementation to select the
+{@link log4cxx::spi::LoggerRepository LoggerRepository}
+ for a particular application context.
- <p>It is the responsability of the <code>RepositorySelector</code>
- implementation to track the application context. log4cxx makes no
- assumptions about the application context or on its management.
+<p>It is the responsability of the <code>RepositorySelector</code>
+implementation to track the application context. log4cxx makes no
+assumptions about the application context or on its management.
- <p>See also LogManager.
- */
- class LOG4CXX_EXPORT RepositorySelector : public virtual helpers::Object
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(RepositorySelector)
- virtual ~RepositorySelector() {}
- virtual LoggerRepositoryPtr& getLoggerRepository() = 0;
- };
- LOG4CXX_PTR_DEF(RepositorySelector);
- } //namespace spi
+<p>See also LogManager.
+*/
+class LOG4CXX_EXPORT RepositorySelector : public virtual helpers::Object
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(RepositorySelector)
+ virtual ~RepositorySelector() {}
+ virtual LoggerRepositoryPtr& getLoggerRepository() = 0;
+};
+LOG4CXX_PTR_DEF(RepositorySelector);
+} //namespace spi
} //namespace log4cxx
#endif //_LOG4CXX_SPI_REPOSITORY_SELECTOR_H
diff --git a/src/main/include/log4cxx/spi/rootlogger.h b/src/main/include/log4cxx/spi/rootlogger.h
index 5027385..bb1073d 100644
--- a/src/main/include/log4cxx/spi/rootlogger.h
+++ b/src/main/include/log4cxx/spi/rootlogger.h
@@ -22,39 +22,39 @@
namespace log4cxx
{
- namespace spi
- {
+namespace spi
+{
+/**
+RootLogger sits at the top of the logger hierachy. It is a
+regular logger except that it provides several guarantees.
+
+<p>First, it cannot be assigned a null
+level. Second, since root logger cannot have a parent, the
+#getEffectiveLevel method always returns the value of the
+level field without walking the hierarchy.
+*/
+class LOG4CXX_EXPORT RootLogger : public Logger
+{
+ public:
/**
- RootLogger sits at the top of the logger hierachy. It is a
- regular logger except that it provides several guarantees.
-
- <p>First, it cannot be assigned a null
- level. Second, since root logger cannot have a parent, the
- #getEffectiveLevel method always returns the value of the
- level field without walking the hierarchy.
+ The root logger names itself as "root". However, the root
+ logger cannot be retrieved by name.
*/
- class LOG4CXX_EXPORT RootLogger : public Logger
- {
- public:
- /**
- The root logger names itself as "root". However, the root
- logger cannot be retrieved by name.
- */
- RootLogger(log4cxx::helpers::Pool& pool, const LevelPtr& level);
+ RootLogger(log4cxx::helpers::Pool& pool, const LevelPtr& level);
- /**
- Return the assigned level value without walking the logger
- hierarchy.
- */
- virtual const LevelPtr& getEffectiveLevel() const;
+ /**
+ Return the assigned level value without walking the logger
+ hierarchy.
+ */
+ virtual const LevelPtr& getEffectiveLevel() const;
- /**
- Setting a null value to the level of the root logger may have catastrophic
- results. We prevent this here.
- */
- void setLevel(const LevelPtr& level);
- };
- } // namespace spi
+ /**
+ Setting a null value to the level of the root logger may have catastrophic
+ results. We prevent this here.
+ */
+ void setLevel(const LevelPtr& level);
+};
+} // namespace spi
} // namespace log4cxx
#endif //_LOG4CXX_SPI_ROOT_LOGGER_H
diff --git a/src/main/include/log4cxx/spi/triggeringeventevaluator.h b/src/main/include/log4cxx/spi/triggeringeventevaluator.h
index 3c6b054..2fac426 100644
--- a/src/main/include/log4cxx/spi/triggeringeventevaluator.h
+++ b/src/main/include/log4cxx/spi/triggeringeventevaluator.h
@@ -22,29 +22,29 @@
namespace log4cxx
{
- namespace spi
- {
- /**
- Implementions of this interface allow certain appenders to decide
- when to perform an appender specific action.
+namespace spi
+{
+/**
+Implementions of this interface allow certain appenders to decide
+when to perform an appender specific action.
- <p>For example the {@link net::SMTPAppender SMTPAppender} sends
- an email when the #isTriggeringEvent method returns
- <code>true</code> and adds the event to an internal buffer when the
- returned result is <code>false</code>.
+<p>For example the {@link net::SMTPAppender SMTPAppender} sends
+an email when the #isTriggeringEvent method returns
+<code>true</code> and adds the event to an internal buffer when the
+returned result is <code>false</code>.
- */
- class LOG4CXX_EXPORT TriggeringEventEvaluator : public virtual helpers::Object
- {
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(TriggeringEventEvaluator)
- /**
- Is this the triggering event?
- */
- virtual bool isTriggeringEvent(const spi::LoggingEventPtr& event) = 0;
- };
- LOG4CXX_PTR_DEF(TriggeringEventEvaluator);
- }
+*/
+class LOG4CXX_EXPORT TriggeringEventEvaluator : public virtual helpers::Object
+{
+ public:
+ DECLARE_ABSTRACT_LOG4CXX_OBJECT(TriggeringEventEvaluator)
+ /**
+ Is this the triggering event?
+ */
+ virtual bool isTriggeringEvent(const spi::LoggingEventPtr& event) = 0;
+};
+LOG4CXX_PTR_DEF(TriggeringEventEvaluator);
+}
}
#endif // _LOG4CXX_SPI_TRIGGERING_EVENT_EVALUATOR_H
diff --git a/src/main/include/log4cxx/stream.h b/src/main/include/log4cxx/stream.h
index 915a310..73814d2 100644
--- a/src/main/include/log4cxx/stream.h
+++ b/src/main/include/log4cxx/stream.h
@@ -25,495 +25,510 @@
namespace log4cxx
{
- /**
- * Base class for the basic_logstream template which attempts
- * to emulate std::basic_ostream but attempts to short-circuit
- * unnecessary operations.
- *
- * The logstream has a logger and level that are used for logging
- * requests. The level of the stream is compared against the
- * current level of the logger to determine if the request should be processed.
+/**
+ * Base class for the basic_logstream template which attempts
+ * to emulate std::basic_ostream but attempts to short-circuit
+ * unnecessary operations.
+ *
+ * The logstream has a logger and level that are used for logging
+ * requests. The level of the stream is compared against the
+ * current level of the logger to determine if the request should be processed.
+ */
+class LOG4CXX_EXPORT logstream_base
+{
+ public:
+ /**
+ * Create new instance.
+ * @param logger logger logger used in log requests.
+ * @param level indicates level that will be used in log requests. Can
+ * be modified later by inserting a level or calling setLevel.
*/
- class LOG4CXX_EXPORT logstream_base {
- public:
- /**
- * Create new instance.
- * @param logger logger logger used in log requests.
- * @param level indicates level that will be used in log requests. Can
- * be modified later by inserting a level or calling setLevel.
- */
- logstream_base(const log4cxx::LoggerPtr& logger,
- const log4cxx::LevelPtr& level);
- /**
- * Destructor.
- */
- virtual ~logstream_base();
- /**
- * Insertion operator for std::fixed and similar manipulators.
- */
- void insert(std::ios_base& (*manip)(std::ios_base&));
+ logstream_base(const log4cxx::LoggerPtr& logger,
+ const log4cxx::LevelPtr& level);
+ /**
+ * Destructor.
+ */
+ virtual ~logstream_base();
+ /**
+ * Insertion operator for std::fixed and similar manipulators.
+ */
+ void insert(std::ios_base & (*manip)(std::ios_base&));
- /**
- * get precision.
- */
- int precision();
- /**
- * get width.
- */
- int width();
- /**
- * set precision. This should be used in preference to inserting an std::setprecision(n)
- * since the other requires construction of an STL stream which may be expensive.
- */
- int precision(int newval);
- /**
- * set width. This should be used in preference to inserting an std::setw(n)
- * since the other requires construction of an STL stream which may be expensive.
- */
- int width(int newval);
- /**
- * Get fill character.
- */
- int fill();
- /**
- * Set fill character.
- */
- int fill(int newval);
+ /**
+ * get precision.
+ */
+ int precision();
+ /**
+ * get width.
+ */
+ int width();
+ /**
+ * set precision. This should be used in preference to inserting an std::setprecision(n)
+ * since the other requires construction of an STL stream which may be expensive.
+ */
+ int precision(int newval);
+ /**
+ * set width. This should be used in preference to inserting an std::setw(n)
+ * since the other requires construction of an STL stream which may be expensive.
+ */
+ int width(int newval);
+ /**
+ * Get fill character.
+ */
+ int fill();
+ /**
+ * Set fill character.
+ */
+ int fill(int newval);
- /**
- * Set flags. see std::ios_base.
- */
- std::ios_base::fmtflags flags(std::ios_base::fmtflags newflags);
- /**
- * Set flags. see std::ios_base.
- */
- std::ios_base::fmtflags setf(std::ios_base::fmtflags newflags, std::ios_base::fmtflags mask);
- /**
- * Set flags. see std::ios_base.
- */
- std::ios_base::fmtflags setf(std::ios_base::fmtflags newflags);
+ /**
+ * Set flags. see std::ios_base.
+ */
+ std::ios_base::fmtflags flags(std::ios_base::fmtflags newflags);
+ /**
+ * Set flags. see std::ios_base.
+ */
+ std::ios_base::fmtflags setf(std::ios_base::fmtflags newflags, std::ios_base::fmtflags mask);
+ /**
+ * Set flags. see std::ios_base.
+ */
+ std::ios_base::fmtflags setf(std::ios_base::fmtflags newflags);
- /**
- * end of message manipulator, triggers logging.
- */
- static logstream_base& endmsg(logstream_base&);
+ /**
+ * end of message manipulator, triggers logging.
+ */
+ static logstream_base& endmsg(logstream_base&);
- /**
- * no-operation manipulator, Used to avoid ambiguity with VC6.
- */
- static logstream_base& nop(logstream_base&);
+ /**
+ * no-operation manipulator, Used to avoid ambiguity with VC6.
+ */
+ static logstream_base& nop(logstream_base&);
- /**
- * end of message action.
- */
- void end_message();
+ /**
+ * end of message action.
+ */
+ void end_message();
- /**
- * Set the level.
- * @param level level
- */
- void setLevel(const LevelPtr& level);
- /**
- * Returns true if the current level is the same or high as the
- * level of logger at time of construction or last setLevel.
- */
- inline bool isEnabled() const {
- return enabled;
- }
+ /**
+ * Set the level.
+ * @param level level
+ */
+ void setLevel(const LevelPtr& level);
+ /**
+ * Returns true if the current level is the same or high as the
+ * level of logger at time of construction or last setLevel.
+ */
+ inline bool isEnabled() const
+ {
+ return enabled;
+ }
- /**
- * Returns if logger is currently enabled for the specified level.
- */
- bool isEnabledFor(const LevelPtr& level) const;
+ /**
+ * Returns if logger is currently enabled for the specified level.
+ */
+ bool isEnabledFor(const LevelPtr& level) const;
- /**
- * Sets the location for subsequent log requests.
- */
- void setLocation(const log4cxx::spi::LocationInfo& location);
+ /**
+ * Sets the location for subsequent log requests.
+ */
+ void setLocation(const log4cxx::spi::LocationInfo& location);
- /**
- * Sets the state of the embedded stream (if any)
- * to the state of the formatting info.
- * @param os stream to receive formatting info.
- * @param fillchar receives fill charater.
- * @return true if fill character was specified.
- */
- bool set_stream_state(std::ios_base& os, int& fillchar);
+ /**
+ * Sets the state of the embedded stream (if any)
+ * to the state of the formatting info.
+ * @param os stream to receive formatting info.
+ * @param fillchar receives fill charater.
+ * @return true if fill character was specified.
+ */
+ bool set_stream_state(std::ios_base& os, int& fillchar);
- protected:
- /**
- * Dispatches the pending log request.
- */
- virtual void log(LoggerPtr& logger,
- const LevelPtr& level,
- const log4cxx::spi::LocationInfo& location) = 0;
- /**
- * Erase any content in the message construction buffer.
- */
- virtual void erase() = 0;
- /**
- * Copy state of embedded stream (if any)
- * to value and mask instances of std::ios_base
- * and return fill character value.
- */
- virtual void get_stream_state(std::ios_base& base,
- std::ios_base& mask,
- int& fill,
- bool& fillSet) const = 0;
- virtual void refresh_stream_state() = 0;
+ protected:
+ /**
+ * Dispatches the pending log request.
+ */
+ virtual void log(LoggerPtr& logger,
+ const LevelPtr& level,
+ const log4cxx::spi::LocationInfo& location) = 0;
+ /**
+ * Erase any content in the message construction buffer.
+ */
+ virtual void erase() = 0;
+ /**
+ * Copy state of embedded stream (if any)
+ * to value and mask instances of std::ios_base
+ * and return fill character value.
+ */
+ virtual void get_stream_state(std::ios_base& base,
+ std::ios_base& mask,
+ int& fill,
+ bool& fillSet) const = 0;
+ virtual void refresh_stream_state() = 0;
- private:
- /**
- * prevent copy constructor.
- */
- logstream_base(logstream_base&);
- /**
- * prevent copy operatpr.
- */
- logstream_base& operator=(logstream_base&);
- /**
- * Minimal extension of std::ios_base to allow creation
- * of embedded IO states.
- */
- class LOG4CXX_EXPORT logstream_ios_base : public std::ios_base {
+ private:
+ /**
+ * prevent copy constructor.
+ */
+ logstream_base(logstream_base&);
+ /**
+ * prevent copy operatpr.
+ */
+ logstream_base& operator=(logstream_base&);
+ /**
+ * Minimal extension of std::ios_base to allow creation
+ * of embedded IO states.
+ */
+ class LOG4CXX_EXPORT logstream_ios_base : public std::ios_base
+ {
public:
logstream_ios_base(std::ios_base::fmtflags initval,
- int initsize);
- } initset, initclear;
- /**
- * fill character.
- */
- int fillchar;
- /**
- * true if fill character is set.
- */
- bool fillset;
- /**
- * true if assigned level was same or higher than level of associated logger.
- */
- bool enabled;
- /**
- * associated logger.
- */
- log4cxx::LoggerPtr logger;
- /**
- * associated level.
- */
- log4cxx::LevelPtr level;
- /**
- * associated level.
- */
- log4cxx::spi::LocationInfo location;
- };
+ int initsize);
+ } initset, initclear;
+ /**
+ * fill character.
+ */
+ int fillchar;
+ /**
+ * true if fill character is set.
+ */
+ bool fillset;
+ /**
+ * true if assigned level was same or higher than level of associated logger.
+ */
+ bool enabled;
+ /**
+ * associated logger.
+ */
+ log4cxx::LoggerPtr logger;
+ /**
+ * associated level.
+ */
+ log4cxx::LevelPtr level;
+ /**
+ * associated level.
+ */
+ log4cxx::spi::LocationInfo location;
+};
- typedef logstream_base& (*logstream_manipulator)(logstream_base&);
+typedef logstream_base& (*logstream_manipulator)(logstream_base&);
+
+/**
+ * An STL-like stream API for log4cxx using char as the character type.
+*. Instances of log4cxx::logstream
+ * are not designedfor use by multiple threads and in general should be short-lived
+ * function scoped objects. Using log4cxx::basic_logstream as a class member or
+ * static instance should be avoided in the same manner as you would avoid placing a std::ostringstream
+ * in those locations. Insertion operations are generally short-circuited if the
+ * level for the stream is not the same of higher that the level of the associated logger.
+ */
+class LOG4CXX_EXPORT logstream : public logstream_base
+{
+ typedef char Ch;
+ public:
+ /**
+ * Constructor.
+ */
+ logstream(const log4cxx::LoggerPtr& logger,
+ const log4cxx::LevelPtr& level);
/**
- * An STL-like stream API for log4cxx using char as the character type.
- *. Instances of log4cxx::logstream
- * are not designedfor use by multiple threads and in general should be short-lived
- * function scoped objects. Using log4cxx::basic_logstream as a class member or
- * static instance should be avoided in the same manner as you would avoid placing a std::ostringstream
- * in those locations. Insertion operations are generally short-circuited if the
- * level for the stream is not the same of higher that the level of the associated logger.
+ * Constructor.
*/
- class LOG4CXX_EXPORT logstream : public logstream_base {
- typedef char Ch;
- public:
- /**
- * Constructor.
- */
- logstream(const log4cxx::LoggerPtr& logger,
- const log4cxx::LevelPtr& level);
+ logstream(const Ch* loggerName,
+ const log4cxx::LevelPtr& level);
- /**
- * Constructor.
- */
- logstream(const Ch* loggerName,
- const log4cxx::LevelPtr& level);
+ /**
+ * Constructor.
+ */
+ logstream(const std::basic_string<Ch>& loggerName,
+ const log4cxx::LevelPtr& level);
- /**
- * Constructor.
- */
- logstream(const std::basic_string<Ch>& loggerName,
- const log4cxx::LevelPtr& level);
+ ~logstream();
- ~logstream();
+ /**
+ * Insertion operator for std::fixed and similar manipulators.
+ */
+ logstream& operator<<(std::ios_base & (*manip)(std::ios_base&));
- /**
- * Insertion operator for std::fixed and similar manipulators.
- */
- logstream& operator<<(std::ios_base& (*manip)(std::ios_base&));
+ /**
+ * Insertion operator for logstream_base::endmsg.
+ */
+ logstream& operator<<(logstream_manipulator manip);
- /**
- * Insertion operator for logstream_base::endmsg.
- */
- logstream& operator<<(logstream_manipulator manip);
+ /**
+ * Insertion operator for level.
+ */
+ logstream& operator<<(const log4cxx::LevelPtr& level);
+ /**
+ * Insertion operator for location.
+ */
+ logstream& operator<<(const log4cxx::spi::LocationInfo& location);
- /**
- * Insertion operator for level.
- */
- logstream& operator<<(const log4cxx::LevelPtr& level);
- /**
- * Insertion operator for location.
- */
- logstream& operator<<(const log4cxx::spi::LocationInfo& location);
+ /**
+ * Alias for insertion operator for location. Kludge to avoid
+ * inappropriate compiler ambiguity.
+ */
+ logstream& operator>>(const log4cxx::spi::LocationInfo& location);
- /**
- * Alias for insertion operator for location. Kludge to avoid
- * inappropriate compiler ambiguity.
- */
- logstream& operator>>(const log4cxx::spi::LocationInfo& location);
-
- /**
- * Cast operator to provide access to embedded std::basic_ostream.
- */
- operator std::basic_ostream<Ch>&();
+ /**
+ * Cast operator to provide access to embedded std::basic_ostream.
+ */
+ operator std::basic_ostream<Ch>& ();
#if !(LOG4CXX_USE_GLOBAL_SCOPE_TEMPLATE)
- /**
- * Template to allow any class with an std::basic_ostream inserter
- * to be applied to this class.
- */
- template <class V>
- inline log4cxx::logstream& operator<<(const V& val) {
- if (LOG4CXX_UNLIKELY(isEnabled())) {
- ((std::basic_ostream<char>&) *this) << val;
- }
- return *this;
- }
+ /**
+ * Template to allow any class with an std::basic_ostream inserter
+ * to be applied to this class.
+ */
+ template <class V>
+ inline log4cxx::logstream& operator<<(const V& val)
+ {
+ if (LOG4CXX_UNLIKELY(isEnabled()))
+ {
+ ((std::basic_ostream<char>&) *this) << val;
+ }
+
+ return *this;
+ }
#endif
- protected:
- virtual void log(LoggerPtr& logger,
- const LevelPtr& level,
- const log4cxx::spi::LocationInfo& location);
+ protected:
+ virtual void log(LoggerPtr& logger,
+ const LevelPtr& level,
+ const log4cxx::spi::LocationInfo& location);
- virtual void erase();
+ virtual void erase();
- virtual void get_stream_state(std::ios_base& base,
- std::ios_base& mask,
- int& fill,
- bool& fillSet) const;
- virtual void refresh_stream_state();
+ virtual void get_stream_state(std::ios_base& base,
+ std::ios_base& mask,
+ int& fill,
+ bool& fillSet) const;
+ virtual void refresh_stream_state();
- private:
- logstream(const logstream&);
- logstream& operator=(const logstream&);
- std::basic_stringstream<Ch>* stream;
+ private:
+ logstream(const logstream&);
+ logstream& operator=(const logstream&);
+ std::basic_stringstream<Ch>* stream;
- };
+};
#if LOG4CXX_WCHAR_T_API
+/**
+ * An STL-like stream API for log4cxx using wchar_t as the character type.
+*. Instances of log4cxx::logstream
+ * are not designedfor use by multiple threads and in general should be short-lived
+ * function scoped objects. Using log4cxx::basic_logstream as a class member or
+ * static instance should be avoided in the same manner as you would avoid placing a std::ostringstream
+ * in those locations. Insertion operations are generally short-circuited if the
+ * level for the stream is not the same of higher that the level of the associated logger.
+ */
+class LOG4CXX_EXPORT wlogstream : public logstream_base
+{
+ typedef wchar_t Ch;
+ public:
/**
- * An STL-like stream API for log4cxx using wchar_t as the character type.
- *. Instances of log4cxx::logstream
- * are not designedfor use by multiple threads and in general should be short-lived
- * function scoped objects. Using log4cxx::basic_logstream as a class member or
- * static instance should be avoided in the same manner as you would avoid placing a std::ostringstream
- * in those locations. Insertion operations are generally short-circuited if the
- * level for the stream is not the same of higher that the level of the associated logger.
+ * Constructor.
*/
- class LOG4CXX_EXPORT wlogstream : public logstream_base {
- typedef wchar_t Ch;
- public:
- /**
- * Constructor.
- */
- wlogstream(const log4cxx::LoggerPtr& logger,
- const log4cxx::LevelPtr& level);
+ wlogstream(const log4cxx::LoggerPtr& logger,
+ const log4cxx::LevelPtr& level);
- /**
- * Constructor.
- */
- wlogstream(const Ch* loggerName,
- const log4cxx::LevelPtr& level);
+ /**
+ * Constructor.
+ */
+ wlogstream(const Ch* loggerName,
+ const log4cxx::LevelPtr& level);
- /**
- * Constructor.
- */
- wlogstream(const std::basic_string<Ch>& loggerName,
- const log4cxx::LevelPtr& level);
+ /**
+ * Constructor.
+ */
+ wlogstream(const std::basic_string<Ch>& loggerName,
+ const log4cxx::LevelPtr& level);
- ~wlogstream();
+ ~wlogstream();
- /**
- * Insertion operator for std::fixed and similar manipulators.
- */
- wlogstream& operator<<(std::ios_base& (*manip)(std::ios_base&));
+ /**
+ * Insertion operator for std::fixed and similar manipulators.
+ */
+ wlogstream& operator<<(std::ios_base & (*manip)(std::ios_base&));
- /**
- * Insertion operator for logstream_base::endmsg.
- */
- wlogstream& operator<<(logstream_manipulator manip);
+ /**
+ * Insertion operator for logstream_base::endmsg.
+ */
+ wlogstream& operator<<(logstream_manipulator manip);
- /**
- * Insertion operator for level.
- */
- wlogstream& operator<<(const log4cxx::LevelPtr& level);
- /**
- * Insertion operator for location.
- */
- wlogstream& operator<<(const log4cxx::spi::LocationInfo& location);
+ /**
+ * Insertion operator for level.
+ */
+ wlogstream& operator<<(const log4cxx::LevelPtr& level);
+ /**
+ * Insertion operator for location.
+ */
+ wlogstream& operator<<(const log4cxx::spi::LocationInfo& location);
- /**
- * Alias for insertion operator for location. Kludge to avoid
- * inappropriate compiler ambiguity.
- */
- wlogstream& operator>>(const log4cxx::spi::LocationInfo& location);
+ /**
+ * Alias for insertion operator for location. Kludge to avoid
+ * inappropriate compiler ambiguity.
+ */
+ wlogstream& operator>>(const log4cxx::spi::LocationInfo& location);
- /**
- * Cast operator to provide access to embedded std::basic_ostream.
- */
- operator std::basic_ostream<Ch>&();
+ /**
+ * Cast operator to provide access to embedded std::basic_ostream.
+ */
+ operator std::basic_ostream<Ch>& ();
#if !(LOG4CXX_USE_GLOBAL_SCOPE_TEMPLATE)
- /**
- * Template to allow any class with an std::basic_ostream inserter
- * to be applied to this class.
- */
- template <class V>
- inline log4cxx::wlogstream& operator<<(const V& val) {
- if (LOG4CXX_UNLIKELY(isEnabled())) {
- ((std::basic_ostream<wchar_t>&) *this) << val;
- }
- return *this;
- }
+ /**
+ * Template to allow any class with an std::basic_ostream inserter
+ * to be applied to this class.
+ */
+ template <class V>
+ inline log4cxx::wlogstream& operator<<(const V& val)
+ {
+ if (LOG4CXX_UNLIKELY(isEnabled()))
+ {
+ ((std::basic_ostream<wchar_t>&) *this) << val;
+ }
+
+ return *this;
+ }
#endif
- protected:
- virtual void log(LoggerPtr& logger,
- const LevelPtr& level,
- const log4cxx::spi::LocationInfo& location);
+ protected:
+ virtual void log(LoggerPtr& logger,
+ const LevelPtr& level,
+ const log4cxx::spi::LocationInfo& location);
- virtual void erase();
+ virtual void erase();
- virtual void get_stream_state(std::ios_base& base,
- std::ios_base& mask,
- int& fill,
- bool& fillSet) const;
- virtual void refresh_stream_state();
+ virtual void get_stream_state(std::ios_base& base,
+ std::ios_base& mask,
+ int& fill,
+ bool& fillSet) const;
+ virtual void refresh_stream_state();
- private:
- wlogstream(const wlogstream&);
- wlogstream& operator=(const wlogstream&);
- std::basic_stringstream<Ch>* stream;
+ private:
+ wlogstream(const wlogstream&);
+ wlogstream& operator=(const wlogstream&);
+ std::basic_stringstream<Ch>* stream;
- };
+};
#endif
#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
+/**
+ * An STL-like stream API for log4cxx using UniChar as the character type.
+*. Instances of log4cxx::logstream
+ * are not designedfor use by multiple threads and in general should be short-lived
+ * function scoped objects. Using log4cxx::basic_logstream as a class member or
+ * static instance should be avoided in the same manner as you would avoid placing a std::ostringstream
+ * in those locations. Insertion operations are generally short-circuited if the
+ * level for the stream is not the same of higher that the level of the associated logger.
+ */
+class LOG4CXX_EXPORT ulogstream : public logstream_base
+{
+ typedef UniChar Ch;
+ public:
/**
- * An STL-like stream API for log4cxx using UniChar as the character type.
- *. Instances of log4cxx::logstream
- * are not designedfor use by multiple threads and in general should be short-lived
- * function scoped objects. Using log4cxx::basic_logstream as a class member or
- * static instance should be avoided in the same manner as you would avoid placing a std::ostringstream
- * in those locations. Insertion operations are generally short-circuited if the
- * level for the stream is not the same of higher that the level of the associated logger.
+ * Constructor.
*/
- class LOG4CXX_EXPORT ulogstream : public logstream_base {
- typedef UniChar Ch;
- public:
- /**
- * Constructor.
- */
- ulogstream(const log4cxx::LoggerPtr& logger,
- const log4cxx::LevelPtr& level);
+ ulogstream(const log4cxx::LoggerPtr& logger,
+ const log4cxx::LevelPtr& level);
#if LOG4CXX_UNICHAR_API
- /**
- * Constructor.
- */
- ulogstream(const Ch* loggerName,
- const log4cxx::LevelPtr& level);
+ /**
+ * Constructor.
+ */
+ ulogstream(const Ch* loggerName,
+ const log4cxx::LevelPtr& level);
- /**
- * Constructor.
- */
- ulogstream(const std::basic_string<Ch>& loggerName,
- const log4cxx::LevelPtr& level);
-#endif
-
-#if LOG4CXX_CFSTRING_API
- ulogstream(const CFStringRef& loggerName,
+ /**
+ * Constructor.
+ */
+ ulogstream(const std::basic_string<Ch>& loggerName,
const log4cxx::LevelPtr& level);
#endif
- ~ulogstream();
-
- /**
- * Insertion operator for std::fixed and similar manipulators.
- */
- ulogstream& operator<<(std::ios_base& (*manip)(std::ios_base&));
-
- /**
- * Insertion operator for logstream_base::endmsg.
- */
- ulogstream& operator<<(logstream_manipulator manip);
-
- /**
- * Insertion operator for level.
- */
- ulogstream& operator<<(const log4cxx::LevelPtr& level);
- /**
- * Insertion operator for location.
- */
- ulogstream& operator<<(const log4cxx::spi::LocationInfo& location);
-
- /**
- * Alias for insertion operator for location. Kludge to avoid
- * inappropriate compiler ambiguity.
- */
- ulogstream& operator>>(const log4cxx::spi::LocationInfo& location);
-
-
- /**
- * Cast operator to provide access to embedded std::basic_ostream.
- */
- operator std::basic_ostream<Ch>&();
-
-#if !(LOG4CXX_USE_GLOBAL_SCOPE_TEMPLATE)
- /**
- * Template to allow any class with an std::basic_ostream inserter
- * to be applied to this class.
- */
- template <class V>
- inline ulogstream& operator<<(const V& val) {
- if (LOG4CXX_UNLIKELY(isEnabled())) {
- ((std::basic_ostream<Ch>&) *this) << val;
- }
- return *this;
- }
+#if LOG4CXX_CFSTRING_API
+ ulogstream(const CFStringRef& loggerName,
+ const log4cxx::LevelPtr& level);
#endif
- protected:
- virtual void log(LoggerPtr& logger,
- const LevelPtr& level,
- const log4cxx::spi::LocationInfo& location);
+ ~ulogstream();
- virtual void erase();
+ /**
+ * Insertion operator for std::fixed and similar manipulators.
+ */
+ ulogstream& operator<<(std::ios_base & (*manip)(std::ios_base&));
- virtual void get_stream_state(std::ios_base& base,
- std::ios_base& mask,
- int& fill,
- bool& fillSet) const;
- virtual void refresh_stream_state();
+ /**
+ * Insertion operator for logstream_base::endmsg.
+ */
+ ulogstream& operator<<(logstream_manipulator manip);
+
+ /**
+ * Insertion operator for level.
+ */
+ ulogstream& operator<<(const log4cxx::LevelPtr& level);
+ /**
+ * Insertion operator for location.
+ */
+ ulogstream& operator<<(const log4cxx::spi::LocationInfo& location);
+
+ /**
+ * Alias for insertion operator for location. Kludge to avoid
+ * inappropriate compiler ambiguity.
+ */
+ ulogstream& operator>>(const log4cxx::spi::LocationInfo& location);
- private:
- ulogstream(const ulogstream&);
- ulogstream& operator=(const ulogstream&);
- std::basic_stringstream<Ch>* stream;
+ /**
+ * Cast operator to provide access to embedded std::basic_ostream.
+ */
+ operator std::basic_ostream<Ch>& ();
- };
+#if !(LOG4CXX_USE_GLOBAL_SCOPE_TEMPLATE)
+ /**
+ * Template to allow any class with an std::basic_ostream inserter
+ * to be applied to this class.
+ */
+ template <class V>
+ inline ulogstream& operator<<(const V& val)
+ {
+ if (LOG4CXX_UNLIKELY(isEnabled()))
+ {
+ ((std::basic_ostream<Ch>&) *this) << val;
+ }
+
+ return *this;
+ }
+#endif
+
+ protected:
+ virtual void log(LoggerPtr& logger,
+ const LevelPtr& level,
+ const log4cxx::spi::LocationInfo& location);
+
+ virtual void erase();
+
+ virtual void get_stream_state(std::ios_base& base,
+ std::ios_base& mask,
+ int& fill,
+ bool& fillSet) const;
+ virtual void refresh_stream_state();
+
+
+ private:
+ ulogstream(const ulogstream&);
+ ulogstream& operator=(const ulogstream&);
+ std::basic_stringstream<Ch>* stream;
+
+};
#endif
@@ -532,11 +547,14 @@
* to be applied to this class.
*/
template <class V>
-inline log4cxx::logstream& operator<<(log4cxx::logstream& os, const V& val) {
- if (LOG4CXX_UNLIKELY(os.isEnabled())) {
- ((std::basic_ostream<char>&) os) << val;
- }
- return os;
+inline log4cxx::logstream& operator<<(log4cxx::logstream& os, const V& val)
+{
+ if (LOG4CXX_UNLIKELY(os.isEnabled()))
+ {
+ ((std::basic_ostream<char>&) os) << val;
+ }
+
+ return os;
}
#if LOG4CXX_WCHAR_T_API
@@ -545,21 +563,24 @@
* to be applied to this class.
*/
template <class V>
-inline log4cxx::wlogstream& operator<<(log4cxx::wlogstream& os, const V& val) {
- if (LOG4CXX_UNLIKELY(os.isEnabled())) {
- ((std::basic_ostream<wchar_t>&) os) << val;
- }
- return os;
+inline log4cxx::wlogstream& operator<<(log4cxx::wlogstream& os, const V& val)
+{
+ if (LOG4CXX_UNLIKELY(os.isEnabled()))
+ {
+ ((std::basic_ostream<wchar_t>&) os) << val;
+ }
+
+ return os;
}
#endif
#endif
#if !defined(LOG4CXX_ENDMSG)
-#if LOG4CXX_LOGSTREAM_ADD_NOP
-#define LOG4CXX_ENDMSG (log4cxx::logstream_manipulator) log4cxx::logstream_base::nop >> LOG4CXX_LOCATION << (log4cxx::logstream_manipulator) log4cxx::logstream_base::endmsg
-#else
-#define LOG4CXX_ENDMSG LOG4CXX_LOCATION << (log4cxx::logstream_manipulator) log4cxx::logstream_base::endmsg
-#endif
+ #if LOG4CXX_LOGSTREAM_ADD_NOP
+ #define LOG4CXX_ENDMSG (log4cxx::logstream_manipulator) log4cxx::logstream_base::nop >> LOG4CXX_LOCATION << (log4cxx::logstream_manipulator) log4cxx::logstream_base::endmsg
+ #else
+ #define LOG4CXX_ENDMSG LOG4CXX_LOCATION << (log4cxx::logstream_manipulator) log4cxx::logstream_base::endmsg
+ #endif
#endif
diff --git a/src/main/include/log4cxx/ttcclayout.h b/src/main/include/log4cxx/ttcclayout.h
index 8c14d65..17e156b 100644
--- a/src/main/include/log4cxx/ttcclayout.h
+++ b/src/main/include/log4cxx/ttcclayout.h
@@ -19,8 +19,8 @@
#define _LOG4CXX_TTCC_LAYOUT_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/helpers/datelayout.h>
@@ -28,70 +28,70 @@
namespace log4cxx
{
- /**
- TTCC layout format consists of time, thread, logger name and nested
- diagnostic context information, hence the name.
+/**
+TTCC layout format consists of time, thread, logger name and nested
+diagnostic context information, hence the name.
- <p>Each of the four fields can be individually enabled or
- disabled. The time format depends on the <code>DateFormat</code>
- used.
+<p>Each of the four fields can be individually enabled or
+disabled. The time format depends on the <code>DateFormat</code>
+used.
- <p>Here is an example TTCCLayout output with the
- {@link helpers::RelativeTimeDateFormat RelativeTimeDateFormat}.
+<p>Here is an example TTCCLayout output with the
+{@link helpers::RelativeTimeDateFormat RelativeTimeDateFormat}.
- <pre>
- 176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse order.
- 225 [main] INFO examples.SortAlgo - Entered the sort method.
- 262 [main] DEBUG examples.SortAlgo.OUTER i=1 - Outer loop.
- 276 [main] DEBUG examples.SortAlgo.SWAP i=1 j=0 - Swapping intArray[0] = 1 and intArray[1] = 0
- 290 [main] DEBUG examples.SortAlgo.OUTER i=0 - Outer loop.
- 304 [main] INFO examples.SortAlgo.DUMP - Dump of interger array:
- 317 [main] INFO examples.SortAlgo.DUMP - Element [0] = 0
- 331 [main] INFO examples.SortAlgo.DUMP - Element [1] = 1
- 343 [main] INFO examples.Sort - The next log statement should be an error message.
- 346 [main] ERROR examples.SortAlgo.DUMP - Tried to dump an uninitialized array.
- 467 [main] INFO examples.Sort - Exiting main method.
- </pre>
+<pre>
+176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse order.
+225 [main] INFO examples.SortAlgo - Entered the sort method.
+262 [main] DEBUG examples.SortAlgo.OUTER i=1 - Outer loop.
+276 [main] DEBUG examples.SortAlgo.SWAP i=1 j=0 - Swapping intArray[0] = 1 and intArray[1] = 0
+290 [main] DEBUG examples.SortAlgo.OUTER i=0 - Outer loop.
+304 [main] INFO examples.SortAlgo.DUMP - Dump of interger array:
+317 [main] INFO examples.SortAlgo.DUMP - Element [0] = 0
+331 [main] INFO examples.SortAlgo.DUMP - Element [1] = 1
+343 [main] INFO examples.Sort - The next log statement should be an error message.
+346 [main] ERROR examples.SortAlgo.DUMP - Tried to dump an uninitialized array.
+467 [main] INFO examples.Sort - Exiting main method.
+</pre>
- <p>The first field is the number of milliseconds elapsed since the
- start of the program. The second field is the thread outputting the
- log statement. The third field is the level, the fourth field is
- the logger to which the statement belongs.
+<p>The first field is the number of milliseconds elapsed since the
+start of the program. The second field is the thread outputting the
+log statement. The third field is the level, the fourth field is
+the logger to which the statement belongs.
- <p>The fifth field (just before the '-') is the nested diagnostic
- context. Note the nested diagnostic context may be empty as in the
- first two statements. The text after the '-' is the message of the
- statement.
+<p>The fifth field (just before the '-') is the nested diagnostic
+context. Note the nested diagnostic context may be empty as in the
+first two statements. The text after the '-' is the message of the
+statement.
- <p><b>WARNING</b> Do not use the same TTCCLayout instance from
- within different appenders. The TTCCLayout is not thread safe when
- used in his way. However, it is perfectly safe to use a TTCCLayout
- instance from just one appender.
+<p><b>WARNING</b> Do not use the same TTCCLayout instance from
+within different appenders. The TTCCLayout is not thread safe when
+used in his way. However, it is perfectly safe to use a TTCCLayout
+instance from just one appender.
- <p>PatternLayout offers a much more flexible alternative.
- */
- class LOG4CXX_EXPORT TTCCLayout : public helpers::DateLayout
- {
- private:
- // Internal representation of options
- bool threadPrinting;
- bool categoryPrefixing;
- bool contextPrinting;
- bool filePrinting;
+<p>PatternLayout offers a much more flexible alternative.
+*/
+class LOG4CXX_EXPORT TTCCLayout : public helpers::DateLayout
+{
+ private:
+ // Internal representation of options
+ bool threadPrinting;
+ bool categoryPrefixing;
+ bool contextPrinting;
+ bool filePrinting;
- public:
- DECLARE_LOG4CXX_OBJECT(TTCCLayout)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(TTCCLayout)
- LOG4CXX_CAST_ENTRY_CHAIN(Layout)
- END_LOG4CXX_CAST_MAP()
+ public:
+ DECLARE_LOG4CXX_OBJECT(TTCCLayout)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(TTCCLayout)
+ LOG4CXX_CAST_ENTRY_CHAIN(Layout)
+ END_LOG4CXX_CAST_MAP()
/**
Instantiate a TTCCLayout object with {@link
helpers::RelativeTimeDateFormat RelativeTimeDateFormat} as the date
formatter in the local time zone.
*/
- TTCCLayout();
+ TTCCLayout();
/**
Instantiate a TTCCLayout object using the local time zone. The
@@ -99,60 +99,76 @@
<p>This constructor just calls the {@link
helpers::DateLayout#setDateFormat DateLayout::setDateFormat} method.
*/
- TTCCLayout(const LogString& dateFormatType);
+ TTCCLayout(const LogString& dateFormatType);
/**
The <b>ThreadPrinting</b> option specifies whether the name of the
current thread is part of log output or not. This is true by default.
*/
- inline void setThreadPrinting(bool threadPrinting1)
- { this->threadPrinting = threadPrinting1; }
+ inline void setThreadPrinting(bool threadPrinting1)
+ {
+ this->threadPrinting = threadPrinting1;
+ }
/**
Returns value of the <b>ThreadPrinting</b> option.
*/
- inline bool getThreadPrinting() const
- { return threadPrinting; }
+ inline bool getThreadPrinting() const
+ {
+ return threadPrinting;
+ }
/**
The <b>CategoryPrefixing</b> option specifies whether Logger
name is part of log output or not. This is true by default.
*/
- inline void setCategoryPrefixing(bool categoryPrefixing1)
- { this->categoryPrefixing = categoryPrefixing1; }
+ inline void setCategoryPrefixing(bool categoryPrefixing1)
+ {
+ this->categoryPrefixing = categoryPrefixing1;
+ }
/**
Returns value of the <b>CategoryPrefixing</b> option.
*/
- inline bool getCategoryPrefixing() const
- { return categoryPrefixing; }
+ inline bool getCategoryPrefixing() const
+ {
+ return categoryPrefixing;
+ }
/**
The <b>ContextPrinting</b> option specifies log output will include
the nested context information belonging to the current thread.
This is true by default.
*/
- inline void setContextPrinting(bool contextPrinting1)
- { this->contextPrinting = contextPrinting1; }
+ inline void setContextPrinting(bool contextPrinting1)
+ {
+ this->contextPrinting = contextPrinting1;
+ }
/**
Returns value of the <b>ContextPrinting</b> option.
*/
- inline bool getContextPrinting() const
- { return contextPrinting; }
+ inline bool getContextPrinting() const
+ {
+ return contextPrinting;
+ }
/**
The <b>FilePrinting</b> option specifies log output will include
the file and the line where the log statement was written.
*/
- inline void setFilePrinting(bool filePrinting1)
- { this->filePrinting = filePrinting1; }
+ inline void setFilePrinting(bool filePrinting1)
+ {
+ this->filePrinting = filePrinting1;
+ }
/**
Returns value of the <b>ContextPrinting</b> option.
*/
- inline bool getFilePrinting() const
- { return filePrinting; }
+ inline bool getFilePrinting() const
+ {
+ return filePrinting;
+ }
/**
In addition to the level of the statement and message, this function
@@ -167,21 +183,24 @@
@param pool pool used to allocate memory needed during formatting.
*/
virtual void format(LogString& output,
- const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool) const;
+ const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool) const;
/**
The TTCCLayout does not handle the throwable contained within
{@link spi::LoggingEvent LoggingEvents}. Thus, it returns
<code>true</code>.
*/
- virtual bool ignoresThrowable() const { return true; }
- };
- LOG4CXX_PTR_DEF(TTCCLayout);
+ virtual bool ignoresThrowable() const
+ {
+ return true;
+ }
+};
+LOG4CXX_PTR_DEF(TTCCLayout);
}
#if defined(_MSC_VER)
-#pragma warning ( pop )
+ #pragma warning ( pop )
#endif
#endif
diff --git a/src/main/include/log4cxx/varia/fallbackerrorhandler.h b/src/main/include/log4cxx/varia/fallbackerrorhandler.h
index af031d2..fe09093 100644
--- a/src/main/include/log4cxx/varia/fallbackerrorhandler.h
+++ b/src/main/include/log4cxx/varia/fallbackerrorhandler.h
@@ -26,92 +26,94 @@
namespace log4cxx
{
- namespace varia
+namespace varia
+{
+/**
+The <code>FallbackErrorHandler</code> implements the ErrorHandler
+interface such that a secondary appender may be specified. This
+secondary appender takes over if the primary appender fails for
+whatever reason.
+
+<p>The error message is printed on <code>System.err</code>, and
+logged in the new secondary appender.
+*/
+class LOG4CXX_EXPORT FallbackErrorHandler :
+ public virtual spi::ErrorHandler,
+ public virtual helpers::ObjectImpl
+{
+ private:
+ AppenderPtr backup;
+ AppenderPtr primary;
+ std::vector<LoggerPtr> loggers;
+
+ public:
+ DECLARE_LOG4CXX_OBJECT(FallbackErrorHandler)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(FallbackErrorHandler)
+ LOG4CXX_CAST_ENTRY_CHAIN(spi::ErrorHandler)
+ END_LOG4CXX_CAST_MAP()
+
+ FallbackErrorHandler();
+ void addRef() const;
+ void releaseRef() const;
+
+
+ /**
+ <em>Adds</em> the logger passed as parameter to the list of
+ loggers that we need to search for in case of appender failure.
+ */
+ void setLogger(const LoggerPtr& logger);
+
+
+ /**
+ No options to activate.
+ */
+ void activateOptions(log4cxx::helpers::Pool& p);
+ void setOption(const LogString& option, const LogString& value);
+
+
+ /**
+ Prints the message and the stack trace of the exception on
+ <code>System.err</code>.
+ */
+ void error(const LogString& message, const std::exception& e,
+ int errorCode) const;
+
+ /**
+ Prints the message and the stack trace of the exception on
+ <code>System.err</code>.
+ */
+ void error(const LogString& message, const std::exception& e,
+ int errorCode, const spi::LoggingEventPtr& event) const;
+
+
+ /**
+ Print a the error message passed as parameter on
+ <code>System.err</code>.
+ */
+ void error(const LogString& /* message */) const {}
+
+ /**
+ Return the backup appender.
+ */
+ const AppenderPtr& getBackupAppender() const
{
- /**
- The <code>FallbackErrorHandler</code> implements the ErrorHandler
- interface such that a secondary appender may be specified. This
- secondary appender takes over if the primary appender fails for
- whatever reason.
+ return backup;
+ }
- <p>The error message is printed on <code>System.err</code>, and
- logged in the new secondary appender.
- */
- class LOG4CXX_EXPORT FallbackErrorHandler :
- public virtual spi::ErrorHandler,
- public virtual helpers::ObjectImpl
- {
- private:
- AppenderPtr backup;
- AppenderPtr primary;
- std::vector<LoggerPtr> loggers;
+ /**
+ The appender to which this error handler is attached.
+ */
+ void setAppender(const AppenderPtr& primary);
- public:
- DECLARE_LOG4CXX_OBJECT(FallbackErrorHandler)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(FallbackErrorHandler)
- LOG4CXX_CAST_ENTRY_CHAIN(spi::ErrorHandler)
- END_LOG4CXX_CAST_MAP()
+ /**
+ Set the backup appender.
+ */
+ void setBackupAppender(const AppenderPtr& backup);
+};
+LOG4CXX_PTR_DEF(FallbackErrorHandler);
- FallbackErrorHandler();
- void addRef() const;
- void releaseRef() const;
-
-
- /**
- <em>Adds</em> the logger passed as parameter to the list of
- loggers that we need to search for in case of appender failure.
- */
- void setLogger(const LoggerPtr& logger);
-
-
- /**
- No options to activate.
- */
- void activateOptions(log4cxx::helpers::Pool& p);
- void setOption(const LogString& option, const LogString& value);
-
-
- /**
- Prints the message and the stack trace of the exception on
- <code>System.err</code>.
- */
- void error(const LogString& message, const std::exception& e,
- int errorCode) const;
-
- /**
- Prints the message and the stack trace of the exception on
- <code>System.err</code>.
- */
- void error(const LogString& message, const std::exception& e,
- int errorCode, const spi::LoggingEventPtr& event) const;
-
-
- /**
- Print a the error message passed as parameter on
- <code>System.err</code>.
- */
- void error(const LogString& /* message */) const {}
-
- /**
- Return the backup appender.
- */
- const AppenderPtr& getBackupAppender() const
- { return backup; }
-
- /**
- The appender to which this error handler is attached.
- */
- void setAppender(const AppenderPtr& primary);
-
- /**
- Set the backup appender.
- */
- void setBackupAppender(const AppenderPtr& backup);
- };
- LOG4CXX_PTR_DEF(FallbackErrorHandler);
-
- } // namespace varia
+} // namespace varia
} // namespace log4cxx
#endif //_LOG4CXX_VARIA_FALLBACK_ERROR_HANDLER_H
diff --git a/src/main/include/log4cxx/writerappender.h b/src/main/include/log4cxx/writerappender.h
index 83db326..2507af1 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>
@@ -29,192 +29,199 @@
namespace log4cxx
{
- namespace helpers {
- class Transcoder;
+namespace helpers
+{
+class Transcoder;
+}
+
+/**
+WriterAppender appends log events to a standard output stream
+*/
+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.
+
+ <p>The <code>immediateFlush</code> variable is set to
+ <code>true</code> by default.
+
+ */
+ 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;
+
+ /**
+ * 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()
+
+ /**
+ This default constructor does nothing.*/
+ WriterAppender();
+ protected:
+ WriterAppender(const LayoutPtr& layout,
+ log4cxx::helpers::WriterPtr& writer);
+ WriterAppender(const LayoutPtr& layout);
+
+ public:
+ ~WriterAppender();
+
+ /**
+ 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.
+
+ <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;
}
/**
- WriterAppender appends log events to a standard output stream
+ 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>The format of the output will depend on this appender's
+ layout.
+
*/
- 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.
-
- <p>The <code>immediateFlush</code> variable is set to
- <code>true</code> by default.
-
- */
- 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;
-
- /**
- * This is the {@link Writer Writer} where we will write to.
- */
- log4cxx::helpers::WriterPtr writer;
+ virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
- public:
- DECLARE_ABSTRACT_LOG4CXX_OBJECT(WriterAppender)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(WriterAppender)
- LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
- END_LOG4CXX_CAST_MAP()
+ protected:
+ /**
+ This method determines if there is a sense in attempting to append.
- /**
- This default constructor does nothing.*/
- WriterAppender();
- protected:
- WriterAppender(const LayoutPtr& layout,
- log4cxx::helpers::WriterPtr& writer);
- WriterAppender(const LayoutPtr& layout);
-
- public:
- ~WriterAppender();
-
- /**
- 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.
-
- <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.
-
- <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.
-
- */
- virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
+ <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;
- protected:
- /**
- This method determines if there is a sense in attempting to append.
+ public:
+ /**
+ Close this appender instance. The underlying stream or writer is
+ also closed.
- <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>Closed appenders cannot be reused.
+ */
+ virtual void close();
+
+ 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);
+
+ 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>The <code>java.io.Writer</code> will be closed when the
+ appender instance is closed.
- public:
- /**
- Close this appender instance. The underlying stream or writer is
- also closed.
-
- <p>Closed appenders cannot be reused.
- */
- virtual void close();
-
- 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);
-
- 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>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&);
- };
+ private:
+ //
+ // prevent copy and assignment
+ WriterAppender(const WriterAppender&);
+ WriterAppender& operator=(const WriterAppender&);
+};
- LOG4CXX_PTR_DEF(WriterAppender);
+LOG4CXX_PTR_DEF(WriterAppender);
} //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 e157a4e..eb049b3 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,278 +40,278 @@
#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
{
- namespace xml
- {
- class XMLWatchdog;
+namespace xml
+{
+class XMLWatchdog;
- /**
- Use this class to initialize the log4cxx environment using a DOM tree.
+/**
+Use this class to initialize the log4cxx environment using a DOM tree.
- <p>Sometimes it is useful to see how log4cxx is reading configuration
- files. You can enable log4cxx internal logging by setting the
- <code>debug</code> attribute in the
- <code>log4cxx</code> element. As in
- <pre>
- <log4j:configuration <b>debug="true"</b> xmlns:log4j="http://jakarta.apache.org/log4j/">
- ...
- </log4j:configuration>
- </pre>
+<p>Sometimes it is useful to see how log4cxx is reading configuration
+files. You can enable log4cxx internal logging by setting the
+<code>debug</code> attribute in the
+<code>log4cxx</code> element. As in
+<pre>
+ <log4j:configuration <b>debug="true"</b> xmlns:log4j="http://jakarta.apache.org/log4j/">
+ ...
+ </log4j:configuration>
+</pre>
- <p>There are sample XML files included in the package.
- */
- class LOG4CXX_EXPORT DOMConfigurator :
- 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);
+<p>There are sample XML files included in the package.
+*/
+class LOG4CXX_EXPORT DOMConfigurator :
+ 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);
- /**
- 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);
- /**
- 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;
- };
- LOG4CXX_PTR_DEF(DOMConfigurator);
- } // namespace xml
+ 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/main/include/log4cxx/xml/xmllayout.h b/src/main/include/log4cxx/xml/xmllayout.h
index fba0ad3..4c5f4e6 100644
--- a/src/main/include/log4cxx/xml/xmllayout.h
+++ b/src/main/include/log4cxx/xml/xmllayout.h
@@ -22,117 +22,125 @@
namespace log4cxx
{
- namespace xml
+namespace xml
+{
+
+/**
+The output of the XMLLayout consists of a series of log4j:event
+elements. It does not output a
+ complete well-formed XML file. The output is designed to be
+included as an <em>external entity</em> in a separate file to form
+a correct XML file.
+
+<p>For example, if <code>abc</code> is the name of the file where
+the XMLLayout ouput goes, then a well-formed XML file would be:
+
+<code>
+<?xml version="1.0" ?>
+
+<!DOCTYPE log4j:eventSet [<!ENTITY data SYSTEM "abc">]>
+
+<log4j:eventSet version="1.2" xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ @&data;
+
+</log4j:eventSet>
+</code>
+
+<p>This approach enforces the independence of the XMLLayout and the
+appender where it is embedded.
+*/
+class LOG4CXX_EXPORT XMLLayout : public Layout
+{
+ private:
+
+ // Print no location info by default
+ bool locationInfo; //= false
+ bool properties; // = false
+
+ public:
+ DECLARE_LOG4CXX_OBJECT(XMLLayout)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(XMLLayout)
+ LOG4CXX_CAST_ENTRY_CHAIN(Layout)
+ END_LOG4CXX_CAST_MAP()
+
+ XMLLayout();
+
+ /**
+ The <b>LocationInfo</b> option takes a boolean value. By
+ default, it is set to false which means there will be no location
+ information output by this layout. If the the option is set to
+ true, then the file name and line number of the statement
+ at the origin of the log statement will be output.
+
+ <p>If you are embedding this layout within a SMTPAppender
+ then make sure to set the
+ <b>LocationInfo</b> option of that appender as well.
+ */
+ inline void setLocationInfo(bool locationInfo1)
{
+ this->locationInfo = locationInfo1;
+ }
- /**
- The output of the XMLLayout consists of a series of log4j:event
- elements. It does not output a
- complete well-formed XML file. The output is designed to be
- included as an <em>external entity</em> in a separate file to form
- a correct XML file.
+ /**
+ Returns the current value of the <b>LocationInfo</b> option.
+ */
+ inline bool getLocationInfo() const
+ {
+ return locationInfo;
+ }
- <p>For example, if <code>abc</code> is the name of the file where
- the XMLLayout ouput goes, then a well-formed XML file would be:
+ /**
+ * Sets whether MDC key-value pairs should be output, default false.
+ * @param flag new value.
+ *
+ */
+ inline void setProperties(bool flag)
+ {
+ properties = flag;
+ }
- <code>
- <?xml version="1.0" ?>
-
- <!DOCTYPE log4j:eventSet [<!ENTITY data SYSTEM "abc">]>
-
- <log4j:eventSet version="1.2" xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- @&data;
-
- </log4j:eventSet>
- </code>
-
- <p>This approach enforces the independence of the XMLLayout and the
- appender where it is embedded.
- */
- class LOG4CXX_EXPORT XMLLayout : public Layout
- {
- private:
-
- // Print no location info by default
- bool locationInfo; //= false
- bool properties; // = false
-
- public:
- DECLARE_LOG4CXX_OBJECT(XMLLayout)
- BEGIN_LOG4CXX_CAST_MAP()
- LOG4CXX_CAST_ENTRY(XMLLayout)
- LOG4CXX_CAST_ENTRY_CHAIN(Layout)
- END_LOG4CXX_CAST_MAP()
-
- XMLLayout();
-
- /**
- The <b>LocationInfo</b> option takes a boolean value. By
- default, it is set to false which means there will be no location
- information output by this layout. If the the option is set to
- true, then the file name and line number of the statement
- at the origin of the log statement will be output.
-
- <p>If you are embedding this layout within a SMTPAppender
- then make sure to set the
- <b>LocationInfo</b> option of that appender as well.
- */
- inline void setLocationInfo(bool locationInfo1)
- { this->locationInfo = locationInfo1; }
-
- /**
- Returns the current value of the <b>LocationInfo</b> option.
- */
- inline bool getLocationInfo() const
- { return locationInfo; }
-
- /**
- * Sets whether MDC key-value pairs should be output, default false.
- * @param flag new value.
- *
- */
- inline void setProperties(bool flag) {
- properties = flag;
- }
-
- /**
- * Gets whether MDC key-value pairs should be output.
- * @return true if MDC key-value pairs are output.
- *
- */
- inline bool getProperties() {
- return properties;
- }
+ /**
+ * Gets whether MDC key-value pairs should be output.
+ * @return true if MDC key-value pairs are output.
+ *
+ */
+ inline bool getProperties()
+ {
+ return properties;
+ }
- /** No options to activate. */
- void activateOptions(log4cxx::helpers::Pool& /* p */) { }
+ /** No options to activate. */
+ void activateOptions(log4cxx::helpers::Pool& /* p */) { }
- /**
- Set options
- */
- virtual void setOption(const LogString& option,
- const LogString& value);
+ /**
+ Set options
+ */
+ virtual void setOption(const LogString& option,
+ const LogString& value);
- /**
- * Formats a {@link spi::LoggingEvent LoggingEvent}
- * in conformance with the log4cxx.dtd.
- **/
- virtual void format(LogString& output,
- const spi::LoggingEventPtr& event,
- log4cxx::helpers::Pool& p) const;
+ /**
+ * Formats a {@link spi::LoggingEvent LoggingEvent}
+ * in conformance with the log4cxx.dtd.
+ **/
+ virtual void format(LogString& output,
+ const spi::LoggingEventPtr& event,
+ log4cxx::helpers::Pool& p) const;
- /**
- The XMLLayout prints and does not ignore exceptions. Hence the
- return value <code>false</code>.
- */
- virtual bool ignoresThrowable() const
- { return false; }
+ /**
+ The XMLLayout prints and does not ignore exceptions. Hence the
+ return value <code>false</code>.
+ */
+ virtual bool ignoresThrowable() const
+ {
+ return false;
+ }
- }; // class XMLLayout
- LOG4CXX_PTR_DEF(XMLLayout);
- } // namespace xml
+}; // class XMLLayout
+LOG4CXX_PTR_DEF(XMLLayout);
+} // namespace xml
} // namespace log4cxx
#endif // _LOG4CXX_XML_LAYOUT_H