Loading...

log4cxx-dev@logging.apache.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

Use std::string with logstream Steck, David Thu Aug 31 18:01:09 2006

Currently, one cannot directly output a std::string through a logstream.  
Rainer Schuetze and I both came up with the suggestion of calling .c_str() in 
an operator<< function, but neither of us felt satisfied with this answer.
http://marc.theaimsgroup.com/?l=log4cxx-user&m=112229621903500&w=2
http://marc.theaimsgroup.com/?l=log4cxx-user&m=113380074400398&w=2

When I looked more closely at the operator<< functions for char, though, I 
discovered the same pattern can be used for std::string.  So, I added those 
functions and am attaching the patch (diff'd against revision 397231 of SVN).

(I believe that the compiler complaint when trying to output std::string 
directly is because logstream is based off logchar, instead of char or wchar.  
The DECODE and ENCODE macros/functions do this conversion, I think.)

I've created an issue for this:
http://issues.apache.org/jira/browse/LOGCXX-135

I've not submitted a patch before.  So, please let me know if I need to do 
something differently.

I'd also like to vote for renaming stream.h to logstream.h.


On another topic, http://issues.apache.org/jira/browse/LOGCXX-82 looks like 
maybe it should be closed?

-David