carnold     2004/11/25 23:23:30

  Modified:    examples Makefile.am delayedloop.cpp
               performance Makefile.am main.cpp
               simplesocketserver Makefile.am simplesocketserver.cpp
               src      Makefile.am logger.cpp loggingevent.cpp mutex.cpp
                        objectimpl.cpp
               tests/src asyncappendertestcase.cpp
               tests/src/helpers Makefile.am cacheddateformattestcase.cpp
  Added:       include/log4cxx/helpers aprinitializer.h
               src      aprinitializer.cpp
  Log:
  LOGCXX-36: APR Thread migration: Linux cycle
  
  Revision  Changes    Path
  1.5       +1 -1      logging-log4cxx/examples/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/examples/Makefile.am,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Makefile.am       7 Oct 2004 18:52:12 -0000       1.4
  +++ Makefile.am       26 Nov 2004 07:23:29 -0000      1.5
  @@ -1,6 +1,6 @@
   noinst_PROGRAMS = trivial delayedloop stream
   
  -INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
  +INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include 
-I/usr/local/apr/include/apr-1
   
   trivial_SOURCES = trivial.cpp
   trivial_LDADD = $(top_builddir)/src/liblog4cxx.la
  
  
  
  1.5       +16 -13    logging-log4cxx/examples/delayedloop.cpp
  
  Index: delayedloop.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/examples/delayedloop.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- delayedloop.cpp   24 Apr 2004 21:35:51 -0000      1.4
  +++ delayedloop.cpp   26 Nov 2004 07:23:29 -0000      1.5
  @@ -1,24 +1,25 @@
   /*
    * Copyright 2003,2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  - 
  +
   #include <log4cxx/logger.h>
   #include <log4cxx//helpers/stringhelper.h>
   #include <log4cxx/xml/domconfigurator.h>
   #include <log4cxx/propertyconfigurator.h>
  -#include <log4cxx/helpers/thread.h>
  +#include <apr_general.h>
  +#include <apr_time.h>
   
   using namespace log4cxx;
   using namespace log4cxx::helpers;
  @@ -33,21 +34,21 @@
        static LoggerPtr logger;
   
   public:
  -     static void main(int argc, char **argv)
  +     static void main(int argc, const char * const argv[])
        {
  -             if(argc == 2) 
  +             if(argc == 2)
                {
                        USES_CONVERSION;
                        init(A2T(argv[1]));
                }
  -             else 
  +             else
                {
                        usage(argv[0], "Wrong number of arguments.");
                }
   
                test();
        }
  -     
  +
        static void usage(const char * programName, const char * msg)
        {
                std::cout << msg << std::endl;
  @@ -63,7 +64,7 @@
                if(StringHelper::endsWith(configFile, _T("xml")))
                {
                        xml::DOMConfigurator::configureAndWatch(configFile, 
3000);
  -             } 
  +             }
                else
   #endif
                {
  @@ -79,8 +80,8 @@
                        LOG4CXX_DEBUG(logger, _T("MSG ") << i++);
                        try
                        {
  -                             Thread::sleep(1000);
  -                     } 
  +                             apr_sleep(1000000);
  +                     }
                        catch(Exception& e)
                        {
                        }
  @@ -90,8 +91,9 @@
   
   LoggerPtr DelayedLoop::logger = Logger::getLogger(_T("DelayedLoop"));
   
  -int main(int argc, char **argv)
  +int main(int argc, const char * const argv[])
   {
  +    apr_app_initialize(&argc, &argv, NULL);
       int result = EXIT_SUCCESS;
       try
       {
  @@ -102,5 +104,6 @@
                result = EXIT_FAILURE;
        }
   
  +    apr_terminate();
       return result;
   }
  
  
  
  1.1                  logging-log4cxx/include/log4cxx/helpers/aprinitializer.h
  
  Index: aprinitializer.h
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  #ifndef _LOG4CXX_HELPERS_APRINITIALIZER_H
  #define _LOG4CXX_HELPERS_APRINITIALIZER_H
  
  class apr_pool_t;
  
  namespace log4cxx
  {
    namespace helpers
    {
      class APRInitializer
      {
      public:
      static void initialize();
  
      private:
        APRInitializer();
        ~APRInitializer();
        apr_pool_t * p;
      };
    } // namespace helpers
  }; // namespace log4cxx
  
  #endif //_LOG4CXX_HELPERS_APRINITIALIZER_H
  
  
  
  1.6       +1 -1      logging-log4cxx/performance/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/performance/Makefile.am,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Makefile.am       13 Nov 2004 02:42:36 -0000      1.5
  +++ Makefile.am       26 Nov 2004 07:23:30 -0000      1.6
  @@ -4,7 +4,7 @@
   performanceincdir = $(includedir)/log4cxx
   noinst_HEADERS= $(top_srcdir)/performance/*.h
   
  -INCLUDES = -I$(top_srcdir)/include  -I$(top_builddir)/include 
-I/usr/local/apr/include
  +INCLUDES = -I$(top_srcdir)/include  -I$(top_builddir)/include 
-I/usr/local/apr/include/apr-1
   
   logging_SOURCES = main.cpp nullappender.cpp
   logging_LDADD = $(top_builddir)/src/liblog4cxx.la
  
  
  
  1.10      +9 -6      logging-log4cxx/performance/main.cpp
  
  Index: main.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/performance/main.cpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- main.cpp  25 Nov 2004 05:18:58 -0000      1.9
  +++ main.cpp  26 Nov 2004 07:23:30 -0000      1.10
  @@ -21,8 +21,8 @@
   #include <log4cxx/helpers/exception.h>
   #include <log4cxx/helpers/optionconverter.h>
   #include <log4cxx/xml/domconfigurator.h>
  -#include <log4cxx/helpers/system.h>
  -#include <log4cxx/helpers/thread.h>
  +#include <apr_general.h>
  +#include <apr_pools.h>
   #include <apr_time.h>
   
   using namespace log4cxx;
  @@ -89,7 +89,7 @@
                logger->info(msg, __FILE__, __LINE__);
       }
        apr_time_t after = apr_time_now();
  -     return ((after - before))/runLength;
  +     return (after - before)/(runLength*1000);
   }
   
   double DelayedLoop(LoggerPtr logger, const String& msg)
  @@ -105,7 +105,7 @@
                        j = 0;
                        try
                        {
  -                             Thread::sleep(delay);
  +                                apr_sleep(delay * 1000);
                        }
                        catch(Exception&)
                        {
  @@ -113,13 +113,14 @@
                }
   
       }
  -    double actualTime = ((apr_time_now()-before)/runLength);
  +    double actualTime = (apr_time_now()-before)/(runLength*1000);
       tcout << "actual time: " << actualTime << std::endl;
       return (actualTime - delay*DELAY_MULT);
   }
   
  -int main(int argc, char* argv[])
  +int main(int argc, const char* const argv[])
   {
  +        apr_app_initialize(&argc, &argv, NULL);
        int ret = EXIT_SUCCESS;
   
        try
  @@ -155,6 +156,8 @@
        {
                ret = EXIT_FAILURE;
        }
  +
  +        apr_terminate();
   
        return ret;
   }
  
  
  
  1.3       +1 -1      logging-log4cxx/simplesocketserver/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/simplesocketserver/Makefile.am,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Makefile.am       13 Aug 2004 12:27:47 -0000      1.2
  +++ Makefile.am       26 Nov 2004 07:23:30 -0000      1.3
  @@ -1,4 +1,4 @@
  -INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
  +INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include 
-I/usr/local/apr/include/apr-1
   
   AM_CPPFLAGS = @CPPFLAGS_XML@ @CPPFLAGS_ODBC@
   
  
  
  
  1.2       +30 -17    logging-log4cxx/simplesocketserver/simplesocketserver.cpp
  
  Index: simplesocketserver.cpp
  ===================================================================
  RCS file: 
/home/cvs/logging-log4cxx/simplesocketserver/simplesocketserver.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- simplesocketserver.cpp    13 Aug 2004 08:50:28 -0000      1.1
  +++ simplesocketserver.cpp    26 Nov 2004 07:23:30 -0000      1.2
  @@ -1,24 +1,23 @@
   /*
    * Copyright 2003,2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  - 
  -#include <log4cxx/portability.h>
   
  -#ifdef WIN32
  -#include <windows.h>
  -#endif
  +#include <apr_general.h>
  +#include <apr_pools.h>
  +
  +#include <log4cxx/portability.h>
   
   #include <log4cxx/logger.h>
   #include <log4cxx/helpers/serversocket.h>
  @@ -56,7 +55,7 @@
        if (StringHelper::endsWith(configFile, _T(".xml")))
        {
                DOMConfigurator::configure(configFile);
  -     } 
  +     }
        else
   #endif
        {
  @@ -64,8 +63,16 @@
        }
   }
   
  -int main(int argc, char * argv[])
  +void* LOG4CXX_THREAD_FUNC runSocket(apr_thread_t* thread, void* data) {
  +  SocketNode* node = (SocketNode*) data;
  +  node->run();
  +  delete node;
  +  return 0;
  +}
  +
  +int main(int argc, const char * const argv[])
   {
  +        apr_app_initialize(&argc, &argv, NULL);
        if(argc == 3)
        {
                USES_CONVERSION;
  @@ -78,25 +85,29 @@
                return 1;
        }
   
  +        apr_pool_t* pool;
  +        apr_status_t stat = apr_pool_create(&pool, NULL);
        try
        {
                LoggerPtr logger = Logger::getLogger(_T("SimpleSocketServer"));
  -             
  +
                LOG4CXX_INFO(logger, _T("Listening on port ") << port);
  -     
  +
                ServerSocket serverSocket(port);
  +
                while(true)
                {
                        LOG4CXX_INFO(logger, _T("Waiting to accept a new 
client."));
                        SocketPtr socket = serverSocket.accept();
  -                     
  +
                        LOG4CXX_INFO(logger, _T("Connected to client at ")
                                << socket->getInetAddress().toString());
                        LOG4CXX_INFO(logger, _T("Starting new socket node."));
  -                     
  -                     Thread * thread = new Thread(new SocketNode(socket,
  -                             LogManager::getLoggerRepository()));
  -                     thread->start();
  +
  +                     Thread * thread = new Thread();
  +                        SocketNode* node = new SocketNode(socket,
  +                             LogManager::getLoggerRepository());
  +                        thread->run(pool, runSocket, node);
                }
        }
        catch(SocketException& e)
  @@ -104,6 +115,8 @@
                tcout << _T("SocketException: ") << e.getMessage() << std::endl;
        }
   
  +        apr_pool_destroy(pool);
  +        apr_terminate();
        return 0;
   }
   
  
  
  
  1.20      +5 -5      logging-log4cxx/src/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/src/Makefile.am,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Makefile.am       13 Nov 2004 02:42:36 -0000      1.19
  +++ Makefile.am       26 Nov 2004 07:23:30 -0000      1.20
  @@ -1,19 +1,18 @@
   lib_LTLIBRARIES = liblog4cxx.la
   
  -INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include 
-I/usr/local/apr/include
  +INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include 
-I/usr/local/apr/include/apr-1
   
   liblog4cxx_la_SOURCES = \
        appenderattachableimpl.cpp \
        appenderskeleton.cpp \
  +        aprinitializer.cpp \
        asyncappender.cpp \
        basicconfigurator.cpp \
  -     boundedfifo.cpp \
           cacheddateformat.cpp \
        class.cpp \
        condition.cpp \
        configurator.cpp \
        consoleappender.cpp \
  -     criticalsection.cpp \
        cyclicbuffer.cpp \
        datagrampacket.cpp \
        datagramsocket.cpp \
  @@ -41,10 +40,10 @@
        loggingevent.cpp \
        loglog.cpp \
        logmanager.cpp \
  +     mdc.cpp \
        msxml.cpp \
        mutex.cpp \
        ndc.cpp \
  -     mdc.cpp \
        nteventlogappender.cpp \
        objectimpl.cpp \
        odbcappender.cpp \
  @@ -53,6 +52,7 @@
        patternconverter.cpp \
        patternlayout.cpp \
        patternparser.cpp \
  +        pool.cpp \
        properties.cpp \
        propertyconfigurator.cpp \
        propertyresourcebundle.cpp \
  @@ -62,7 +62,6 @@
        rollingfileappender.cpp \
        rootcategory.cpp \
        serversocket.cpp \
  -     semaphore.cpp \
           simpledateformat.cpp \
        simplelayout.cpp \
        smtpappender.cpp \
  @@ -77,6 +76,7 @@
        stringhelper.cpp \
        stringmatchfilter.cpp \
        stringtokenizer.cpp \
  +     synchronized.cpp \
        syslogappender.cpp \
        syslogwriter.cpp \
        system.cpp \
  
  
  
  1.18      +490 -492  logging-log4cxx/src/logger.cpp
  
  Index: logger.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/src/logger.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- logger.cpp        25 Nov 2004 05:18:58 -0000      1.17
  +++ logger.cpp        26 Nov 2004 07:23:30 -0000      1.18
  @@ -1,494 +1,492 @@
  -/*
  - * Copyright 2003,2004 The Apache Software Foundation.
  - *
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - *
  - *      http://www.apache.org/licenses/LICENSE-2.0
  - *
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -
  -#include <log4cxx/logger.h>
  -#include <log4cxx/spi/loggingevent.h>
  -#include <log4cxx/logmanager.h>
  -#include <log4cxx/spi/loggerfactory.h>
  -#include <log4cxx/appender.h>
  -#include <log4cxx/level.h>
  -#include <log4cxx/helpers/loglog.h>
  -#include <log4cxx/spi/loggerrepository.h>
  -#include <log4cxx/helpers/stringhelper.h>
  +/*
  + * Copyright 2003,2004 The Apache Software Foundation.
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +#include <log4cxx/logger.h>
  +#include <log4cxx/spi/loggingevent.h>
  +#include <log4cxx/logmanager.h>
  +#include <log4cxx/spi/loggerfactory.h>
  +#include <log4cxx/appender.h>
  +#include <log4cxx/level.h>
  +#include <log4cxx/helpers/loglog.h>
  +#include <log4cxx/spi/loggerrepository.h>
  +#include <log4cxx/helpers/stringhelper.h>
   #include <log4cxx/helpers/synchronized.h>
   #include <stdarg.h>
  -
  -using namespace log4cxx;
  -using namespace log4cxx::helpers;
  -using namespace log4cxx::spi;
  -
  -IMPLEMENT_LOG4CXX_OBJECT(Logger)
  -
  -const String Logger::FQCN(getFQCN());
  -
  -Logger::Logger(const String& name)
  -: name(name), additive(true), repository(0), pool(), mutex(pool)
  -{
  -}
  -
  -Logger::~Logger()
  -{
  -}
  -
  -const String& Logger::getFQCN() {
  -   static const String fqcn(Logger::getStaticClass().getName());
  -   return fqcn;
  -}
  -
  -
  -
  -
  -void Logger::addAppender(const AppenderPtr& newAppender)
  -{
  -     synchronized sync(mutex);
  -
  -     if (aai == 0)
  -     {
  -               aai = new AppenderAttachableImpl();
  -     }
  -     aai->addAppender(newAppender);
  -     repository->fireAddAppenderEvent(this, newAppender);
  -}
  -
  -
  -void Logger::assertLog(bool assertion, const String& msg)
  -{
  -     if(!assertion)
  -     {
  -             this->error(msg);
  -     }
  -}
  -
  -void Logger::callAppenders(const spi::LoggingEventPtr& event)
  -{
  -     int writes = 0;
  -
  -     for(LoggerPtr logger = this; logger != 0; logger = logger->parent)
  -     {
  -             // Protected against simultaneous call to addAppender, 
removeAppender,...
  -             synchronized sync(logger->mutex);
  -
  -             if (logger->aai != 0)
  -             {
  -                     writes += logger->aai->appendLoopOnAppenders(event);
  -             }
  -
  -             if(!logger->additive)
  -             {
  -                     break;
  -             }
  -     }
  -
  -     if(writes == 0)
  -     {
  -             repository->emitNoAppenderWarning(this);
  -     }
  -}
  -
  -void Logger::closeNestedAppenders()
  -{
  -     synchronized sync(mutex);
  -
  -    AppenderList appenders = getAllAppenders();
  -    for(AppenderList::iterator it=appenders.begin(); it!=appenders.end(); 
++it)
  -    {
  -       (*it)->close();
  -    }
  -}
  -
  -void Logger::debug(const String& message, const char* file, int line)
  -{
  -     if(repository->isDisabled(Level::DEBUG_INT))
  -     {
  -             return;
  -     }
  -
  -     if(Level::getDebug()->isGreaterOrEqual(getEffectiveLevel()))
  -     {
  -              forcedLog(getFQCN(), Level::getDebug(), message, file, line);
  -     }
  -}
  -
  -void Logger::error(const String& message, const char* file, int line)
  -{
  -     if(repository->isDisabled(Level::ERROR_INT))
  -     {
  -             return;
  -     }
  -
  -     if(Level::getError()->isGreaterOrEqual(getEffectiveLevel()))
  -     {
  -              forcedLog(getFQCN(), Level::getError(), message, file, line);
  -     }
  -}
  -
  -void Logger::fatal(const String& message, const char* file, int line)
  -{
  -     if(repository->isDisabled(Level::FATAL_INT))
  -     {
  -             return;
  -     }
  -
  -     if(Level::getFatal()->isGreaterOrEqual(getEffectiveLevel()))
  -     {
  -              forcedLog(getFQCN(), Level::getFatal(), message, file, line);
  -     }
  -}
  -
  -void Logger::forcedLog(const LevelPtr& level, const String& message,
  -     const char* file, int line)
  -{
  -     callAppenders(new LoggingEvent(getFQCN(), this, level, message, file, 
line));
  -}
  -
  -void Logger::forcedLog(const String& fqcn, const LevelPtr& level, const 
String& message,
  -                     const char* file, int line)
  -{
  -     callAppenders(new LoggingEvent(fqcn, this, level, message, file, line));
  -}
  -
  -bool Logger::getAdditivity() const
  -{
  -     return additive;
  -}
  -
  -AppenderList Logger::getAllAppenders() const
  -{
  -     synchronized sync(mutex);
  -
  -     if (aai == 0)
  -     {
  -             return AppenderList();
  -     }
  -     else
  -     {
  -             return aai->getAllAppenders();
  -     }
  -}
  -
  -AppenderPtr Logger::getAppender(const String& name) const
  -{
  -     synchronized sync(mutex);
  -
  -     if (aai == 0 || name.empty())
  -     {
  -             return 0;
  -     }
  -
  -     return aai->getAppender(name);
  -}
  -
  -const LevelPtr& Logger::getEffectiveLevel() const
  -{
  -     for(const Logger * l = this; l != 0; l=l->parent)
  -     {
  -             if(l->level != 0)
  -             {
  -                     return l->level;
  -             }
  -     }
  -
  -     throw RuntimeException();
  -     return this->level;
  -}
  -
  -LoggerRepositoryPtr Logger::getLoggerRepository() const
  -{
  -     return repository;
  -}
  -
  -ResourceBundlePtr Logger::getResourceBundle() const
  -{
  -     for (LoggerPtr l = this; l != 0; l = l->parent)
  -     {
  -             if (l->resourceBundle != 0)
  -             {
  -                     return l->resourceBundle;
  -             }
  -     }
  -
  -     // It might be the case that there is no resource bundle
  -     return 0;
  -}
  -
  -String Logger::getResourceBundleString(const String& key) const
  -{
  -     ResourceBundlePtr rb = getResourceBundle();
  -
  -     // This is one of the rare cases where we can use logging in order
  -     // to report errors from within log4j.
  -     if (rb == 0)
  -     {
  -             return String();
  -     }
  -     else
  -     {
  -             try
  -             {
  -                     return rb->getString(key);
  -             }
  -             catch (MissingResourceException&)
  -             {
  -                     ((Logger *)this)->error(_T("No resource is associated 
with key \"") +
  -                             key + _T("\"."));
  -
  -                     return String();
  -             }
  -     }
  -}
  -
  -const LoggerPtr& Logger::getParent() const
  -{
  -     return parent;
  -}
  -
  -const LevelPtr& Logger::getLevel() const
  -{
  -     return level;
  -}
  -
  -void Logger::info(const String& message, const char* file, int line)
  -{
  -     if(repository->isDisabled(Level::INFO_INT))
  -     {
  -             return;
  -     }
  -
  -     if(Level::getInfo()->isGreaterOrEqual(getEffectiveLevel()))
  -     {
  -              forcedLog(getFQCN(), Level::getInfo(), message, file, line);
  -     }
  -}
  -
  -bool Logger::isAttached(const AppenderPtr& appender) const
  -{
  -     synchronized sync(mutex);
  -
  -     if (appender == 0 || aai == 0)
  -     {
  -             return false;
  -     }
  -     else
  -     {
  -             return aai->isAttached(appender);
  -     }
  -}
  -
  -bool Logger::isDebugEnabled() const
  -{
  -     if(repository->isDisabled(Level::DEBUG_INT))
  -     {
  -             return false;
  -     }
  -
  -     return Level::getDebug()->isGreaterOrEqual(getEffectiveLevel());
  -}
  -
  -bool Logger::isEnabledFor(const LevelPtr& level) const
  -{
  -     if(repository->isDisabled(level->level))
  -     {
  -             return false;
  -     }
  -
  -     return level->isGreaterOrEqual(getEffectiveLevel());
  -}
  -
  -bool Logger::isInfoEnabled() const
  -{
  -     if(repository->isDisabled(Level::INFO_INT))
  -     {
  -             return false;
  -     }
  -
  -     return Level::getInfo()->isGreaterOrEqual(getEffectiveLevel());
  -}
  -
  -bool Logger::isErrorEnabled() const
  -{
  -     if(repository->isDisabled(Level::ERROR_INT))
  -     {
  -             return false;
  -     }
  -
  -     return Level::getError()->isGreaterOrEqual(getEffectiveLevel());
  -}
  -
  -bool Logger::isWarnEnabled() const
  -{
  -     if(repository->isDisabled(Level::WARN_INT))
  -     {
  -             return false;
  -     }
  -
  -     return Level::getWarn()->isGreaterOrEqual(getEffectiveLevel());
  -}
  -
  -bool Logger::isFatalEnabled() const
  -{
  -     if(repository->isDisabled(Level::FATAL_INT))
  -     {
  -             return false;
  -     }
  -
  -     return Level::getFatal()->isGreaterOrEqual(getEffectiveLevel());
  -}
  -
  -/*void Logger::l7dlog(const LevelPtr& level, const String& key,
  -                     const char* file, int line)
  -{
  -     if (repository->isDisabled(level->level))
  -     {
  -             return;
  -     }
  -
  -     if (level->isGreaterOrEqual(getEffectiveLevel()))
  -     {
  -             String msg = getResourceBundleString(key);
  -
  -             // if message corresponding to 'key' could not be found in the
  -             // resource bundle, then default to 'key'.
  -             if (msg.empty())
  -             {
  -                     msg = key;
  -             }
  -
  -             forcedLog(FQCN, level, msg, file, line);
  -     }
  -}*/
  -
  -void Logger::l7dlog(const LevelPtr& level, const String& key,
  -                     const char* file, int line, ...)
  -{
  -     if (repository->isDisabled(level->level))
  -     {
  -             return;
  -     }
  -
  -     if (level->isGreaterOrEqual(getEffectiveLevel()))
  -     {
  -             String pattern = getResourceBundleString(key);
  -             String msg;
  -
  -             if (pattern.empty())
  -             {
  -                     msg = key;
  -             }
  -             else
  -             {
  -                     va_list params;
  -                     va_start (params, line);
  -                     msg = StringHelper::format(pattern, params);
  -                     va_end (params);
  -             }
  -
  -             forcedLog(getFQCN(), level, msg, file, line);
  -     }
  -}
  -
  -void Logger::log(const LevelPtr& level, const String& message,
  -     const char* file, int line)
  -{
  -
  -     if(repository->isDisabled(level->level))
  -     {
  -             return;
  -     }
  -     if(level->isGreaterOrEqual(getEffectiveLevel()))
  -     {
  -             forcedLog(getFQCN(), level, message, file, line);
  -     }
  -
  -}
  -
  -void Logger::removeAllAppenders()
  -{
  -     synchronized sync(mutex);
  -
  -     if(aai != 0)
  -     {
  -             aai->removeAllAppenders();
  -             aai = 0;
  -     }
  -}
  -
  -void Logger::removeAppender(const AppenderPtr& appender)
  -{
  -     synchronized sync(mutex);
  -
  -     if(appender == 0 || aai == 0)
  -     {
  -             return;
  -     }
  -
  -     aai->removeAppender(appender);
  -}
  -
  -void Logger::removeAppender(const String& name)
  -{
  -     synchronized sync(mutex);
  -
  -     if(name.empty() || aai == 0)
  -     {
  -             return;
  -     }
  -
  -     aai->removeAppender(name);
  -}
  -
  -void Logger::setAdditivity(bool additive)
  -{
  -     this->additive = additive;
  -}
  -
  -void Logger::setHierarchy(spi::LoggerRepository * repository)
  -{
  -     this->repository = repository;
  -}
  -
  -void Logger::setLevel(const LevelPtr& level)
  -{
  -     this->level = level;
  -}
  -
  -void Logger::warn(const String& message, const char* file, int line)
  -{
  -     if(repository->isDisabled(Level::WARN_INT))
  -     {
  -             return;
  -     }
  -
  -     if(Level::getWarn()->isGreaterOrEqual(getEffectiveLevel()))
  -     {
  -              forcedLog(getFQCN(), Level::getWarn(), message, file, line);
  -     }
  -}
  -
  -
  -LoggerPtr Logger::getLogger(const String& name)
  -{
  -     return LogManager::getLogger(name);
  -}
  -
  -LoggerPtr Logger::getRootLogger() {
  -     return LogManager::getRootLogger();
  -}
  -
  -LoggerPtr Logger::getLogger(const String& name,
  -                                                     spi::LoggerFactoryPtr 
factory)
  -{
  -     return LogManager::getLogger(name, factory);
  -}
  +
  +using namespace log4cxx;
  +using namespace log4cxx::helpers;
  +using namespace log4cxx::spi;
  +
  +IMPLEMENT_LOG4CXX_OBJECT(Logger)
  +
  +const String Logger::FQCN(getFQCN());
  +
  +Logger::Logger(const String& name)
  +: name(name), additive(true), repository(0), pool(), mutex(pool)
  +{
  +}
  +
  +Logger::~Logger()
  +{
  +}
  +
  +const String& Logger::getFQCN() {
  +   static const String fqcn(Logger::getStaticClass().getName());
  +   return fqcn;
  +}
  +
  +
  +
  +
  +void Logger::addAppender(const AppenderPtr& newAppender)
  +{
  +     synchronized sync(mutex);
  +
  +     if (aai == 0)
  +     {
  +               aai = new AppenderAttachableImpl();
  +     }
  +     aai->addAppender(newAppender);
  +     repository->fireAddAppenderEvent(this, newAppender);
  +}
  +
  +
  +void Logger::assertLog(bool assertion, const String& msg)
  +{
  +     if(!assertion)
  +     {
  +             this->error(msg);
  +     }
  +}
  +
  +void Logger::callAppenders(const spi::LoggingEventPtr& event)
  +{
  +     int writes = 0;
  +
  +     for(LoggerPtr logger = this; logger != 0; logger = logger->parent)
  +     {
  +             // Protected against simultaneous call to addAppender, 
removeAppender,...
  +             synchronized sync(logger->mutex);
  +
  +             if (logger->aai != 0)
  +             {
  +                     writes += logger->aai->appendLoopOnAppenders(event);
  +             }
  +
  +             if(!logger->additive)
  +             {
  +                     break;
  +             }
  +     }
  +
  +     if(writes == 0)
  +     {
  +             repository->emitNoAppenderWarning(this);
  +     }
  +}
  +
  +void Logger::closeNestedAppenders()
  +{
  +    AppenderList appenders = getAllAppenders();
  +    for(AppenderList::iterator it=appenders.begin(); it!=appenders.end(); 
++it)
  +    {
  +       (*it)->close();
  +    }
  +}
  +
  +void Logger::debug(const String& message, const char* file, int line)
  +{
  +     if(repository->isDisabled(Level::DEBUG_INT))
  +     {
  +             return;
  +     }
  +
  +     if(Level::getDebug()->isGreaterOrEqual(getEffectiveLevel()))
  +     {
  +              forcedLog(getFQCN(), Level::getDebug(), message, file, line);
  +     }
  +}
  +
  +void Logger::error(const String& message, const char* file, int line)
  +{
  +     if(repository->isDisabled(Level::ERROR_INT))
  +     {
  +             return;
  +     }
  +
  +     if(Level::getError()->isGreaterOrEqual(getEffectiveLevel()))
  +     {
  +              forcedLog(getFQCN(), Level::getError(), message, file, line);
  +     }
  +}
  +
  +void Logger::fatal(const String& message, const char* file, int line)
  +{
  +     if(repository->isDisabled(Level::FATAL_INT))
  +     {
  +             return;
  +     }
  +
  +     if(Level::getFatal()->isGreaterOrEqual(getEffectiveLevel()))
  +     {
  +              forcedLog(getFQCN(), Level::getFatal(), message, file, line);
  +     }
  +}
  +
  +void Logger::forcedLog(const LevelPtr& level, const String& message,
  +     const char* file, int line)
  +{
  +     callAppenders(new LoggingEvent(getFQCN(), this, level, message, file, 
line));
  +}
  +
  +void Logger::forcedLog(const String& fqcn, const LevelPtr& level, const 
String& message,
  +                     const char* file, int line)
  +{
  +     callAppenders(new LoggingEvent(fqcn, this, level, message, file, line));
  +}
  +
  +bool Logger::getAdditivity() const
  +{
  +     return additive;
  +}
  +
  +AppenderList Logger::getAllAppenders() const
  +{
  +     synchronized sync(mutex);
  +
  +     if (aai == 0)
  +     {
  +             return AppenderList();
  +     }
  +     else
  +     {
  +             return aai->getAllAppenders();
  +     }
  +}
  +
  +AppenderPtr Logger::getAppender(const String& name) const
  +{
  +     synchronized sync(mutex);
  +
  +     if (aai == 0 || name.empty())
  +     {
  +             return 0;
  +     }
  +
  +     return aai->getAppender(name);
  +}
  +
  +const LevelPtr& Logger::getEffectiveLevel() const
  +{
  +     for(const Logger * l = this; l != 0; l=l->parent)
  +     {
  +             if(l->level != 0)
  +             {
  +                     return l->level;
  +             }
  +     }
  +
  +     throw RuntimeException();
  +     return this->level;
  +}
  +
  +LoggerRepositoryPtr Logger::getLoggerRepository() const
  +{
  +     return repository;
  +}
  +
  +ResourceBundlePtr Logger::getResourceBundle() const
  +{
  +     for (LoggerPtr l = this; l != 0; l = l->parent)
  +     {
  +             if (l->resourceBundle != 0)
  +             {
  +                     return l->resourceBundle;
  +             }
  +     }
  +
  +     // It might be the case that there is no resource bundle
  +     return 0;
  +}
  +
  +String Logger::getResourceBundleString(const String& key) const
  +{
  +     ResourceBundlePtr rb = getResourceBundle();
  +
  +     // This is one of the rare cases where we can use logging in order
  +     // to report errors from within log4j.
  +     if (rb == 0)
  +     {
  +             return String();
  +     }
  +     else
  +     {
  +             try
  +             {
  +                     return rb->getString(key);
  +             }
  +             catch (MissingResourceException&)
  +             {
  +                     ((Logger *)this)->error(_T("No resource is associated 
with key \"") +
  +                             key + _T("\"."));
  +
  +                     return String();
  +             }
  +     }
  +}
  +
  +const LoggerPtr& Logger::getParent() const
  +{
  +     return parent;
  +}
  +
  +const LevelPtr& Logger::getLevel() const
  +{
  +     return level;
  +}
  +
  +void Logger::info(const String& message, const char* file, int line)
  +{
  +     if(repository->isDisabled(Level::INFO_INT))
  +     {
  +             return;
  +     }
  +
  +     if(Level::getInfo()->isGreaterOrEqual(getEffectiveLevel()))
  +     {
  +              forcedLog(getFQCN(), Level::getInfo(), message, file, line);
  +     }
  +}
  +
  +bool Logger::isAttached(const AppenderPtr& appender) const
  +{
  +     synchronized sync(mutex);
  +
  +     if (appender == 0 || aai == 0)
  +     {
  +             return false;
  +     }
  +     else
  +     {
  +             return aai->isAttached(appender);
  +     }
  +}
  +
  +bool Logger::isDebugEnabled() const
  +{
  +     if(repository->isDisabled(Level::DEBUG_INT))
  +     {
  +             return false;
  +     }
  +
  +     return Level::getDebug()->isGreaterOrEqual(getEffectiveLevel());
  +}
  +
  +bool Logger::isEnabledFor(const LevelPtr& level) const
  +{
  +     if(repository->isDisabled(level->level))
  +     {
  +             return false;
  +     }
  +
  +     return level->isGreaterOrEqual(getEffectiveLevel());
  +}
  +
  +bool Logger::isInfoEnabled() const
  +{
  +     if(repository->isDisabled(Level::INFO_INT))
  +     {
  +             return false;
  +     }
  +
  +     return Level::getInfo()->isGreaterOrEqual(getEffectiveLevel());
  +}
  +
  +bool Logger::isErrorEnabled() const
  +{
  +     if(repository->isDisabled(Level::ERROR_INT))
  +     {
  +             return false;
  +     }
  +
  +     return Level::getError()->isGreaterOrEqual(getEffectiveLevel());
  +}
  +
  +bool Logger::isWarnEnabled() const
  +{
  +     if(repository->isDisabled(Level::WARN_INT))
  +     {
  +             return false;
  +     }
  +
  +     return Level::getWarn()->isGreaterOrEqual(getEffectiveLevel());
  +}
  +
  +bool Logger::isFatalEnabled() const
  +{
  +     if(repository->isDisabled(Level::FATAL_INT))
  +     {
  +             return false;
  +     }
  +
  +     return Level::getFatal()->isGreaterOrEqual(getEffectiveLevel());
  +}
  +
  +/*void Logger::l7dlog(const LevelPtr& level, const String& key,
  +                     const char* file, int line)
  +{
  +     if (repository->isDisabled(level->level))
  +     {
  +             return;
  +     }
  +
  +     if (level->isGreaterOrEqual(getEffectiveLevel()))
  +     {
  +             String msg = getResourceBundleString(key);
  +
  +             // if message corresponding to 'key' could not be found in the
  +             // resource bundle, then default to 'key'.
  +             if (msg.empty())
  +             {
  +                     msg = key;
  +             }
  +
  +             forcedLog(FQCN, level, msg, file, line);
  +     }
  +}*/
  +
  +void Logger::l7dlog(const LevelPtr& level, const String& key,
  +                     const char* file, int line, ...)
  +{
  +     if (repository->isDisabled(level->level))
  +     {
  +             return;
  +     }
  +
  +     if (level->isGreaterOrEqual(getEffectiveLevel()))
  +     {
  +             String pattern = getResourceBundleString(key);
  +             String msg;
  +
  +             if (pattern.empty())
  +             {
  +                     msg = key;
  +             }
  +             else
  +             {
  +                     va_list params;
  +                     va_start (params, line);
  +                     msg = StringHelper::format(pattern, params);
  +                     va_end (params);
  +             }
  +
  +             forcedLog(getFQCN(), level, msg, file, line);
  +     }
  +}
  +
  +void Logger::log(const LevelPtr& level, const String& message,
  +     const char* file, int line)
  +{
  +
  +     if(repository->isDisabled(level->level))
  +     {
  +             return;
  +     }
  +     if(level->isGreaterOrEqual(getEffectiveLevel()))
  +     {
  +             forcedLog(getFQCN(), level, message, file, line);
  +     }
  +
  +}
  +
  +void Logger::removeAllAppenders()
  +{
  +     synchronized sync(mutex);
  +
  +     if(aai != 0)
  +     {
  +             aai->removeAllAppenders();
  +             aai = 0;
  +     }
  +}
  +
  +void Logger::removeAppender(const AppenderPtr& appender)
  +{
  +     synchronized sync(mutex);
  +
  +     if(appender == 0 || aai == 0)
  +     {
  +             return;
  +     }
  +
  +     aai->removeAppender(appender);
  +}
  +
  +void Logger::removeAppender(const String& name)
  +{
  +     synchronized sync(mutex);
  +
  +     if(name.empty() || aai == 0)
  +     {
  +             return;
  +     }
  +
  +     aai->removeAppender(name);
  +}
  +
  +void Logger::setAdditivity(bool additive)
  +{
  +     this->additive = additive;
  +}
  +
  +void Logger::setHierarchy(spi::LoggerRepository * repository)
  +{
  +     this->repository = repository;
  +}
  +
  +void Logger::setLevel(const LevelPtr& level)
  +{
  +     this->level = level;
  +}
  +
  +void Logger::warn(const String& message, const char* file, int line)
  +{
  +     if(repository->isDisabled(Level::WARN_INT))
  +     {
  +             return;
  +     }
  +
  +     if(Level::getWarn()->isGreaterOrEqual(getEffectiveLevel()))
  +     {
  +              forcedLog(getFQCN(), Level::getWarn(), message, file, line);
  +     }
  +}
  +
  +
  +LoggerPtr Logger::getLogger(const String& name)
  +{
  +     return LogManager::getLogger(name);
  +}
  +
  +LoggerPtr Logger::getRootLogger() {
  +     return LogManager::getRootLogger();
  +}
  +
  +LoggerPtr Logger::getLogger(const String& name,
  +                                                     spi::LoggerFactoryPtr 
factory)
  +{
  +     return LogManager::getLogger(name, factory);
  +}
  
  
  
  1.18      +365 -391  logging-log4cxx/src/loggingevent.cpp
  
  Index: loggingevent.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/src/loggingevent.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- loggingevent.cpp  25 Nov 2004 05:18:58 -0000      1.17
  +++ loggingevent.cpp  26 Nov 2004 07:23:30 -0000      1.18
  @@ -1,396 +1,370 @@
  -/*
  - * Copyright 2003,2004 The Apache Software Foundation.
  - *
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - *
  - *      http://www.apache.org/licenses/LICENSE-2.0
  - *
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -
  -#include <log4cxx/spi/loggingevent.h>
  -#include <log4cxx/ndc.h>
  -
  -#include <log4cxx/level.h>
  -#include <log4cxx/helpers/socketoutputstream.h>
  -#include <log4cxx/helpers/socketinputstream.h>
  -#include <log4cxx/helpers/loglog.h>
  -#include <log4cxx/helpers/system.h>
  -#include <log4cxx/helpers/loader.h>
  +/*
  + * Copyright 2003,2004 The Apache Software Foundation.
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +#include <log4cxx/spi/loggingevent.h>
  +#include <log4cxx/ndc.h>
  +
  +#include <log4cxx/level.h>
  +#include <log4cxx/helpers/socketoutputstream.h>
  +#include <log4cxx/helpers/socketinputstream.h>
  +#include <log4cxx/helpers/loglog.h>
  +#include <log4cxx/helpers/system.h>
  +#include <log4cxx/helpers/loader.h>
   #include <log4cxx/helpers/socket.h>
  +#include <log4cxx/helpers/aprinitializer.h>
   
   #include <apr_time.h>
  -#include <apr_pools.h>
  -#include <apr_atomic.h>
   #include <apr_portable.h>
  -
  -using namespace log4cxx;
  -using namespace log4cxx::spi;
  -using namespace log4cxx::helpers;
  -
  -IMPLEMENT_LOG4CXX_OBJECT(LoggingEvent)
  -
  -
  -/**
  - *   Apache Portable Runtime (APR) initializer
  - */
  -namespace log4cxx {
  -  namespace spi {
  -    class APRInitializer {
  -      public:
  -      APRInitializer() {
  -        apr_initialize();
  -             apr_pool_create(&p, NULL);
  -             apr_atomic_init(p);
  -      }
  -
  -      ~APRInitializer() {
  -             apr_pool_destroy(p);
  -        apr_terminate();
  -      }
  -
  -       private:
  -               apr_pool_t* p;
  -    };
  -  }
  -}
  -
  -
  -//
  -//   Accessor for start time.
  -//     Called from LogManager::getRepositorySelector
  -//       to initialize APR and set "start" time.
  -//
  -apr_time_t LoggingEvent::getStartTime() {
  -  static APRInitializer aprInit;
  -  static apr_time_t startTime(apr_time_now());
  -  return startTime;
  -}
  -
  -LoggingEvent::LoggingEvent()
  -: timeStamp(0), ndcLookupRequired(true), line(0),
  -mdcCopyLookupRequired(true), properties(0)
  -{
  -}
  -
  -LoggingEvent::LoggingEvent(const String& fqnOfCategoryClass,
  -     const LoggerPtr& logger, const LevelPtr& level,
  -     const String& message, const char* file, int line)
  -: fqnOfCategoryClass(fqnOfCategoryClass), logger(logger), level(level),
  -message(message), file((char*)file), line(line),
  -timeStamp(apr_time_now()), ndcLookupRequired(true),
  -mdcCopyLookupRequired(true), properties(0)
  -{
  -     apr_os_thread_t thread = apr_os_thread_current();
  -     threadId = (unsigned long) thread;
  -}
  -
  -LoggingEvent::~LoggingEvent()
  -{
  -     if (properties != 0)
  -     {
  -             delete properties;
  -     }
  -}
  -
  -const String& LoggingEvent::getLoggerName() const
  -{
  -     return logger->getName();
  -}
  -
  -const String& LoggingEvent::getNDC() const
  -{
  -     if(ndcLookupRequired)
  -     {
  -             ((LoggingEvent *)this)->ndcLookupRequired = false;
  -             ((LoggingEvent *)this)->ndc = NDC::get();
  -     }
  -
  -     return ndc;
  -}
  -
  -String LoggingEvent::getMDC(const String& key) const
  -{
  -   // Note the mdcCopy is used if it exists. Otherwise we use the MDC
  -    // that is associated with the thread.
  -    if (!mdcCopy.empty())
  -     {
  -             MDC::Map::const_iterator it = mdcCopy.find(key);
  -
  -             if (it != mdcCopy.end())
  -             {
  -                     String r = it->second;
  -
  -                     if (!r.empty())
  -                     {
  -                             return r;
  -                     }
  -             }
  -    }
  -
  -    return MDC::get(key);
  -
  -}
  -
  -std::set<String> LoggingEvent::getMDCKeySet() const
  -{
  -     std::set<String> set;
  -
  -     if (!mdcCopy.empty())
  -     {
  -             MDC::Map::const_iterator it;
  -             for (it = mdcCopy.begin(); it != mdcCopy.end(); it++)
  -             {
  -                     set.insert(it->first);
  -
  -             }
  -     }
  -     else
  -     {
  -             MDC::Map m = MDC::getContext();
  -
  -             MDC::Map::const_iterator it;
  -             for (it = m.begin(); it != m.end(); it++)
  -             {
  -                     set.insert(it->first);
  -             }
  -     }
  -
  -     return set;
  -}
  -
  -void LoggingEvent::getMDCCopy() const
  -{
  -     if(mdcCopyLookupRequired)
  -     {
  -             ((LoggingEvent *)this)->mdcCopyLookupRequired = false;
  -             // the clone call is required for asynchronous logging.
  -             ((LoggingEvent *)this)->mdcCopy = MDC::getContext();
  -     }
  -}
  -
  -String LoggingEvent::getProperty(const String& key) const
  -{
  -     if (properties == 0)
  -     {
  -             return String();
  -     }
  -
  -     std::map<String, String>::const_iterator  it = properties->find(key);
  -
  -     if (it != properties->end())
  -     {
  -             const String& p = it->second;
  -
  -             if (!p.empty())
  -             {
  -                     return p;
  -             }
  -     }
  -
  -     return String();
  -}
  -
  -std::set<String> LoggingEvent::getPropertyKeySet() const
  -{
  -     std::set<String> set;
  -
  -     if (properties != 0)
  -     {
  -             std::map<String, String>::const_iterator it;
  -             for (it = properties->begin(); it != properties->end(); it++)
  -             {
  -                     set.insert(it->first);
  -             }
  -     }
  -
  -     return set;
  -}
  -
  -void LoggingEvent::read(const helpers::SocketInputStreamPtr& is)
  -{
  -     // fqnOfCategoryClass
  -     is->read(fqnOfCategoryClass);
  -
  -     // name
  -     String name;
  -     is->read(name);
  -     logger = Logger::getLogger(name);
  -
  -     // level
  -     readLevel(is);
  -
  -     // message
  -     is->read(message);
  -
  -     // timeStamp
  -     is->read(&timeStamp, sizeof(timeStamp));
  -
  -     // file
  -     String buffer;
  -     is->read(buffer);
  -
  -     if (!buffer.empty())
  -     {
  -             USES_CONVERSION;
  -             fileFromStream = T2A(buffer.c_str());
  -             file = (char *)fileFromStream.c_str();
  -     }
  -
  -     // line
  -     is->read(line);
  -
  -     // ndc
  -     is->read(ndc);
  -     ndcLookupRequired = false;
  -
  -     // mdc
  -     String key, value;
  -     int n, size;
  -     is->read(size);
  -     for (n = 0; n < size; n++)
  -     {
  -             is->read(key);
  -             is->read(value);
  -             mdcCopy[key] = value;
  -     }
  -     mdcCopyLookupRequired = false;
  -
  -     // properties
  -     is->read(size);
  -     for (n = 0; n < size; n++)
  -     {
  -             is->read(key);
  -             is->read(value);
  -             setProperty(key, value);
  -     }
  -
  -     // threadId
  +
  +using namespace log4cxx;
  +using namespace log4cxx::spi;
  +using namespace log4cxx::helpers;
  +
  +IMPLEMENT_LOG4CXX_OBJECT(LoggingEvent)
  +
  +
  +//
  +//   Accessor for start time.
  +//     Called from LogManager::getRepositorySelector
  +//       to initialize APR and set "start" time.
  +//
  +apr_time_t LoggingEvent::getStartTime() {
  +  log4cxx::helpers::APRInitializer::initialize();
  +  static apr_time_t startTime(apr_time_now());
  +  return startTime;
  +}
  +
  +LoggingEvent::LoggingEvent()
  +: timeStamp(0), ndcLookupRequired(true), line(0),
  +mdcCopyLookupRequired(true), properties(0)
  +{
  +}
  +
  +LoggingEvent::LoggingEvent(const String& fqnOfCategoryClass,
  +     const LoggerPtr& logger, const LevelPtr& level,
  +     const String& message, const char* file, int line)
  +: fqnOfCategoryClass(fqnOfCategoryClass), logger(logger), level(level),
  +message(message), file((char*)file), line(line),
  +timeStamp(apr_time_now()), ndcLookupRequired(true),
  +mdcCopyLookupRequired(true), properties(0)
  +{
  +     apr_os_thread_t thread = apr_os_thread_current();
  +     threadId = (unsigned long) thread;
  +}
  +
  +LoggingEvent::~LoggingEvent()
  +{
  +     if (properties != 0)
  +     {
  +             delete properties;
  +     }
  +}
  +
  +const String& LoggingEvent::getLoggerName() const
  +{
  +     return logger->getName();
  +}
  +
  +const String& LoggingEvent::getNDC() const
  +{
  +     if(ndcLookupRequired)
  +     {
  +             ((LoggingEvent *)this)->ndcLookupRequired = false;
  +             ((LoggingEvent *)this)->ndc = NDC::get();
  +     }
  +
  +     return ndc;
  +}
  +
  +String LoggingEvent::getMDC(const String& key) const
  +{
  +   // Note the mdcCopy is used if it exists. Otherwise we use the MDC
  +    // that is associated with the thread.
  +    if (!mdcCopy.empty())
  +     {
  +             MDC::Map::const_iterator it = mdcCopy.find(key);
  +
  +             if (it != mdcCopy.end())
  +             {
  +                     String r = it->second;
  +
  +                     if (!r.empty())
  +                     {
  +                             return r;
  +                     }
  +             }
  +    }
  +
  +    return MDC::get(key);
  +
  +}
  +
  +std::set<String> LoggingEvent::getMDCKeySet() const
  +{
  +     std::set<String> set;
  +
  +     if (!mdcCopy.empty())
  +     {
  +             MDC::Map::const_iterator it;
  +             for (it = mdcCopy.begin(); it != mdcCopy.end(); it++)
  +             {
  +                     set.insert(it->first);
  +
  +             }
  +     }
  +     else
  +     {
  +             MDC::Map m = MDC::getContext();
  +
  +             MDC::Map::const_iterator it;
  +             for (it = m.begin(); it != m.end(); it++)
  +             {
  +                     set.insert(it->first);
  +             }
  +     }
  +
  +     return set;
  +}
  +
  +void LoggingEvent::getMDCCopy() const
  +{
  +     if(mdcCopyLookupRequired)
  +     {
  +             ((LoggingEvent *)this)->mdcCopyLookupRequired = false;
  +             // the clone call is required for asynchronous logging.
  +             ((LoggingEvent *)this)->mdcCopy = MDC::getContext();
  +     }
  +}
  +
  +String LoggingEvent::getProperty(const String& key) const
  +{
  +     if (properties == 0)
  +     {
  +             return String();
  +     }
  +
  +     std::map<String, String>::const_iterator  it = properties->find(key);
  +
  +     if (it != properties->end())
  +     {
  +             const String& p = it->second;
  +
  +             if (!p.empty())
  +             {
  +                     return p;
  +             }
  +     }
  +
  +     return String();
  +}
  +
  +std::set<String> LoggingEvent::getPropertyKeySet() const
  +{
  +     std::set<String> set;
  +
  +     if (properties != 0)
  +     {
  +             std::map<String, String>::const_iterator it;
  +             for (it = properties->begin(); it != properties->end(); it++)
  +             {
  +                     set.insert(it->first);
  +             }
  +     }
  +
  +     return set;
  +}
  +
  +void LoggingEvent::read(const helpers::SocketInputStreamPtr& is)
  +{
  +     // fqnOfCategoryClass
  +     is->read(fqnOfCategoryClass);
  +
  +     // name
  +     String name;
  +     is->read(name);
  +     logger = Logger::getLogger(name);
  +
  +     // level
  +     readLevel(is);
  +
  +     // message
  +     is->read(message);
  +
  +     // timeStamp
  +     is->read(&timeStamp, sizeof(timeStamp));
  +
  +     // file
  +     String buffer;
  +     is->read(buffer);
  +
  +     if (!buffer.empty())
  +     {
  +             USES_CONVERSION;
  +             fileFromStream = T2A(buffer.c_str());
  +             file = (char *)fileFromStream.c_str();
  +     }
  +
  +     // line
  +     is->read(line);
  +
  +     // ndc
  +     is->read(ndc);
  +     ndcLookupRequired = false;
  +
  +     // mdc
  +     String key, value;
  +     int n, size;
  +     is->read(size);
  +     for (n = 0; n < size; n++)
  +     {
  +             is->read(key);
  +             is->read(value);
  +             mdcCopy[key] = value;
  +     }
  +     mdcCopyLookupRequired = false;
  +
  +     // properties
  +     is->read(size);
  +     for (n = 0; n < size; n++)
  +     {
  +             is->read(key);
  +             is->read(value);
  +             setProperty(key, value);
  +     }
  +
  +     // threadId
        is->read(threadId);
  -}
  -
  -void LoggingEvent::readLevel(const helpers::SocketInputStreamPtr& is)
  -{
  -     int levelInt;
  -     is->read(levelInt);
  -
  -    String className;
  -     is->read(className);
  -
  -     if (className.empty())
  -     {
  -             level = Level::toLevel(levelInt);
  -     }
  -     else try
  -     {
  -             Level::LevelClass& levelClass =
  -                     (Level::LevelClass&)Loader::loadClass(className);
  -             level = levelClass.toLevel(levelInt);
  -     }
  -     catch (Exception& oops)
  -     {
  -             LogLog::warn(
  -                     _T("Level deserialization failed, reverting to 
default."), oops);
  -             level = Level::toLevel(levelInt);
  -     }
  -     catch (...)
  -     {
  -             LogLog::warn(
  -                     _T("Level deserialization failed, reverting to 
default."));
  -             level = Level::toLevel(levelInt);
  -     }
  -}
  -
  -void LoggingEvent::setProperty(const String& key, const String& value)
  -{
  -     if (properties == 0)
  -     {
  -             properties = new std::map<String, String>;
  -     }
  -
  -     (*properties)[key] = value;
  -}
  -
  -void LoggingEvent::write(helpers::SocketOutputStreamPtr& os) const
  -{
  -     // fqnOfCategoryClass
  -     os->write(fqnOfCategoryClass);
  -
  -     // name
  -     os->write(logger->getName());
  -
  -     // level
  -     writeLevel(os);
  -
  -     // message
  -     os->write(message);
  -
  -     // timeStamp
  -     os->write(&timeStamp, sizeof(timeStamp));
  -
  -     // file
  -     String buffer;
  -     if (file != 0)
  -     {
  -             USES_CONVERSION;
  -             buffer = A2T(file);
  -     }
  -     os->write(buffer);
  -
  -     // line
  -     os->write(line);
  -
  -     // ndc
  -     os->write(getNDC());
  -
  -     // mdc
  -     getMDCCopy();
  -     os->write((int)mdcCopy.size());
  -     MDC::Map::const_iterator it;
  -     for (it = mdcCopy.begin(); it != mdcCopy.end(); it++)
  -     {
  -             os->write(it->first);
  -             os->write(it->second);
  -     }
  -
  -     // properties
  -     int size = (properties != 0) ? (int)properties->size() : 0;
  -     os->write(size);
  -
  -     if (size > 0)
  -     {
  -             std::map<String, String>::const_iterator it;
  -             for (it = properties->begin(); it != properties->end(); it++)
  -             {
  -                     os->write(it->first);
  -                     os->write(it->second);
  -             }
  -     }
  -
  -     // threadId
  -     os->write(threadId);
  -}
  -
  -void LoggingEvent::writeLevel(helpers::SocketOutputStreamPtr& os) const
  -{
  -     os->write(level->toInt());
  -
  -     const Class& clazz = level->getClass();
  -
  -     if (&clazz == &Level::getStaticClass())
  -     {
  -             os->write(String());
  -     }
  -     else
  -     {
  -             os->write(clazz.getName());
  -     }
  -}
  -
  -
  +}
  +
  +void LoggingEvent::readLevel(const helpers::SocketInputStreamPtr& is)
  +{
  +     int levelInt;
  +     is->read(levelInt);
  +
  +    String className;
  +     is->read(className);
  +
  +     if (className.empty())
  +     {
  +             level = Level::toLevel(levelInt);
  +     }
  +     else try
  +     {
  +             Level::LevelClass& levelClass =
  +                     (Level::LevelClass&)Loader::loadClass(className);
  +             level = levelClass.toLevel(levelInt);
  +     }
  +     catch (Exception& oops)
  +     {
  +             LogLog::warn(
  +                     _T("Level deserialization failed, reverting to 
default."), oops);
  +             level = Level::toLevel(levelInt);
  +     }
  +     catch (...)
  +     {
  +             LogLog::warn(
  +                     _T("Level deserialization failed, reverting to 
default."));
  +             level = Level::toLevel(levelInt);
  +     }
  +}
  +
  +void LoggingEvent::setProperty(const String& key, const String& value)
  +{
  +     if (properties == 0)
  +     {
  +             properties = new std::map<String, String>;
  +     }
  +
  +     (*properties)[key] = value;
  +}
  +
  +void LoggingEvent::write(helpers::SocketOutputStreamPtr& os) const
  +{
  +     // fqnOfCategoryClass
  +     os->write(fqnOfCategoryClass);
  +
  +     // name
  +     os->write(logger->getName());
  +
  +     // level
  +     writeLevel(os);
  +
  +     // message
  +     os->write(message);
  +
  +     // timeStamp
  +     os->write(&timeStamp, sizeof(timeStamp));
  +
  +     // file
  +     String buffer;
  +     if (file != 0)
  +     {
  +             USES_CONVERSION;
  +             buffer = A2T(file);
  +     }
  +     os->write(buffer);
  +
  +     // line
  +     os->write(line);
  +
  +     // ndc
  +     os->write(getNDC());
  +
  +     // mdc
  +     getMDCCopy();
  +     os->write((int)mdcCopy.size());
  +     MDC::Map::const_iterator it;
  +     for (it = mdcCopy.begin(); it != mdcCopy.end(); it++)
  +     {
  +             os->write(it->first);
  +             os->write(it->second);
  +     }
  +
  +     // properties
  +     int size = (properties != 0) ? (int)properties->size() : 0;
  +     os->write(size);
  +
  +     if (size > 0)
  +     {
  +             std::map<String, String>::const_iterator it;
  +             for (it = properties->begin(); it != properties->end(); it++)
  +             {
  +                     os->write(it->first);
  +                     os->write(it->second);
  +             }
  +     }
  +
  +     // threadId
  +     os->write(threadId);
  +}
  +
  +void LoggingEvent::writeLevel(helpers::SocketOutputStreamPtr& os) const
  +{
  +     os->write(level->toInt());
  +
  +     const Class& clazz = level->getClass();
  +
  +     if (&clazz == &Level::getStaticClass())
  +     {
  +             os->write(String());
  +     }
  +     else
  +     {
  +             os->write(clazz.getName());
  +     }
  +}
  +
  +
  
  
  
  1.8       +26 -26    logging-log4cxx/src/mutex.cpp
  
  Index: mutex.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/src/mutex.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- mutex.cpp 25 Nov 2004 05:18:58 -0000      1.7
  +++ mutex.cpp 26 Nov 2004 07:23:30 -0000      1.8
  @@ -1,31 +1,31 @@
  -/*
  - * Copyright 2003,2004 The Apache Software Foundation.
  - * 
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - * 
  - *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  - 
  -#include <log4cxx/portability.h>
  -
  -#include <log4cxx/helpers/mutex.h>
  +/*
  + * Copyright 2003,2004 The Apache Software Foundation.
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +#include <log4cxx/portability.h>
  +
  +#include <log4cxx/helpers/mutex.h>
   #include <apr_thread_mutex.h>
  -
  -using namespace log4cxx::helpers;
  -using namespace log4cxx;
   
  -
  +using namespace log4cxx::helpers;
  +using namespace log4cxx;
  +
  +
   Mutex::Mutex(apr_pool_t* p) {
  -     apr_status_t stat = apr_thread_mutex_create(&mutex, 
  -             APR_THREAD_MUTEX_DEFAULT, p);
  +     apr_status_t stat = apr_thread_mutex_create(&mutex,
  +             APR_THREAD_MUTEX_NESTED, p);
        if (stat != APR_SUCCESS) {
                throw MutexException(stat);
        }
  @@ -33,4 +33,4 @@
   
   Mutex::~Mutex() {
        apr_status_t stat = apr_thread_mutex_destroy(mutex);
  -}
  +}
  
  
  
  1.20      +10 -15    logging-log4cxx/src/objectimpl.cpp
  
  Index: objectimpl.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/src/objectimpl.cpp,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- objectimpl.cpp    25 Nov 2004 05:18:58 -0000      1.19
  +++ objectimpl.cpp    26 Nov 2004 07:23:30 -0000      1.20
  @@ -14,20 +14,15 @@
    * limitations under the License.
    */
   
  -#include <log4cxx/portability.h>
  -
  -#ifdef LOG4CXX_HAVE_MS_THREAD
  -#include <windows.h>
  -#endif
  -
   #include <log4cxx/helpers/objectimpl.h>
  -#include <log4cxx/helpers/event.h>
  -#include <apr_atomic.h>
  +#include <apr_atomic.h>
  +#include <log4cxx/helpers/aprinitializer.h>
   
   using namespace log4cxx::helpers;
   
  -ObjectImpl::ObjectImpl() : ref(0)
  +ObjectImpl::ObjectImpl() : ref( 0 )
   {
  +  log4cxx::helpers::APRInitializer::initialize();
   }
   
   ObjectImpl::~ObjectImpl()
  @@ -35,14 +30,14 @@
   }
   
   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;
  +  }
   }
  
  
  
  1.1                  logging-log4cxx/src/aprinitializer.cpp
  
  Index: aprinitializer.cpp
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  #include <log4cxx/helpers/aprinitializer.h>
  #include <apr_pools.h>
  #include <apr_atomic.h>
  
  using namespace log4cxx::helpers;
  using namespace log4cxx;
  
  APRInitializer::APRInitializer() {
      apr_initialize();
      apr_pool_create(&p, NULL);
      apr_atomic_init(p);
  }
  
  APRInitializer::~APRInitializer() {
      apr_pool_destroy(p);
      apr_terminate();
  }
  
  void APRInitializer::initialize() {
    static APRInitializer init;
  }
  
  
  
  1.8       +130 -130  logging-log4cxx/tests/src/asyncappendertestcase.cpp
  
  Index: asyncappendertestcase.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/tests/src/asyncappendertestcase.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- asyncappendertestcase.cpp 25 Nov 2004 05:18:59 -0000      1.7
  +++ asyncappendertestcase.cpp 26 Nov 2004 07:23:30 -0000      1.8
  @@ -1,134 +1,134 @@
  -/*
  - * Copyright 2003,2004 The Apache Software Foundation.
  - *
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - *
  - *      http://www.apache.org/licenses/LICENSE-2.0
  - *
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -
  -#include <cppunit/TestFixture.h>
  -#include <cppunit/extensions/HelperMacros.h>
  -
  -#include <log4cxx/logger.h>
  -#include <log4cxx/logmanager.h>
  +/*
  + * Copyright 2003,2004 The Apache Software Foundation.
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +#include <cppunit/TestFixture.h>
  +#include <cppunit/extensions/HelperMacros.h>
  +
  +#include <log4cxx/logger.h>
  +#include <log4cxx/logmanager.h>
   #include <log4cxx/simplelayout.h>
  -#include "vectorappender.h"
  -#include <log4cxx/asyncappender.h>
  -#include "appenderskeletontestcase.h"
  -
  -using namespace log4cxx;
  -using namespace log4cxx::helpers;
  -
  -/**
  -   A superficial but general test of log4j.
  - */
  -class AsyncAppenderTestCase : public AppenderSkeletonTestCase
  -{
  -     CPPUNIT_TEST_SUITE(AsyncAppenderTestCase);
  -                //
  -                //    tests inherited from AppenderSkeletonTestCase
  -                //
  -                CPPUNIT_TEST(testDefaultThreshold);
  -                CPPUNIT_TEST(testSetOptionThreshold);
  -
  -             CPPUNIT_TEST(closeTest);
  -             CPPUNIT_TEST(test2);
  +#include "vectorappender.h"
  +#include <log4cxx/asyncappender.h>
  +#include "appenderskeletontestcase.h"
  +
  +using namespace log4cxx;
  +using namespace log4cxx::helpers;
  +
  +/**
  +   A superficial but general test of log4j.
  + */
  +class AsyncAppenderTestCase : public AppenderSkeletonTestCase
  +{
  +     CPPUNIT_TEST_SUITE(AsyncAppenderTestCase);
  +                //
  +                //    tests inherited from AppenderSkeletonTestCase
  +                //
  +                CPPUNIT_TEST(testDefaultThreshold);
  +                CPPUNIT_TEST(testSetOptionThreshold);
  +
  +             CPPUNIT_TEST(closeTest);
  +             CPPUNIT_TEST(test2);
   //  TODO: deadlocks on Win32, will debug on Linux
   #if !defined(_WIN32)
                CPPUNIT_TEST(test3);
  -#endif
  -     CPPUNIT_TEST_SUITE_END();
  -
  -
  -public:
  -     void setUp() {
  -           AppenderSkeletonTestCase::setUp();
  -        }
  -
  -     void tearDown()
  -     {
  -             LogManager::shutdown();
  -                AppenderSkeletonTestCase::tearDown();
  -     }
  -
  -        AppenderSkeleton* createAppenderSkeleton() const {
  -          return new AsyncAppender();
  -        }
  -
  -     // this test checks whether it is possible to write to a closed 
AsyncAppender
  -     void closeTest() throw(Exception)
  -     {
  -             LoggerPtr root = Logger::getRootLogger();
  -             LayoutPtr layout = new SimpleLayout();
  -             VectorAppenderPtr vectorAppender = new VectorAppender();
  -             AsyncAppenderPtr asyncAppender = new AsyncAppender();
  -             asyncAppender->setName(_T("async-CloseTest"));
  -             asyncAppender->addAppender(vectorAppender);
  -             root->addAppender(asyncAppender);
  -
  -             root->debug(_T("m1"));
  -             asyncAppender->close();
  -             root->debug(_T("m2"));
  -
  -             const std::vector<spi::LoggingEventPtr>& v = 
vectorAppender->getVector();
  -             CPPUNIT_ASSERT(v.size() == 1);
  -     }
  -
  -     // this test checks whether appenders embedded within an AsyncAppender 
are also
  -     // closed
  -     void test2()
  -     {
  -             LoggerPtr root = Logger::getRootLogger();
  -             LayoutPtr layout = new SimpleLayout();
  -             VectorAppenderPtr vectorAppender = new VectorAppender();
  -             AsyncAppenderPtr asyncAppender = new AsyncAppender();
  -             asyncAppender->setName(_T("async-test2"));
  -             asyncAppender->addAppender(vectorAppender);
  -             root->addAppender(asyncAppender);
  -
  -             root->debug(_T("m1"));
  -             asyncAppender->close();
  -             root->debug(_T("m2"));
  -
  -             const std::vector<spi::LoggingEventPtr>& v = 
vectorAppender->getVector();
  -             CPPUNIT_ASSERT(v.size() == 1);
  -             CPPUNIT_ASSERT(vectorAppender->isClosed());
  -     }
  -
  -     // this test checks whether appenders embedded within an AsyncAppender 
are also
  -     // closed
  -     void test3()
  -     {
  -             typedef std::vector<spi::LoggingEventPtr>::size_type size_type;
  -             size_type LEN = 200;
  -             LoggerPtr root = Logger::getRootLogger();
  -             LayoutPtr layout = new SimpleLayout();
  -             VectorAppenderPtr vectorAppender = new VectorAppender();
  -             AsyncAppenderPtr asyncAppender = new AsyncAppender();
  -             asyncAppender->setName(_T("async-test3"));
  -             asyncAppender->addAppender(vectorAppender);
  -             root->addAppender(asyncAppender);
  -
  -             for (size_type i = 0; i < LEN; i++)
  -             {
  -                     LOG4CXX_DEBUG(root, _T("message") << i);
  -             }
  -
  -             asyncAppender->close();
  -             root->debug(_T("m2"));
  -
  -             const std::vector<spi::LoggingEventPtr>& v = 
vectorAppender->getVector();
  -             CPPUNIT_ASSERT(v.size() == LEN);
  -             CPPUNIT_ASSERT(vectorAppender->isClosed());
  -     }
  -};
  -
  -CPPUNIT_TEST_SUITE_REGISTRATION(AsyncAppenderTestCase);
  +#endif
  +     CPPUNIT_TEST_SUITE_END();
  +
  +
  +public:
  +     void setUp() {
  +           AppenderSkeletonTestCase::setUp();
  +        }
  +
  +     void tearDown()
  +     {
  +             LogManager::shutdown();
  +                AppenderSkeletonTestCase::tearDown();
  +     }
  +
  +        AppenderSkeleton* createAppenderSkeleton() const {
  +          return new AsyncAppender();
  +        }
  +
  +     // this test checks whether it is possible to write to a closed 
AsyncAppender
  +     void closeTest() throw(Exception)
  +     {
  +             LoggerPtr root = Logger::getRootLogger();
  +             LayoutPtr layout = new SimpleLayout();
  +             VectorAppenderPtr vectorAppender = new VectorAppender();
  +             AsyncAppenderPtr asyncAppender = new AsyncAppender();
  +             asyncAppender->setName(_T("async-CloseTest"));
  +             asyncAppender->addAppender(vectorAppender);
  +             root->addAppender(asyncAppender);
  +
  +             root->debug(_T("m1"));
  +             asyncAppender->close();
  +             root->debug(_T("m2"));
  +
  +             const std::vector<spi::LoggingEventPtr>& v = 
vectorAppender->getVector();
  +             CPPUNIT_ASSERT(v.size() == 1);
  +     }
  +
  +     // this test checks whether appenders embedded within an AsyncAppender 
are also
  +     // closed
  +     void test2()
  +     {
  +             LoggerPtr root = Logger::getRootLogger();
  +             LayoutPtr layout = new SimpleLayout();
  +             VectorAppenderPtr vectorAppender = new VectorAppender();
  +             AsyncAppenderPtr asyncAppender = new AsyncAppender();
  +             asyncAppender->setName(_T("async-test2"));
  +             asyncAppender->addAppender(vectorAppender);
  +             root->addAppender(asyncAppender);
  +
  +             root->debug(_T("m1"));
  +             asyncAppender->close();
  +             root->debug(_T("m2"));
  +
  +             const std::vector<spi::LoggingEventPtr>& v = 
vectorAppender->getVector();
  +             CPPUNIT_ASSERT(v.size() == 1);
  +             CPPUNIT_ASSERT(vectorAppender->isClosed());
  +     }
  +
  +     // this test checks whether appenders embedded within an AsyncAppender 
are also
  +     // closed
  +     void test3()
  +     {
  +             typedef std::vector<spi::LoggingEventPtr>::size_type size_type;
  +             size_type LEN = 200;
  +             LoggerPtr root = Logger::getRootLogger();
  +             LayoutPtr layout = new SimpleLayout();
  +             VectorAppenderPtr vectorAppender = new VectorAppender();
  +             AsyncAppenderPtr asyncAppender = new AsyncAppender();
  +             asyncAppender->setName(_T("async-test3"));
  +             asyncAppender->addAppender(vectorAppender);
  +             root->addAppender(asyncAppender);
  +
  +             for (size_type i = 0; i < LEN; i++)
  +             {
  +                     LOG4CXX_DEBUG(root, _T("message") << i);
  +             }
  +
  +             asyncAppender->close();
  +             root->debug(_T("m2"));
  +
  +             const std::vector<spi::LoggingEventPtr>& v = 
vectorAppender->getVector();
  +             CPPUNIT_ASSERT(v.size() == LEN);
  +             CPPUNIT_ASSERT(vectorAppender->isClosed());
  +     }
  +};
  +
  +CPPUNIT_TEST_SUITE_REGISTRATION(AsyncAppenderTestCase);
  
  
  
  1.5       +0 -1      logging-log4cxx/tests/src/helpers/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/tests/src/helpers/Makefile.am,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Makefile.am       13 Nov 2004 02:42:37 -0000      1.4
  +++ Makefile.am       26 Nov 2004 07:23:30 -0000      1.5
  @@ -8,7 +8,6 @@
   
   libhelpers_a_SOURCES = \
           absolutetimedateformattestcase.cpp \
  -     boundedfifotestcase.cpp\
           cacheddateformattestcase.cpp \
        cyclicbuffertestcase.cpp\
           datetimedateformattestcase.cpp \
  
  
  
  1.5       +2 -2      
logging-log4cxx/tests/src/helpers/cacheddateformattestcase.cpp
  
  Index: cacheddateformattestcase.cpp
  ===================================================================
  RCS file: 
/home/cvs/logging-log4cxx/tests/src/helpers/cacheddateformattestcase.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- cacheddateformattestcase.cpp      25 Nov 2004 06:52:52 -0000      1.4
  +++ cacheddateformattestcase.cpp      26 Nov 2004 07:23:30 -0000      1.5
  @@ -30,7 +30,7 @@
   #define LOCALE_JP "jpn"
   #else
   #define LOCALE_US "en_US"
  -#define LOCALE_JP "jp_JP"
  +#define LOCALE_JP "ja_JP"
   #endif
   
   //Define INT64_C for compilers that don't have it
  @@ -50,7 +50,7 @@
        CPPUNIT_TEST( test2 );
        CPPUNIT_TEST( test3 );
        CPPUNIT_TEST( test4 );
  -#if !defined(_WIN32)
  +#if defined(_WIN32)
        CPPUNIT_TEST( test5 );
   #endif
        CPPUNIT_TEST( test6 );
  
  
  

Reply via email to