Subject: Re: [boost] [Log] Running in a separate thread
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2015-07-01 17:41:12
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
> 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 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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk