logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Bartnikowski" <sbartnikow...@barkinglizards.com>
Subject logstream and a std::string with zeros
Date Tue, 28 Nov 2006 00:08:37 GMT
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



Mime
View raw message