From 4ab99d4f57c251b2f39387ffc08a73a7e851835b Mon Sep 17 00:00:00 2001 From: Odysseas Georgoudis Date: Fri, 25 Nov 2022 12:11:59 +0000 Subject: [PATCH] backend logging thread improvements (#207) backend logging thread performance improvements --- CHANGELOG.md | 7 +++ examples/example_custom_handler.cpp | 2 +- examples/example_filters.cpp | 4 +- examples/example_multiple_handlers.cpp | 2 +- quill/include/quill/PatternFormatter.h | 6 +-- quill/include/quill/Quill.h | 4 +- quill/include/quill/TransitEvent.h | 48 ++----------------- quill/include/quill/bundled/fmt/format.h | 2 +- quill/include/quill/detail/Serialize.h | 4 +- .../quill/detail/backend/BackendWorker.h | 8 ++-- quill/include/quill/detail/misc/Common.h | 2 + quill/include/quill/filters/FilterBase.h | 2 +- quill/include/quill/handlers/ConsoleHandler.h | 2 +- quill/include/quill/handlers/Handler.h | 4 +- .../include/quill/handlers/JsonFileHandler.h | 4 +- .../quill/handlers/RotatingFileHandler.h | 2 +- quill/include/quill/handlers/StreamHandler.h | 2 +- .../quill/handlers/TimeRotatingFileHandler.h | 8 ++-- quill/src/PatternFormatter.cpp | 2 +- quill/src/detail/backend/BacktraceStorage.cpp | 2 +- quill/src/handlers/ConsoleHandler.cpp | 2 +- quill/src/handlers/Handler.cpp | 2 +- quill/src/handlers/JsonFileHandler.cpp | 2 +- quill/src/handlers/RotatingFileHandler.cpp | 2 +- quill/src/handlers/StreamHandler.cpp | 2 +- .../src/handlers/TimeRotatingFileHandler.cpp | 3 +- quill/test/LogTest.cpp | 4 +- quill/test/PatternFormatterTest.cpp | 20 ++++---- 28 files changed, 62 insertions(+), 92 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a009976a..7b69ec6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +- [v2.5.0](#v2.5.0) - [v2.4.2](#v2.4.2) - [v2.4.1](#v2.4.1) - [v2.4.0](#v2.4.0) @@ -35,6 +36,12 @@ - [v1.1.0](#v1.1.0) - [v1.0.0](#v1.0.0) +## v2.5.0 + +**Improvements** + +- Performance improvements for the backend logging thread + ## v2.4.2 **Fixes** diff --git a/examples/example_custom_handler.cpp b/examples/example_custom_handler.cpp index b9043e7b..2b627fce 100644 --- a/examples/example_custom_handler.cpp +++ b/examples/example_custom_handler.cpp @@ -15,7 +15,7 @@ class CustomHandler : public quill::Handler * @param formatted_log_message input message to write * @param log_message_timestamp log timestamp */ - void write(fmt::memory_buffer const& formatted_log_message, quill::TransitEvent const& log_event) override + void write(quill::fmt_buffer_t const& formatted_log_message, quill::TransitEvent const& log_event) override { // write a formatted log std::string log{formatted_log_message.data(), formatted_log_message.size()}; diff --git a/examples/example_filters.cpp b/examples/example_filters.cpp index 78c8f340..43aa1da3 100644 --- a/examples/example_filters.cpp +++ b/examples/example_filters.cpp @@ -16,7 +16,7 @@ class FileFilter : public quill::FilterBase QUILL_NODISCARD bool filter(char const* thread_id, std::chrono::nanoseconds log_message_timestamp, quill::MacroMetadata const& metadata, - fmt::memory_buffer const& formatted_record) noexcept override + quill::fmt_buffer_t const& formatted_record) noexcept override { // log only messages that are INFO or above in the file return metadata.level() < quill::LogLevel::Warning; @@ -33,7 +33,7 @@ class StdoutFilter : public quill::FilterBase QUILL_NODISCARD bool filter(char const* thread_id, std::chrono::nanoseconds log_message_timestamp, quill::MacroMetadata const& metadata, - fmt::memory_buffer const& formatted_record) noexcept override + quill::fmt_buffer_t const& formatted_record) noexcept override { // log only WARNINGS or higher to stdout return metadata.level() >= quill::LogLevel::Warning; diff --git a/examples/example_multiple_handlers.cpp b/examples/example_multiple_handlers.cpp index 6c207de1..edb2ebd9 100644 --- a/examples/example_multiple_handlers.cpp +++ b/examples/example_multiple_handlers.cpp @@ -12,7 +12,7 @@ class VectorHandler final : public quill::Handler VectorHandler() = default; /***/ - void write(fmt::memory_buffer const& formatted_log_message, quill::TransitEvent const& log_event) override + void write(quill::fmt_buffer_t const& formatted_log_message, quill::TransitEvent const& log_event) override { // Called by the logger backend worker thread for each LOG_* macro // formatted_log_message.size() - 1 to exclude '/n' diff --git a/quill/include/quill/PatternFormatter.h b/quill/include/quill/PatternFormatter.h index f0dc293e..5598bba8 100644 --- a/quill/include/quill/PatternFormatter.h +++ b/quill/include/quill/PatternFormatter.h @@ -98,7 +98,7 @@ class PatternFormatter QUILL_ATTRIBUTE_HOT void format(std::chrono::nanoseconds timestamp, std::string_view thread_id, std::string_view thread_name, std::string_view process_id, std::string_view logger_name, MacroMetadata const& macro_metadata, - fmt::memory_buffer const& log_msg); + fmt_buffer_t const& log_msg); QUILL_ATTRIBUTE_HOT std::string_view format_timestamp(std::chrono::nanoseconds timestamp); @@ -106,7 +106,7 @@ class PatternFormatter * Returns the stored formatted record, to be called after format(...) is called * @return Returns the stored formatted record */ - QUILL_NODISCARD QUILL_ATTRIBUTE_HOT fmt::memory_buffer const& formatted_log_message() const noexcept + QUILL_NODISCARD QUILL_ATTRIBUTE_HOT fmt_buffer_t const& formatted_log_message() const noexcept { return _formatted_log_message; } @@ -163,6 +163,6 @@ class PatternFormatter /** The buffer where we store each formatted string, also stored as class member to avoid * re-allocations. This is mutable so we can have a format() const function **/ - fmt::memory_buffer _formatted_log_message; + fmt_buffer_t _formatted_log_message; }; } // namespace quill diff --git a/quill/include/quill/Quill.h b/quill/include/quill/Quill.h index 9bc533a7..66f6cad9 100644 --- a/quill/include/quill/Quill.h +++ b/quill/include/quill/Quill.h @@ -28,8 +28,8 @@ namespace quill /** Version Info **/ constexpr uint32_t VersionMajor{2}; -constexpr uint32_t VersionMinor{4}; -constexpr uint32_t VersionPatch{2}; +constexpr uint32_t VersionMinor{5}; +constexpr uint32_t VersionPatch{0}; constexpr uint32_t Version{VersionMajor * 10000 + VersionMinor * 100 + VersionPatch}; /** forward declarations **/ diff --git a/quill/include/quill/TransitEvent.h b/quill/include/quill/TransitEvent.h index ad520127..df366a66 100644 --- a/quill/include/quill/TransitEvent.h +++ b/quill/include/quill/TransitEvent.h @@ -7,7 +7,6 @@ #include "quill/Fmt.h" #include "quill/detail/Serialize.h" -#include "quill/detail/ThreadContext.h" namespace quill { @@ -17,45 +16,8 @@ struct TransitEvent TransitEvent() = default; ~TransitEvent() = default; - TransitEvent(detail::ThreadContext* thread_context, detail::Header header, - fmt::memory_buffer formatted_msg, std::atomic* flush_flag) - : thread_id(thread_context->thread_id()), - thread_name(thread_context->thread_name()), - header(header), - formatted_msg(std::move(formatted_msg)), - flush_flag(flush_flag) - { - } - - TransitEvent(TransitEvent const& other) - : structured_keys(other.structured_keys), - structured_values(other.structured_values), - thread_id(other.thread_id), - thread_name(other.thread_name), - header(other.header), - flush_flag(other.flush_flag) - - { - formatted_msg.clear(); - formatted_msg.append(other.formatted_msg.begin(), other.formatted_msg.end()); - } - - TransitEvent& operator=(TransitEvent const& other) - { - if (this != &other) - { - structured_keys = other.structured_keys; - structured_values = other.structured_values; - thread_id = other.thread_id; - thread_name = other.thread_name; - header = other.header; - formatted_msg.clear(); - formatted_msg.append(other.formatted_msg.begin(), other.formatted_msg.end()); - flush_flag = other.flush_flag; - } - - return *this; - } + TransitEvent(TransitEvent const& other) = delete; + TransitEvent& operator=(TransitEvent const& other) = delete; TransitEvent(TransitEvent&& other) noexcept : structured_keys(std::move(other.structured_keys)), @@ -93,16 +55,16 @@ struct TransitEvent std::string thread_id; std::string thread_name; detail::Header header; - fmt::memory_buffer formatted_msg; /** buffer for message **/ + fmt_buffer_t formatted_msg; /** buffer for message **/ std::atomic* flush_flag{nullptr}; /** This is only used in the case of Event::Flush **/ }; class TransitEventComparator { public: - bool operator()(TransitEvent const* lhs, TransitEvent const* rhs) + bool operator()(std::pair const& lhs, std::pair const& rhs) { - return lhs->header.timestamp > rhs->header.timestamp; + return lhs.first > rhs.first; } }; } // namespace quill \ No newline at end of file diff --git a/quill/include/quill/bundled/fmt/format.h b/quill/include/quill/bundled/fmt/format.h index 7c607dbd..5b269fae 100644 --- a/quill/include/quill/bundled/fmt/format.h +++ b/quill/include/quill/bundled/fmt/format.h @@ -802,7 +802,7 @@ enum { inline_buffer_size = 500 }; **Example**:: - auto out = fmt::memory_buffer(); + auto out = fmt_buffer_t(); format_to(std::back_inserter(out), "The answer is {}.", 42); This will append the following output to the ``out`` object: diff --git a/quill/include/quill/detail/Serialize.h b/quill/include/quill/detail/Serialize.h index 305d0297..a20474e4 100644 --- a/quill/include/quill/detail/Serialize.h +++ b/quill/include/quill/detail/Serialize.h @@ -289,12 +289,12 @@ QUILL_NODISCARD QUILL_ATTRIBUTE_HOT constexpr std::byte* encode_args(size_t* c_s /** * Format function */ -using FormatToFn = std::byte* (*)(std::string_view format, std::byte* data, fmt::memory_buffer& out, +using FormatToFn = std::byte* (*)(std::string_view format, std::byte* data, fmt_buffer_t& out, std::vector>& args); template QUILL_NODISCARD QUILL_ATTRIBUTE_HOT std::byte* format_to(std::string_view format, std::byte* data, - fmt::memory_buffer& out, + fmt_buffer_t& out, std::vector>& args) { constexpr size_t num_dtors = fmt::detail::count()...>(); diff --git a/quill/include/quill/detail/backend/BackendWorker.h b/quill/include/quill/detail/backend/BackendWorker.h index 76abd83c..4a1ebafb 100644 --- a/quill/include/quill/detail/backend/BackendWorker.h +++ b/quill/include/quill/detail/backend/BackendWorker.h @@ -156,7 +156,7 @@ class BackendWorker std::chrono::nanoseconds _backend_thread_sleep_duration; /** backend_thread_sleep_duration from config **/ size_t _max_transit_events; /** limit of transit events before start flushing, value from config */ - std::priority_queue, TransitEventComparator> _transit_events; + std::priority_queue, std::vector>, TransitEventComparator> _transit_events; std::vector> _args; /** Format args tmp storage as member to avoid reallocation */ @@ -471,7 +471,7 @@ bool BackendWorker::_read_queue_messages_and_decode(ThreadContext* thread_contex queue.finish_read(read_size); bytes_available -= read_size; - _transit_events.emplace(transit_event); + _transit_events.emplace(std::make_pair(transit_event->header.timestamp, transit_event)); } // read everything @@ -481,7 +481,7 @@ bool BackendWorker::_read_queue_messages_and_decode(ThreadContext* thread_contex /***/ void BackendWorker::_process_transit_event() { - TransitEvent const* transit_event = _transit_events.top(); + TransitEvent* transit_event = _transit_events.top().second; // If backend_process(...) throws we want to skip this event and move to the next so we catch the // error here instead of catching it in the parent try/catch block of main_loop @@ -509,7 +509,7 @@ void BackendWorker::_process_transit_event() else { // this is a backtrace log and we will store it - _backtrace_log_message_storage.store(*transit_event); + _backtrace_log_message_storage.store(std::move(*transit_event)); } } else if (transit_event->header.metadata->macro_metadata.event() == MacroMetadata::Event::InitBacktrace) diff --git a/quill/include/quill/detail/misc/Common.h b/quill/include/quill/detail/misc/Common.h index 31f488b9..e06350d8 100644 --- a/quill/include/quill/detail/misc/Common.h +++ b/quill/include/quill/detail/misc/Common.h @@ -146,6 +146,8 @@ constexpr bool detect_structured_log_template(std::wstring_view) } } // namespace detail +using fmt_buffer_t = fmt::basic_memory_buffer; + /** * Enum to select a timezone */ diff --git a/quill/include/quill/filters/FilterBase.h b/quill/include/quill/filters/FilterBase.h index f68083ef..c9ef7d7e 100644 --- a/quill/include/quill/filters/FilterBase.h +++ b/quill/include/quill/filters/FilterBase.h @@ -39,7 +39,7 @@ class FilterBase */ QUILL_NODISCARD virtual bool filter(char const* thread_id, std::chrono::nanoseconds log_message_timestamp, MacroMetadata const& metadata, - fmt::memory_buffer const& formatted_record) noexcept = 0; + fmt_buffer_t const& formatted_record) noexcept = 0; /** * Gets the name of the filter. Only useful if an existing filter is needed to be looked up diff --git a/quill/include/quill/handlers/ConsoleHandler.h b/quill/include/quill/handlers/ConsoleHandler.h index f27e38c2..7ce22f3c 100644 --- a/quill/include/quill/handlers/ConsoleHandler.h +++ b/quill/include/quill/handlers/ConsoleHandler.h @@ -196,7 +196,7 @@ class ConsoleHandler : public StreamHandler * @param formatted_log_message input log message to write * @param transit_Event transit_Event */ - QUILL_ATTRIBUTE_HOT void write(fmt::memory_buffer const& formatted_log_message, + QUILL_ATTRIBUTE_HOT void write(fmt_buffer_t const& formatted_log_message, TransitEvent const& transit_Event) override; /** diff --git a/quill/include/quill/handlers/Handler.h b/quill/include/quill/handlers/Handler.h index 8ce4d0ad..b19cbb12 100644 --- a/quill/include/quill/handlers/Handler.h +++ b/quill/include/quill/handlers/Handler.h @@ -73,7 +73,7 @@ class Handler * @param formatted_log_message input log message to write * @param log_event transit event */ - QUILL_ATTRIBUTE_HOT virtual void write(fmt::memory_buffer const& formatted_log_message, + QUILL_ATTRIBUTE_HOT virtual void write(fmt_buffer_t const& formatted_log_message, quill::TransitEvent const& log_event) = 0; /** @@ -114,7 +114,7 @@ class Handler * @return result of all filters */ QUILL_NODISCARD bool apply_filters(char const* thread_id, std::chrono::nanoseconds log_message_timestamp, - MacroMetadata const& metadata, fmt::memory_buffer const& formatted_record); + MacroMetadata const& metadata, fmt_buffer_t const& formatted_record); protected: /**< Owned formatter for this handler, we have to use a pointer here since the PatterFormatter diff --git a/quill/include/quill/handlers/JsonFileHandler.h b/quill/include/quill/handlers/JsonFileHandler.h index 7dc19d66..7ac99156 100644 --- a/quill/include/quill/handlers/JsonFileHandler.h +++ b/quill/include/quill/handlers/JsonFileHandler.h @@ -27,10 +27,10 @@ class JsonFileHandler : public FileHandler * @param formatted_log_message input log message to write * @param log_event log_event */ - QUILL_ATTRIBUTE_HOT void write(fmt::memory_buffer const& formatted_log_message, + QUILL_ATTRIBUTE_HOT void write(fmt_buffer_t const& formatted_log_message, quill::TransitEvent const& log_event) override; private: - fmt::memory_buffer _json_message; + fmt_buffer_t _json_message; }; } // namespace quill diff --git a/quill/include/quill/handlers/RotatingFileHandler.h b/quill/include/quill/handlers/RotatingFileHandler.h index a71a5994..535bfa68 100644 --- a/quill/include/quill/handlers/RotatingFileHandler.h +++ b/quill/include/quill/handlers/RotatingFileHandler.h @@ -46,7 +46,7 @@ class RotatingFileHandler final : public FileHandler * @param formatted_log_message input log message to write * @param log_event transit_event */ - QUILL_ATTRIBUTE_HOT void write(fmt::memory_buffer const& formatted_log_message, + QUILL_ATTRIBUTE_HOT void write(fmt_buffer_t const& formatted_log_message, quill::TransitEvent const& log_event) override; private: diff --git a/quill/include/quill/handlers/StreamHandler.h b/quill/include/quill/handlers/StreamHandler.h index 40af690b..192c6a8f 100644 --- a/quill/include/quill/handlers/StreamHandler.h +++ b/quill/include/quill/handlers/StreamHandler.h @@ -38,7 +38,7 @@ class StreamHandler : public Handler * @param formatted_log_message input log message to write * @param log_event log_event */ - QUILL_ATTRIBUTE_HOT void write(fmt::memory_buffer const& formatted_log_message, + QUILL_ATTRIBUTE_HOT void write(fmt_buffer_t const& formatted_log_message, quill::TransitEvent const& log_event) override; /** diff --git a/quill/include/quill/handlers/TimeRotatingFileHandler.h b/quill/include/quill/handlers/TimeRotatingFileHandler.h index 9bd680d2..cebc7f2f 100644 --- a/quill/include/quill/handlers/TimeRotatingFileHandler.h +++ b/quill/include/quill/handlers/TimeRotatingFileHandler.h @@ -30,9 +30,9 @@ class TimeRotatingFileHandler final : public FileHandler * @param timezone if true gmt time then UTC times are used instead * @param at_time used when 'daily' is specified */ - TimeRotatingFileHandler(fs::path const& base_filename, std::string const& mode, - std::string when, uint32_t interval, uint32_t backup_count, - Timezone timezone, std::string const& at_time); + TimeRotatingFileHandler(fs::path const& base_filename, std::string const& mode, std::string when, + uint32_t interval, uint32_t backup_count, Timezone timezone, + std::string const& at_time); ~TimeRotatingFileHandler() override = default; @@ -41,7 +41,7 @@ class TimeRotatingFileHandler final : public FileHandler * @param formatted_log_message input log message to write * @param log_event log_event */ - QUILL_ATTRIBUTE_HOT void write(fmt::memory_buffer const& formatted_log_message, + QUILL_ATTRIBUTE_HOT void write(fmt_buffer_t const& formatted_log_message, quill::TransitEvent const& log_event) override; private: diff --git a/quill/src/PatternFormatter.cpp b/quill/src/PatternFormatter.cpp index 9ecc87ad..fe09d89a 100644 --- a/quill/src/PatternFormatter.cpp +++ b/quill/src/PatternFormatter.cpp @@ -179,7 +179,7 @@ void PatternFormatter::_set_pattern(std::string const& format_pattern) /***/ void PatternFormatter::format(std::chrono::nanoseconds timestamp, std::string_view thread_id, std::string_view thread_name, std::string_view process_id, std::string_view logger_name, - MacroMetadata const& macro_metadata, fmt::memory_buffer const& log_msg) + MacroMetadata const& macro_metadata, fmt_buffer_t const& log_msg) { if (_format.empty()) { diff --git a/quill/src/detail/backend/BacktraceStorage.cpp b/quill/src/detail/backend/BacktraceStorage.cpp index 09e677c0..e9969136 100644 --- a/quill/src/detail/backend/BacktraceStorage.cpp +++ b/quill/src/detail/backend/BacktraceStorage.cpp @@ -30,7 +30,7 @@ void BacktraceStorage::store(TransitEvent transit_event) else { // Store the object in the vector - stored_object_info.stored_records_collection[stored_object_info.index] = transit_event; + stored_object_info.stored_records_collection[stored_object_info.index] = std::move(transit_event); // Update the index wrapping around the vector capacity if (stored_object_info.index < stored_object_info.capacity - 1) diff --git a/quill/src/handlers/ConsoleHandler.cpp b/quill/src/handlers/ConsoleHandler.cpp index 17691248..df75504f 100644 --- a/quill/src/handlers/ConsoleHandler.cpp +++ b/quill/src/handlers/ConsoleHandler.cpp @@ -172,7 +172,7 @@ ConsoleHandler::ConsoleHandler(std::string stream, FILE* file, ConsoleColours co } /***/ -void ConsoleHandler::write(fmt::memory_buffer const& formatted_log_message, quill::TransitEvent const& log_event) +void ConsoleHandler::write(fmt_buffer_t const& formatted_log_message, quill::TransitEvent const& log_event) { #if defined(_WIN32) if (_console_colours.using_colours()) diff --git a/quill/src/handlers/Handler.cpp b/quill/src/handlers/Handler.cpp index df979ecf..8da6779b 100644 --- a/quill/src/handlers/Handler.cpp +++ b/quill/src/handlers/Handler.cpp @@ -31,7 +31,7 @@ void Handler::add_filter(std::unique_ptr filter) /***/ QUILL_NODISCARD bool Handler::apply_filters(char const* thread_id, std::chrono::nanoseconds log_message_timestamp, - MacroMetadata const& metadata, fmt::memory_buffer const& formatted_record) + MacroMetadata const& metadata, fmt_buffer_t const& formatted_record) { if (metadata.level() < _log_level.load(std::memory_order_relaxed)) { diff --git a/quill/src/handlers/JsonFileHandler.cpp b/quill/src/handlers/JsonFileHandler.cpp index 93a720c8..c05add40 100644 --- a/quill/src/handlers/JsonFileHandler.cpp +++ b/quill/src/handlers/JsonFileHandler.cpp @@ -4,7 +4,7 @@ namespace quill { /***/ -void JsonFileHandler::write(fmt::memory_buffer const& formatted_log_message, quill::TransitEvent const& log_event) +void JsonFileHandler::write(fmt_buffer_t const& formatted_log_message, quill::TransitEvent const& log_event) { _json_message.clear(); diff --git a/quill/src/handlers/RotatingFileHandler.cpp b/quill/src/handlers/RotatingFileHandler.cpp index e3df49d4..ad4a3d58 100644 --- a/quill/src/handlers/RotatingFileHandler.cpp +++ b/quill/src/handlers/RotatingFileHandler.cpp @@ -72,7 +72,7 @@ RotatingFileHandler::RotatingFileHandler(fs::path const& base_filename, } /***/ -void RotatingFileHandler::write(fmt::memory_buffer const& formatted_log_message, quill::TransitEvent const& log_event) +void RotatingFileHandler::write(fmt_buffer_t const& formatted_log_message, quill::TransitEvent const& log_event) { _current_size += formatted_log_message.size(); diff --git a/quill/src/handlers/StreamHandler.cpp b/quill/src/handlers/StreamHandler.cpp index 5cad9e9a..9a259479 100644 --- a/quill/src/handlers/StreamHandler.cpp +++ b/quill/src/handlers/StreamHandler.cpp @@ -21,7 +21,7 @@ StreamHandler::StreamHandler(fs::path stream, FILE* file /* = nullptr */) } /***/ -void StreamHandler::write(fmt::memory_buffer const& formatted_log_message, quill::TransitEvent const& log_event) +void StreamHandler::write(fmt_buffer_t const& formatted_log_message, quill::TransitEvent const& log_event) { detail::fwrite_fully(formatted_log_message.data(), sizeof(char), formatted_log_message.size(), _file); } diff --git a/quill/src/handlers/TimeRotatingFileHandler.cpp b/quill/src/handlers/TimeRotatingFileHandler.cpp index 4ba88bac..cdb086ae 100644 --- a/quill/src/handlers/TimeRotatingFileHandler.cpp +++ b/quill/src/handlers/TimeRotatingFileHandler.cpp @@ -79,8 +79,7 @@ TimeRotatingFileHandler::TimeRotatingFileHandler(fs::path const& base_filename, } /***/ -void TimeRotatingFileHandler::write(fmt::memory_buffer const& formatted_log_message, - quill::TransitEvent const& log_event) +void TimeRotatingFileHandler::write(fmt_buffer_t const& formatted_log_message, quill::TransitEvent const& log_event) { bool const should_rotate = (std::chrono::nanoseconds{log_event.header.timestamp} >= _next_rotation_time.time_since_epoch()); diff --git a/quill/test/LogTest.cpp b/quill/test/LogTest.cpp index be54e319..8243c136 100644 --- a/quill/test/LogTest.cpp +++ b/quill/test/LogTest.cpp @@ -1054,7 +1054,7 @@ class FileFilter1 : public quill::FilterBase QUILL_NODISCARD bool filter(char const* thread_id, std::chrono::nanoseconds log_message_timestamp, quill::MacroMetadata const& metadata, - fmt::memory_buffer const& formatted_record) noexcept override + fmt_buffer_t const& formatted_record) noexcept override { if (metadata.level() < quill::LogLevel::Warning) { @@ -1074,7 +1074,7 @@ class FileFilter2 : public quill::FilterBase QUILL_NODISCARD bool filter(char const* thread_id, std::chrono::nanoseconds log_message_timestamp, quill::MacroMetadata const& metadata, - fmt::memory_buffer const& formatted_record) noexcept override + fmt_buffer_t const& formatted_record) noexcept override { if (metadata.level() >= quill::LogLevel::Warning) { diff --git a/quill/test/PatternFormatterTest.cpp b/quill/test/PatternFormatterTest.cpp index f575fbc8..f96569c8 100644 --- a/quill/test/PatternFormatterTest.cpp +++ b/quill/test/PatternFormatterTest.cpp @@ -25,7 +25,7 @@ TEST_CASE("default_pattern_formatter") MacroMetadata::Event::Log, false}; // Format to a buffer - fmt::memory_buffer mbuff; + fmt_buffer_t mbuff; fmt::format_to(std::back_inserter(mbuff), fmt::runtime(log_line_info.message_format()), "pattern", 1234); default_pattern_formatter.format(ts, thread_id, thread_name, process_id, logger_name.data(), log_line_info, mbuff); @@ -56,7 +56,7 @@ TEST_CASE("custom_pattern_message_only") MacroMetadata::Event::Log, false}; // Format to a buffer - fmt::memory_buffer mbuff; + fmt_buffer_t mbuff; fmt::format_to(std::back_inserter(mbuff), fmt::runtime(log_line_info.message_format()), "pattern", 12.34); custom_pattern_formatter.format(ts, thread_id, thread_name, process_id, logger_name.data(), log_line_info, mbuff); @@ -88,7 +88,7 @@ TEST_CASE("custom_pattern_timestamp_precision_nanoseconds") MacroMetadata::Event::Log, false}; // Format to a buffer - fmt::memory_buffer mbuff; + fmt_buffer_t mbuff; fmt::format_to(std::back_inserter(mbuff), fmt::runtime(log_line_info.message_format()), "pattern", 1234); custom_pattern_formatter.format(ts, thread_id, thread_name, process_id, logger_name.data(), log_line_info, mbuff); @@ -121,7 +121,7 @@ TEST_CASE("custom_pattern_timestamp_precision_microseconds") MacroMetadata::Event::Log, false}; // Format to a buffer - fmt::memory_buffer mbuff; + fmt_buffer_t mbuff; fmt::format_to(std::back_inserter(mbuff), fmt::runtime(log_line_info.message_format()), "pattern", 1234); custom_pattern_formatter.format(ts, thread_id, thread_name, process_id, logger_name.data(), log_line_info, mbuff); @@ -154,7 +154,7 @@ TEST_CASE("custom_pattern_timestamp_precision_milliseconds") MacroMetadata::Event::Log, false}; // Format to a buffer - fmt::memory_buffer mbuff; + fmt_buffer_t mbuff; fmt::format_to(std::back_inserter(mbuff), fmt::runtime(log_line_info.message_format()), "pattern", 1234); custom_pattern_formatter.format(ts, thread_id, thread_name, process_id, logger_name.data(), log_line_info, mbuff); @@ -187,7 +187,7 @@ TEST_CASE("custom_pattern_timestamp_precision_none") MacroMetadata::Event::Log, false}; // Format to a buffer - fmt::memory_buffer mbuff; + fmt_buffer_t mbuff; fmt::format_to(std::back_inserter(mbuff), fmt::runtime(log_line_info.message_format()), "pattern", 1234); custom_pattern_formatter.format(ts, thread_id, thread_name, process_id, logger_name.data(), log_line_info, mbuff); @@ -223,7 +223,7 @@ TEST_CASE("custom_pattern_timestamp_strftime_reallocation_on_format_string_2") for (size_t i = 0; i < 5; ++i) { // Format to a buffer - fmt::memory_buffer mbuff; + fmt_buffer_t mbuff; fmt::format_to(std::back_inserter(mbuff), fmt::runtime(log_line_info.message_format()), "pattern", 1234); custom_pattern_formatter.format(ts, thread_id, thread_name, process_id, logger_name.data(), @@ -260,7 +260,7 @@ TEST_CASE("custom_pattern_timestamp_strftime_reallocation_when_adding_fractional for (size_t i = 0; i < 5; ++i) { // Format to a buffer - fmt::memory_buffer mbuff; + fmt_buffer_t mbuff; fmt::format_to(std::back_inserter(mbuff), fmt::runtime(log_line_info.message_format()), "pattern", 1234); custom_pattern_formatter.format(ts, thread_id, thread_name, process_id, logger_name.data(), @@ -315,7 +315,7 @@ TEST_CASE("custom_pattern") MacroMetadata::Event::Log, false}; // Format to a buffer - fmt::memory_buffer mbuff; + fmt_buffer_t mbuff; fmt::format_to(std::back_inserter(mbuff), fmt::runtime(log_line_info.message_format()), "pattern", 1234); custom_pattern_formatter.format(ts, thread_id, thread_name, process_id, logger_name.data(), log_line_info, mbuff); @@ -349,7 +349,7 @@ TEST_CASE("custom_pattern_part_3_no_format_specifiers") MacroMetadata::Event::Log, false}; // Format to a buffer - fmt::memory_buffer mbuff; + fmt_buffer_t mbuff; fmt::format_to(std::back_inserter(mbuff), fmt::runtime(log_line_info.message_format()), "pattern", 1234); custom_pattern_formatter.format(ts, thread_id, thread_name, process_id, logger_name.data(), log_line_info, mbuff);