我boost::log
在这个函数中使用:
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/utility/setup/file.hpp>
void InitLog() {
logging::core::get()->set_filter(logging::trivial::severity >= logging::trivial::debug);
logging::add_file_log(
keywords::file_name = AppHolder::Instance().config().log_folder + "/sign_%Y-%m-%d_%H-%M-%S.%N.log",
keywords::rotation_size = 10 * 1024 * 1024,
keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0),
keywords::format = "%TimeStamp% (%LineID%) <%Severity%>: %Message%"
);
}
然后,给定电话:
BOOST_LOG_TRIVIAL(info) << "thread id: " << this_thread::get_id() << " Initialization succeeded";
输出与预期不符:时间戳、行 ID和严重性为空。
() <>: thread id: 7f58e30e8740 初始化成功