From 8ee2a0a4297d712286fd1d8488cdbc0f8de29cae Mon Sep 17 00:00:00 2001 From: Shane Yao Date: Sat, 13 Oct 2018 18:34:50 +0800 Subject: [PATCH] Add a high time resolution tweak with default pattern --- include/spdlog/details/pattern_formatter.h | 5 +++++ include/spdlog/tweakme.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/include/spdlog/details/pattern_formatter.h b/include/spdlog/details/pattern_formatter.h index a35564be..afa75f16 100644 --- a/include/spdlog/details/pattern_formatter.h +++ b/include/spdlog/details/pattern_formatter.h @@ -498,8 +498,13 @@ class full_formatter final : public flag_formatter } fmt_helper::append_buf(cached_datetime_, dest); +#ifdef SPDLOG_HIGH_RES + auto micros = fmt_helper::time_fraction(msg.time); + fmt_helper::pad6(static_cast(micros.count()), dest); +#else auto millis = fmt_helper::time_fraction(msg.time); fmt_helper::pad3(static_cast(millis.count()), dest); +#endif dest.push_back(']'); dest.push_back(' '); diff --git a/include/spdlog/tweakme.h b/include/spdlog/tweakme.h index 2c260ec5..caa88814 100644 --- a/include/spdlog/tweakme.h +++ b/include/spdlog/tweakme.h @@ -61,6 +61,13 @@ // #define SPDLOG_NO_NAME /////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +// Uncomment to make default pattern replace milliseconds with microseconds on +// tail. +// +// #define SPDLOG_HIGH_RES +/////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////// // Uncomment to enable the SPDLOG_DEBUG/SPDLOG_TRACE macros. //