Update socket_info.
[platform/core/multimedia/libmedia-thumbnail.git] / src / include / util / media-thumb-debug.h
1 /*
2  * libmedia-thumbnail
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hyunjun Ko <zzoon.ko@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 #ifndef _MEDIA_THUMB_DEBUG_H_
23 #define _MEDIA_THUMB_DEBUG_H_
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <dlog.h>
28
29 #include <unistd.h>
30 #include <asm/unistd.h>
31 #include <errno.h>
32
33 #ifdef LOG_TAG
34 #undef LOG_TAG
35 #endif
36
37 #define LOG_TAG "MEDIA_THUMBNAIL"
38
39 static pid_t gettid(void)
40 {
41         return syscall(__NR_gettid);
42 }
43
44 #define FONT_COLOR_RESET    "\033[0m"
45 #define FONT_COLOR_RED      "\033[31m"
46 #define FONT_COLOR_GREEN    "\033[32m"
47 #define FONT_COLOR_YELLOW   "\033[33m"
48 #define FONT_COLOR_BLUE     "\033[34m"
49 #define FONT_COLOR_PURPLE   "\033[35m"
50 #define FONT_COLOR_CYAN     "\033[36m"
51 #define FONT_COLOR_GRAY     "\033[37m"
52
53 #define thumb_dbg(fmt, arg...)  do{ \
54                 LOGD(FONT_COLOR_RESET"[%d] " fmt "\n", gettid(), ##arg); \
55                 } while(0)
56
57 #define thumb_warn(fmt, arg...) do{ \
58                 LOGW(FONT_COLOR_GREEN"[%d] " fmt "\n", gettid(), ##arg); \
59                 } while(0)
60
61 #define thumb_err(fmt, arg...)  do{ \
62                  LOGE(FONT_COLOR_RED"[%d] " fmt "\n", gettid(), ##arg); \
63                 } while(0)
64
65 #define thumb_dbg_slog(fmt, arg...)     do{ \
66                 SECURE_LOGD(FONT_COLOR_RESET"[%d] " fmt "\n", gettid(), ##arg); \
67                 } while(0)
68
69 #define thumb_warn_slog(fmt, arg...)    do{ \
70                 SECURE_LOGW(FONT_COLOR_GREEN"[%d] " fmt "\n", gettid(), ##arg); \
71                 } while(0)
72
73
74 #define ERR_BUF_LENGHT 256
75 #define thumb_stderror(fmt) do { \
76                         char buf[ERR_BUF_LENGHT] = {0,}; \
77                         strerror_r(errno, buf, ERR_BUF_LENGHT); \
78                         LOGE(FONT_COLOR_RED fmt" : standard error [%s]", buf); \
79                 } while (0)
80
81 #ifdef _USE_LOG_FILE_
82 void thumb_init_file_debug();
83 void thumb_close_file_debug();
84 FILE* get_fp();
85 #define thumb_file_dbg(fmt,arg...)      fprintf( get_fp(), "[%s: %d] " fmt "\n", __FUNCTION__, __LINE__, ##arg)
86
87 #endif
88
89
90 #ifdef _PERFORMANCE_CHECK_
91 long
92 thumb_get_debug_time(void);
93 void
94 thumb_reset_debug_time(void);
95 void
96 thumb_print_debug_time(char* time_string);
97 void
98 thumb_print_debug_time_ex(long start, long end, const char* func_name, char* time_string);
99 #endif
100
101 #endif /*_MEDIA_THUMB_DEBUG_H_*/
102