diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:14:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:14:49 +0000 |
commit | 2f230033794fafdf10822568e763d4db68cf6c6b (patch) | |
tree | 39ca5c2325b7b43c9a28ca6d4ad4026a61e7eb97 /logging.hh | |
parent | Adding debian version 1.8.3-3. (diff) | |
download | dnsdist-2f230033794fafdf10822568e763d4db68cf6c6b.tar.xz dnsdist-2f230033794fafdf10822568e763d4db68cf6c6b.zip |
Merging upstream version 1.9.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'logging.hh')
-rw-r--r-- | logging.hh | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -69,7 +69,7 @@ struct is_to_string_available<T, std::void_t<decltype(std::to_string(std::declva { }; -// Same mechanism for t.toLogString() +// Same mechanism for t.toLogString() and t.toStructuredLogString() template <typename T, typename = void> struct is_toLogString_available : std::false_type { @@ -81,6 +81,16 @@ struct is_toLogString_available<T, std::void_t<decltype(std::declval<T>().toLogS }; template <typename T, typename = void> +struct is_toStructuredLogString_available : std::false_type +{ +}; + +template <typename T> +struct is_toStructuredLogString_available<T, std::void_t<decltype(std::declval<T>().toStructuredLogString())>> : std::true_type +{ +}; + +template <typename T, typename = void> struct is_toString_available : std::false_type { }; @@ -103,6 +113,9 @@ struct Loggable : public Logr::Loggable if constexpr (std::is_same_v<T, std::string>) { return _t; } + else if constexpr (is_toStructuredLogString_available<T>::value) { + return _t.toStructuredLogString(); + } else if constexpr (is_toLogString_available<T>::value) { return _t.toLogString(); } @@ -202,6 +215,7 @@ extern bool g_slogStructured; // SLOG(g_log<<Logger::Warning<<"Unable to parse configuration file '"<<configname<<"'"<<endl, // startupLog->error("No such file", "Unable to parse configuration file", "config_file", Logging::Loggable(configname)); // +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define SLOG(oldStyle, slogCall) \ do { \ if (g_slogStructured) { \ @@ -210,11 +224,12 @@ extern bool g_slogStructured; else { \ oldStyle; \ } \ - } while (0); + } while (0) #else // No structured logging (e.g. auth) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define SLOG(oldStyle, slogCall) \ do { \ oldStyle; \ - } while (0); + } while (0) #endif // RECURSOR |