Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2002-04-09 05:20:33

Andras Erdei wrote:
> On Mon, 08 Apr 2002 21:47:35 -0400, "Ernie Makris" <ernie_makris_at_[hidden]> wrote:
> >I'd like to propose the design and development of a logging library
> >to be included in boost.
> That would be really nice (i suspect i'm not the only one who have
> implemented one several times -- in fact i'm just working on one
> right now).

Guess what I'm working on right now :)

> >Is there any interest in such a library.

I'm not sure it is possible to do it in a way general enough for most
people, but anyway: We have one particular useful feature implemented,
based on the fact that logging-information is never needed for the
program to work and thus shouldn't prevent it's execution. Another
important observation is, that some logging-code is executed only if
special cases occur. This lead us to (optionally) add a guard for all

/// The basic underlying LOG-macro (implementing the guard if requested)
#define AIXIGO_LOG( level, errorlevel, message ) \
do { \
   if( ::Base::Log::hasLoggers( ::Base::Log::level ) ) { \
      ::Base::Log::log( ::Base::Log::level, __FILE__, __LINE__, message
); \
   } \
} while( false )
#define AIXIGO_LOG( level, errorlevel, message ) \
do { \
   try { \
      if( ::Base::Log::hasLoggers( ::Base::Log::level ) ) { \
         ::Base::Log::log( ::Base::Log::level, __FILE__, __LINE__,
message ); \
      } \
   } catch( ... ) { \
      ::Base::Log::log( ::Base::Log::errorlevel, __FILE__, __LINE__,
"Failed to process " #level " log message `" #message "'" ); \
   } \
} while( false )

/// Write data to the log file.
/// Use this to dump data.
#define LOG_DATA( message ) AIXIGO_LOG( DATA, ERROR, message )

/// Write developer information to the log file.
#define LOG_DEVELOP( message ) AIXIGO_LOG( DEVELOP, ERROR, message )


the details are not important here, the important thing is the
try/catch-block. Something similar should be added to any
logging-library to make it useful in environments where a stable program
is the highest priority. If used this way:

  LOG_INFO( Base::format( "Hello, [0]!", userName_ ) );

The call to Base::format is protected and may fail without breaking the
programm (e.g. if I use "[1]" accidentially instead of "[0]").

As another point I'd vote for the logging-library just piping out as
much data as possible. The analysis can be done with external programs
(we are using grep, etc.) and should not affect the logging itself. One
imporant thing I learned already is, that if you cut down log
information too early, it is lost and you'll always regret it :)

Regards, Daniel

Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web:

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