diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a7a27af..b4ca5b76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +- [v2.8.1](#v281) - [v2.8.0](#v280) - [v2.7.0](#v270) - [v2.6.0](#v260) @@ -40,6 +41,12 @@ - [v1.1.0](#v110) - [v1.0.0](#v100) +## v2.8.1 + +**Fixes** + +- Fixed a bug in TimeRotatingFileHandler ([#287](https://github.com/odygrd/quill/pull/287)) + ## v2.8.0 **Breaking Changes** diff --git a/quill/include/quill/Quill.h b/quill/include/quill/Quill.h index 28eb505a..742a401b 100644 --- a/quill/include/quill/Quill.h +++ b/quill/include/quill/Quill.h @@ -31,7 +31,7 @@ namespace quill /** Version Info **/ constexpr uint32_t VersionMajor{2}; constexpr uint32_t VersionMinor{8}; -constexpr uint32_t VersionPatch{0}; +constexpr uint32_t VersionPatch{1}; constexpr uint32_t Version{VersionMajor * 10000 + VersionMinor * 100 + VersionPatch}; /** forward declarations **/ diff --git a/quill/src/Quill.cpp b/quill/src/Quill.cpp index d4d32944..a3ded8cb 100644 --- a/quill/src/Quill.cpp +++ b/quill/src/Quill.cpp @@ -69,7 +69,8 @@ std::shared_ptr file_handler(fs::path const& filename, std::string cons std::shared_ptr time_rotating_file_handler( fs::path const& base_filename, std::string const& mode /* = std::string{"a"} */, FilenameAppend append_to_filename /* = FilenameAppend::None */, - std::string const& when /* = std::string{"H"} */, uint32_t interval /* = 1 */, uint32_t backup_count /* = 0 */, + std::string const& when /* = std::string{"H"} */, uint32_t interval /* = 1 */, + uint32_t backup_count /* = std::numeric_limits::max() */, Timezone timezone /* = Timezone::LocalTime */, std::string const& at_time /* = std::string{} */, FileEventNotifier file_event_notifier /* = FileEventNotifier{} */, bool do_fsync /* = false */) { @@ -82,7 +83,8 @@ std::shared_ptr time_rotating_file_handler( std::shared_ptr rotating_file_handler( fs::path const& base_filename, std::string const& mode /* = std::string {"a"} */, FilenameAppend append_to_filename /* = FilenameAppend::None */, size_t max_bytes /* = 0 */, - uint32_t backup_count /* = 0 */, bool overwrite_oldest_files /* = true */, bool clean_old_files /* = false */, + uint32_t backup_count /* = std::numeric_limits::max() */, + bool overwrite_oldest_files /* = true */, bool clean_old_files /* = false */, FileEventNotifier file_event_notifier /* = FileEventNotifier{} */, bool do_fsync /* = false */) { return create_handler(base_filename.string(), mode, append_to_filename, diff --git a/quill/src/handlers/TimeRotatingFileHandler.cpp b/quill/src/handlers/TimeRotatingFileHandler.cpp index 4ec5601d..c5b67c6d 100644 --- a/quill/src/handlers/TimeRotatingFileHandler.cpp +++ b/quill/src/handlers/TimeRotatingFileHandler.cpp @@ -75,6 +75,7 @@ TimeRotatingFileHandler::TimeRotatingFileHandler(fs::path const& base_filename, _calculate_initial_rotation_tp(_file_creation_time, _when, timezone, at_time_hours, at_time_minutes); // Open file for logging + _created_files.emplace_front(0, _filename); open_file(_filename, mode); } @@ -100,7 +101,7 @@ void TimeRotatingFileHandler::write(fmt_buffer_t const& formatted_log_message, q detail::rename_file(previous_file, new_file); // Also store the file name in a queue to remove_file it later if we exceed backup count - _created_files.push_front(std::make_pair(0, new_file)); + _created_files.emplace_front(0, new_file); } else if ((_append_to_filename == FilenameAppend::Date) || (_append_to_filename == FilenameAppend::DateTime)) { @@ -125,7 +126,7 @@ void TimeRotatingFileHandler::write(fmt_buffer_t const& formatted_log_message, q quill::detail::rename_file(previous_file, new_file); } - _created_files.push_front(std::make_pair(0, _filename)); + _created_files.emplace_front(0, _filename); } // If we have too many files in the queue remove_file the oldest one