bd4f1e72b845f076be34a6e3a128ab7b8e5a083f
[platform/core/multimedia/libmedia-service.git] / src / include / common / media-svc-debug.h
1 /*
2  * libmedia-service
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22
23
24 #ifndef _MEDIA_SVC_DEBUG_H_
25 #define _MEDIA_SVC_DEBUG_H_
26
27 #include <dlog.h>
28 #include <errno.h>
29
30 #ifdef LOG_TAG
31 #undef LOG_TAG
32 #endif
33
34 #define LOG_TAG "MEDIA_SERVICE"
35
36 #define FONT_COLOR_RESET        "\033[0m"
37 #define FONT_COLOR_RED          "\033[31m"
38 #define FONT_COLOR_GREEN        "\033[32m"
39 #define FONT_COLOR_YELLOW       "\033[33m"
40 #define FONT_COLOR_BLUE "\033[34m"
41 #define FONT_COLOR_PURPLE       "\033[35m"
42 #define FONT_COLOR_CYAN "\033[36m"
43 #define FONT_COLOR_GRAY "\033[37m"
44
45 #define media_svc_debug(fmt, arg...) do { \
46                         LOGD(FONT_COLOR_RESET"" fmt "", ##arg); \
47                 } while (0)
48
49 #define media_svc_error(fmt, arg...) do { \
50                         LOGE(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET, ##arg); \
51                 } while (0)
52
53 #define media_svc_debug_fenter() do { \
54                         LOGD(FONT_COLOR_YELLOW"<ENTER>" FONT_COLOR_RESET); \
55                 } while (0)
56
57 #define media_svc_debug_fleave() do { \
58                         LOGD(FONT_COLOR_YELLOW"<LEAVE>" FONT_COLOR_RESET); \
59                 } while (0)
60
61 #define media_svc_retm_if(expr, fmt, arg...) do { \
62                         if (expr) { \
63                                 LOGE(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET, ##arg); \
64                                 return; \
65                         } \
66                 } while (0)
67 #define media_svc_retv_if(expr, val) do { \
68                         if (expr) { \
69                                 LOGE(FONT_COLOR_RED"" FONT_COLOR_RESET);     \
70                                 return (val); \
71                         } \
72                 } while (0)
73 #define media_svc_retvm_if(expr, val, fmt, arg...) do { \
74                         if (expr) { \
75                                 LOGE(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET, ##arg); \
76                                 return (val); \
77                         } \
78                 } while (0)
79
80 #define media_svc_retv_del_if(expr, val, p_str) do { \
81                         if (expr) { \
82                                 LOGE(FONT_COLOR_RED"" FONT_COLOR_RESET);     \
83                                 _media_svc_destroy_content_info(p_str);        \
84                                 return (val); \
85                         } \
86                 } while (0)
87
88 #define media_svc_sec_debug(fmt, arg...) do { \
89                         SECURE_LOGI(FONT_COLOR_GREEN"" fmt "" FONT_COLOR_RESET, ##arg); \
90                 } while (0)
91
92 #define media_svc_sec_warn(fmt, arg...) do { \
93                         SECURE_LOGW(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET, ##arg); \
94                 } while (0)
95
96 #define media_svc_sec_error(fmt, arg...) do { \
97                         SECURE_LOGE(FONT_COLOR_RED"" fmt "" FONT_COLOR_RESET, ##arg); \
98                 } while (0)
99
100 #define ERR_BUF_LENGHT 256
101 #define media_svc_stderror(fmt) do { \
102                         char media_svc_stderror_buf[ERR_BUF_LENGHT] = {0,}; \
103                         strerror_r(errno, media_svc_stderror_buf, ERR_BUF_LENGHT); \
104                         LOGE(FONT_COLOR_RED""fmt" : standard error= [%s]", media_svc_stderror_buf); \
105                 } while (0)
106
107 #endif /*_MEDIA_SVC_DEBUG_H_*/