You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by ca...@apache.org on 2007/01/10 19:18:41 UTC
svn commit: r494914 - in /logging/log4cxx/trunk: include/log4cxx/
include/log4cxx/helpers/ include/log4cxx/rolling/ include/log4cxx/spi/ src/
tests/src/ tests/src/customlogger/
Author: carnold
Date: Wed Jan 10 10:18:39 2007
New Revision: 494914
URL: http://svn.apache.org/viewvc?view=rev&rev=494914
Log:
LOGCXX-161: Using RollingFileAppender increases the working set with each rollover
Modified:
logging/log4cxx/trunk/include/log4cxx/appenderskeleton.h
logging/log4cxx/trunk/include/log4cxx/defaultcategoryfactory.h
logging/log4cxx/trunk/include/log4cxx/helpers/appenderattachableimpl.h
logging/log4cxx/trunk/include/log4cxx/helpers/mutex.h
logging/log4cxx/trunk/include/log4cxx/hierarchy.h
logging/log4cxx/trunk/include/log4cxx/logger.h
logging/log4cxx/trunk/include/log4cxx/rolling/action.h
logging/log4cxx/trunk/include/log4cxx/spi/loggerfactory.h
logging/log4cxx/trunk/include/log4cxx/spi/rootcategory.h
logging/log4cxx/trunk/src/action.cpp
logging/log4cxx/trunk/src/appenderattachableimpl.cpp
logging/log4cxx/trunk/src/appenderskeleton.cpp
logging/log4cxx/trunk/src/charsetdecoder.cpp
logging/log4cxx/trunk/src/defaultcategoryfactory.cpp
logging/log4cxx/trunk/src/hierarchy.cpp
logging/log4cxx/trunk/src/logger.cpp
logging/log4cxx/trunk/src/logmanager.cpp
logging/log4cxx/trunk/src/mutex.cpp
logging/log4cxx/trunk/src/rootcategory.cpp
logging/log4cxx/trunk/tests/src/customlogger/xlogger.cpp
logging/log4cxx/trunk/tests/src/customlogger/xlogger.h
logging/log4cxx/trunk/tests/src/loggertestcase.cpp
Modified: logging/log4cxx/trunk/include/log4cxx/appenderskeleton.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/include/log4cxx/appenderskeleton.h?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/appenderskeleton.h (original)
+++ logging/log4cxx/trunk/include/log4cxx/appenderskeleton.h Wed Jan 10 10:18:39 2007
@@ -68,6 +68,7 @@
*/
volatile unsigned int closed;
+ log4cxx::helpers::Pool pool;
log4cxx::helpers::Mutex mutex;
public:
Modified: logging/log4cxx/trunk/include/log4cxx/defaultcategoryfactory.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/include/log4cxx/defaultcategoryfactory.h?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/defaultcategoryfactory.h (original)
+++ logging/log4cxx/trunk/include/log4cxx/defaultcategoryfactory.h Wed Jan 10 10:18:39 2007
@@ -35,7 +35,9 @@
LOG4CXX_CAST_ENTRY(spi::LoggerFactory)
END_LOG4CXX_CAST_MAP()
- virtual LoggerPtr makeNewLoggerInstance(const LogString& name) const;
+ virtual LoggerPtr makeNewLoggerInstance(
+ log4cxx::helpers::Pool& pool,
+ const LogString& name) const;
};
} // namespace log4cxx
Modified: logging/log4cxx/trunk/include/log4cxx/helpers/appenderattachableimpl.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/include/log4cxx/helpers/appenderattachableimpl.h?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/helpers/appenderattachableimpl.h (original)
+++ logging/log4cxx/trunk/include/log4cxx/helpers/appenderattachableimpl.h Wed Jan 10 10:18:39 2007
@@ -100,6 +100,7 @@
inline const log4cxx::helpers::Mutex& getMutex() const { return mutex; }
private:
+ log4cxx::helpers::Pool pool;
log4cxx::helpers::Mutex mutex;
AppenderAttachableImpl(const AppenderAttachableImpl&);
AppenderAttachableImpl& operator=(const AppenderAttachableImpl&);
Modified: logging/log4cxx/trunk/include/log4cxx/helpers/mutex.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/include/log4cxx/helpers/mutex.h?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/helpers/mutex.h (original)
+++ logging/log4cxx/trunk/include/log4cxx/helpers/mutex.h Wed Jan 10 10:18:39 2007
@@ -30,7 +30,6 @@
class LOG4CXX_EXPORT Mutex
{
public:
- Mutex();
Mutex(log4cxx::helpers::Pool& p);
~Mutex();
const log4cxx_thread_mutex_t* getAPRMutex() const;
Modified: logging/log4cxx/trunk/include/log4cxx/hierarchy.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/include/log4cxx/hierarchy.h?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/hierarchy.h (original)
+++ logging/log4cxx/trunk/include/log4cxx/hierarchy.h Wed Jan 10 10:18:39 2007
@@ -93,9 +93,8 @@
/**
Create a new logger hierarchy.
- @param root The root of the new hierarchy.
*/
- Hierarchy(const LoggerPtr& root);
+ Hierarchy();
~Hierarchy();
@@ -276,6 +275,7 @@
Hierarchy& operator=(const Hierarchy&);
void updateChildren(ProvisionNode& pn, LoggerPtr logger);
+ log4cxx::helpers::Pool pool;
log4cxx::helpers::Mutex mutex;
volatile log4cxx_uint32_t configured;
};
Modified: logging/log4cxx/trunk/include/log4cxx/logger.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/include/log4cxx/logger.h?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/logger.h (original)
+++ logging/log4cxx/trunk/include/log4cxx/logger.h Wed Jan 10 10:18:39 2007
@@ -103,9 +103,10 @@
<p>It is intended to be used by sub-classes only. You should not
create categories directly.
+ @param pool, lifetime of pool must be longer than logger.
@param name The name of the logger.
*/
- Logger(const LogString& name);
+ Logger(log4cxx::helpers::Pool& pool, const LogString& name);
public:
~Logger();
Modified: logging/log4cxx/trunk/include/log4cxx/rolling/action.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/include/log4cxx/rolling/action.h?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/rolling/action.h (original)
+++ logging/log4cxx/trunk/include/log4cxx/rolling/action.h Wed Jan 10 10:18:39 2007
@@ -20,6 +20,7 @@
#include <log4cxx/portability.h>
#include <log4cxx/helpers/objectimpl.h>
#include <log4cxx/helpers/mutex.h>
+#include <log4cxx/helpers/pool.h>
namespace log4cxx {
namespace rolling {
@@ -40,6 +41,7 @@
*/
bool interrupted;
+ log4cxx::helpers::Pool pool;
log4cxx::helpers::Mutex mutex;
Modified: logging/log4cxx/trunk/include/log4cxx/spi/loggerfactory.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/include/log4cxx/spi/loggerfactory.h?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/spi/loggerfactory.h (original)
+++ logging/log4cxx/trunk/include/log4cxx/spi/loggerfactory.h Wed Jan 10 10:18:39 2007
@@ -37,7 +37,9 @@
public:
DECLARE_ABSTRACT_LOG4CXX_OBJECT(LoggerFactory)
virtual ~LoggerFactory() {}
- virtual LoggerPtr makeNewLoggerInstance(const LogString& name) const = 0;
+ virtual LoggerPtr makeNewLoggerInstance(
+ log4cxx::helpers::Pool& pool,
+ const LogString& name) const = 0;
};
typedef helpers::ObjectPtrT<LoggerFactory> LoggerFactoryPtr;
Modified: logging/log4cxx/trunk/include/log4cxx/spi/rootcategory.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/include/log4cxx/spi/rootcategory.h?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/include/log4cxx/spi/rootcategory.h (original)
+++ logging/log4cxx/trunk/include/log4cxx/spi/rootcategory.h Wed Jan 10 10:18:39 2007
@@ -39,7 +39,7 @@
The root logger names itself as "root". However, the root
logger cannot be retrieved by name.
*/
- RootCategory(const LevelPtr& level);
+ RootCategory(log4cxx::helpers::Pool& pool, const LevelPtr& level);
/**
Return the assigned level value without walking the category
Modified: logging/log4cxx/trunk/src/action.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/action.cpp?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/src/action.cpp (original)
+++ logging/log4cxx/trunk/src/action.cpp Wed Jan 10 10:18:39 2007
@@ -25,7 +25,9 @@
Action::Action() :
complete(false),
- interrupted(false) {
+ interrupted(false),
+ pool(),
+ mutex(pool) {
}
Action::~Action() {
Modified: logging/log4cxx/trunk/src/appenderattachableimpl.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/appenderattachableimpl.cpp?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/src/appenderattachableimpl.cpp (original)
+++ logging/log4cxx/trunk/src/appenderattachableimpl.cpp Wed Jan 10 10:18:39 2007
@@ -30,7 +30,8 @@
AppenderAttachableImpl::AppenderAttachableImpl()
: appenderList(),
- mutex() {
+ pool(),
+ mutex(pool) {
}
Modified: logging/log4cxx/trunk/src/appenderskeleton.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/appenderskeleton.cpp?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/src/appenderskeleton.cpp (original)
+++ logging/log4cxx/trunk/src/appenderskeleton.cpp Wed Jan 10 10:18:39 2007
@@ -37,7 +37,8 @@
headFilter(),
tailFilter(),
closed(0),
- mutex()
+ pool(),
+ mutex(pool)
{
}
@@ -49,7 +50,8 @@
headFilter(),
tailFilter(),
closed(0),
- mutex()
+ pool(),
+ mutex(pool)
{
}
Modified: logging/log4cxx/trunk/src/charsetdecoder.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/charsetdecoder.cpp?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/src/charsetdecoder.cpp (original)
+++ logging/log4cxx/trunk/src/charsetdecoder.cpp Wed Jan 10 10:18:39 2007
@@ -20,6 +20,7 @@
#include <log4cxx/helpers/unicodehelper.h>
#include <log4cxx/helpers/mutex.h>
#include <log4cxx/helpers/synchronized.h>
+#include <log4cxx/helpers/pool.h>
#include <apr_xlate.h>
#include <log4cxx/private/log4cxx_private.h>
@@ -47,21 +48,17 @@
* Creates a new instance.
* @param frompage name of source encoding.
*/
- APRCharsetDecoder(const char* frompage) {
+ APRCharsetDecoder(const char* frompage) : pool(), mutex(pool) {
#if LOG4CXX_LOGCHAR_IS_WCHAR
const char* topage = "WCHAR_T";
#endif
#if LOG4CXX_LOGCHAR_IS_UTF8
const char* topage = "UTF-8";
#endif
- apr_status_t stat = apr_pool_create(&pool, NULL);
- if (stat != APR_SUCCESS) {
- throw PoolException(stat);
- }
- stat = apr_xlate_open(&convset,
+ apr_status_t stat = apr_xlate_open(&convset,
topage,
frompage,
- pool);
+ (apr_pool_t*) pool.getAPRPool());
if (stat != APR_SUCCESS) {
if (frompage == APR_DEFAULT_CHARSET) {
throw IllegalArgumentException("APR_DEFAULT_CHARSET");
@@ -77,8 +74,6 @@
* Destructor.
*/
virtual ~APRCharsetDecoder() {
- apr_xlate_close(convset);
- apr_pool_destroy(pool);
}
virtual log4cxx_status_t decode(ByteBuffer& in,
@@ -119,7 +114,7 @@
private:
APRCharsetDecoder(const APRCharsetDecoder&);
APRCharsetDecoder& operator=(const APRCharsetDecoder&);
- apr_pool_t* pool;
+ log4cxx::helpers::Pool pool;
Mutex mutex;
apr_xlate_t *convset;
};
Modified: logging/log4cxx/trunk/src/defaultcategoryfactory.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/defaultcategoryfactory.cpp?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/src/defaultcategoryfactory.cpp (original)
+++ logging/log4cxx/trunk/src/defaultcategoryfactory.cpp Wed Jan 10 10:18:39 2007
@@ -21,7 +21,9 @@
IMPLEMENT_LOG4CXX_OBJECT(DefaultCategoryFactory)
-LoggerPtr DefaultCategoryFactory::makeNewLoggerInstance(const LogString& name) const
+LoggerPtr DefaultCategoryFactory::makeNewLoggerInstance(
+ log4cxx::helpers::Pool& pool,
+ const LogString& name) const
{
- return new Logger(name);
+ return new Logger(pool, name);
}
Modified: logging/log4cxx/trunk/src/hierarchy.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/hierarchy.cpp?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/src/hierarchy.cpp (original)
+++ logging/log4cxx/trunk/src/hierarchy.cpp Wed Jan 10 10:18:39 2007
@@ -29,6 +29,7 @@
#include <log4cxx/helpers/stringhelper.h>
#include <log4cxx/helpers/aprinitializer.h>
#include <log4cxx/defaultconfigurator.h>
+#include <log4cxx/spi/rootcategory.h>
#include <apr_atomic.h>
#include "assert.h"
@@ -39,12 +40,14 @@
IMPLEMENT_LOG4CXX_OBJECT(Hierarchy)
-Hierarchy::Hierarchy(const LoggerPtr& root1) : root(root1),
+Hierarchy::Hierarchy() :
thresholdInt(Level::ALL_INT), threshold(Level::getAll()),
emittedNoAppenderWarning(false), emittedNoResourceBundleWarning(false),
-mutex(), configured(false)
+pool(),
+mutex(pool), configured(false)
{
- this->root->setHierarchy(this);
+ root = new RootCategory(pool, Level::getDebug());
+ root->setHierarchy(this);
defaultFactory = new DefaultCategoryFactory();
}
@@ -173,7 +176,7 @@
}
else
{
- LoggerPtr logger(factory->makeNewLoggerInstance(name));
+ LoggerPtr logger(factory->makeNewLoggerInstance(pool, name));
logger->setHierarchy(this);
loggers.insert(LoggerMap::value_type(name, logger));
Modified: logging/log4cxx/trunk/src/logger.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/logger.cpp?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/src/logger.cpp (original)
+++ logging/log4cxx/trunk/src/logger.cpp Wed Jan 10 10:18:39 2007
@@ -37,9 +37,9 @@
IMPLEMENT_LOG4CXX_OBJECT(Logger)
-Logger::Logger(const LogString& name1)
+Logger::Logger(Pool& pool, const LogString& name1)
: name(name1), level(), parent(), resourceBundle(),
-repository(0), aai(), additive(true), mutex()
+repository(0), aai(), additive(true), mutex(pool)
{
}
Modified: logging/log4cxx/trunk/src/logmanager.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/logmanager.cpp?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/src/logmanager.cpp (original)
+++ logging/log4cxx/trunk/src/logmanager.cpp Wed Jan 10 10:18:39 2007
@@ -75,8 +75,7 @@
{
if (getRepositorySelector() == 0)
{
- LoggerPtr root(new RootCategory(Level::getDebug()));
- LoggerRepositoryPtr hierarchy(new Hierarchy(root));
+ LoggerRepositoryPtr hierarchy(new Hierarchy());
RepositorySelectorPtr selector(new DefaultRepositorySelector(hierarchy));
getRepositorySelector() = selector;
}
Modified: logging/log4cxx/trunk/src/mutex.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/mutex.cpp?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/src/mutex.cpp (original)
+++ logging/log4cxx/trunk/src/mutex.cpp Wed Jan 10 10:18:39 2007
@@ -37,18 +37,6 @@
#endif
}
-Mutex::Mutex() {
-#if APR_HAS_THREADS
- apr_thread_mutex_t* aprMutex = NULL;
- apr_status_t stat = apr_thread_mutex_create(&aprMutex,
- APR_THREAD_MUTEX_NESTED, APRInitializer::getRootPool());
- if (stat != APR_SUCCESS) {
- throw MutexException(stat);
- }
- mutex = aprMutex;
-#endif
-}
-
Mutex::~Mutex() {
#if APR_HAS_THREADS
Modified: logging/log4cxx/trunk/src/rootcategory.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/rootcategory.cpp?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/src/rootcategory.cpp (original)
+++ logging/log4cxx/trunk/src/rootcategory.cpp Wed Jan 10 10:18:39 2007
@@ -23,7 +23,8 @@
using namespace log4cxx::spi;
using namespace log4cxx::helpers;
-RootCategory::RootCategory(const LevelPtr& level1) : Logger(LOG4CXX_STR("root"))
+RootCategory::RootCategory(Pool& pool, const LevelPtr& level1) :
+ Logger(pool, LOG4CXX_STR("root"))
{
setLevel(level1);
}
Modified: logging/log4cxx/trunk/tests/src/customlogger/xlogger.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/tests/src/customlogger/xlogger.cpp?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/tests/src/customlogger/xlogger.cpp (original)
+++ logging/log4cxx/trunk/tests/src/customlogger/xlogger.cpp Wed Jan 10 10:18:39 2007
@@ -95,7 +95,8 @@
{
}
-LoggerPtr XFactory::makeNewLoggerInstance(const LogString& name) const
+LoggerPtr XFactory::makeNewLoggerInstance(log4cxx::helpers::Pool& pool,
+ const LogString& name) const
{
- return new XLogger(name);
+ return new XLogger(pool, name);
}
Modified: logging/log4cxx/trunk/tests/src/customlogger/xlogger.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/tests/src/customlogger/xlogger.h?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/tests/src/customlogger/xlogger.h (original)
+++ logging/log4cxx/trunk/tests/src/customlogger/xlogger.h Wed Jan 10 10:18:39 2007
@@ -40,7 +40,9 @@
END_LOG4CXX_CAST_MAP()
XFactory();
- virtual LoggerPtr makeNewLoggerInstance(const LogString& name) const;
+ virtual LoggerPtr makeNewLoggerInstance(
+ log4cxx::helpers::Pool& pool,
+ const LogString& name) const;
};
typedef helpers::ObjectPtrT<XFactory> XFactoryPtr;
@@ -67,7 +69,8 @@
/**
Just calls the parent constuctor.
*/
- XLogger(const LogString& name1) : Logger(name1) {}
+ XLogger(log4cxx::helpers::Pool& pool,
+ const LogString& name1) : Logger(pool, name1) {}
/**
Nothing to activate.
Modified: logging/log4cxx/trunk/tests/src/loggertestcase.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/tests/src/loggertestcase.cpp?view=diff&rev=494914&r1=494913&r2=494914
==============================================================================
--- logging/log4cxx/trunk/tests/src/loggertestcase.cpp (original)
+++ logging/log4cxx/trunk/tests/src/loggertestcase.cpp Wed Jan 10 10:18:39 2007
@@ -385,8 +385,9 @@
void testHierarchy1()
{
- LoggerPtr root(new RootCategory(Level::ERROR));
- LoggerRepositoryPtr h = new Hierarchy(root);
+ LoggerRepositoryPtr h = new Hierarchy();
+ LoggerPtr root(h->getRootLogger());
+ root->setLevel(Level::getError());
LoggerPtr a0 = h->getLogger(LOG4CXX_STR("a"));
CPPUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR("a"), a0->getName());
CPPUNIT_ASSERT(a0->getLevel() == 0);