Added SECURE_LOG* macro
authorZbigniew Jasinski <z.jasinski@samsung.com>
Tue, 18 Jun 2013 08:40:23 +0000 (10:40 +0200)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 6 Feb 2014 16:11:45 +0000 (17:11 +0100)
[Issue#]        SSDWSSP-323
[Bug/Feature]   Log messages refactoring
[Cause]         SECURE_LOG* macro added for log messages refactoring
[Solution]      Added SECURE_LOG* macro
[Verification]  Compile with LOG_DEBUG_ENABLED and run. No tests should fail

Change-Id: Id9181d91c3bc571bd122edbc9e641fbcca39af7e

src/include/security-server-common.h

index 4b89ee6..f4bd665 100644 (file)
@@ -113,6 +113,26 @@ void printhex(const unsigned char *data, int size);
                __FILE__, __LINE__, ##ARG)
 
 #elif SECURITY_SERVER_DEBUG_DLOG       /* debug msg will be printed by dlog daemon */
+
+/* for SECURE_LOG* purpose */
+#undef _SECURE_
+#ifndef _SECURE_LOG
+#define _SECURE_ (0)
+#else
+#define _SECURE_ (1)
+#endif
+#undef LOG_
+#define LOG_(id, prio, tag, fmt, arg...) \
+    ( __dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg))
+#undef SECURE_LOG_
+#define SECURE_LOG_(id, prio, tag, fmt, arg...) \
+    (_SECURE_ ? ( __dlog_print(id, prio, tag, "%s: %s(%d) > [SECURE_LOG] " fmt, __MODULE__, __func__, __LINE__, ##arg)) : (0))
+
+#define SECURE_LOGD(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_DEBUG, LOG_TAG, format, ##arg)
+#define SECURE_LOGI(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_INFO, LOG_TAG, format, ##arg)
+#define SECURE_LOGW(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_WARN, LOG_TAG, format, ##arg)
+#define SECURE_LOGE(format, arg...) SECURE_LOG_(LOG_ID_MAIN, DLOG_ERROR, LOG_TAG, format, ##arg)
+/****************************/
 #define LOG_TAG "SECURITY_SERVER"
 #include <dlog.h>
 #define SEC_SVR_DBG    SLOGD