[custom clock] support custom clocks compatible with chrono interface

pull/886/head
Joe McAtee 7 years ago
parent 240a58fd6e
commit cd005dff8e

@ -51,7 +51,7 @@ namespace sinks {
class sink; class sink;
} }
using log_clock = std::chrono::system_clock; using log_clock = spd_clock_t;
using sink_ptr = std::shared_ptr<sinks::sink>; using sink_ptr = std::shared_ptr<sinks::sink>;
using sinks_init_list = std::initializer_list<sink_ptr>; using sinks_init_list = std::initializer_list<sink_ptr>;
using log_err_handler = std::function<void(const std::string &err_msg)>; using log_err_handler = std::function<void(const std::string &err_msg)>;

@ -128,3 +128,27 @@
// //
// #define SPDLOG_DISABLE_DEFAULT_LOGGER // #define SPDLOG_DISABLE_DEFAULT_LOGGER
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Install spd_clock_t compatible with chrono clock to be used by spdlog
//
// // example of custom clock that has std::chrono compatible interface
// struct custom_clock
// {
// typedef chrono::nanoseconds duration;
// typedef duration::rep rep;
// typedef duration::period period;
// typedef chrono::time_point<system_clock, duration> time_point;
//
// /// set true if clock increases at uniform rate
// static constexpr bool is_steady = false;
//
// /// \return time_point representing now in nanosecond precision
// /// as specified in duration typedef
// static time_point now() noexcept;
//
// static std::time_t to_time_t(const time_point& __t) noexcept;
// };
#include <chrono>
using spd_clock_t = std::chrono::system_clock;
///////////////////////////////////////////////////////////////////////////////

Loading…
Cancel
Save