From: Pieter Lexis Date: Thu, 25 Sep 2025 15:46:33 +0000 (+0200) Subject: feat: implement ostream << operator for TraceID X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=97c7387bc76807e2f2a9621b329b7a3cda2ea404;p=thirdparty%2Fpdns.git feat: implement ostream << operator for TraceID --- diff --git a/pdns/protozero-trace.cc b/pdns/protozero-trace.cc index 06b78016b2..7fdc2644a7 100644 --- a/pdns/protozero-trace.cc +++ b/pdns/protozero-trace.cc @@ -583,4 +583,9 @@ std::string SpanID::toLogString() const return makeHexDump(std::string(this->begin(), this->end()), ""); } +std::string TraceID::toLogString() const +{ + return makeHexDump(std::string(this->begin(), this->end()), ""); +} + } // namespace pdns::trace diff --git a/pdns/protozero-trace.hh b/pdns/protozero-trace.hh index f90d21ff85..3ba88ccf04 100644 --- a/pdns/protozero-trace.hh +++ b/pdns/protozero-trace.hh @@ -228,7 +228,15 @@ struct InstrumentationScope static InstrumentationScope decode(protozero::pbf_reader& reader); }; -using TraceID = std::array; +struct TraceID : public std::array +{ + [[nodiscard]] std::string toLogString() const; + friend std::ostream& operator<<(std::ostream& ostrm, const TraceID& val) + { + return ostrm << val.toLogString(); + } +}; + struct SpanID : public std::array { [[nodiscard]] std::string toLogString() const;