Here level.get() always returns "info". All my logs are done with the BOOST_LOG_TRIVIAL(...) macro. The formatter whereas displays correctly the severity level. Here is how it is defined:Hi all,I am trying to extract severity level from a log record, but i seems that I am doing it the wrong way. Here is the code I use:
void LogDockWidget::receiveLog(boost::log::record_view const& rec, const std::string& log)
{
logging::value_ref< logging::trivial::severity_level > level = logging::extract< logging::trivial::severity_level >("Severity", rec);
// ...
}
void LogDockWidget::init_logging()
{
boost::shared_ptr< logging::core > core = logging::core::get();
typedef sinks::synchronous_sink< QTextEditFormattedSinkBackend > sink_t;
boost::shared_ptr< sink_t > sink(new sink_t);
// ...
logging::add_file_log( keywords::file_name = logFilename,
keywords::auto_flush = true,
keywords::format = ( BUILD_LOG_FORMATTER() )
);
sink->set_formatter( BUILD_LOG_FORMATTER() );
core->add_sink(sink);
// Add attributes that we will use
logging::add_common_attributes();
core->add_global_attribute( "ThreadID", attrs::current_thread_id());
}
#define BUILD_LOG_FORMATTER() \
expr::stream \
<< "[" << expr::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S") << "] " \
<< expr::attr<unsigned int>("LineID") << " " \
<< ": <" << logging::trivial::severity << "> " \
<< " [" << expr::attr<attrs::current_thread_id::value_type>("ThreadID") << "] " \
<< expr::if_(expr::has_attr(scope_attribute)) \
[ \
expr::stream << "[" << scope_attribute << "] " \
] \
<< expr::message
Could you please let me know what I am doing wrong?Regards,Olivier