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