log: Make LogLevel statically configurable 06/226206/6
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 26 Feb 2020 08:24:40 +0000 (09:24 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Tue, 3 Mar 2020 08:23:33 +0000 (09:23 +0100)
Change-Id: I6d38d777ec5aaef0e8ba71d6d1c91907c4a68057

include/defs.h.in
packaging/crash-worker.spec
src/shared/log.h

index 30b61f4..a3196cf 100644 (file)
@@ -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__ */
index 07c2027..9aaf71a 100644 (file)
@@ -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}
index bee783b..0710ec6 100644 (file)
@@ -15,8 +15,6 @@
  * limitations under the License.
  */
 
-
-
 #ifndef __CRASH_LOG_H__
 #define __CRASH_LOG_H__
 
@@ -25,6 +23,8 @@
 #endif
 #include <dlog.h>
 
+#include "defs.h" // for DLOG_LOG_LEVEL
+
 #ifdef LOG_FILE
 #include <sys/types.h>
 #include <unistd.h>
@@ -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)