Subject: Re: [boost] [logging] Interest check on logging library.
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2008-12-27 14:25:20
On Fri, Dec 26, 2008 at 9:48 AM, Jason Wagner <jason_at_[hidden]> wrote:
> Hello all,
> I know there are two proposed logging libraries out there for Boost,
> already, but I had a different itch to scratch on a project. I think I saw
> that Andrey Semashev was going to submit his far more mature version soon,
> but I thought I'd throw my technique out there for an interest check and
> hopefully commentary. This is very much a prototype-- there's a lot of work
> yet to be done but the basic outline and functionality is implemented.
> Getting the code
What is the motivation for using boost::mpl in the logging library? I
didn't look too deeply into your code, but wouldn't something like
this work just as well:
In other words, let the user provide an explicit specialization to
configure the logger; once that's done, they just do:
My reasoning is that a logging library should be lightweight in terms
of source code; when I need logging, I'd rather not get boost::mpl
A few more comments:
In general I don't like using macros or #ifdefs, but one place where I
think they are OK is in a logging library interface, partially because
they make it much lighter, and partially because automatically logging
__FILE__, __LINE__, etc. is desirable IMO.
Finally, I think that all the machinery a typical logging lib uses to
kill logging expressions when they're not needed is an overkill. I've
found that using something as simple as the code below works just
static bool const warnings=false;
static bool const errors=true;
if( logging::warnings )
log << "Warning";
where log simply implements std::ostream.
You could put the if in a macro but frankly, I personally don't mind
typing it every time; compared to the rest of the junk I have to type
to format a meaningful logging message, the if is not an issue. As a
bonus, you don't have to worry about functions referenced by a logging
expression being executed when logging is not enabled.
-- Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk