increase code quality
[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         LOGE(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\
46         for (; i < length; i++)\
47                 LOGE(LOG_COLOR_BLUE" [0x%x] "LOG_COLOR_END, buffer[i]);\
48         LOGE(LOG_COLOR_BLUE""LOG_COLOR_END);\
49 } while (0)
50
51 #define DEBUG_MSG_PRINT_BUFFER_CHAR(buffer, length) \
52 do {\
53         int i = 0;\
54         LOGE(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\
55         for (; i < length; i++)\
56                 LOGE(LOG_COLOR_BLUE" [%c] "LOG_COLOR_END, buffer[i]);\
57         LOGE(LOG_COLOR_BLUE""LOG_COLOR_END);\
58 } while (0)
59
60 #define DEBUG_MSG(format, args...) \
61 do {\
62         LOGE(LOG_COLOR_CYAN" "format""LOG_COLOR_END, ##args);\
63 } while (0)
64
65 #define DEBUG_ERR_MSG(format, args...) \
66 do {\
67         LOGE(LOG_COLOR_RED" "format""LOG_COLOR_END, ##args);\
68 } while (0)
69
70 #define DEBUG_EMUL_BEGIN() \
71 do {\
72         LOGE(LOG_COLOR_CYAN" BEGIN >>>>"LOG_COLOR_END);\
73 } while (0)
74
75 #define DEBUG_EMUL_END() \
76 do {\
77         LOGE(LOG_COLOR_CYAN" END >>>>"LOG_COLOR_END);\
78 } while (0)
79
80 #define PROFILING(str) \
81 do {\
82         struct timeval mytime;\
83         char buf[128]; = {0};\
84         memset(buf, 0x00, 128);\
85         gettimeofday(&mytime, NULL);\
86         char time_string[128] = {0,};\
87         sprintf(time_string, "%d.%4d", mytime.tv_sec, mytime.tv_usec);\
88         LOGE(str);\
89         LOGE("\t time = [%s]", time_string);\
90 } while (0)
91
92 #endif