Boost logo

Boost :

Subject: Re: [boost] [Log] Running in a separate thread
From: Klaim - Joël Lamotte (mjklaim_at_[hidden])
Date: 2015-07-01 18:06:30


On 1 July 2015 at 23:41, Andrey Semashev <andrey.semashev_at_[hidden]> wrote:

> On 02.07.2015 00:16, Andrew Hundt wrote:
>
>> I really only need some of the functionality of BOOST_LOG_TRIVIAL, perhaps
>> plus loving to a file in addition to the console. However, my only true
>> need is that all the work (or as much as possible) must be done in a
>> separate thread so as not to slow the current thread down. Right now when
>> I
>> use BOOST_LOG_TRIVIAL as is it causes latency in my network communications
>> which have soft realtime requirements so I've had to comment all of my
>> logs
>> out.
>>
>> Is there a straightforward non-intrusive solution to having as much of the
>> work as possible for boost.log be done in a separate thread?
>>
>
> Boost.Log does support asynchronous logging[1] although the current
> implementation might not suit well for realtime use either. It does have a
> lock in the internal record queue which is used to pass log records from
> the application threads to the log processing thread, although the critical
> section is minimal.
>
> In order to enable async logging you have to configure the library by
> adding asynchronous sinks and probably some attributes on your application
> startup. You can keep using BOOST_LOG_TRIVIAL for emitting log records, the
> only change needed is the initial configuration.
>
> [1]
> http://www.boost.org/doc/libs/1_58_0/libs/log/doc/html/log/detailed/sink_frontends.html#log.detailed.sink_frontends.async
>
>
>
Just an additional suggestion for Andrew, if I understood correctly:
depending on the context of the application, you might also want to just log
on sockets, as suggested in the answer there:
http://gamedev.stackexchange.com/questions/8691/logging-library-for-c-games
I don't know if boost.log already have a sink like that but it might not be
difficult to setup if you use boost.asio for example.

>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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