From 7ffa0766b45209be73890bf3272bc8feb9798381 Mon Sep 17 00:00:00 2001 From: Shintaro Seki Date: Mon, 1 Jul 2019 15:57:48 +0900 Subject: [PATCH] Fix rotation condition when SPDLOG_NO_DATETIME is defined. When SPDLOG_NO_DATETIME is defined, the rotation was never worked because `msg.time` is always zero. --- include/spdlog/sinks/daily_file_sink.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/spdlog/sinks/daily_file_sink.h b/include/spdlog/sinks/daily_file_sink.h index 687da043..91809e90 100644 --- a/include/spdlog/sinks/daily_file_sink.h +++ b/include/spdlog/sinks/daily_file_sink.h @@ -67,8 +67,11 @@ public: protected: void sink_it_(const details::log_msg &msg) override { - +#ifdef SPDLOG_NO_DATETIME + if (log_clock::now() >= rotation_tp_) +#else if (msg.time >= rotation_tp_) +#endif { file_helper_.open(FileNameCalc::calc_filename(base_filename_, now_tm(msg.time)), truncate_); rotation_tp_ = next_rotation_tp_();