From 464013d95885dce996e0f29c416bc115ca3f5ef4 Mon Sep 17 00:00:00 2001 From: mmanoj Date: Sun, 7 May 2023 12:48:31 +0530 Subject: [PATCH] Add files via upload Change the logger name to reflect the minutes interval based rotation and remove the check for max min 59 in configuration. --- include/spdlog/sinks/minute_file_sink.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/include/spdlog/sinks/minute_file_sink.h b/include/spdlog/sinks/minute_file_sink.h index 24875447..539874b4 100644 --- a/include/spdlog/sinks/minute_file_sink.h +++ b/include/spdlog/sinks/minute_file_sink.h @@ -46,11 +46,11 @@ struct minute_filename_calculator * If max_files > 0, retain only the last max_files and delete previous. */ template -class minute_file_sink final : public base_sink +class minute_interval_file_sink final : public base_sink { public: // create every minute file sink which rotates on given time - minute_file_sink( + minute_interval_file_sink( filename_t base_filename, bool truncate = false, uint16_t max_files = 0, int rotation_minute = 0, const file_event_handlers &event_handlers = {}) : base_filename_(std::move(base_filename)) @@ -61,10 +61,7 @@ public: , filenames_q_() { - if (rotation_minute < 0 || rotation_minute > 59) - { - throw_spdlog_ex("daily_file_sink: Invalid rotation time in ctor"); - } + auto now = log_clock::now(); auto filename = FileNameCalc::calc_filename(base_filename_, now_tm(now)); @@ -193,8 +190,8 @@ private: bool remove_init_file_; }; -using minute_file_sink_mt = minute_file_sink; -using minute_file_sink_st = minute_file_sink; +using minute_interval_file_sink_mt = minute_interval_file_sink; +using minute_interval_file_sink_st = minute_interval_file_sink; } // namespace sinks @@ -202,16 +199,16 @@ using minute_file_sink_st = minute_file_sink; // factory functions // template -inline std::shared_ptr minute_logger_mt(const std::string &logger_name, const filename_t &filename, bool truncate = false, +inline std::shared_ptr minute_interval_logger_mt(const std::string &logger_name, const filename_t &filename, bool truncate = false, uint16_t max_files = 0, int minute = 0, const file_event_handlers &event_handlers = {}) { - return Factory::template create(logger_name, filename, truncate, max_files, minute ,event_handlers); + return Factory::template create(logger_name, filename, truncate, max_files, minute ,event_handlers); } template -inline std::shared_ptr minute_logger_st(const std::string &logger_name, const filename_t &filename, bool truncate = false, +inline std::shared_ptr minute_interval_logger_st(const std::string &logger_name, const filename_t &filename, bool truncate = false, uint16_t max_files = 0,int minute = 0, const file_event_handlers &event_handlers = {}) { - return Factory::template create(logger_name, filename, truncate, max_files, minute, event_handlers); + return Factory::template create(logger_name, filename, truncate, max_files, minute, event_handlers); } } // namespace spdlog