From 6fc9a708eb53bc951f1164deb9750249cfa90c49 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Tue, 15 Oct 2024 19:39:36 -0400 Subject: [PATCH] simplify logging (#759) --- include/ada/log.h | 49 ++++++----------------------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/include/ada/log.h b/include/ada/log.h index 7f5948346..c05526ae8 100644 --- a/include/ada/log.h +++ b/include/ada/log.h @@ -19,56 +19,19 @@ namespace ada { /** - * Private function used for logging messages. + * Log a message. If you want to have no overhead when logging is disabled, use + * the ada_log macro. * @private */ -template -ada_really_inline void inner_log([[maybe_unused]] T t) { +template +constexpr ada_really_inline void log([[maybe_unused]] Args... args) { #if ADA_LOGGING - std::cout << t << std::endl; -#endif -} - -/** - * Private function used for logging messages. - * @private - */ -template -ada_really_inline void inner_log([[maybe_unused]] T t, - [[maybe_unused]] Args... args) { -#if ADA_LOGGING - std::cout << t; - inner_log(args...); -#endif -} - -/** - * Log a message. - * @private - */ -template -ada_really_inline void log([[maybe_unused]] T t, - [[maybe_unused]] Args... args) { -#if ADA_LOGGING - std::cout << "ADA_LOG: " << t; - inner_log(args...); -#endif -} - -/** - * Log a message. - * @private - */ -template -ada_really_inline void log([[maybe_unused]] T t) { -#if ADA_LOGGING - std::cout << "ADA_LOG: " << t << std::endl; -#endif + ((std::cout << "ADA_LOG: ") << ... << args) << std::endl; +#endif // ADA_LOGGING } } // namespace ada #if ADA_LOGGING - #ifndef ada_log #define ada_log(...) \ do { \