45fc6130b23be10b09fcbd4cca6c3dd085ea0b93
[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 <stdio.h>
28 #include <stdlib.h>
29 #include <dlog.h>
30 #include <errno.h>
31
32 #ifdef LOG_TAG
33 #undef LOG_TAG
34 #endif
35
36 #define LOG_TAG "MEDIA_SERVICE"
37
38 #define FONT_COLOR_RESET        "\033[0m"
39 #define FONT_COLOR_RED          "\033[31m"
40 #define FONT_COLOR_GREEN        "\033[32m"
41 #define FONT_COLOR_YELLOW       "\033[33m"
42 #define FONT_COLOR_BLUE "\033[34m"
43 #define FONT_COLOR_PURPLE       "\033[35m"
44 #define FONT_COLOR_CYAN "\033[36m"
45 #define FONT_COLOR_GRAY "\033[37m"
46
47 #define media_svc_debug(fmt, arg...) do { \
48                         LOGD(FONT_COLOR_RESET""fmt"", ##arg); \
49                 } while (0)
50
51 #define media_svc_error(fmt, arg...) do { \
52                         LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
53                 } while (0)
54
55 #define media_svc_debug_fenter() do { \
56                         LOGD(FONT_COLOR_YELLOW"<ENTER>"FONT_COLOR_RESET); \
57                 } while (0)
58
59 #define media_svc_debug_fleave() do { \
60                         LOGD(FONT_COLOR_YELLOW"<LEAVE>"FONT_COLOR_RESET); \
61                 } while (0)
62
63 #define media_svc_retm_if(expr, fmt, arg...) do { \
64                         if (expr) { \
65                                 LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
66                                 return; \
67                         } \
68                 } while (0)
69 #define media_svc_retv_if(expr, val) do { \
70                         if (expr) { \
71                                 LOGE(FONT_COLOR_RED""FONT_COLOR_RESET);     \
72                                 return (val); \
73                         } \
74                 } while (0)
75 #define media_svc_retvm_if(expr, val, fmt, arg...) do { \
76                         if (expr) { \
77                                 LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
78                                 return (val); \
79                         } \
80                 } while (0)
81
82 #define media_svc_retv_del_if(expr, val, p_str) do { \
83                         if (expr) { \
84                                 LOGE(FONT_COLOR_RED""FONT_COLOR_RESET);     \
85                                 _media_svc_destroy_content_info(p_str);        \
86                                 return (val); \
87                         } \
88                 } while (0)
89
90 #define media_svc_sec_debug(fmt, arg...) do { \
91                         SECURE_LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \
92                 } while (0)
93
94 #define media_svc_sec_warn(fmt, arg...) do { \
95                         SECURE_LOGW(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
96                 } while (0)
97
98 #define media_svc_sec_error(fmt, arg...) do { \
99                         SECURE_LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
100                 } while (0)
101
102 #define ERR_BUF_LENGHT 256
103 #define media_svc_stderror(fmt) do { \
104                         char media_svc_stderror_buf[ERR_BUF_LENGHT] = {0,}; \
105                         strerror_r(errno, media_svc_stderror_buf, ERR_BUF_LENGHT); \
106                         LOGE(FONT_COLOR_RED""fmt" : standard error= [%s]", media_svc_stderror_buf); \
107                 } while (0)
108
109
110 #ifdef _PERFORMANCE_CHECK_
111 long
112 mediainfo_get_debug_time(void);
113 void
114 mediainfo_reset_debug_time(void);
115 void
116 mediainfo_print_debug_time(char *time_string);
117 void
118 mediainfo_print_debug_time_ex(long start, long end, const char *func_name, char *time_string);
119 #endif
120
121 #endif /*_MEDIA_SVC_DEBUG_H_*/