Initial commit
[platform/adaptation/emulator/nfc-plugin-emul.git] / src / nfc_debug_private.h
1 /*
2  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #ifndef __NFC_DEBUG_PRIVATE_H__
19 #define __NFC_DEBUG_PRIVATE_H__
20
21 #include <stdio.h>
22 #include <errno.h>
23 #include <time.h>
24 #include <sys/time.h>
25 #include <libgen.h>
26
27 // below define should define before blog.h
28 #define LOG_TAG "NFC_PLUGIN_EMUL"
29
30 #include <dlog.h>
31
32 #define LOG_COLOR_RED           "\033[0;31m"
33 #define LOG_COLOR_GREEN         "\033[0;32m"
34 #define LOG_COLOR_BROWN         "\033[0;33m"
35 #define LOG_COLOR_BLUE          "\033[0;34m"
36 #define LOG_COLOR_PURPLE        "\033[0;35m"
37 #define LOG_COLOR_CYAN          "\033[0;36m"
38 #define LOG_COLOR_LIGHTBLUE "\033[0;37m"
39 #define LOG_COLOR_END           "\033[0;m"
40
41
42 #define DEBUG_MSG_PRINT_BUFFER(buffer,length) \
43 do {\
44         int i = 0;\
45         LOGD(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\
46         for(; i < length; i++)\
47         {\
48                 LOGD(LOG_COLOR_BLUE" [0x%x] "LOG_COLOR_END,buffer[i]);\
49         }\
50         LOGD(LOG_COLOR_BLUE""LOG_COLOR_END);\
51 }while(0)
52
53 #define DEBUG_MSG_PRINT_BUFFER_CHAR(buffer,length) \
54 do {\
55         int i = 0;\
56         LOGD(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\
57         for(; i < length; i++)\
58         {\
59                 LOGD(LOG_COLOR_BLUE" [%c] "LOG_COLOR_END,buffer[i]);\
60         }\
61         LOGD(LOG_COLOR_BLUE""LOG_COLOR_END);\
62 }while(0)
63
64 #define DEBUG_MSG(format,args...) \
65 do {\
66         LOGD(LOG_COLOR_CYAN" "format""LOG_COLOR_END, ##args);\
67 }while(0)
68
69 #define DEBUG_ERR_MSG(format,args...) \
70 do {\
71         LOGD(LOG_COLOR_RED" "format""LOG_COLOR_END, ##args);\
72 }while(0)
73
74 #define DEBUG_EMUL_BEGIN() \
75         do\
76     {\
77                 LOGD(LOG_COLOR_CYAN" BEGIN >>>>"LOG_COLOR_END); \
78     } while( 0 )
79
80 #define DEBUG_EMUL_END() \
81         do\
82     {\
83                 LOGD(LOG_COLOR_CYAN" END >>>>"LOG_COLOR_END); \
84     } \
85     while( 0 )
86
87 #define PROFILING(str) \
88 do{ \
89         struct timeval mytime;\
90         char buf[128]; = {0};\
91         memset(buf, 0x00, 128);\
92         gettimeofday(&mytime, NULL);\
93         char time_string[128] = {0,};\
94         sprintf(time_string, "%d.%4d", mytime.tv_sec, mytime.tv_usec);\
95         LOGD(str); \
96         LOGD("\t time = [%s]", time_string);\
97 }while(0)
98
99 #endif