Boost logo

Boost :

Subject: Re: [boost] [log] Comments
From: Vladimir Prus (ghost_at_[hidden])
Date: 2010-03-15 15:33:39

On Monday 15 March 2010 22:07:57 Roland Bock wrote:

> Vladimir Prus wrote:
> > First, it seems to me that if two major projects use component/severity scheme,
> > then presumably it's of general utility. Second, in the thread you have
> > mentioned, you yourself provide example solution that are far from trivial.
> > Maybe I'm missing something? In essence, I would like to have:
> >
> > magic_logger lg;
> > DO_MAGIC(lg, "my_component", debug) << "hi there";
> >
> > Could you show what will it take?
> >
> We are using component/severity, too. I decided to interpret the channel
> as component. Some sample code is attached to my review:
> After some preparation in the init function, developers can do the
> following:
> src::severity_channel_logger<severity_level> lg1(keywords::channel = "FirstComponent");
> BOOST_LOG_SEV(lg1, trace) << "A trace severity message";
> BOOST_LOG_SEV(lg1, debug) << "A debug severity message";
> I plan to hide most of the first line in a typedef and a convenience
> function.

What I don't like about this solution is that it requires that you define a
new object for every componen, which can be inconvenient, including for
header-only libraries. What I would like to have is something like

        // myproject.hpp
        #ifndef COMPONENT
        #define COMPONENT "unspecified"

        #define DEBUG BOOST_LOG_XXX(mygloballogger, COMPONENT, debug)

- Volodya

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