Expend support for any std::chrono::duration in spdlog::flush_every

This allows things like:

spdlog::flush_every(std::chrono::minutes(10));
spdlog::flush_every(std::chrono::milliseconds(100));
This commit is contained in:
Lucas CHOLLET
2022-07-17 18:36:11 +02:00
parent 6c95f4c816
commit dfe1009080
6 changed files with 33 additions and 37 deletions

View File

@@ -81,7 +81,11 @@ SPDLOG_API void flush_on(level::level_enum log_level);
// Start/Restart a periodic flusher thread
// Warning: Use only if all your loggers are thread safe!
SPDLOG_API void flush_every(std::chrono::seconds interval);
template<typename Rep, typename Period>
inline void flush_every(std::chrono::duration<Rep, Period> interval)
{
details::registry::instance().flush_every(interval);
}
// Set global error handler
SPDLOG_API void set_error_handler(void (*handler)(const std::string &msg));