1. Changed license copyright year
[apps/core/preloaded/print-service.git] / include / pt_debug.h
1 /*
2 *       Printservice
3 *
4 * Copyright 2012-2013  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 __PT_DEBUG_H__
21 #define __PT_DEBUG_H__
22
23 #define PT_DLOG_OUT
24
25 #ifdef PT_DLOG_OUT
26 #undef LOG_TAG
27 #define LOG_TAG "PRINT_SERVICE"
28 #include <dlog.h>
29
30 #define PT_VERBOSE(fmt, args...) \
31         LOGV(fmt, ##args)
32 #define PT_INFO(fmt, args...) \
33         LOGI(fmt, ##args)
34 #define PT_DEBUG(fmt, args...) \
35         LOGD(fmt, ##args)
36 #define PT_WARN(fmt, args...) \
37         LOGW(fmt, ##args)
38 #define PT_ERROR(fmt, args...) \
39         LOGE(fmt, ##args)
40 #define PT_FATAL(fmt, args...) \
41         LOGF(fmt, ##args)
42
43 #define PT_RET_IF(expr, fmt, args...) \
44         do { \
45                 if(expr) { \
46                         PT_DEBUG("[%s] Return, message "fmt, #expr, ##args );\
47                         return; \
48                 } \
49         } while (0)
50
51 #define PT_RETV_IF(expr, val, fmt, args...) \
52         do { \
53                 if(expr) { \
54                         PT_DEBUG("[%s] Return value, message "fmt, #expr, ##args );\
55                         return (val); \
56                 } \
57         } while (0)
58
59 #define PT_IF_FREE_MEM(mem) \
60         do { \
61                 if(mem) { \
62                         free(mem);\
63                         mem = NULL; \
64                 } \
65         } while (0)
66
67 #define PRINT_SERVICE_FUNC_ENTER PT_INFO("ENTER FUNCTION: %s\n", __FUNCTION__);
68 #define PRINT_SERVICE_FUNC_LEAVE PT_INFO("EXIT FUNCTION: %s\n", __FUNCTION__);
69
70 #else /* PT_DLOG_OUT */
71
72 #define PT_PRT(prio, fmt, arg...) \
73         do { \
74                 fprintf((prio ? stderr : stdout), "%s:%s(%d)>"fmt"\n", __FILE__, __func__, __LINE__, ##arg);\
75         } while (0)
76
77 #define PT_DEBUG(fmt, arg...) \
78         do { \
79                 printf("%s:%s(%d)>"fmt"\n", __FILE__, __func__, __LINE__, ##arg); \
80         } while (0)
81
82 #define PRINT_SERVICE_FUNC_ENTER PT_PRT(0, "%s enter\n", __FUNCTION__);
83 #define PRINT_SERVICE_FUNC_LEAVE PT_PRT(0, "%s leave\n", __FUNCTION__);
84
85 #define PT_RET_IF(expr, fmt, args...) \
86         do { \
87                 if(expr) { \
88                         PT_DEBUG("[%s] Return, message "fmt, #expr, ##args );\
89                         return; \
90                 } \
91         } while (0)
92
93 #define PT_RETV_IF(expr, val, fmt, args...) \
94         do { \
95                 if(expr) { \
96                         PT_DEBUG("[%s] Return value, message "fmt, #expr, ##args );\
97                         return (val); \
98                 } \
99         } while (0)
100
101 #define PT_IF_FREE_MEM(mem) \
102         do { \
103                 if(mem) { \
104                         free(mem);\
105                         mem = NULL; \
106                 } \
107         } while (0)
108
109 #endif /* PT_DLOG_OUT */
110
111 #endif /* __PT_DEBUG_H__ */