|
Boost : |
Subject: Re: [boost] [log] Review-ready version in the Vault
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2009-02-10 11:55:13
vicente.botet wrote:
> ----- Original Message -----
> From: "Vladimir Batov" <batov_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Tuesday, February 10, 2009 9:25 AM
> Subject: Re: [boost] [log] Review-ready version in the Vault
>
>
>>> ... You can either create a logger and use it as an independent object, or
>>> you can declare a global logger and use it everywhere you need it. The
>>> first approach is good to store loggers as class members. The second is
>>> convenient if you tend to use functional code or don't need any
>>> context-specific attributes in it. It can be done like this:
>>>
>>> BOOST_LOG_DECLARE_GLOBAL_LOGGER(my_logger, src::severity_logger_mt< >)
>>>
>>> void foo()
>>> {
>>> src::severity_logger_mt< >& lg = my_logger::get();
>>> // go ahead logging
>>> }
>> Hmm, I honestly think that having "loggers as class members" is a bad idea.
>> I do not usually like global objects either (static initialization issues,
>> too much visibility). However, what I definitely use a lot is retrieving the
>> same log by name in different compilation modules (that takes the visibility
>> down). Like
>>
>> boost::log log1(name);
>> boost::log log2(name); // The same as log1
>
> Hi,
>
> I'm curious ti know how do you retrieve the same log by name without static initialization?
This is what my example does, if I understand you correctly. The logger
is initialized only when first requested.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk