logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dale King" <dalewk...@gmail.com>
Subject Re: Major problem with wide vs. normal strings in log messages
Date Fri, 23 May 2008 00:51:57 GMT
On Thu, May 22, 2008 at 7:55 PM, Jacob L. Anawalt
<janawalt@geckosoftware.com> wrote:
> Dale King wrote:
>>
>> Most of the << operators in the MessageBuffer class return either
>> CharMessageBuffer & or std::ostream &. I think all of these should
>> probably be returning MessageBuffer which would allow it to switch to
>> a WideMessageBuffer if I ever add a wide string, not just if the first
>> string is wide.
>
>
> But is it the right thing to do?

Yes. I think the simpler we can make the logging without worrying
about character types the better.

> 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.

> This seems to keep going down the path of automagically 'just working' so
> perhaps it is.

The question is the sometimes automagically working and sometimes not.

This works:

  LOG4CXX_TRACE( logger, "A message" );

But whether this works depends on the type of value:

  LOG4CXX_TRACE( logger, "The value is " << value );

A user shouldn't have to think about what type of string to use based
on the value.

And experimenting around with it, it is a bit more complex to fix than
I first thought. The code is trying very hard to do the most efficient
thing and only promote to wide when it has to. It uses the return type
to signal what level of promotion it has done.
-- 
Dale King

Mime
View raw message