Commit 5afce169 authored by Gabi Melman's avatar Gabi Melman

Merge pull request #117 from rpopescu/master

fixed issue 115 Nanosecond resolution timestamps
parents 5fc6002f b3050aa8
......@@ -265,6 +265,17 @@ class f_formatter :public flag_formatter
}
};
// nanoseconds
class F_formatter :public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
auto duration = msg.time.time_since_epoch();
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count() % 1000000000;
msg.formatted << fmt::pad(static_cast<int>(ns), 9, '0');
}
};
// AM/PM
class p_formatter :public flag_formatter
{
......@@ -575,6 +586,9 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
case('f') :
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::f_formatter()));
break;
case('F') :
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::F_formatter()));
break;
case('p') :
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::p_formatter()));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment