1. Changed license year
[apps/home/mobileprint.git] / mobileprint / include / pts_debug.h
1 /*
2 *  Mobileprint
3 *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
6 * Licensed under the Flora License, Version 1.1 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9
10 * http://floralicense.org/license/
11
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20 #ifndef __PTS_DEBUG_H__
21 #define __PTS_DEBUG_H__
22
23 __BEGIN_DECLS
24
25 #define PTS_DLOG_OUT
26
27 #ifdef PTS_DLOG_OUT
28 #undef LOG_TAG
29 #define LOG_TAG "MOBILEPRINT"
30 #include <dlog.h>
31
32 #define PTS_VERBOSE(fmt, args...) \
33         LOGV(fmt, ##args)
34 #define PTS_INFO(fmt, args...) \
35         LOGI(fmt, ##args)
36 #define PTS_DEBUG(fmt, args...) \
37         LOGD(fmt, ##args)
38 #define PTS_WARN(fmt, args...) \
39         LOGW(fmt, ##args)
40 #define PTS_ERROR(fmt, args...) \
41         LOGE(fmt, ##args)
42 #define PTS_FATAL(fmt, args...) \
43         LOGF(fmt, ##args)
44
45 #define PTS_RET_IF(expr, fmt, args...) \
46         do { \
47                 if(expr) { \
48                         PTS_DEBUG("[%s] Return, message "fmt, #expr, ##args );\
49                         return; \
50                 } \
51         } while (0)
52
53 #define PTS_RETV_IF(expr, val, fmt, args...) \
54         do { \
55                 if(expr) { \
56                         PTS_DEBUG("[%s] Return value, message "fmt, #expr, ##args );\
57                         return (val); \
58                 } \
59         } while (0)
60
61 #define PTS_TRACE_BEGIN PTS_INFO("ENTER FUNCTION: %s\n", __FUNCTION__);
62 #define PTS_TRACE_END PTS_INFO("EXIT FUNCTION: %s\n", __FUNCTION__);
63
64 #else
65 #define PTS_PRT(prio, fmt, arg...) \
66         do { fprintf((prio ? stderr : stdout), "%s:%s(%d)>"fmt"\n", __FILE__, __func__, __LINE__, ##arg); } while (0)
67
68 #define DBG(fmt, arg...) \
69         do { \
70                 printf("%s:%s(%d)>"fmt"\n", __FILE__, __func__, __LINE__, ##arg); \
71         } while (0)
72
73 #define PTS_RET_IF(expr, fmt, args...) \
74         do { \
75                 if(expr) { \
76                         PTS_PRT("[%s] Return, message "fmt, #expr, ##args );\
77                         return; \
78                 } \
79         } while (0)
80
81 #define PTS_RETV_IF(expr, val, fmt, args...) \
82         do { \
83                 if(expr) { \
84                         PTS_PRT("[%s] Return value, message "fmt, #expr, ##args );\
85                         return (val); \
86                 } \
87         } while (0)
88
89 #define PTS_TRACE_BEGIN PTS_PRT(0, "%s enter\n", __FUNCTION__)
90 #define PTS_TRACE_END PTS_PRT(0, "%s leave\n", __FUNCTION__)
91
92 #endif
93
94 #define PTS_FILE_EXISTS(path) \
95         (path && (1 == ecore_file_exists(path)) && (ecore_file_size(path) > 0))
96
97 #define PTS_IF_DEL_TIMER(timer) \
98         do { \
99                 if(timer) { \
100                         ecore_timer_del(timer); \
101                         timer = NULL; \
102                 } \
103         } while (0)
104
105 #define PTS_IF_DEL_IDLER(idler) \
106         do { \
107                 if(idler) { \
108                         ecore_idler_del(idler); \
109                         idler = NULL; \
110                 } \
111         } while (0)
112
113
114 #define PTS_IF_DEL_OBJ(obj) \
115         do { \
116                 if(obj) { \
117                         evas_object_del(obj); \
118                         obj = NULL; \
119                 } \
120         } while (0)
121
122 #define PTS_IF_FREE_MEM(mem) \
123         do { \
124                 if(mem) { \
125                         free(mem); \
126                         mem = NULL; \
127                 } \
128         } while (0)
129
130 __END_DECLS
131
132 #endif /* __PTS_DEBUG_H__ */