mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 10:01:33 +08:00
Merge pull request #117 from rpopescu/master
fixed issue 115 Nanosecond resolution timestamps
This commit is contained in:
commit
5afce16979
@ -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