dc621a786bc3ba841821c06e2a67f29c0058dbfe
[apps/native/sample/adventure.git] / new / inc / log.h
1 #ifndef __MOMENT_LOG_H__
2 #define __MOMENT_LOG_H__
3
4 #include <dlog.h>
5
6 #undef LOG_TAG
7 #define LOG_TAG "ADVENTURE"
8
9 #define COLOR_RED           "\033[0;40;31m"
10 #define COLOR_LIGHTBLUE     "\033[1;40;34m"
11 #define COLOR_YELLOW        "\033[1;40;33m"
12 #define COLOR_END           "\033[0;m"
13 #define COLOR_GRAY          "\033[1;40;30m"
14 #define COLOR_MAGENTA       "\033[1;35m"
15
16 #if !defined(_D)
17 #define _D(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, COLOR_YELLOW "[%s:%d]" fmt COLOR_END"\n", __func__, __LINE__, ##arg)
18 #endif
19
20 #if !defined(_W)
21 #define _W(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, COLOR_GRAY "[%s:%d]" fmt COLOR_END"\n", __func__, __LINE__, ##arg)
22 #endif
23
24 #if !defined(_E)
25 #define _E(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, COLOR_RED "[%s:%d]" fmt COLOR_END"\n", __func__, __LINE__, ##arg)
26 #endif
27
28 #define retv_if(expr, val) do { \
29         if(expr) { \
30                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
31                 return (val); \
32         } \
33 } while (0)
34
35 #define ret_if(expr) do { \
36         if(expr) { \
37                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
38                 return; \
39         } \
40 } while (0)
41
42 #define goto_if(expr, val) do { \
43         if(expr) { \
44                 _E("(%s) -> goto", #expr); \
45                 goto val; \
46         } \
47 } while (0)
48
49 #define break_if(expr) { \
50         if(expr) { \
51                 _E("(%s) -> break", #expr); \
52                 break; \
53         } \
54 }
55
56 #define continue_if(expr) { \
57         if(expr) { \
58                 _E("(%s) -> continue", #expr); \
59                 continue; \
60         } \
61 }
62
63 #endif                          /* __MOMENT_LOG_H__ */