Boost.Log时间格式,以秒为单位

时间:2019-03-04 15:15:59

标签: c++ boost boost-log

我在项目中使用Boost.Log格式化程序。

问题是日期时间用6位小数秒打印。

示例:

2019-03-04 12:26:48.338046

我希望将小数秒限制为3位数字。

不幸的是,Boost.Loger似乎不支持本机方式,

如果我错了,请纠正我。

实际代码:

logging::formatter formatter = expr::stream
        << expr::format_date_time(timestamp, "%Y-%m-%d %H:%M:%S.%f") << " "
        << "[" << std::this_thread::get_id() " ]" << " "
        << expr::attr< severity_level, severity_tag >("Severity")
        << " "
        << expr::if_ (expr::has_attr< string >("Data"))
           [expr::stream << data]
        << " - "
        << expr::if_ (expr::has_attr< string >("Guid"))
           [expr::stream << guid]
        << " - " << expr::smessage;
sink->set_formatter(formatter);

0 个答案:

没有答案
相关问题