|
Boost : |
Subject: Re: [boost] [log] Comments
From: Christian Holmquist (c.holmquist_at_[hidden])
Date: 2010-03-15 16:40:07
On 15 March 2010 14:31, Vladimir Prus <ghost_at_[hidden]> wrote:
> On Monday 15 March 2010 22:50:59 Steven Watanabe wrote:
>
> > > // myproject.hpp
> > > #ifndef COMPONENT
> > > #define COMPONENT "unspecified"
> > > #endif
> > >
> > > #define DEBUG BOOST_LOG_XXX(mygloballogger, COMPONENT, debug)
> > >
> >
> > I guess that what I'd like is a way to specify arbitrary attributes when
> > logging, so BOOST_LOG_XXX would be defined like
> >
> > #define BOOST_LOG_XXX(lg, component, severity) BOOST_LOG_WITH_ATTRS(lg,
> > ("Severity", severity)("Channel", component))
>
> Yes, I think this would be nice.
>
> There's another thing about component/severity logging that I have
> apparently
> forgot about -- filtering. It is surely necessary to change filtered
> components
> dynamically -- either while the application is running, or between runs,
> therefore
> lambda expression that compares to a fixed string will not be enough -- we
> need
> a lookup in a map. It's not obvious to me how to form a lambda expression
> to do a lookup in a map using the library, e.g. something like:
>
> enabled_components.count(attr<string>("Component"))
>
>
This was part of my questions too (
http://comments.gmane.org/gmane.comp.lib.boost.devel/200785). I found it
quite difficult to setup the system so could enable/disable logs to
std::cout dynamically, based on component (although I called it System) and
severity.
That's why the lambda style filters didn't help me, since they were designed
for statically defining filters, while I need to be able to modify them at
runtime.
/ christian
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk