You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Stephen Bartnikowski <sb...@barkinglizards.com> on 2006/11/28 01:08:37 UTC
logstream and a std::string with zeros
Hello,
I'm doing the following:
std::string message;
[...]
if (sm_logger->isDebugEnabled()) {
log4cxx::logstream oss(sm_logger, log4cxx::Level::getDebug());
oss.setLocation(LOG4CXX_LOCATION);
oss << message;
oss.flush();
}
but in one circumstance I found that "message" contained actual zeros
as part of the string data. (std::string allows this and does not
recognize them as null terminators.)
When "message" is streamed into "oss", my program hangs. If I convert
"message" to a c_str prior to calling my block of code, everything runs
fine. I think the logstream operator<< is converting the std::string to
a type that isn't able to handle zeros in the string for whatever
reason. Should this be a bug report?
(I'm using the log4cxx code from SVN about 2 weeks ago on FreeBSD 6.0.)
Thanks!
Steve
RE: logstream and a std::string with zeros
Posted by Stephen Bartnikowski <sb...@barkinglizards.com>.
Oops - thanks Curt!
-----Original Message-----
From: Curt Arnold [mailto:carnold@apache.org]
Sent: Friday, December 01, 2006 12:25 AM
To: Log4CXX User
Subject: Re: logstream and a std::string with zeros
On Nov 27, 2006, at 6:08 PM, Stephen Bartnikowski wrote:
> Hello,
>
> I'm doing the following:
>
> std::string message;
>
> [...]
>
> if (sm_logger->isDebugEnabled()) {
> log4cxx::logstream oss(sm_logger, log4cxx::Level::getDebug());
> oss.setLocation(LOG4CXX_LOCATION);
> oss << message;
> oss.flush();
> }
>
> but in one circumstance I found that "message" contained actual zeros
> as part of the string data. (std::string allows this and does not
> recognize them as null terminators.)
>
> When "message" is streamed into "oss", my program hangs. If I convert
> "message" to a c_str prior to calling my block of code, everything
> runs
> fine. I think the logstream operator<< is converting the
> std::string to
> a type that isn't able to handle zeros in the string for whatever
> reason. Should this be a bug report?
>
> (I'm using the log4cxx code from SVN about 2 weeks ago on FreeBSD
> 6.0.)
>
> Thanks!
> Steve
>
Already reported as http://issues.apache.org/jira/browse/LOGCXX-162.
There is a patch associated with the bug report, but it has not been
reviewed.
Re: logstream and a std::string with zeros
Posted by Curt Arnold <ca...@apache.org>.
On Nov 27, 2006, at 6:08 PM, Stephen Bartnikowski wrote:
> Hello,
>
> I'm doing the following:
>
> std::string message;
>
> [...]
>
> if (sm_logger->isDebugEnabled()) {
> log4cxx::logstream oss(sm_logger, log4cxx::Level::getDebug());
> oss.setLocation(LOG4CXX_LOCATION);
> oss << message;
> oss.flush();
> }
>
> but in one circumstance I found that "message" contained actual zeros
> as part of the string data. (std::string allows this and does not
> recognize them as null terminators.)
>
> When "message" is streamed into "oss", my program hangs. If I convert
> "message" to a c_str prior to calling my block of code, everything
> runs
> fine. I think the logstream operator<< is converting the
> std::string to
> a type that isn't able to handle zeros in the string for whatever
> reason. Should this be a bug report?
>
> (I'm using the log4cxx code from SVN about 2 weeks ago on FreeBSD
> 6.0.)
>
> Thanks!
> Steve
>
Already reported as http://issues.apache.org/jira/browse/LOGCXX-162.
There is a patch associated with the bug report, but it has not been
reviewed.