From bd71e0b794407869d00f4973571d3f6c4a48d137 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 30 Jan 2024 17:12:41 +0800 Subject: [PATCH] tracing: add formatter for tracing::span_id before this change, we rely on the default-generated fmt::formatter created from operator<<, but fmt v10 dropped the default-generated formatter. in this change, we define formatters for `tracing::span_id`, and drop its operator<<. Refs #13245 Signed-off-by: Kefu Chai Closes scylladb/scylladb#17058 --- tracing/tracing.cc | 4 ---- tracing/tracing.hh | 9 +++++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tracing/tracing.cc b/tracing/tracing.cc index 2f74738643..deddaa0365 100644 --- a/tracing/tracing.cc +++ b/tracing/tracing.cc @@ -195,8 +195,4 @@ one_session_records::one_session_records(trace_type type, std::chrono::seconds s { } -std::ostream& operator<<(std::ostream& os, const span_id& id) { - return os << id.get_id(); } -} - diff --git a/tracing/tracing.hh b/tracing/tracing.hh index 7af98ba229..0c4b7f35ab 100644 --- a/tracing/tracing.hh +++ b/tracing/tracing.hh @@ -90,8 +90,6 @@ public: static span_id make_span_id(); }; -std::ostream& operator<<(std::ostream& os, const span_id& id); - // !!!!IMPORTANT!!!! // // The enum_set based on this enum is serialized using IDL, therefore new items @@ -661,3 +659,10 @@ inline span_id span_id::make_span_id() { return 1 + (tracing::get_local_tracing_instance().get_next_rand_uint64() << 1); } } + +template <> struct fmt::formatter { + constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } + auto format(const tracing::span_id& id, fmt::format_context& ctx) const { + return fmt::format_to(ctx.out(), "{}", id.get_id()); + } +};