相关疑难解决方法(0)

Boost Log 2.0:日志中的空严重级别

我正在使用Boost-Log 2.0,它与版本1存在一些差异,我很难输出"Severity"属性.

我正在使用"Boost.Format-style"格式化程序

"%TimeStamp% [%Uptime%] (%LineID%) <%Severity%>: %Message%"
Run Code Online (Sandbox Code Playgroud)

TimeStamp,LineIDMessagecommon_attributes.Uptime是我添加的属性attrs::timer().我认为Severity在使用时会自动添加severity_logger,但显然不是,这是我的问题.我得到空的严重性,例如:

2013-Apr-06 19:21:52.408974 [00:00:00.001337] (3) <>: A warning severity message
Run Code Online (Sandbox Code Playgroud)

注意空<>.我试图添加严重性,register_simple_formatter_factory但后来我得到编译器错误:

error: no matching function for call to ‘register_simple_formatter_factory(const char [9])’
Run Code Online (Sandbox Code Playgroud)

而且我不明白为什么.

这是我的代码:

#include <iostream>


#include <boost/log/common.hpp>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include <boost/log/sinks/sync_frontend.hpp>
#include <boost/log/sinks/text_ostream_backend.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/utility/setup/formatter_parser.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/severity_feature.hpp>
#include <boost/log/sources/record_ostream.hpp>

#include <boost/log/attributes.hpp> …
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-log

25
推荐指数
2
解决办法
1万
查看次数

标签 统计

boost ×1

boost-log ×1

c++ ×1