3557672cb12c1f4b316ac30f8dc1fa54ff4db232
[o-du/phy.git] / fhi_lib / app / src / debug.h
1 /******************************************************************************\r
2 *\r
3 *   Copyright (c) 2019 Intel.\r
4 *\r
5 *   Licensed under the Apache License, Version 2.0 (the "License");\r
6 *   you may not use this file except in compliance with the License.\r
7 *   You may obtain a copy of the License at\r
8 *\r
9 *       http://www.apache.org/licenses/LICENSE-2.0\r
10 *\r
11 *   Unless required by applicable law or agreed to in writing, software\r
12 *   distributed under the License is distributed on an "AS IS" BASIS,\r
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 *   See the License for the specific language governing permissions and\r
15 *   limitations under the License.\r
16 *\r
17 *******************************************************************************/\r
18 \r
19 /**\r
20  * @brief\r
21  * @file\r
22  * @ingroup\r
23  * @author Intel Corporation\r
24  **/\r
25 \r
26 #ifndef _SAMPLEAPP__DEBUG_H_\r
27 #define _SAMPLEAPP__DEBUG_H_\r
28 \r
29 #include <stdio.h>\r
30 \r
31 #include "config.h"\r
32 \r
33 #define MAX_FILE_NAME_LEN (512)\r
34 #define MAX_PATH_NAME_LEN (1024)\r
35 \r
36 #ifdef _DEBUG\r
37     #define log_dbg(fmt, ...)                       \\r
38         fprintf(stderr,                     \\r
39             "DEBUG: %s(%d): " fmt "\n",             \\r
40             __FILE__,                       \\r
41             __LINE__, ##__VA_ARGS__)\r
42 #else\r
43     #define log_dbg(fmt, ...)\r
44 #endif\r
45 \r
46 #if defined(_DEBUG) || defined(_VERBOSE)\r
47     #define log_wrn(fmt, ...)                               \\r
48         fprintf(                                            \\r
49             stderr,                                     \\r
50             "WARNING: %s(%d): " fmt "\n",                   \\r
51             __FILE__,                                       \\r
52             __LINE__, ##__VA_ARGS__)\r
53 #else\r
54     #define log_dbg(fmt, ...)\r
55     #define log_wrn(fmt, ...)\r
56 #endif\r
57 \r
58 \r
59 #define log_err(fmt, ...)                       \\r
60     fprintf(stderr,                     \\r
61         "ERROR: %s(%d): " fmt "\n",             \\r
62         __FILE__,                       \\r
63         __LINE__, ##__VA_ARGS__)\r
64 \r
65 \r
66 inline void ShowData(void* ptr, unsigned int size)\r
67 {\r
68     uint8_t *d =  (uint8_t *)ptr;\r
69     unsigned int i;\r
70 \r
71     for(i = 0; i < size; i++)\r
72     {\r
73         if ( !(i & 0xf) )\r
74             printf("\n");\r
75         printf("%02x ", d[i]);\r
76     }\r
77     printf("\n");\r
78 }\r
79 \r
80 \r
81 #endif /* _SAMPLEAPP__DEBUG_H_ */\r