the repository of RSA merge with private repository.
[framework/uifw/e17-extra-modules.git] / devmode-tizen / include / e_mod_devmode_log.h
1
2 #ifndef __TSP_LOG_H__
3 #define __TSP_LOG_H__
4
5 #include <stdio.h>
6 #include <dlog.h>
7 #include <assert.h>
8 #include <stdbool.h>
9 #include <stdlib.h>
10
11 #ifdef LOG_TAG
12 #undef LOG_TAG
13 #endif
14 #define LOG_TAG           "devmode"
15 #define TSP_DEBUG_MODE    1
16
17 /* anci c color type */
18 #define FONT_COLOR_RESET  "\033[0m"
19 #define FONT_COLOR_RED    "\033[31m"
20 #define FONT_COLOR_GREEN  "\033[32m"
21 #define FONT_COLOR_YELLOW "\033[33m"
22 #define FONT_COLOR_BLUE   "\033[34m"
23 #define FONT_COLOR_PURPLE "\033[35m"
24 #define FONT_COLOR_CYAN   "\033[36m"
25 #define FONT_COLOR_GRAY   "\033[37m"
26
27 #define PRINT_FUNC_LINE
28 #if TSP_DEBUG_MODE
29 #ifdef PRINT_FUNC_LINE
30 #define TSP_DEBUG(fmt, args ...) LOGD("[%s : <%05d>] " fmt, __func__, __LINE__, ##args)
31 #define TSP_WARN(fmt, args ...)  LOGW(FONT_COLOR_YELLOW "[%s : <%05d>] " fmt FONT_COLOR_RESET, __func__, __LINE__, ##args)
32 #define TSP_ERROR(fmt, args ...) LOGE(FONT_COLOR_RED "[%s : <%05d>] ####" fmt "####"FONT_COLOR_RESET, __func__, __LINE__, ##args)
33 #define TSP_FUNC_ENTER()         LOGD(FONT_COLOR_BLUE "[%s : <%05d>] <<<< enter!!"FONT_COLOR_RESET, __func__, __LINE__)
34 #define TSP_FUNC_LEAVE()         LOGD(FONT_COLOR_BLUE "[%s : <%05d>] >>>> leave!!"FONT_COLOR_RESET, __func__, __LINE__)
35 #else
36 #define TSP_DEBUG(fmt, args ...) LOGD("[AT] " fmt "\n", ##args)
37 #define TSP_WARN(fmt, args ...)  LOGW(FONT_COLOR_YELLOW "[AT] " fmt "\n"FONT_COLOR_RESET, ##args)
38 #define TSP_ERROR(fmt, args ...) LOGE(FONT_COLOR_RED "[AT] " fmt "\n"FONT_COLOR_RESET, ##args)
39 #define TSP_FUNC_ENTER()         LOGD(FONT_COLOR_BLUE "*********************** [Func: %s] enter!! ********************* \n"FONT_COLOR_RESET, __func__)
40 #define TSP_FUNC_LEAVE()         LOGD(FONT_COLOR_BLUE "*********************** [Func: %s] leave!! ********************* \n"FONT_COLOR_RESET, __func__)
41 #endif
42 #else
43 #ifdef TSP_DEBUG
44         #undef TSP_DEBUG
45 #endif
46 #define TSP_DEBUG(fmt, args ...)
47 #ifdef TSP_WARN
48         #undef TSP_WARN
49 #endif
50 #define TSP_WARN(fmt, args ...)
51 #ifdef TSP_FUNC_ENTER
52         #undef TSP_FUNC_ENTER
53 #endif
54 #define TSP_FUNC_ENTER(fmt, args ...)
55 #ifdef TSP_FUNC_LEAVE
56         #undef TSP_FUNC_LEAVE
57 #endif
58 #define TSP_FUNC_LEAVE(fmt, args ...)
59 #ifdef PRINT_FUNC_LINE
60 #define TSP_ERROR(fmt, args ...)               LOGE(FONT_COLOR_RED "[%s : <%05d>] ####" fmt "####"FONT_COLOR_RESET, __func__, __LINE__, ##args)
61 #else
62 #define TSP_ERROR(fmt, args ...)               LOGE(FONT_COLOR_RED "[AT] " fmt "\n"FONT_COLOR_RESET, ##args)
63 #endif
64 #endif
65
66 #define TSP_RET_IF(expr)                       do { \
67        if (expr) {                                  \
68             TSP_ERROR("[%s] Return", #expr);        \
69             return;                                 \
70          }                                          \
71   } while (0)
72
73 #define TSP_RETV_IF(expr, val)                 do { \
74        if (expr) {                                  \
75             TSP_ERROR("[%s] Return value", #expr);  \
76             return (val);                           \
77          }                                          \
78   } while (0)
79 #define TSP_RETM_IF(expr, fmt, args ...)       do {               \
80        if (expr) {                                                \
81             TSP_ERROR("[%s] Return, message "fmt, #expr, ##args); \
82             return;                                               \
83          }                                                        \
84   } while (0)
85 #define TSP_RETVM_IF(expr, val, fmt, args ...) do {                     \
86        if (expr) {                                                      \
87             TSP_ERROR("[%s] Return value, message "fmt, #expr, ##args); \
88             return (val);                                               \
89          }                                                              \
90   } while (0)
91
92 #define TSP_CHECK(expr)                        TSP_RETM_IF(!(expr), "Invalid param")
93 #define TSP_CHECK_NULL(expr)                   TSP_RETVM_IF(!(expr), NULL, "Invalid param")
94 #define TSP_CHECK_FALSE(expr)                  TSP_RETVM_IF(!(expr), false, "Invalid param")
95 #define TSP_CHECK_VAL(expr, val)               TSP_RETVM_IF(!(expr), val, "Invalid param")
96
97 #define TSP_ASSERT(expr)                       do {                                                  \
98        if (!(expr)) {                                                                                \
99             TSP_ERROR("CRITICAL ERROR ########################################## CHECK BELOW ITEM"); \
100             assert(false);                                                                           \
101          }                                                                                           \
102   } while (0)
103
104 #endif /* __TSP_LOG_H__ */
105