This patch fixes the localized logging which was still #if 0'ed out.

To read the resource files, a FileInputStream class was added.
This aligns the class structure better with the java world,
instead of having read/write methods directly on the File class.

Best Regards,

        Andreas
Index: include/log4cxx/helpers/properties.h
===================================================================
--- include/log4cxx/helpers/properties.h        (Revision 373510)
+++ include/log4cxx/helpers/properties.h        (Arbeitskopie)
@@ -20,6 +20,7 @@
 #include <log4cxx/logstring.h>
 #include <log4cxx/helpers/objectptr.h>
 #include <log4cxx/helpers/objectimpl.h>
+#include <log4cxx/helpers/inputstream.h>
 #include <map>
 #include <vector>
 #include <istream>
@@ -112,6 +113,9 @@
                         @throw IOException if an error occurred when reading 
from the input
                         stream.
                         */
+                        void load(InputStreamPtr inStream);
+
+                        // @deprecated
                         void load(LogString& inStream);
 
                         /**
Index: include/log4cxx/helpers/loader.h
===================================================================
--- include/log4cxx/helpers/loader.h    (Revision 373510)
+++ include/log4cxx/helpers/loader.h    (Arbeitskopie)
@@ -20,6 +20,7 @@
 #include <log4cxx/helpers/objectptr.h>
 #include <log4cxx/logstring.h>
 #include <log4cxx/helpers/exception.h>
+#include <log4cxx/helpers/inputstream.h>
 
 
 namespace log4cxx
@@ -34,8 +35,9 @@
                         static const Class& loadClass(const LogString& clazz);
 //  TODO
 //       static LogString getResource(const LogString& name);
-//       static void* getResourceAsStream(const LogString& name,
-//                            apr_size_t* size, log4cxx::helpers::Pool& pool);
+
+                        static InputStreamPtr getResourceAsStream(
+                                                         const LogString& 
name);
                 };
         }  // namespace helpers
 } // namespace log4cxx
Index: include/log4cxx/helpers/fileinputstream.h
===================================================================
--- include/log4cxx/helpers/fileinputstream.h   (Revision 0)
+++ include/log4cxx/helpers/fileinputstream.h   (Revision 0)
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2003,2005 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_FILEINPUTSTREAM_H
+#define _LOG4CXX_HELPERS_FILEINPUTSTREAM_H
+
+#include <log4cxx/helpers/inputstream.h>
+#include <log4cxx/file.h>
+#include <log4cxx/helpers/pool.h>
+
+
+namespace log4cxx
+{
+
+        namespace helpers {
+
+          /**
+           * InputStream implemented on top of APR file IO.
+           * @since 0.9.8
+           */
+          class LOG4CXX_EXPORT FileInputStream : public InputStream
+          {
+          private:
+                  Pool pool;
+                  void* fileptr;
+
+          public:
+                  DECLARE_ABSTRACT_LOG4CXX_OBJECT(FileInputStream)
+                  BEGIN_LOG4CXX_CAST_MAP()
+                          LOG4CXX_CAST_ENTRY(FileInputStream)
+                          LOG4CXX_CAST_ENTRY_CHAIN(InputStream)
+                  END_LOG4CXX_CAST_MAP()
+
+                  FileInputStream(const LogString& filename);
+
+                  FileInputStream(const File& aFile);
+
+                  virtual ~FileInputStream();
+
+                  virtual void close();
+
+                  LogString read(log4cxx::helpers::Pool& pool) const;
+
+          private:
+
+                  FileInputStream(const FileInputStream&);
+
+                  FileInputStream& operator=(const FileInputStream&);
+
+          };
+
+          typedef helpers::ObjectPtrT<FileInputStream> FileInputStreamPtr;
+        } // namespace helpers
+
+}  //namespace log4cxx
+
+#endif //_LOG4CXX_HELPERS_FILEINPUTSTREAM_H
Index: include/log4cxx/helpers/propertyresourcebundle.h
===================================================================
--- include/log4cxx/helpers/propertyresourcebundle.h    (Revision 373510)
+++ include/log4cxx/helpers/propertyresourcebundle.h    (Arbeitskopie)
@@ -19,6 +19,7 @@
 
 #include <log4cxx/helpers/resourcebundle.h>
 #include <log4cxx/helpers/properties.h>
+#include <log4cxx/helpers/inputstream.h>
 
 namespace log4cxx
 {
@@ -47,8 +48,12 @@
                         @throw IOException if an error occurred when reading 
from the
                         input stream.
                         */
+                        PropertyResourceBundle(InputStreamPtr inStream);
+
+                        // @deprecated Use 
PropertyResourceBundle(InputStreamPtr) instead
                         PropertyResourceBundle(LogString& inStream);
 
+
                         virtual LogString getString(const LogString& key) 
const;
 
                 protected:
Index: include/log4cxx/helpers/stringhelper.h
===================================================================
--- include/log4cxx/helpers/stringhelper.h      (Revision 373510)
+++ include/log4cxx/helpers/stringhelper.h      (Arbeitskopie)
@@ -18,7 +18,7 @@
 #define _LOG4CXX_HELPERS_STRING_HELPER_H
 
 #include <log4cxx/logstring.h>
-#include <stdarg.h>
+#include <vector>
 
 
 namespace log4cxx
@@ -57,6 +57,8 @@
 
             static bool getline(std::string& buf, std::string& line);
 
+            static LogString format(const LogString& pattern, const 
std::vector<LogString>& params);
+
 #if LOG4CXX_HAS_WCHAR_T
             static std::wstring trim(const std::wstring& s);
             static bool startsWith(const std::wstring& s, const std::wstring& 
suffix);
Index: include/log4cxx/helpers/inputstream.h
===================================================================
--- include/log4cxx/helpers/inputstream.h       (Revision 0)
+++ include/log4cxx/helpers/inputstream.h       (Revision 0)
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2003,2005 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_INPUTSTREAM_H
+#define _LOG4CXX_HELPERS_INPUTSTREAM_H
+
+#include <log4cxx/helpers/objectimpl.h>
+
+namespace log4cxx
+{
+
+        namespace helpers {
+          class ByteBuffer;
+
+          /**
+           * Abstract class for reading from character streams.
+           * @since 0.9.8
+           */
+          class LOG4CXX_EXPORT InputStream : public ObjectImpl
+          {
+          public:
+                  DECLARE_ABSTRACT_LOG4CXX_OBJECT(InputStream)
+                  BEGIN_LOG4CXX_CAST_MAP()
+                          LOG4CXX_CAST_ENTRY(InputStream)
+                  END_LOG4CXX_CAST_MAP()
+
+          protected:
+                  InputStream();
+
+                  virtual ~InputStream();
+
+          public:
+                  virtual LogString read(log4cxx::helpers::Pool& pool) const = 
0;
+
+                  virtual void close() = 0;
+
+          private:
+                  InputStream(const InputStream&);
+                  InputStream& operator=(const InputStream&);
+          };
+
+          typedef helpers::ObjectPtrT<InputStream> InputStreamPtr;
+        } // namespace helpers
+
+}  //namespace log4cxx
+
+#endif //_LOG4CXX_HELPERS_INPUTSTREAM_H
Index: include/log4cxx/logger.h
===================================================================
--- include/log4cxx/logger.h    (Revision 373510)
+++ include/log4cxx/logger.h    (Arbeitskopie)
@@ -452,23 +452,44 @@
         First, the user supplied
         <code>key</code> is searched in the resource bundle. Next, the 
resulting
         pattern is formatted using helpers::StringHelper::format method with 
the user
-        supplied object array <code>params</code>.
+        supplied string array <code>params</code>.
 
         @param level The level of the logging request.
-        @param key The key to be searched in the #resourceBundle.
-        @param file The source file of the logging request, may be null.
-        @param line The number line of the logging request.
+        @param key The key to be searched in the #ResourceBundle.
+        @param locationInfo The location info of the logging request.
+        @param values The values for the placeholders <code>{0}</code>,
+                      <code>{1}</code> etc. within the pattern.
 
         @see #setResourceBundle
         */
+        void l7dlog(const LevelPtr& level, const LogString& key,
+                    const log4cxx::spi::LocationInfo& locationInfo,
+                    const std::vector<LogString>& values);
+
 #if LOG4CXX_HAS_WCHAR_T
         void l7dlog(const LevelPtr& level, const std::wstring& key,
-                                const log4cxx::spi::LocationInfo& locationInfo,
-                                ...);
+                    const log4cxx::spi::LocationInfo& locationInfo);
+        void l7dlog(const LevelPtr& level, const std::wstring& key,
+                    const log4cxx::spi::LocationInfo& locationInfo,
+                    const std::wstring& val1);
+        void l7dlog(const LevelPtr& level, const std::wstring& key,
+                    const log4cxx::spi::LocationInfo& locationInfo,
+                    const std::wstring& val1, const std::wstring& val2);
+        void l7dlog(const LevelPtr& level, const std::wstring& key,
+                    const log4cxx::spi::LocationInfo& locationInfo,
+                    const std::wstring& val1, const std::wstring& val2, const 
std::wstring& val3);
 #endif
         void l7dlog(const LevelPtr& level, const std::string& key,
-                                const log4cxx::spi::LocationInfo& locationInfo,
-                                ...);
+                    const log4cxx::spi::LocationInfo& locationInfo);
+        void l7dlog(const LevelPtr& level, const std::string& key,
+                    const log4cxx::spi::LocationInfo& locationInfo,
+                    const std::string& val1);
+        void l7dlog(const LevelPtr& level, const std::string& key,
+                    const log4cxx::spi::LocationInfo& locationInfo,
+                    const std::string& val1, const std::string& val2);
+        void l7dlog(const LevelPtr& level, const std::string& key,
+                    const log4cxx::spi::LocationInfo& locationInfo,
+                    const std::string& val1, const std::string& val2, const 
std::string& val3);
 
           /**
         This is the most generic printing method. It is intended to be
Index: include/log4cxx/file.h
===================================================================
--- include/log4cxx/file.h      (Revision 373510)
+++ include/log4cxx/file.h      (Arbeitskopie)
@@ -57,8 +57,7 @@
                        return osName;
                     }
 
-                    LogString read(log4cxx::helpers::Pool& pool) const;
-
+                    // @deprecated Use FileOutputStream instead
                     log4cxx_status_t write(const LogString& src, 
log4cxx::helpers::Pool& p) const;
 
                     log4cxx_status_t open(apr_file_t** file, int flags,
Index: src/file.cpp
===================================================================
--- src/file.cpp        (Revision 373510)
+++ src/file.cpp        (Arbeitskopie)
@@ -133,57 +133,6 @@
 //   Current implementation is limited to MBCS files
 //
 //
-LogString File::read(Pool& p) const {
-  LogString output;
-  apr_file_t* f = NULL;
-  apr_status_t rv = open(&f, APR_READ, APR_OS_DEFAULT, p);
-  if (rv != APR_SUCCESS) {
-      throw IOException(rv);
-  } else {
-    const size_t BUFSIZE = 4096;
-    char* buf = p.palloc(BUFSIZE);
-    char* contents = buf;
-    apr_size_t contentLength = 0;
-    do {
-      apr_size_t bytesRead = BUFSIZE;
-      rv = apr_file_read(f, buf, &bytesRead);
-      contentLength += bytesRead;
-      if (APR_STATUS_IS_EOF(rv)  || (rv == APR_SUCCESS && bytesRead < 
BUFSIZE)) {
-          //
-          //     finished file
-          //        transcode and exit
-          Transcoder::decode(contents, contentLength, output);
-//
-//          TODO - assertion here when called from Compare
-//
-//          rv = apr_file_close(f);
-//          assert(rv == APR_SUCCESS);
-          return output;
-      } else if (rv == APR_SUCCESS) {
-         //
-         //   file was larger than the buffer
-         //      realloc a bigger buffer
-         char* newContents = p.palloc(contentLength + BUFSIZE);
-         buf = newContents + contentLength;
-         memcpy(newContents, contents, contentLength);
-         //
-         //   we would free contents here if you did that sort of thing
-         //
-         contents = newContents;
-      }
-    } while(rv == APR_SUCCESS);
-    rv = apr_file_close(f);
-    assert(rv == APR_SUCCESS);
-  }
-  return output;
-}
-
-
-
-//
-//   Current implementation is limited to MBCS files
-//
-//
 log4cxx_status_t File::write(const LogString& src, Pool& p) const {
   LogString output;
   apr_file_t* f = NULL;
Index: src/fileinputstream.cpp
===================================================================
--- src/fileinputstream.cpp     (Revision 0)
+++ src/fileinputstream.cpp     (Revision 0)
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2003,2005 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/fileinputstream.h>
+#include <log4cxx/helpers/exception.h>
+#include <log4cxx/helpers/bytebuffer.h>
+#include <apr_file_io.h>
+#include <log4cxx/helpers/transcoder.h>
+#include <log4cxx/helpers/aprinitializer.h>
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+
+IMPLEMENT_LOG4CXX_OBJECT(FileInputStream)
+
+FileInputStream::FileInputStream(const LogString& filename) {
+    apr_fileperms_t perm = APR_OS_DEFAULT;
+    apr_int32_t flags = APR_READ;
+    LOG4CXX_ENCODE_CHAR(fn, filename);
+    apr_status_t stat = apr_file_open((apr_file_t**) &fileptr,
+        fn.c_str(), flags, perm, (apr_pool_t*) pool.getAPRPool());
+    if (stat != APR_SUCCESS) {
+      throw IOException(stat);
+    }
+}
+
+
+FileInputStream::FileInputStream(const File& aFile) {
+    apr_fileperms_t perm = APR_OS_DEFAULT;
+    apr_int32_t flags = APR_READ;
+    LOG4CXX_ENCODE_CHAR(fn, aFile.getName());
+    apr_status_t stat = apr_file_open((apr_file_t**) &fileptr,
+        fn.c_str(), flags, perm, (apr_pool_t*) pool.getAPRPool());
+    if (stat != APR_SUCCESS) {
+      throw IOException(stat);
+    }
+}
+
+
+FileInputStream::~FileInputStream() {
+  if (fileptr != NULL && !APRInitializer::isDestructed) {
+    apr_file_close((apr_file_t*) fileptr);
+  }
+}
+
+
+void FileInputStream::close() {
+  apr_status_t stat = apr_file_close((apr_file_t*) fileptr);
+  if (stat == APR_SUCCESS) {
+    fileptr = NULL;
+  } else {
+    throw IOException(stat);
+  }
+}
+
+
+//
+//   Current implementation is limited to MBCS files
+//
+//
+LogString FileInputStream::read(Pool& p) const {
+    LogString output;
+    apr_status_t rv = APR_SUCCESS;
+    const size_t BUFSIZE = 4096;
+    char* buf = p.palloc(BUFSIZE);
+    char* contents = buf;
+    apr_size_t contentLength = 0;
+    do {
+      apr_size_t bytesRead = BUFSIZE;
+      rv = apr_file_read((apr_file_t*) fileptr, buf, &bytesRead);
+      contentLength += bytesRead;
+      if (APR_STATUS_IS_EOF(rv)  || (rv == APR_SUCCESS && bytesRead < 
BUFSIZE)) {
+          //
+          //     finished file
+          //        transcode and exit
+          Transcoder::decode(contents, contentLength, output);
+//
+//          TODO - assertion here when called from Compare
+//
+//          rv = apr_file_close(f);
+//          assert(rv == APR_SUCCESS);
+          return output;
+      } else if (rv == APR_SUCCESS) {
+         //
+         //   file was larger than the buffer
+         //      realloc a bigger buffer
+         char* newContents = p.palloc(contentLength + BUFSIZE);
+         buf = newContents + contentLength;
+         memcpy(newContents, contents, contentLength);
+         //
+         //   we would free contents here if you did that sort of thing
+         //
+         contents = newContents;
+      }
+    } while(rv == APR_SUCCESS);
+
+    return output;
+}
Index: src/loader.cpp
===================================================================
--- src/loader.cpp      (Revision 373510)
+++ src/loader.cpp      (Arbeitskopie)
@@ -30,6 +30,7 @@
 #include <sys/stat.h>
 #include <fstream>
 #include <log4cxx/helpers/transcoder.h>
+#include <log4cxx/helpers/fileinputstream.h>
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
@@ -80,29 +81,20 @@
 }
 #endif
 
-#if 0
-istream * Loader::getResourceAsStream(const LogString& name)
-{
-   String path = getResource(name);
-   if (path.empty())
-   {
-      return 0;
-   }
 
-#ifdef LOG4CXX_UNICODE
-      std::wifstream * stream = new std::wifstream();
-#else
-      std::ifstream * stream = new std::ifstream();
+InputStreamPtr Loader::getResourceAsStream(const LogString& name) {
+#if 0
+  String path = getResource(name);
+  if (path.empty())
+  {
+    return 0;
+  }
 #endif
 
-   USES_CONVERSION;
-   stream->open(T2A(name.c_str()));
-   if (stream->fail())
-   {
-      delete stream;
-      return 0;
-   }
+  try {
+    return new FileInputStream(name);
+  } catch(const IOException& ioex) {
+  }
 
-   return stream;
+  return 0;
 }
-#endif
Index: src/propertyconfigurator.cpp
===================================================================
--- src/propertyconfigurator.cpp        (Revision 373510)
+++ src/propertyconfigurator.cpp        (Arbeitskopie)
@@ -35,6 +35,7 @@
 #include <apr_file_info.h>
 #include <apr_pools.h>
 #include <log4cxx/helpers/transcoder.h>
+#include <log4cxx/helpers/fileinputstream.h>
 
 
 using namespace log4cxx;
@@ -80,8 +81,11 @@
         spi::LoggerRepositoryPtr& hierarchy)
 {
        hierarchy->setConfigured(true);
-        Pool pool;
-        LogString config(configFileName.read(pool));
+       Pool pool;
+
+        InputStreamPtr inputStream = new FileInputStream(configFileName);
+        LogString config = inputStream->read(pool);
+
         if (config.length() == 0) {
             LogLog::error(((LogString) LOG4CXX_STR("Could not read 
configuration file ["))
                 + configFileName.getName() + LOG4CXX_STR("]."));
Index: src/resourcebundle.cpp
===================================================================
--- src/resourcebundle.cpp      (Revision 373510)
+++ src/resourcebundle.cpp      (Arbeitskopie)
@@ -21,6 +21,8 @@
 #include <log4cxx/helpers/transcoder.h>
 #include <log4cxx/helpers/locale.h>
 
+#include <apr_lib.h>
+
 using namespace log4cxx;
 using namespace log4cxx::helpers;
 
@@ -56,19 +58,16 @@
    }
 
    bundlesNames.push_back(baseName);
-        Pool pool;
 
    for (std::vector<LogString>::iterator it = bundlesNames.begin();
       it != bundlesNames.end(); it++)
    {
-#if 0
-// TODO
 
-                LogString bundleStream;
       bundleName = *it;
 
       PropertyResourceBundlePtr current;
 
+      // Try loading a class which implements ResourceBundle
       try
       {
          const Class& classObj = Loader::loadClass(bundleName);
@@ -79,29 +78,27 @@
          current = 0;
       }
 
+      // No class found, then try to create a PropertyResourceBundle from a 
file
       if (current == 0)
       {
-                        apr_size_t bytes = 0;
-                        void* buf = Loader::getResourceAsStream(
-                           bundleName + LOG4CXX_STR(".properties"),
-                           &bytes, pool);
-                        if (bytes == 0 || buf == NULL) {
-                          continue;
-                        }
-                        log4cxx::helpers::Transcoder::decode(buf, bytes, pool, 
bundleStream);
-      }
+        InputStreamPtr bundleStream =
+                  Loader::getResourceAsStream(
+                                bundleName + LOG4CXX_STR(".properties"));
+        if (bundleStream == 0) {
+          continue;
+        }
 
-      try
-      {
-         current = new PropertyResourceBundle(bundleStream);
+        try
+        {
+          current = new PropertyResourceBundle(bundleStream);
+        }
+        catch(Exception&)
+        {
+          throw;
+        }
       }
-      catch(Exception&)
-      {
-         throw;
-      }
 
-      bundleStream.erase(bundleStream.begin(), bundleStream.end());
-
+      // Add the new resource bundle to the hierarchy
       if (resourceBundle == 0)
       {
          resourceBundle = current;
@@ -112,9 +109,9 @@
          previous->setParent(current);
          previous = current;
       }
-#endif
    }
 
+   // no resource bundle found at all, then throw exception
    if (resourceBundle == 0)
    {
       throw MissingResourceException(
Index: src/Makefile.am
===================================================================
--- src/Makefile.am     (Revision 373510)
+++ src/Makefile.am     (Arbeitskopie)
@@ -37,6 +37,7 @@
         file.cpp \
         fileappender.cpp \
         filedatepatternconverter.cpp \
+        fileinputstream.cpp \
         filelocationpatternconverter.cpp \
         fileoutputstream.cpp \
         filerenameaction.cpp \
@@ -49,6 +50,7 @@
         hierarchy.cpp \
         htmllayout.cpp \
         inetaddress.cpp \
+        inputstream.cpp \
         integer.cpp \
         integerpatternconverter.cpp \
         layout.cpp\
Index: src/stringhelper.cpp
===================================================================
--- src/stringhelper.cpp        (Revision 373510)
+++ src/stringhelper.cpp        (Arbeitskopie)
@@ -279,3 +279,23 @@
   toString((log4cxx_int64_t) n, pool, ws);
 }
 #endif
+
+
+LogString StringHelper::format(const LogString& pattern, const 
std::vector<LogString>& params) {
+
+  LogString result;
+  int i = 0;
+  while(pattern[i] != LOG4CXX_STR('\0')) {
+    if (pattern[i] == LOG4CXX_STR('{') && pattern[i + 1] >= LOG4CXX_STR('0') &&
+        pattern[i + 1] <= LOG4CXX_STR('9') && pattern[i + 2] == 
LOG4CXX_STR('}')) {
+      int arg = pattern[i + 1] - LOG4CXX_STR('0');
+      result = result + params[arg];
+      i += 3;
+    } else {
+      result = result + pattern[i];
+      i++;
+    }
+  }
+
+  return result;
+}
Index: src/inputstream.cpp
===================================================================
--- src/inputstream.cpp (Revision 0)
+++ src/inputstream.cpp (Revision 0)
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2003,2005 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/inputstream.h>
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+
+IMPLEMENT_LOG4CXX_OBJECT(InputStream)
+
+InputStream::InputStream() {
+}
+
+InputStream::~InputStream() {
+}
Index: src/properties.cpp
===================================================================
--- src/properties.cpp  (Revision 373510)
+++ src/properties.cpp  (Arbeitskopie)
@@ -16,6 +16,7 @@
 
 #include <log4cxx/helpers/properties.h>
 #include <log4cxx/helpers/exception.h>
+#include <log4cxx/helpers/pool.h>
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
@@ -331,6 +332,13 @@
         parser.parse(inStream, *this);
 }
 
+
+void Properties::load(InputStreamPtr inStream) {
+        Pool pool;
+        LogString contents = inStream->read(pool);
+        load(contents);
+}
+
 std::vector<LogString> Properties::propertyNames() const
 {
         std::vector<LogString> names;
Index: src/logger.cpp
===================================================================
--- src/logger.cpp      (Revision 373510)
+++ src/logger.cpp      (Arbeitskopie)
@@ -25,7 +25,6 @@
 #include <log4cxx/helpers/stringhelper.h>
 #include <log4cxx/helpers/synchronized.h>
 #include <log4cxx/helpers/transcoder.h>
-#include <stdarg.h>
 #include <log4cxx/helpers/appenderattachableimpl.h>
 #include <log4cxx/helpers/exception.h>
 #include <log4cxx/helpers/aprinitializer.h>
@@ -208,8 +207,8 @@
         return 0;
 }
 
-#if 0
-String Logger::getResourceBundleString(const String& key) const
+
+LogString Logger::getResourceBundleString(const LogString& key) const
 {
         ResourceBundlePtr rb = getResourceBundle();
 
@@ -217,7 +216,7 @@
         // to report errors from within log4j.
         if (rb == 0)
         {
-                return String();
+                return LogString();
         }
         else
         {
@@ -227,15 +226,15 @@
                 }
                 catch (MissingResourceException&)
                 {
-                        ((Logger *)this)->error(LOG4CXX_WSTR("No resource is 
associated with key \"") +
-                                key + LOG4CXX_WSTR("\"."));
+                        ((Logger *)this)->error(LOG4CXX_STR("No resource is 
associated with key \"") +
+                                key + LOG4CXX_STR("\"."));
 
-                        return String();
+                        return LogString();
                 }
         }
 }
-#endif
 
+
 const LoggerPtr& Logger::getParent() const
 {
         return parent;
@@ -325,7 +324,7 @@
 /*void Logger::l7dlog(const LevelPtr& level, const String& key,
                         const char* file, int line)
 {
-        if (repository == 0 || repository->isDisabled(level->level))
+        if (repository->isDisabled(level->level))
         {
                 return;
         }
@@ -345,8 +344,9 @@
         }
 }*/
 
-void Logger::l7dlog(const LevelPtr& level, const std::string& key,
-                        const LocationInfo& location, ...)
+
+void Logger::l7dlog(const LevelPtr& level, const LogString& key,
+                    const LocationInfo& location, const 
std::vector<LogString>& params)
 {
         if (repository == 0 || repository->isDisabled(level->toInt()))
         {
@@ -355,10 +355,8 @@
 
         if (level->isGreaterOrEqual(getEffectiveLevel()))
         {
-#if 0
-//    TODO
-                String pattern = getResourceBundleString(key);
-                String msg;
+                LogString pattern = getResourceBundleString(key);
+                LogString msg;
 
                 if (pattern.empty())
                 {
@@ -366,47 +364,119 @@
                 }
                 else
                 {
-                        va_list params;
-                        va_start (params, line);
                         msg = StringHelper::format(pattern, params);
-                        va_end (params);
                 }
-#endif
-                forcedLog(level, key, location);
+
+                forcedLog(level, msg, location);
         }
 }
 
+void Logger::l7dlog(const LevelPtr& level, const std::string& key,
+                    const LocationInfo& location) {
+  LogString lkey;
+  Transcoder::decode(key.c_str(), strlen(key.c_str()), lkey);
+
+  std::vector<LogString> values(0);
+  l7dlog(level, lkey, location, values);
+}
+
+void Logger::l7dlog(const LevelPtr& level, const std::string& key,
+                    const LocationInfo& location, const std::string& val1) {
+  LogString lval1;
+  Transcoder::decode(val1.c_str(), strlen(val1.c_str()), lval1);
+  LogString lkey;
+  Transcoder::decode(key.c_str(), strlen(key.c_str()), lkey);
+
+  std::vector<LogString> values(1);
+  values[0] = lval1;
+  l7dlog(level, lkey, location, values);
+}
+
+void Logger::l7dlog(const LevelPtr& level, const std::string& key,
+                    const LocationInfo& location, 
+                    const std::string& val1, const std::string& val2) {
+  LogString lval1;
+  LogString lval2;
+  Transcoder::decode(val1.c_str(), strlen(val1.c_str()), lval1);
+  Transcoder::decode(val2.c_str(), strlen(val2.c_str()), lval2);
+  LogString lkey;
+  Transcoder::decode(key.c_str(), strlen(key.c_str()), lkey);
+
+  std::vector<LogString> values(2);
+  values[0] = lval1;
+  values[1] = lval2;
+  l7dlog(level, lkey, location, values);
+}
+
+void Logger::l7dlog(const LevelPtr& level, const std::string& key,
+                    const LocationInfo& location, 
+                    const std::string& val1, const std::string& val2, const 
std::string& val3) {
+  LogString lval1;
+  LogString lval2;
+  LogString lval3;
+  Transcoder::decode(val1.c_str(), strlen(val1.c_str()), lval1);
+  Transcoder::decode(val2.c_str(), strlen(val2.c_str()), lval2);
+  Transcoder::decode(val3.c_str(), strlen(val3.c_str()), lval3);
+  LogString lkey;
+  Transcoder::decode(key.c_str(), strlen(key.c_str()), lkey);
+
+  std::vector<LogString> values(3);
+  values[0] = lval1;
+  values[1] = lval2;
+  values[3] = lval3;
+  l7dlog(level, lkey, location, values);
+}
+
+
 #if LOG4CXX_HAS_WCHAR_T
+
 void Logger::l7dlog(const LevelPtr& level, const std::wstring& key,
-                        const LocationInfo& location, ...)
-{
-        if (repository == 0 || repository->isDisabled(level->toInt()))
-        {
-                return;
-        }
+                    const LocationInfo& location) {
+  LOG4CXX_DECODE_WCHAR(lkey, key);
 
-        if (level->isGreaterOrEqual(getEffectiveLevel()))
-        {
-#if 0
-//    TODO
-                String pattern = getResourceBundleString(key);
-                String msg;
+  std::vector<LogString> values(0);
+  l7dlog(level, lkey, location, values);
+}
 
-                if (pattern.empty())
-                {
-                        msg = key;
-                }
-                else
-                {
-                        va_list params;
-                        va_start (params, line);
-                        msg = StringHelper::format(pattern, params);
-                        va_end (params);
-                }
-#endif
-                forcedLog(level, key, location);
-        }
+void Logger::l7dlog(const LevelPtr& level, const std::wstring& key,
+                    const LocationInfo& location,
+                    const std::wstring& val1) {
+  LOG4CXX_DECODE_WCHAR(lval1, val1);
+  LOG4CXX_DECODE_WCHAR(lkey, key);
+
+  std::vector<LogString> values(1);
+  values[0] = lval1;
+  l7dlog(level, lkey, location, values);
 }
+
+void Logger::l7dlog(const LevelPtr& level, const std::wstring& key,
+                    const LocationInfo& location,
+                    const std::wstring& val1, const std::wstring& val2) {
+  LOG4CXX_DECODE_WCHAR(lval1, val1);
+  LOG4CXX_DECODE_WCHAR(lval2, val2);
+  LOG4CXX_DECODE_WCHAR(lkey, key);
+
+  std::vector<LogString> values(2);
+  values[0] = lval1;
+  values[1] = lval2;
+  l7dlog(level, lkey, location, values);
+}
+
+void Logger::l7dlog(const LevelPtr& level, const std::wstring& key,
+                    const LocationInfo& location,
+                    const std::wstring& val1, const std::wstring& val2, const 
std::wstring& val3) {
+  LOG4CXX_DECODE_WCHAR(lval1, val1);
+  LOG4CXX_DECODE_WCHAR(lval2, val2);
+  LOG4CXX_DECODE_WCHAR(lval3, val3);
+  LOG4CXX_DECODE_WCHAR(lkey, key);
+
+  std::vector<LogString> values(3);
+  values[0] = lval1;
+  values[1] = lval2;
+  values[2] = lval3;
+  l7dlog(level, lkey, location, values);
+}
+
 #endif
 
 void Logger::removeAllAppenders()
Index: src/propertyresourcebundle.cpp
===================================================================
--- src/propertyresourcebundle.cpp      (Revision 373510)
+++ src/propertyresourcebundle.cpp      (Arbeitskopie)
@@ -23,6 +23,12 @@
 
 IMPLEMENT_LOG4CXX_OBJECT(PropertyResourceBundle)
 
+
+PropertyResourceBundle::PropertyResourceBundle(InputStreamPtr inStream)
+{
+   properties.load(inStream);
+}
+
 PropertyResourceBundle::PropertyResourceBundle(LogString& inStream)
 {
    properties.load(inStream);
Index: tests/src/filetestcase.cpp
===================================================================
--- tests/src/filetestcase.cpp  (Revision 373510)
+++ tests/src/filetestcase.cpp  (Arbeitskopie)
@@ -20,6 +20,7 @@
 #include <log4cxx/helpers/pool.h>
 #include <apr_errno.h>
 #include <log4cxx/helpers/exception.h>
+#include <log4cxx/helpers/fileinputstream.h>
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
@@ -62,7 +63,8 @@
           File defFile;
           Pool pool;
           try {
-            LogString contents(defFile.read(pool));
+            FileInputStream defInput(defFile);
+            LogString contents(defInput.read(pool));
             CPPUNIT_ASSERT(false);
           } catch(IOException &ex) {
           }
@@ -106,7 +108,8 @@
         void propertyRead() {
           File propFile("input/patternLayout1.properties");
           Pool pool;
-          LogString props(propFile.read(pool));
+          FileInputStream propStream(propFile);
+          LogString props(propStream.read(pool));
           LogString line1(LOG4CXX_STR("log4j.rootCategory=DEBUG, 
testAppender"));
           CPPUNIT_ASSERT_EQUAL(line1, props.substr(0, line1.length()));
           LogString tail(LOG4CXX_STR("%-5p - %m%n"));
@@ -128,7 +131,8 @@
           apr_status_t stat = outFile.write(greeting, pool);
           CPPUNIT_ASSERT_EQUAL(0, stat);
 
-          LogString reply(outFile.read(pool));
+          FileInputStream outStream(outFile);
+          LogString reply(outStream.read(pool));
           CPPUNIT_ASSERT_EQUAL(greeting, reply);
         }
         
Index: tests/src/l7dtestcase.cpp
===================================================================
--- tests/src/l7dtestcase.cpp   (Revision 373510)
+++ tests/src/l7dtestcase.cpp   (Arbeitskopie)
@@ -103,4 +103,4 @@
 
 };
 
-//CPPUNIT_TEST_SUITE_REGISTRATION(L7dTestCase);
+CPPUNIT_TEST_SUITE_REGISTRATION(L7dTestCase);
Index: tests/src/util/compare.cpp
===================================================================
--- tests/src/util/compare.cpp  (Revision 373510)
+++ tests/src/util/compare.cpp  (Arbeitskopie)
@@ -21,6 +21,7 @@
 #include <log4cxx/helpers/pool.h>
 #include <log4cxx/file.h>
 #include <log4cxx/helpers/stringhelper.h>
+#include <log4cxx/helpers/fileinputstream.h>
 
 using namespace log4cxx;
 using namespace log4cxx::helpers;
@@ -28,10 +29,12 @@
 bool Compare::compare(const File& file1, const File& file2)
 {
     Pool pool;
+    FileInputStream fileIn1(file1);
+    LogString in1(fileIn1.read(pool));
 
-    LogString in1(file1.read(pool));
     Pool pool2;
-    LogString in2(file2.read(pool2));
+    FileInputStream fileIn2(file2);
+    LogString in2(fileIn2.read(pool2));
 
     LogString back1(in1);
     LogString back2(in2);

Reply via email to