Boost logo

Boost :

Subject: Re: [boost] [log] Review-ready version in the Vault
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2009-02-11 16:01:48


Christopher Jefferson wrote:
>
> On 11 Feb 2009, at 19:28, Andrey Semashev wrote:
>
>> vicente.botet wrote:
>>>> I have some innocent questions: * Is logging thread-safe? * If yes,
>>>> are the lines interleaved as it is the case for output streams? * If
>>>> not could you point out how and where in the implementation this is
>>>> handled?
>>> Hi again,
>>> well i have found some anwers to my questions on the document. I'll
>>> come back later on.
>>
>> I'm glad you did. :)
>>
>>> How a log record is recognized, i.e. I don't see std::endl neither
>>> std::flush are used in the examples. How many lines result in the
>>> following example if condifiton is true (2 or 3)
>>> src::logger_mt& lg = my_logger::get();
>>> if (lg.open_record()) {
>>> lg.strm() << "Hello ";
>>> lg.strm() << "world!";
>>> }
>>
>> That one is not valid in the current implementation. It should be
>> replaced with:
>>
>> if (lg.open_record())
>> lg.strm() << "Hello ";
>> if (lg.open_record())
>> lg.strm() << "world!";
>
> What would happen if someone did write the above?

Officially - unspecified behavior. In current implementation, in case if
no records are open recursively, the library would open a new record itself.

> I really don't think this is an acceptable limitation. Don't you think
> people will often write to a stream more than once in the same function?

No, I think they won't. Most of the time BOOST_LOG & co. macros will be
used, and they hide this "if" internally:

   BOOST_LOG(lg) << "Hello";


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk