Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / service / resource-hosting / SampleApp / tizen / sampleConsumer / src / oicapp-log.h
1 /*
2  * Copyright (c) 2010 Samsung Electronics, Inc.
3  * All rights reserved.
4  *
5  * This software is a confidential and proprietary information
6  * of Samsung Electronics, Inc. ("Confidential Information").  You
7  * shall not disclose such Confidential Information and shall use
8  * it only in accordance with the terms of the license agreement
9  * you entered into with Samsung Electronics.
10  */
11 #ifndef __OICAPP_LOG_H__
12 #define __OICAPP_LOG_H__
13
14 #define TIZEN_DEBUG_ENABLE
15 #define LOG_TAG "OIC_TEST"
16 #include <dlog.h>
17
18 #define LOG_COLOR_RED       "\033[0;31m"
19 #define LOG_COLOR_BROWN     "\033[0;33m"
20 #define LOG_COLOR_BLUE      "\033[0;34m"
21 #define LOG_COLOR_END       "\033[0;m"
22
23
24 #if 1
25 #define _DBG(fmt, arg...) SLOGD(fmt, ##arg)
26 #define _INFO(fmt, arg...) SLOGI(fmt, ##arg)
27 #define _WARN(fmt, arg...) SLOGW(fmt, ##arg)
28 #define _ERR(fmt, arg...) SLOGE(fmt, ##arg)
29 #else
30 #define _DBG(fmt, arg...) \
31     printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
32 #define _INFO(fmt, arg...) \
33     printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
34 #define _WARN(fmt, arg...) \
35     printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
36 #define _ERR(fmt, arg...) \
37     printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
38 #endif
39
40 #define DBG(fmt, arg...) _DBG(fmt, ##arg)
41 #define WARN(fmt, arg...) _WARN(LOG_COLOR_BROWN fmt LOG_COLOR_END, ##arg)
42 #define ERR(fmt, arg...) _ERR(LOG_COLOR_RED fmt LOG_COLOR_END, ##arg)
43 #define INFO(fmt, arg...) _INFO(LOG_COLOR_BLUE fmt LOG_COLOR_END, ##arg)
44
45 #define ret_if(expr) \
46     do { \
47         if (expr) { \
48             ERR("(%s)", #expr); \
49             return; \
50         }\
51     } while(0)
52 #define retv_if(expr, val) \
53     do {\
54         if (expr) { \
55             ERR("(%s)", #expr); \
56             return (val); \
57         } \
58     } while(0)
59 #define retm_if(expr, fmt, arg...) \
60     do {\
61         if (expr) { \
62             ERR(fmt, ##arg); \
63             return; \
64         }\
65     } while(0)
66 #define retvm_if(expr, val, fmt, arg...) \
67     do {\
68         if (expr) { \
69             ERR(fmt, ##arg); \
70             return (val); \
71         } \
72     } while(0)
73 #define warn_if(expr) \
74     do { \
75         if (expr) { \
76             WARN("(%s)", #expr); \
77         } \
78     } while (0)
79
80
81 #endif //__OICAPP_LOG_H__
82