#include <dlog.h>
+#ifdef TIZEN_DEBUG_ENABLE
// Using static inline function with no operation inside to cause compiler types check.
-// Using empty do {} while in WEBAPI_NOP macro will cause that when TIZEN_DEBUG_ENABLE flag
-// is turned off, then no types checking will be performed. This could cause problems when
-// developing code with this flag off and then enabling it.
-static inline int _noop_print(const char *fmt __attribute__((unused)), ...) { return 0; }
-#define WEBAPI_NOP(...) ({ do { _noop_print(__VA_ARGS__); } while (0); })
+// Using empty do {} while in WEBAPI_CHECK_PRINTF_FORMAT_ARGS macro will cause that when
+// TIZEN_DEBUG_ENABLE flag is turned off, then no types checking will be performed. This could cause
+// problems when developing code with this flag off and then enabling it.
+static inline int _printf_format_checker(const char* fmt, ...)
+ __attribute__((format(printf, 1, 2)));
+
+int _printf_format_checker(const char* fmt, ...) {
+ return 0;
+}
+
+#define WEBAPI_CHECK_PRINTF_FORMAT_ARGS(...) \
+ ({ \
+ do { \
+ _printf_format_checker(__VA_ARGS__); \
+ } while (0); \
+ })
+
+#else // TIZEN_DEBUG_ENABLE
+
+#define WEBAPI_NOOP() \
+ do { \
+ } while (0);
+#endif // TIZEN_DEBUG_ENABLE
// Tizen 3.0 uses different debug flag (DLOG_DEBUG_ENABLE) which is always
// enabled, following code allows to disable logs with DLOG_DEBUG priority if
#define LOG_(id, prio, tag, fmt, arg...) \
({ \
do { \
+ WEBAPI_CHECK_PRINTF_FORMAT_ARGS(fmt, ##arg); \
__dlog_print(id, prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); \
} while (0); \
})
#define SECURE_LOG_(id, prio, tag, fmt, arg...) \
({ \
do { \
+ WEBAPI_CHECK_PRINTF_FORMAT_ARGS(fmt, ##arg); \
__dlog_print(id, prio, tag, "%s: %s(%d) > [SECURE_LOG] " fmt, __MODULE__, __func__, \
__LINE__, ##arg); \
} while (0); \
})
#else // TIZEN_DEBUG_ENABLE
-#define SECURE_LOG_(id, prio, tag, fmt, arg...) WEBAPI_NOP(fmt, ##arg)
+#define SECURE_LOG_(id, prio, tag, fmt, arg...) WEBAPI_NOOP()
#endif // TIZEN_DEBUG_ENABLE
#include <cstring>
#ifdef TIZEN_DEBUG_ENABLE
#define ScopeLogger(EX, args...) \
+ WEBAPI_CHECK_PRINTF_FORMAT_ARGS("noop" EX, ##args); \
__dlog_print(LOG_ID_MAIN, DLOG_DEBUG, LOGGER_TAG, \
"logger.h: ScopeLogger > %s: %s(%d) > Enter " EX, __MODULE__, __func__, __LINE__, \
##args); \
const common::ScopeLogger __sl__{__MODULE__, __func__};
#else
-#define ScopeLogger(EX, args...)
+#define ScopeLogger(EX, args...) WEBAPI_NOOP()
#endif
#endif // COMMON_LOGGER_H_