mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-28 00:10:21 +08:00
add formatter for unix epoch time in seconds.
This commit is contained in:
parent
a4e6d8877c
commit
f7fabfb2c4
@ -262,6 +262,16 @@ class F_formatter SPDLOG_FINAL:public flag_formatter
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class E_formatter SPDLOG_FINAL:public flag_formatter
|
||||||
|
{
|
||||||
|
void format(details::log_msg& msg, const std::tm&) override
|
||||||
|
{
|
||||||
|
auto duration = msg.time.time_since_epoch();
|
||||||
|
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration).count();
|
||||||
|
msg.formatted << seconds;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// AM/PM
|
// AM/PM
|
||||||
class p_formatter SPDLOG_FINAL:public flag_formatter
|
class p_formatter SPDLOG_FINAL:public flag_formatter
|
||||||
{
|
{
|
||||||
@ -598,6 +608,10 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
|
|||||||
_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('E'):
|
||||||
|
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::E_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()));
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user