1
我正在使用自定義格式功能,並試圖弄清楚如何格式化範圍屬性。我找到的boost文檔中的示例是lambda表達式格式化程序,我不知道如何在我的格式化程序函數中使用它。現在我成功地使用了像timetamp這樣的屬性,但是scope屬性卻讓我感到不安。在自定義提升日誌格式函數中格式化範圍屬性
BOOST_LOG_ATTRIBUTE_KEYWORD(scope, "Scope", attributes::named_scope_list)
BOOST_LOG_ATTRIBUTE_KEYWORD(timestamp, "TimeStamp", boost::posix_time::ptime)
void formatter(boost::log::record_view const& record, boost::log::formatting_ostream& stream) {
stream << record[timestamp];
// stream << record[scope].file_name or something like that
}