From 52e6e10e28603eed5f89bb37c6fb94f13aabba3c Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 15 Aug 2018 15:29:43 +0300 Subject: [PATCH] MXS-2014 Remove duplicate function Two functions that essentially did the same thing, but had slightly different name. --- maxutils/maxbase/include/maxbase/log.h | 14 ++++++-------- maxutils/maxbase/src/log.cc | 25 +------------------------ 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/maxutils/maxbase/include/maxbase/log.h b/maxutils/maxbase/include/maxbase/log.h index 42661825d..6e472cb36 100644 --- a/maxutils/maxbase/include/maxbase/log.h +++ b/maxutils/maxbase/include/maxbase/log.h @@ -129,7 +129,11 @@ bool mxb_log_set_priority_enabled(int priority, bool enabled); * * @return True if enabled, false otherwise. */ -bool mxs_log_is_priority_enabled(int priority); +static inline bool mxb_log_is_priority_enabled(int priority) +{ + assert((priority & ~LOG_PRIMASK) == 0); + return MXB_LOG_PRIORITY_IS_ENABLED(priority) || priority == LOG_ALERT; +} /** * Enable/disable syslog logging. @@ -178,12 +182,6 @@ void mxb_log_set_throttling(const MXB_LOG_THROTTLING* throttling); void mxb_log_get_throttling(MXB_LOG_THROTTLING* throttling); -static inline bool mxb_log_priority_is_enabled(int priority) -{ - assert((priority & ~LOG_PRIMASK) == 0); - return MXB_LOG_PRIORITY_IS_ENABLED(priority) || priority == LOG_ALERT; -} - int mxb_log_message(int priority, const char* modname, const char* file, int line, const char* function, @@ -199,7 +197,7 @@ int mxb_log_message(int priority, * MXB_ERROR, MXB_WARNING, etc. macros instead. */ #define MXB_LOG_MESSAGE(priority, format, ...)\ - (mxb_log_priority_is_enabled(priority) ? \ + (mxb_log_is_priority_enabled(priority) ? \ mxb_log_message(priority, MXB_MODULE_NAME, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__) :\ 0) diff --git a/maxutils/maxbase/src/log.cc b/maxutils/maxbase/src/log.cc index d3ca068ed..450294802 100644 --- a/maxutils/maxbase/src/log.cc +++ b/maxutils/maxbase/src/log.cc @@ -16,15 +16,13 @@ #include #include -#include #include #include +#include #include #include #include -#include -#include #include #define CALCLEN(i) ((size_t)(floor(log10(abs((int64_t)i))) + 1)) @@ -605,27 +603,6 @@ bool mxb_log_set_priority_enabled(int level, bool enable) return rv; } -bool mxb_log_is_priority_enabled(int level) -{ - bool rv = false; - - if ((level & ~LOG_PRIMASK) == 0) - { - int bit = (1 << level); - - if (mxb_log_enabled_priorities & bit) - { - rv = true; - } - } - else - { - MXB_ERROR("Attempt to query unknown syslog priority %d.", level); - } - - return rv; -} - typedef struct log_prefix { const char* text; // The prefix, e.g. "error: "