|
Boost : |
From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-11-12 12:21:10
Markus Schöpflin wrote:
> John Torjo wrote:
>
>> Finally, have had some time to update the logging lib. Get it from:
>> http://www.torjo.com/ (of course, it comes packed with docs)
>
>
>
> Just a quick thought that came to my mind...
>
> Did you consider using the syntax 'BOOST_LOG(dbg, "message" << foobar);'
> instead of 'BOOST_LOG(dbg) << "message" << foobar;'?
>
> While I think the syntax you use looks far nicer, we ususally need the
> ability to be able to compile away the logging calls completely and this
> only can be done with the first form.
Why not do:
#define BOOST_LOG(id) /##/
to remove the logs at compile time?
The only issue AFAICS is that the above needs the BOOST_LOG usage on a
single line. But if you need multi-line support, can't you have
BOOST_LOG_BEGIN(id)/END like this:
#define BOOST_LOG_BEGIN(id) /##*
#define BOOST_LOG_END *##/
Usage:
BOOST_LOG(dbg) << "message" << foobar;
BOOST_LOG_BEGIN(dbg)
<< "message" << foobar;
BOOST_LOG_END
Effectively transforming this into:
// << "message" << foobar;
/*
<< "message" << foobar;
*/
You would need to be careful about usage of C-style comments within
these macros:
BOOST_LOG(dbg) << foobar; /*
line above commented out: error at '*/'
*/
BOOST_LOG_BEGIN(dbg)
<< foobar; /**< error here: nested C-style comment */
BOOST_LOG_END
Regards,
Reece
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk