You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by "Steck, David" <da...@lmco.com> on 2006/05/26 15:45:59 UTC
RE: Use std::string with logstream
I discovered that my previous patch seems to only be necessary if you pass --with-logchar=wchar_t to configure, and could cause problems otherwise. Knowing that, I improved the patch. For more, see:
http://issues.apache.org/jira/browse/LOGCXX-135
-David
-----Original Message-----
From: Steck, David
Sent: Wednesday, April 26, 2006 2:19 PM
To: Log4CXX Dev
Subject: Use std::string with logstream
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