$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [log] How to set/reset a channel-specific filter
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2010-03-16 13:42:28
On 03/16/2010 08:22 PM, Andreas Huber wrote:
> "Andrey Semashev" <andrey.semashev_at_[hidden]> wrote in message
> news:4B9FAFD5.50409_at_gmail.com...
>>> If we go with method a), we'd need a way to enumerate all global
>>> loggers.
>>
>> Not sure why would you need to enumerate loggers. You could simply
>> specify all the channels in the filter, if their number is not very big.
>
> Loggers are declared by thrird party code, so we have no idea about the
> number of loggers.
I see.
>> If it is, you can create your own function that accepts the channel
>> name and then decides if it is enabled. This function can then be
>> converted into a filter like this:
>>
>> bool is_channel_enabled(std::string const& chan_name);
>>
>>
>> sink->set_filter(
>> flt::attr< std::string >("Channel").satisfies(&is_channel_enabled)
>> );
>
> Ok, that will certainly work for us, but I'd consider this a (small)
> hack, because we'd have to duplicate information that is presumably
> already present in Boost.Log.
The loggers are not related to each other, so if some logger has a
channel attribute, the library (the core, filters, etc.) won't know that
until it starts emitting log records.
> More precisely, we want to provide a utility function where you pass in
> a logger and a severity and the function then modifies the global filter
> so that all records comming from the specified logger with a severity
> below the specified one will be discarded.
But if you can pass a logger to this function, why can't you pass the
channel name?
> Unless I'm missing something,
> this would require us keeping a global list of all loggers that have a
> filter applied, correct?
Unless you can work with channel names instead of loggers, yes.
> I assumed that somewhere Boost.Log keeps such a list anyway, so I'd
> rather use that one than build our own.
No, the library doesn't keep track of loggers.