From: Adam C. Emerson Date: Wed, 25 Feb 2026 15:30:53 +0000 (-0500) Subject: log: Add StringEntry to avoid using ostream X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e885b11c1c161cc4239c92955aa4bfb020bc01f7;p=ceph.git log: Add StringEntry to avoid using ostream Create a log entry where we can fill a buffer with `format` instead of needing to go through stringstream. Signed-off-by: Adam C. Emerson --- diff --git a/src/log/Entry.h b/src/log/Entry.h index 6bba9707c43..33c535ce316 100644 --- a/src/log/Entry.h +++ b/src/log/Entry.h @@ -117,6 +117,32 @@ private: boost::container::small_vector str; }; +class StringEntry : public Entry { +public: + StringEntry() = delete; + StringEntry(short pr, short sub, std::string_view prefix) + : Entry(pr, sub), str(prefix.begin(), prefix.end()) {} + ~StringEntry() override = default; + + StringEntry(const StringEntry&) = default; + StringEntry& operator=(const StringEntry&) = default; + StringEntry(StringEntry&&) = default; + StringEntry& operator=(StringEntry&&) = default; + + std::string_view strv() const override { + return std::string_view(str.data(), str.size()); + } + std::size_t size() const override { + return str.size(); + } + + auto get_inserter() { + return std::back_inserter(str); + } + +private: + boost::container::small_vector str; +}; } }