Boost logo

Boost :

Subject: Re: [boost] [logging] Interest check on logging library.
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2009-01-01 17:11:10

Emil Dotchevski wrote:
> On Thu, Jan 1, 2009 at 6:51 AM, Andrey Semashev
> <andrey.semashev_at_[hidden]> wrote:
>> 2. You will have to write an "if" around the streaming statement. That "if"
>> will check the filters in run time and decide whether the record will be
>> processed or not. You can wrap it into a macro, but it will be there, and it
>> will not be zero-cost in terms of performance and code size.
> With risk of being annoying, I'll second my earlier post about "the
> if" in question. :)
> I'd rather have "the if" out of any macros and fully visible in user
> code. That way it would be clear what enables or disables the logging
> statement itself, and what functions are called and when.

That is your choice, indeed. However, in general, this will not allow
you to immediately see if the record will be processed or not. This is
because filters are usually set up in some initialization code, which is
rather remote from places where you actually write logs. So, you'll have
a trivial "if" most of the time, something like this:

   if (logger.is_enabled(severity::normal))
     logger << ...;

This check does not say that filtering is based on severity (and if it
is, in what way). Instead, it checks if a record with normal severity
will pass the (opaque) filter. You can write it all the time, but,
personally, I find it annoying.

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