Hi,

logstream has indeed a problem: ios_base needs to be initialized. Normally 
should happen by calling basic_ios<...>::init(), which is protected. Before 
calling init the values are undefined. Width() returns on my machine 
2507262709. This is not very useful to set up the wostingstream. The 
example-program segfaults.

I think it would be better to derive logstream from ostream or do not derive 
at all. I removed the base-class and the example-program works now. Here is 
my patch.

I fixed also another bug: The stream must be cleared in flush even when 
logging is disabled.

Tommi
Index: include/log4cxx/stream.h
===================================================================
RCS file: /home/cvspublic/logging-log4cxx/include/log4cxx/stream.h,v
retrieving revision 1.6
diff -u -r1.6 stream.h
--- include/log4cxx/stream.h	15 Dec 2004 00:15:19 -0000	1.6
+++ include/log4cxx/stream.h	21 Dec 2004 23:32:14 -0000
@@ -29,7 +29,7 @@
          * and defers the potentially expensive construction
          * of basic_stream until needed.
          */
-           class logstream : public ::std::ios_base {
+           class logstream {
              public:
              /**
               * Constructor.
@@ -98,9 +98,9 @@
                     logger->log(currentLevel,
                        impl->str(),
                        location);
-                    const std::wstring emptyStr;
-                    impl->str(emptyStr);
                 }
+                const std::wstring emptyStr;
+                impl->str(emptyStr);
              }
 
              inline void flush() {
@@ -112,9 +112,6 @@
                 if (0 == impl) {
                   impl = new ::std::wostringstream();
                 }
-                impl->precision(precision());
-                impl->width(width());
-                impl->flags(flags());
                 return *impl;
              }
 
@@ -166,7 +163,7 @@
 ::log4cxx::logstream& operator<<(
    ::log4cxx::logstream& lhs,
    ::std::ios_base& (*manip)(::std::ios_base&)) {
-     (*manip)(lhs);
+     (*manip)(lhs.getStream());
    return lhs;
 }
 

Reply via email to