Boost logo

Boost :

From: Michael Lacher (michael.lacher_at_[hidden])
Date: 2007-04-05 11:39:30

Richard Day wrote:
> Michael Lacher wrote:
>> 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
> My thinking is that macros are really just for trace during debugging
> for the most part.
> Basically so you have a way to turn them off in a release build if/when
> desired.
> Stream statements are much nicer for regular logging. No need to know
> arguments ahead of time and setup macros for every possibility.
Well, my idea was basically that stream statements are the "canonical"
way of writing any log message, and that convenience macros ar eprovided
to provide a functional style interface for common and quick cases.
Depending on the lazy evaluation and the "no global object" requirement
the thing you actually stream your message into (the variable 'logger'
in the example) might actually be a macro evaluating to a stream object.


Boost list run by bdawes at, gregod at, cpdaniel at, john at