using namespace boost;
template<typename Stream>
-void append_timestamp(Stream& stream)
+void append_timestamp(Stream& stream, boost::posix_time::ptime timestamp)
{
- auto timestamp = boost::posix_time::microsec_clock::local_time();
auto date = timestamp.date();
auto time = timestamp.time_of_day();
auto milliseconds = time.fractional_seconds() / 1000; // microseconds to milliseconds
namespace expr = boost::log::expressions;
std::wstringstream pre_message_stream;
- append_timestamp(pre_message_stream);
+ append_timestamp(pre_message_stream, boost::log::extract<boost::posix_time::ptime>("TimestampMillis", rec).get());
thread_id_column.write(pre_message_stream, boost::log::extract<std::int64_t>("NativeThreadId", rec));
severity_column.write(pre_message_stream, boost::log::extract<boost::log::trivial::severity_level>("Severity", rec));
{
boost::log::add_common_attributes();
boost::log::core::get()->add_global_attribute("NativeThreadId", boost::log::attributes::make_function(&get_current_thread_id));
+ boost::log::core::get()->add_global_attribute("TimestampMillis", boost::log::attributes::make_function([]
+ {
+ return boost::posix_time::microsec_clock::local_time();
+ }));
typedef boost::log::sinks::asynchronous_sink<boost::log::sinks::wtext_ostream_backend> stream_sink_type;
auto stream_backend = boost::make_shared<boost::log::sinks::wtext_ostream_backend>();