Details
Description
log4cxx dll built with log4cxx.h set to:
#define LOG4CXX_LOGCHAR_IS_UTF8 1
#define LOG4CXX_HAS_WCHAR_T 0
Build fails due to encode/decode missing. Changed unicodehelper.cpp+95 from:
#if defined(_WIN32)
unsigned int UnicodeHelper::decodeWide(const wchar_t*& src, const wchar_t* srcEnd) {
to
#if LOG4CXX_HAS_WCHAR_T && defined(_WIN32)
unsigned int UnicodeHelper::decodeWide(const wchar_t*& src, const wchar_t* srcEnd) {
build worked, but when a client uses the library, it crashes when trying to destroy the string being streamed if not a std::string type (i.e. char). See 'logstr2 << "Testing stream" << LOG4CXX_ENDMSG' line in sample below.
Note, this is with 'inline' added to stream.h
Chris
Sample code:
#include "stdafx.h"
#include "Windows.h"
#include <conio.h>
log4cxx::LoggerPtr logger;
log4cxx::logstream* logstr;
int _tmain(int argc, _TCHAR* argv[])
{
logger = log4cxx::Logger::getRootLogger();
log4cxx::PropertyConfigurator::configureAndWatch(log4cxx::File("log.cfg"));
log4cxx::logstream logstr2(logger, log4cxx::Level::getError());
logstr = &logstr2;
LOG4CXX_DEBUG(logger, "Starting tests");
int count = 0;
while (!_kbhit())
LOG4CXX_DEBUG(logger, "Stopped tests");
printf("Press Q and RETURN\n");
scanf("%d");
return 0;
}