From 96a8f68ff5d4ce1e9ad8222fd298334f6064e615 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Wed, 26 Feb 2020 09:24:40 +0100 Subject: [PATCH] log: Make LogLevel statically configurable Change-Id: I6d38d777ec5aaef0e8ba71d6d1c91907c4a68057 --- include/defs.h.in | 1 + packaging/crash-worker.spec | 1 + src/shared/log.h | 13 +++++++------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/defs.h.in b/include/defs.h.in index 30b61f4..a3196cf 100644 --- a/include/defs.h.in +++ b/include/defs.h.in @@ -16,5 +16,6 @@ #define MINICOREDUMPER_CONFIG_PATH "@MINICOREDUMPER_CONFIG_PATH@" #define DEBUGMODE_PATH "@DEBUGMODE_PATH@" #define LIVEDUMPER_BIN_PATH "@LIVEDUMPER_BIN_PATH@" +#define DLOG_LOG_LEVEL @DLOG_LOG_LEVEL@ #endif /* __DEFS_H__ */ diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index 07c2027..9aaf71a 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -149,6 +149,7 @@ export CFLAGS+=" -Werror" -DCRASH_SERVICE=%{on_off crashservice} \ -DUPGRADE_SCRIPT_PATH=%{upgrade_script_path} \ -DLOGGER=dlog \ + -DDLOG_LOG_LEVEL=DLOG_INFO \ -DVERSION=%{version} make %{?jobs:-j%jobs} diff --git a/src/shared/log.h b/src/shared/log.h index bee783b..0710ec6 100644 --- a/src/shared/log.h +++ b/src/shared/log.h @@ -15,8 +15,6 @@ * limitations under the License. */ - - #ifndef __CRASH_LOG_H__ #define __CRASH_LOG_H__ @@ -25,6 +23,8 @@ #endif #include +#include "defs.h" // for DLOG_LOG_LEVEL + #ifdef LOG_FILE #include #include @@ -52,10 +52,11 @@ static inline char __dlog_prio(int prio) } while (0); }) #endif -#define _D(fmt, arg...) SLOGD(fmt, ##arg) -#define _I(fmt, arg...) SLOGI(fmt, ##arg) -#define _W(fmt, arg...) SLOGW(fmt, ##arg) -#define _E(fmt, arg...) SLOGE(fmt, ##arg) +#define _D(fmt, arg...) do { if (DLOG_LOG_LEVEL <= DLOG_DEBUG) SLOGD(fmt, ##arg); } while (0) +#define _I(fmt, arg...) do { if (DLOG_LOG_LEVEL <= DLOG_INFO) SLOGI(fmt, ##arg); } while (0) +#define _W(fmt, arg...) do { if (DLOG_LOG_LEVEL <= DLOG_WARN) SLOGW(fmt, ##arg); } while (0) +#define _E(fmt, arg...) do { if (DLOG_LOG_LEVEL <= DLOG_ERROR) SLOGE(fmt, ##arg); } while (0) + #define _SD(fmt, arg...) SECURE_SLOGD(fmt, ##arg) #define _SI(fmt, arg...) SECURE_SLOGI(fmt, ##arg) #define _SW(fmt, arg...) SECURE_SLOGW(fmt, ##arg) -- 2.7.4