On Dec 21, 2004, at 5:34 PM, Tommi M�kitalo wrote:
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.
There was a conditional to call _Init for the VC implementation, guess it was also needed for GCC. I guess I can test this by creating a new unit test that creates a logstream and then gets its width expecting it to be zero.
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 had originally implemented this based on std::basic_ostream<logchar> but that was many times more expensive than the traditional log4cxx API calls when calls were below the threshold. If it isn't derived from std::ios_base, then manipulators like std::width etc can't be applied. The sample test is pretty simple but my guess is the modifications would break tests/src/streamtestcase.cpp.
I fixed also another bug: The stream must be cleared in flush even when logging is disabled.
What was the symptom?
