Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2005-08-01 10:02:53

Hi all,

Just updated the Logging library. Find it here:
Also, I've updated the docs. Feedback is welcome.

**** Multiple levels.
**** Easier manipulation of logs
**** Modifiers/Appenders can now be deleted.
**** Shortcut for BOOST_IS_LOG_ENABLED
**** Exception guards
**** Shared Memory Appender

**** Multiple levels.
You can specify levels, very much like log4j.

To assign a level to a message, use BOOST_LOGL, like this:
BOOST_LOGL(app,dbg) << "some debug message";
BOOST_LOGL(app,err) << "some error";
BOOST_LOGL(gui,warn) << "some GUIsh warning";

Note the BOOST_LOG still works:
BOOST_LOG(app) << "some message";
// equivalent to:
// BOOST_LOGL(app,default_) << "some message"

**** Easier manipulation of logs
Every time you need to manipulate some logs
(add/delete appenders/modifiers, set the log's level),
you use manipulate_logs("logs_spec")

     // all logs prefix the message by time
     .add_modifier(prepend_time("$hh:$mm:$ss "), DEFAULT_INDEX + 1 )
     // all log' messages are prefixed by the log name
     // all messages are written to cout

// write all dbg messages and above to app.* logs

**** Modifiers/Appenders can now be deleted.
In order to delete a modifier/appender, just give it a name:

// prepend time, and name this modifier as "time"
   .add_modifier(prepend_time("$hh:$mm:$ss "), "time" );

// at a later time
BOOST_LOG(app) << "this is prefixed by time";
BOOST_LOG(app) << "this is NOT prefixed by time";

***** Shortcut for BOOST_IS_LOG_ENABLED
Instead of saying:
// test if message should be written to this log
if ( BOOST_IS_LOG_ENABLED(app,some_level)) ...;
You can say:
if ( app()(some_level)) ...;

**** Exception guards
When logging, if any modifier/appender throws, the exception is not
allowed to propagate.

**** Shared Memory Appender
An appender that allows writing to a shared memory zone, internally
using shmem library.

Still to do:
**** compile-time logs: write docs about it
**** appenders to Event log
**** alternate logging manager


John Torjo,    Contributing editor, C/C++ Users Journal
-- "Win32 GUI Generics" -- generics & GUI do mix, after all
-- -v1.6.3 (Resource Splitter)
-- - Click, Build, Run!

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