|
Boost : |
From: Michael Lacher (michael.lacher_at_[hidden])
Date: 2007-04-05 10:28:16
Greer, Joe wrote:
>
>> -----Original Message-----
>> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]]
>> On Behalf Of Richard Day
>>
>> Simple examples.
>>
>> DBG_LOG( "Null pointer we are now dying a hard death" );
>> vs
>> logger << CLASS_WARNING << "File not found : " << filename << endl;
>>
>> With two completely different in many respects requirements satisfying
>> everyones needs is the issue.
>>
> [Joe] I agree. In fact, in the system I currently use, my usage pattern
> is a hybrid. My log messages look something like:
>
> CDBG(TRACE, "network") << "Some network related message." << endl;
>
Maybe optional log information (channel, type, loglevel, ...) could all
be passed similar to manipulators in std::stream. This would keep the
basic interface clean (just << operator) and extensible. There would be
no need to anticipate numbers/types of function arguments.
If people prefer a functional interface, then they could go for either
#define MYLOG1(LEVEL,CHANNEL,MESSAGE) logger << setLevel(LEVEL) <<
setChannel(CHANNEL) << MESSAGE << endl
MYLOG1(WARNING,"Debug","Caught Exception: " << e.what());
or
#define MYLOG2(LEVEL,CHANNEL) logger << setLevel(LEVEL) <<
setChannel(CHANNEL)
MYLOG2(WARNING,"Debug") << "Caught Exception: " << e.what() << endl;
Of course a commonly used subset of such macros could be provided.
Michael
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk