Fix coverity issue 1149129
[apps/native/volume-app.git] / inc / app_log.h
1 #ifndef __APP_LOG_H__
2 #define __APP_LOG_H__
3
4 #include <dlog.h>
5
6 #include "test.h"
7
8 #ifndef  LOG_TAG
9 #define LOG_TAG "VOLUME"
10 #endif
11
12 #ifndef __MODULE__
13 #define __MODULE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
14 #endif
15
16 #define LOG_(prio, tag, fmt, arg...) ({ dlog_print(prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); })
17
18 #if (TEST_MODE == TEST_UNIT)
19 #define TEST_APP_LOG_TAG "TEST_APP"
20 #define TEST_UNIT_LOG_TAG "TEST_UNIT"
21 #define __D(format, arg...) LOG_(DLOG_DEBUG, LOG_TAG, format, ##arg)
22 #define __I(format, arg...) LOG_(DLOG_INFO, LOG_TAG, format, ##arg)
23 #define __E(format, arg...) LOG_(DLOG_ERROR, LOG_TAG, format, ##arg)
24 #define __T(format, arg...) ({ dlog_print(DLOG_DEBUG, TEST_APP_LOG_TAG, format, ##arg); unit_write_log(format, ##arg); })
25 #define __TU(format, arg...) LOG_(DLOG_DEBUG, TEST_UNIT_LOG_TAG, format, ##arg)
26 #elif (TEST_MODE == TEST_APP)
27 #define TEST_APP_LOG_TAG "TEST_APP"
28 #define __D(format, arg...) ({ dlog_print(DLOG_DEBUG, LOG_TAG, format, ##arg); unit_write_log(format, ##arg); })
29 #define __I(format, arg...) LOG_(DLOG_INFO, LOG_TAG, format, ##arg)
30 #define __E(format, arg...) LOG_(DLOG_ERROR, LOG_TAG, format, ##arg)
31 #define __T(format, arg...) LOG_(DLOG_DEBUG, TEST_APP_LOG_TAG, format, ##arg)
32 #else
33 #define __D(format, arg...) LOG_(DLOG_DEBUG, LOG_TAG, format, ##arg)
34 #define __I(format, arg...) LOG_(DLOG_INFO, LOG_TAG, format, ##arg)
35 #define __E(format, arg...) LOG_(DLOG_ERROR, LOG_TAG, format, ##arg)
36 #endif
37 #endif