Fix sign-compare
[platform/core/multimedia/libmedia-service.git] / include / media-svc-debug.h
1 /*
2  * libmedia-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (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://www.apache.org/licenses/LICENSE-2.0
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
21
22 #ifndef _MEDIA_SVC_DEBUG_H_
23 #define _MEDIA_SVC_DEBUG_H_
24
25 #include <dlog.h>
26 #include <errno.h>
27
28 #ifdef LOG_TAG
29 #undef LOG_TAG
30 #endif
31
32 #define LOG_TAG "MEDIA_SERVICE"
33
34 #define FONT_COLOR_RESET        "\033[0m"
35 #define FONT_COLOR_RED          "\033[31m"
36 #define FONT_COLOR_GREEN        "\033[32m"
37 #define FONT_COLOR_YELLOW       "\033[33m"
38 #define FONT_COLOR_BLUE "\033[34m"
39 #define FONT_COLOR_PURPLE       "\033[35m"
40 #define FONT_COLOR_CYAN "\033[36m"
41 #define FONT_COLOR_GRAY "\033[37m"
42
43 #define media_svc_debug(fmt, arg...) do { \
44                         LOGD(FONT_COLOR_RESET"" fmt "", ##arg); \
45                 } while (0)
46
47 #define media_svc_error(fmt, arg...) do { \
48                         LOGE(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET, ##arg); \
49                 } while (0)
50
51 #define media_svc_debug_fenter() do { \
52                         LOGD(FONT_COLOR_YELLOW"<ENTER>" FONT_COLOR_RESET); \
53                 } while (0)
54
55 #define media_svc_debug_fleave() do { \
56                         LOGD(FONT_COLOR_YELLOW"<LEAVE>" FONT_COLOR_RESET); \
57                 } while (0)
58
59 #define media_svc_retm_if(expr, fmt, arg...) do { \
60                         if (expr) { \
61                                 LOGE(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET, ##arg); \
62                                 return; \
63                         } \
64                 } while (0)
65 #define media_svc_retv_if(expr, val) do { \
66                         if (expr) { \
67                                 LOGE(FONT_COLOR_RED"" FONT_COLOR_RESET);     \
68                                 return (val); \
69                         } \
70                 } while (0)
71 #define media_svc_retvm_if(expr, val, fmt, arg...) do { \
72                         if (expr) { \
73                                 LOGE(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET, ##arg); \
74                                 return (val); \
75                         } \
76                 } while (0)
77
78 #define media_svc_retv_del_if(expr, val, p_str) do { \
79                         if (expr) { \
80                                 LOGE(FONT_COLOR_RED"" FONT_COLOR_RESET);     \
81                                 _media_svc_destroy_content_info(p_str);        \
82                                 return (val); \
83                         } \
84                 } while (0)
85
86 #define media_svc_sec_debug(fmt, arg...) do { \
87                         SECURE_LOGI(FONT_COLOR_GREEN"" fmt "" FONT_COLOR_RESET, ##arg); \
88                 } while (0)
89
90 #define media_svc_sec_warn(fmt, arg...) do { \
91                         SECURE_LOGW(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET, ##arg); \
92                 } while (0)
93
94 #define media_svc_sec_error(fmt, arg...) do { \
95                         SECURE_LOGE(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET, ##arg); \
96                 } while (0)
97
98 #define ERR_BUF_LENGHT 256
99 #define media_svc_stderror(fmt) do { \
100                         char media_svc_stderror_buf[ERR_BUF_LENGHT] = {0,}; \
101                         strerror_r(errno, media_svc_stderror_buf, ERR_BUF_LENGHT); \
102                         LOGE(FONT_COLOR_RED""fmt" : standard error= [%s]", media_svc_stderror_buf); \
103                 } while (0)
104
105 #endif /*_MEDIA_SVC_DEBUG_H_*/