[Log] Extract severity value

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); // ... } 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: 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
Could you please let me know what I am doing wrong? Regards, Olivier
participants (2)
-
Olaf Peter
-
Olivier Tournaire