Boost logo

Boost :

Subject: Re: [boost] [logging] Interest check on logging library.
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-01-01 14:24:08

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.

In a simple case, you'd simply write:

if( logging::severity>=2 )
  log() << "whatever: " << whatever();

and you'll know that the function wouldn't be called if
logging::severity is below 2. In more complex conditions, users can
decide to separate the condition in a predicate:

if( logging_connections() )
  log() << "server: connection from " << connection.ip();


bool logging_connections()
  return (server_logging::connections || client_logging::connections)
&& logging::severity>=1;

Emil Dotchevski
Reverge Studios, Inc.

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