From: Ronen Friedman Date: Sat, 27 Dec 2025 17:26:18 +0000 (+0000) Subject: common/Formatter: add dump_named_fmt() method X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d68b329035a295abc78276f5bf9458bde3c1aaa5;p=ceph-ci.git common/Formatter: add dump_named_fmt() method 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 --- diff --git a/src/common/Formatter.h b/src/common/Formatter.h index e50834980c4..e2c7eb152b1 100644 --- a/src/common/Formatter.h +++ b/src/common/Formatter.h @@ -13,6 +13,8 @@ #include +#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 + void dump_named_fmt(std::string_view name, fmt::format_string fmtformat, Args&&... args) + { + dump_string(name, fmt::format(fmtformat, std::forward(args)...)); + } }; std::string fixed_to_string(int64_t num, int scale);