Commit 267c9c68 authored by Gabi Melman's avatar Gabi Melman

Merge pull request #27 from Zor-X-L/add-microsec-formatter

add a %f formatter for microseconds
parents bf3997de ed4368a6
......@@ -245,6 +245,17 @@ class e_formatter :public flag_formatter
}
};
// microseconds
class f_formatter :public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
auto duration = msg.time.time_since_epoch();
auto micros = std::chrono::duration_cast<std::chrono::microseconds>(duration).count() % 1000000;
msg.formatted << fmt::pad(static_cast<int>(micros), 6, '0');
}
};
// AM/PM
class p_formatter :public flag_formatter
{
......@@ -537,6 +548,10 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::e_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()));
break;
......
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