Dale King wrote:
On Thu, May 22, 2008 at 7:55 PM, Jacob L. Anawalt
<[EMAIL PROTECTED]> wrote:
I get the same error if I write a wide
string to std::cout via <<.

Not exactly. For std::cout all of the wide strings would print out as
the address, not just some of them.


Right, all uses of std::cout would, and all uses of std::wcout would not. All uses of LOG4CXX_* macros that choose the narrow buffer override would, and all that choose the wide buffer override would not.


LOG4CXX_TRACE( logger, L"1" << L"2" << "3" << "4" );
std::wcout << L"1" << L"2" << "3" << "4";

LOG4CXX_TRACE( logger, 1 << L"2" << "3" << L"4" );
std::cout << 1 << L"2" << "3" << L"4";


I am pleased with how the insertion operator works with log4cxx macros in the code I have used it in. The function overloads appear to be efficient and have done the right thing. You bring up a case where they might not do what is expected, and the problem may not be immediately obvious.


std::string v1; // or some object that makes the LOG4CXX macro not go wide.
std::wstring v1;
...
LOG4CXX_TRACE( logger, v1 << v2);


The src/main/include/log4cxx/helpers/tchar.h file gives some background and suggestions for using one character type or another. Reading through it and the other headers it references I am tempted to prefer a WLOG4CXX_* macro that forces the use of only wide streams in log4cxx if I knew my app would be using wide and narrow strings. Less typing :).

Hopefully this discussion results in a wiki page and later documentation with 'best practice' examples.

--
Jacob Anawalt
Gecko Software, Inc.
[EMAIL PROTECTED]
435-752-8026

Reply via email to