From 070462540176820a83fd78d4498fc697ccbdb741 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 19 Jul 2019 17:15:47 -0700 Subject: [PATCH] ircd::log: Simplify log class member interface. --- include/ircd/logger.h | 190 ------------------------------------------ ircd/db.cc | 12 ++- 2 files changed, 10 insertions(+), 192 deletions(-) diff --git a/include/ircd/logger.h b/include/ircd/logger.h index 4b98b0479..4a6e75032 100644 --- a/include/ircd/logger.h +++ b/include/ircd/logger.h @@ -95,56 +95,6 @@ struct ircd::log::log public: template void operator()(const level &, const string_view &fmt, args&&...); - #if RB_LOG_LEVEL >= 0 && !defined(NDEBUG) && !defined(RB_ASSERT) - template [[noreturn]] void critical(const string_view &fmt, args&&...); - #elif RB_LOG_LEVEL >= 0 - template void critical(const string_view &fmt, args&&...); - #else - void critical(const string_view &fmt, ...); - #endif - - #if RB_LOG_LEVEL >= 1 - template void error(const string_view &fmt, args&&...); - #else // Required for DCE in gcc 6.3.0 20170519 - void error(const string_view &fmt, ...); - #endif - - #if RB_LOG_LEVEL >= 2 - template void warning(const string_view &fmt, args&&...); - #else // Required for DCE in gcc 6.3.0 20170519 - void warning(const string_view &fmt, ...); - #endif - - #if RB_LOG_LEVEL >= 3 - template void notice(const string_view &fmt, args&&...); - #else // Required for DCE in gcc 6.3.0 20170519 - void notice(const string_view &fmt, ...); - #endif - - #if RB_LOG_LEVEL >= 4 - template void info(const string_view &fmt, args&&...); - #else // Required for DCE in gcc 6.3.0 20170519 - void info(const string_view &fmt, ...); - #endif - - #if RB_LOG_LEVEL >= 5 - template void derror(const string_view &fmt, args&&...); - #else // Required for DCE in gcc 6.3.0 20170519 - void derror(const string_view &fmt, ...); - #endif - - #if RB_LOG_LEVEL >= 6 - template void dwarning(const string_view &fmt, args&&...); - #else // Required for DCE in gcc 6.3.0 20170519 - void dwarning(const string_view &fmt, ...); - #endif - - #if RB_LOG_LEVEL >= 7 - template void debug(const string_view &fmt, args&&...); - #else // Required for DCE in gcc 6.3.0 20170519 - void debug(const string_view &fmt, ...); - #endif - log(const string_view &name, const char &snote = '\0'); log(log &&) = delete; log(const log &) = delete; @@ -551,146 +501,6 @@ struct ircd::log::critical }; #endif -#if RB_LOG_LEVEL >= 7 -template -void -ircd::log::log::debug(const string_view &fmt, - args&&... a) -{ - operator()(level::DEBUG, fmt, va_rtti{std::forward(a)...}); -} -#else -inline void -ircd::log::log::debug(const string_view &fmt, - ...) -{ - // Required in gcc 6.3.0 20170519, template param packs are not DCE'ed -} -#endif - -#if RB_LOG_LEVEL >= 6 -template -void -ircd::log::log::dwarning(const string_view &fmt, - args&&... a) -{ - operator()(level::DWARNING, fmt, va_rtti{std::forward(a)...}); -} -#else -inline void -ircd::log::log::dwarning(const string_view &fmt, - ...) -{ - // Required in gcc 6.3.0 20170519, template param packs are not DCE'ed -} -#endif - -#if RB_LOG_LEVEL >= 5 -template -void -ircd::log::log::derror(const string_view &fmt, - args&&... a) -{ - operator()(level::DERROR, fmt, va_rtti{std::forward(a)...}); -} -#else -inline void -ircd::log::log::derror(const string_view &fmt, - ...) -{ - // Required in gcc 6.3.0 20170519, template param packs are not DCE'ed -} -#endif - -#if RB_LOG_LEVEL >= 4 -template -void -ircd::log::log::info(const string_view &fmt, - args&&... a) -{ - operator()(level::INFO, fmt, va_rtti{std::forward(a)...}); -} -#else -inline void -ircd::log::log::info(const string_view &fmt, - ...) -{ - // Required in gcc 6.3.0 20170519, template param packs are not DCE'ed -} -#endif - -#if RB_LOG_LEVEL >= 3 -template -void -ircd::log::log::notice(const string_view &fmt, - args&&... a) -{ - operator()(level::NOTICE, fmt, va_rtti{std::forward(a)...}); -} -#else -inline void -ircd::log::log::notice(const string_view &fmt, - ...) -{ - // Required in gcc 6.3.0 20170519, template param packs are not DCE'ed -} -#endif - -#if RB_LOG_LEVEL >= 2 -template -void -ircd::log::log::warning(const string_view &fmt, - args&&... a) -{ - operator()(level::WARNING, fmt, va_rtti{std::forward(a)...}); -} -#else -inline void -ircd::log::log::warning(const string_view &fmt, - ...) -{ - // Required in gcc 6.3.0 20170519, template param packs are not DCE'ed -} -#endif - -#if RB_LOG_LEVEL >= 1 -template -void -ircd::log::log::error(const string_view &fmt, - args&&... a) -{ - operator()(level::ERROR, fmt, va_rtti{std::forward(a)...}); -} -#else -inline void -ircd::log::log::error(const string_view &fmt, - ...) -{ - // Required in gcc 6.3.0 20170519, template param packs are not DCE'ed -} -#endif - -#if RB_LOG_LEVEL >= 0 -template -void -ircd::log::log::critical(const string_view &fmt, - args&&... a) -{ - operator()(level::CRITICAL, fmt, va_rtti{std::forward(a)...}); - - #ifndef NDEBUG - __assert_fail("critical", "", 0, ""); - #endif -} -#else -inline void -ircd::log::log::critical(const string_view &fmt, - ...) -{ - // Required in gcc 6.3.0 20170519, template param packs are not DCE'ed -} -#endif - template void ircd::log::log::operator()(const level &f, diff --git a/ircd/db.cc b/ircd/db.cc index 5ef150cf6..b99cb3cc7 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -2292,12 +2292,20 @@ const noexcept try } catch(const std::bad_function_call &e) { - log.critical("merge: missing merge operator (%s)", e); + log::critical + { + log, "merge: missing merge operator (%s)", e + }; + return false; } catch(const std::exception &e) { - log.error("merge: %s", e); + log::error + { + log, "merge: %s", e + }; + return false; }