]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/Formatter: add dump_named_fmt() method
authorRonen Friedman <rfriedma@redhat.com>
Sat, 27 Dec 2025 17:26:18 +0000 (17:26 +0000)
committerRonen Friedman <rfriedma@redhat.com>
Mon, 5 Jan 2026 13:23:27 +0000 (15:23 +0200)
dump_named_fmt() allows to dump a named field using an fmtlib-style
format string (improving code clarity and performance).

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/common/Formatter.h

index e50834980c47679e60aec57384ad64fcbfadcf4a..e2c7eb152b188b4f5f04ed677632119c07995a51 100644 (file)
@@ -13,6 +13,8 @@
 
 #include <stdarg.h>
 
+#include "common/fmt_common.h"
+
 namespace ceph {
 
   struct FormatterAttrs {
@@ -242,6 +244,12 @@ namespace ceph {
       return nullptr;
     }
     virtual void write_bin_data(const char* buff, int buf_len);
+
+    template <typename... Args>
+    void dump_named_fmt(std::string_view name, fmt::format_string<Args...> fmtformat, Args&&... args)
+    {
+      dump_string(name, fmt::format(fmtformat, std::forward<Args>(args)...));
+    }
   };
 
   std::string fixed_to_string(int64_t num, int scale);