Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to retrieve the logged message as a string from boost::log::record_view?

Tags:

boost-log

The documentation of record_view states that it encapsulates the log message string.

I'd like to retrieve it in the context of the consume function of a custom basic_string_backend subclass.

Is it possible, or do I have to derive from basic_formatted_sink_backend?

like image 561
Romain Deterre Avatar asked Jan 20 '14 19:01

Romain Deterre


1 Answers

You can get it like this:

void consume(boost::logger::record_view const& rec)
{
    std::string myString = *rec[boost::logger::expressions::smessage];
    // etc...
}

Include boost/logger/expressions.h to get boost::logger::expressions::smessage.

like image 195
Nathan Monteleone Avatar answered Sep 20 '22 11:09

Nathan Monteleone