A sink backend expecting a non-const parameter in its constructor can't be used, as the wrapping sink frontend seems to only forward const parameters.
Example:
class buffering_sink_backend :
public boost::log::sinks::basic_formatted_sink_backend <
char,
boost::log::sinks::synchronized_feeding
>
{
public:
buffering_sink_backend(std::string &buffer)
: _buffer(buffer)
{}
void consume(boost::log::record_view const &rec, string_type const &formattedMessage)
{
_buffer += formattedMessage;
}
private:
std::string &_buffer;
};
typedef boost::log::sinks::synchronous_sink< buffering_sink_backend > buffering_sink;
void main()
{
std::string buffer;
buffering_sink *bla = new buffering_sink(buffer); // --> compiler error: cannot convert argument 1 from 'const std::string' to 'std::string &'
}
Is there any way to provide a custom sink backend with non-const object references or am I doing something conceptually wrong?