From 2f9e182b20addad728fadd9f7507807d63d63923 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Mon, 18 Jul 2022 13:07:33 -0300 Subject: [PATCH] Avoid ctor inheritance to make diagnostics better Using constructor inheritance DRYs the code, but unfortunately confuses GCC as to where the proper "required from here" location is, which makes debugging formatting errors very difficult. Avoid it (and update oxen-logging to avoid it there as well). --- external/oxen-logging | 2 +- llarp/util/logging.hpp | 75 ++++++++++++++++++++++++++++-------------- 2 files changed, 51 insertions(+), 26 deletions(-) diff --git a/external/oxen-logging b/external/oxen-logging index 0fc1b3528..9d65a01ca 160000 --- a/external/oxen-logging +++ b/external/oxen-logging @@ -1 +1 @@ -Subproject commit 0fc1b3528a52475c4007d734a7861faa2212fe75 +Subproject commit 9d65a01ca73a944cd22e3a2966da2eaa76296456 diff --git a/llarp/util/logging.hpp b/llarp/util/logging.hpp index d549dcb8c..7d1407390 100644 --- a/llarp/util/logging.hpp +++ b/llarp/util/logging.hpp @@ -42,47 +42,72 @@ namespace llarp return std::string_view{ concat_args_fmt_impl>::format.data(), 2 * N}; } - - template - struct LegacyLeveledLogger : log::detail::LeveledLogger - { - LegacyLeveledLogger( - T&&... args, const slns::source_location& location = slns::source_location::current()) - : log::detail::LeveledLogger::LeveledLogger{ - legacy_logger, concat_args_fmt(), std::forward(args)..., location} - {} - }; } // namespace log_detail template - struct LOKINET_LOG_DEPRECATED(Trace) LogTrace - : log_detail::LegacyLeveledLogger + struct LOKINET_LOG_DEPRECATED(Trace) LogTrace : log::trace { - using log_detail::LegacyLeveledLogger::LegacyLeveledLogger; + LogTrace( + T&&... args, + const log::slns::source_location& location = log::slns::source_location::current()) + : log::trace::trace{ + log_detail::legacy_logger, + log_detail::concat_args_fmt(), + std::forward(args)..., + location} + {} }; template - struct LOKINET_LOG_DEPRECATED(Debug) LogDebug - : log_detail::LegacyLeveledLogger + struct LOKINET_LOG_DEPRECATED(Debug) LogDebug : log::debug { - using log_detail::LegacyLeveledLogger::LegacyLeveledLogger; + LogDebug( + T&&... args, + const log::slns::source_location& location = log::slns::source_location::current()) + : log::debug::debug{ + log_detail::legacy_logger, + log_detail::concat_args_fmt(), + std::forward(args)..., + location} + {} }; template - struct LOKINET_LOG_DEPRECATED(Info) LogInfo - : log_detail::LegacyLeveledLogger + struct LOKINET_LOG_DEPRECATED(Info) LogInfo : log::info { - using log_detail::LegacyLeveledLogger::LegacyLeveledLogger; + LogInfo( + T&&... args, + const log::slns::source_location& location = log::slns::source_location::current()) + : log::info::info{ + log_detail::legacy_logger, + log_detail::concat_args_fmt(), + std::forward(args)..., + location} + {} }; template - struct LOKINET_LOG_DEPRECATED(Warning) LogWarn - : log_detail::LegacyLeveledLogger + struct LOKINET_LOG_DEPRECATED(Warning) LogWarn : log::warning { - using log_detail::LegacyLeveledLogger::LegacyLeveledLogger; + LogWarn( + T&&... args, + const log::slns::source_location& location = log::slns::source_location::current()) + : log::warning::warning{ + log_detail::legacy_logger, + log_detail::concat_args_fmt(), + std::forward(args)..., + location} + {} }; template - struct LOKINET_LOG_DEPRECATED(Error) LogError - : log_detail::LegacyLeveledLogger + struct LOKINET_LOG_DEPRECATED(Error) LogError : log::error { - using log_detail::LegacyLeveledLogger::LegacyLeveledLogger; + LogError( + T&&... args, + const log::slns::source_location& location = log::slns::source_location::current()) + : log::error::error{ + log_detail::legacy_logger, + log_detail::concat_args_fmt(), + std::forward(args)..., + location} + {} }; template