Boost 1.54 Log を使用しており、次の方法でログを初期化しています。
namespace logging = boost::log;
namespace src = boost::log::sources;
namespace expr = boost::log::expressions;
namespace sinks = boost::log::sinks;
namespace attrs = boost::log::attributes;
namespace keywords = boost::log::keywords;
BOOST_LOG_ATTRIBUTE_KEYWORD(line_id, "LineID", unsigned int)
BOOST_LOG_ATTRIBUTE_KEYWORD(severity, "Severity", severity_level)
BOOST_LOG_ATTRIBUTE_KEYWORD(tag_attr, "Tag", std::string)
BOOST_LOG_ATTRIBUTE_KEYWORD(timestamp, "TimeStamp", boost::posix_time::ptime)
logging::add_common_attributes();
boost::shared_ptr<logging::core> core = logging::core::get();
// setup console log
logging::add_console_log (
std::clog,
keywords::filter = severity >= debug,
keywords::format = (
expr::stream << expr::format_date_time(timestamp, "%Y-%m-%d %H:%M:%S") <<
line_id << " [" << severity << "] " << expr::smessage
)
);
これは、生成された出力のサンプルです。
2013-09-13 10:17:471 [warn] You are running in debug mode - assertions are enabled.
2013-09-13 10:17:472 [info] loading data completed
2013-09-13 10:17:473 [debug] applying xxx completed
2013-09-13 10:17:474 [debug] computing xxx completed
2013-09-13 10:17:475 [debug] xxx completed
2013-09-13 10:17:476 [info] xxx completed
2013-09-13 10:17:477 [debug] xxx completed
2013-09-13 10:17:478 [debug] computing xxx completed
2013-09-13 10:17:479 [info] testing xxx completed
2013-09-13 10:17:4710 [info] xxx
2013-09-13 10:17:4711 [debug] xxx completed
タイムスタンプの出力秒は完全に正しくありませんが、Boost Log のドキュメントによると%S
、秒の正しいフォーマット設定です。これはバグでしょうか?