mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 16:35:45 +08:00
fixed issue 115 Nanosecond resolution timestamps
This commit is contained in:
parent
5fc6002fc2
commit
b3050aa8a9
@ -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
|
// AM/PM
|
||||||
class p_formatter :public flag_formatter
|
class p_formatter :public flag_formatter
|
||||||
{
|
{
|
||||||
@ -575,6 +586,9 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
|
|||||||
case('f') :
|
case('f') :
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::f_formatter()));
|
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::f_formatter()));
|
||||||
break;
|
break;
|
||||||
|
case('F') :
|
||||||
|
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::F_formatter()));
|
||||||
|
break;
|
||||||
|
|
||||||
case('p') :
|
case('p') :
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::p_formatter()));
|
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::p_formatter()));
|
||||||
|
Loading…
Reference in New Issue
Block a user