From: Otto Moerbeek Date: Fri, 3 Nov 2023 08:42:06 +0000 (+0100) Subject: rec: for structured logging always log addresses including port X-Git-Tag: rec-5.0.0-beta1~11^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a632f29bf2139d3a058074142f049f8050b02e13;p=thirdparty%2Fpdns.git rec: for structured logging always log addresses including port As documented. The way this is done is by defined a specific log function if SL is used. Could potentially be used for other cases. --- diff --git a/pdns/iputils.hh b/pdns/iputils.hh index c5fbf16425..f61fed8402 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -332,6 +332,11 @@ union ComboAddress { return toStringWithPortExcept(53); } + [[nodiscard]] string toStructuredLogString() const + { + return toStringWithPort(); + } + string toByteString() const { if (isIPv4()) { diff --git a/pdns/logging.hh b/pdns/logging.hh index 12c46ed581..dfff184efe 100644 --- a/pdns/logging.hh +++ b/pdns/logging.hh @@ -69,7 +69,7 @@ struct is_to_string_available struct is_toLogString_available : std::false_type { @@ -80,6 +80,16 @@ struct is_toLogString_available().toLogS { }; +template +struct is_toStructuredLogString_available : std::false_type +{ +}; + +template +struct is_toStructuredLogString_available().toStructuredLogString())>> : std::true_type +{ +}; + template struct is_toString_available : std::false_type { @@ -103,6 +113,9 @@ struct Loggable : public Logr::Loggable if constexpr (std::is_same_v) { return _t; } + else if constexpr (is_toStructuredLogString_available::value) { + return _t.toStructuredLogString(); + } else if constexpr (is_toLogString_available::value) { return _t.toLogString(); }