PDK API Guide for AM65xx
enet_trace_priv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2020
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
40 #ifndef ENET_TRACE_PRIV_H_
41 #define ENET_TRACE_PRIV_H_
42 
43 /* ========================================================================== */
44 /* Include Files */
45 /* ========================================================================== */
46 
47 #include <stdint.h>
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 /* ========================================================================== */
56 /* Macros */
57 /* ========================================================================== */
58 
68 void EnetTrace_trace(EnetTrace_TraceLevel globalLevel,
70  const char *fmt,
71  ...);
72 
74 #if (ENET_CFG_TRACE_LEVEL > ENET_CFG_TRACE_LEVEL_NONE)
75 #if (ENET_CFG_TRACE_FORMAT == ENET_CFG_FORMAT_FUNC)
76 /* Trace prefix: "<func>: fmt" */
77 #define ENETTRACE_trace(globalLevel, level, fmt, ...) \
78  EnetTrace_trace((globalLevel), (level), \
79  "%s: " fmt, \
80  __func__, ## __VA_ARGS__)
81 
82 #elif (ENET_CFG_TRACE_FORMAT == ENET_CFG_FORMAT_FILE)
83 /* Trace prefix: "<file>: <line>: fmt" */
84 #define ENETTRACE_trace(globalLevel, level, fmt, ...) \
85  EnetTrace_trace((globalLevel), (level), \
86  "%s: %d: " fmt, \
87  __FILE__, __LINE__, ## __VA_ARGS__)
88 #else
89 /* Trace prefix: "<file>: <line>: <func>: fmt" */
90 #define ENETTRACE_trace(globalLevel, level, fmt, ...) \
91  EnetTrace_trace((globalLevel), (level), \
92  "%s: %d: %s: " fmt, \
93  __FILE__, __LINE__, __func__, ## __VA_ARGS__)
94 #endif
95 #else /* ENET_CFG_TRACE_LEVEL_NONE */
96 #define ENETTRACE_trace(globalLevel, level, fmt, ...)
97 #endif
98 
102 #if (ENET_CFG_TRACE_LEVEL >= ENET_CFG_TRACE_LEVEL_ERROR)
103 #define ENETTRACE_ERR(fmt, ...) ENETTRACE_trace(gEnetTrace_runtimeLevel, \
104  ENET_TRACE_ERROR, \
105  fmt, \
106  ## __VA_ARGS__)
107 /* TODO: Replace the below #ifdef with a method applicable for both C & C++ */
112 #ifdef __cplusplus
113 #define ENETTRACE_ERR_IF(cond, ...) ((cond) ? ENETTRACE_ERR(__VA_ARGS__) : void())
114 #else
115 #define ENETTRACE_ERR_IF(cond, ...) ((cond) ? ENETTRACE_ERR(__VA_ARGS__) : 0U)
116 #endif
117 #else
118 #define ENETTRACE_ERR(fmt, ...)
119 #define ENETTRACE_ERR_IF(cond, ...)
120 #endif
121 
125 #if (ENET_CFG_TRACE_LEVEL >= ENET_CFG_TRACE_LEVEL_WARN)
126 #define ENETTRACE_WARN(fmt, ...) ENETTRACE_trace(gEnetTrace_runtimeLevel, \
127  ENET_TRACE_WARN, \
128  fmt, \
129  ## __VA_ARGS__)
130 
134 #ifdef __cplusplus
135 #define ENETTRACE_WARN_IF(cond, ...) ((cond) ? ENETTRACE_WARN(__VA_ARGS__) : void())
136 #else
137 #define ENETTRACE_WARN_IF(cond, ...) ((cond) ? ENETTRACE_WARN(__VA_ARGS__) : 0U)
138 #endif
139 #else
140 #define ENETTRACE_WARN(fmt, ...)
141 #define ENETTRACE_WARN_IF(cond, ...)
142 #endif
143 
152 #if (ENET_CFG_TRACE_LEVEL >= ENET_CFG_TRACE_LEVEL_INFO)
153 #define ENETTRACE_INFO(fmt, ...) ENETTRACE_trace(gEnetTrace_runtimeLevel, \
154  ENET_TRACE_INFO, \
155  fmt, \
156  ## __VA_ARGS__)
157 
161 #ifdef __cplusplus
162 #define ENETTRACE_INFO_IF(cond, ...) ((cond) ? ENETTRACE_INFO(__VA_ARGS__) : void())
163 #else
164 #define ENETTRACE_INFO_IF(cond, ...) ((cond) ? ENETTRACE_INFO(__VA_ARGS__) : 0U)
165 #endif
166 #else
167 #define ENETTRACE_INFO(fmt, ...)
168 #define ENETTRACE_INFO_IF(cond, ...)
169 #endif
170 
180 #if (ENET_CFG_TRACE_LEVEL >= ENET_CFG_TRACE_LEVEL_DEBUG)
181 #define ENETTRACE_DBG(fmt, ...) ENETTRACE_trace(gEnetTrace_runtimeLevel, \
182  ENET_TRACE_DEBUG, \
183  fmt, \
184  ## __VA_ARGS__)
185 
189 #ifdef __cplusplus
190 #define ENETTRACE_DBG_IF(cond, ...) ((cond) ? ENETTRACE_DBG(__VA_ARGS__) : void())
191 #else
192 #define ENETTRACE_DBG_IF(cond, ...) ((cond) ? ENETTRACE_DBG(__VA_ARGS__) : 0U)
193 #endif
194 #else
195 #define ENETTRACE_DBG(fmt, ...)
196 #define ENETTRACE_DBG_IF(cond, ...)
197 #endif
198 
209 #if (ENET_CFG_TRACE_LEVEL >= ENET_CFG_TRACE_LEVEL_VERBOSE)
210 #define ENETTRACE_VERBOSE(fmt, ...) ENETTRACE_trace(gEnetTrace_runtimeLevel, \
211  ENET_TRACE_VERBOSE, \
212  fmt, \
213  ## __VA_ARGS__)
214 
218 #ifdef __cplusplus
219 #define ENETTRACE_VERBOSE_IF(cond, ...) ((cond) ? ENETTRACE_VERBOSE(__VA_ARGS__) : void())
220 #else
221 #define ENETTRACE_VERBOSE_IF(cond, ...) ((cond) ? ENETTRACE_VERBOSE(__VA_ARGS__) : 0U)
222 #endif
223 #else
224 #define ENETTRACE_VERBOSE(fmt, ...)
225 #define ENETTRACE_VERBOSE_IF(cond, ...)
226 #endif
227 
233 #define ENETTRACE_VAR(var) ((var) = (var))
234 
235 /* ========================================================================== */
236 /* Structures and Enums */
237 /* ========================================================================== */
238 
239 /* None */
240 
241 /* ========================================================================== */
242 /* Global Variables Declarations */
243 /* ========================================================================== */
244 
249 
250 /* ========================================================================== */
251 /* Function Declarations */
252 /* ========================================================================== */
253 
263 
272 
273 /* ========================================================================== */
274 /* Deprecated Function Declarations */
275 /* ========================================================================== */
276 
277 /* None */
278 
279 #ifdef __cplusplus
280 }
281 #endif
282 
283 #endif /* ENET_TRACE_H_ */
This file contains the basic types using across the Enet driver.
EnetTrace_TraceLevel EnetTrace_setLevel(EnetTrace_TraceLevel level)
Set runtime trace level.
EnetTrace_TraceLevel EnetTrace_getLevel(void)
Get runtime trace level.
EnetTrace_TraceLevel gEnetTrace_runtimeLevel
Enabled runtime trace level.
EnetTrace_TraceLevel
Enumerates the types of trace level.
Definition: enet_trace.h:108
void EnetTrace_trace(EnetTrace_TraceLevel globalLevel, EnetTrace_TraceLevel level, const char *fmt,...)
Log a trace message if log level is enabled.
This file contains the type definitions and helper macros for the Enet Trace interface.