22 #include "cne_build_config.h"
28 #define foreach_cndp_log_level \
34 _(6, NOTICE, notice) \
53 #define _(n, uc, lc) CNE_LOG_##uc = n,
54 foreach_cndp_log_level
110 CNDP_API
int cne_log(uint32_t level,
const char *func,
int line,
const char *format, ...)
112 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2))
113 __attribute__((cold))
116 __attribute__((format(printf, 4, 5)));
132 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2))
133 __attribute__((cold))
136 __attribute__((format(printf, 1, 2)));
165 CNDP_API
int cne_vlog(uint32_t level,
const char *func,
int line,
const char *format, va_list ap)
166 __attribute__((format(printf, 4, 0)));
184 #define CNE_LOG(f, ...) cne_log(CNE_LOG_##f, __func__, __LINE__, #f ": " __VA_ARGS__)
198 #define CNE_PRINT(f, args...) cne_print(f, ##args)
203 #define CNE_EMERG(...) CNE_LOG(EMERG, __VA_ARGS__)
204 #define CNE_ALERT(...) CNE_LOG(ALERT, __VA_ARGS__)
205 #define CNE_CRIT(...) CNE_LOG(CRIT, __VA_ARGS__)
206 #define CNE_ERR(...) CNE_LOG(ERR, __VA_ARGS__)
207 #define CNE_WARN(...) CNE_LOG(WARNING, __VA_ARGS__)
208 #define CNE_NOTICE(...) CNE_LOG(NOTICE, __VA_ARGS__)
209 #define CNE_INFO(...) CNE_LOG(INFO, __VA_ARGS__)
210 #define CNE_DEBUG(...) CNE_LOG(DEBUG, __VA_ARGS__)
222 #define CNE_ERR_RET_VAL(_val, ...) \
224 CNE_ERR(__VA_ARGS__); \
238 #define CNE_RET(...) CNE_ERR_RET_VAL(, __VA_ARGS__)
250 #define CNE_ERR_RET(...) CNE_ERR_RET_VAL(-1, __VA_ARGS__)
262 #define CNE_NULL_RET(...) CNE_ERR_RET_VAL(NULL, __VA_ARGS__)
273 #define CNE_ERR_GOTO(lbl, ...) \
275 CNE_ERR(__VA_ARGS__); \
300 #define cne_panic(format, args...) __cne_panic(__func__, __LINE__, format "\n", ##args)
315 #define cne_exit(format, args...) __cne_exit(__func__, __LINE__, format "\n", ##args)
317 #if CNE_ENABLE_ASSERT
327 #define CNE_ASSERT(exp) CNE_VERIFY(exp)
329 #define CNE_ASSERT(exp) \
342 #define CNE_VERIFY(exp) \
344 if (unlikely(!(exp))) \
345 cne_panic("assert \"%s\" failed", #exp); \
354 CNDP_API
void __cne_panic(
const char *funcname,
int line,
const char *format, ...)
356 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2))
357 __attribute__((cold))
360 __attribute__((noreturn)) __attribute__((format(printf, 3, 4)));
368 CNDP_API
void __cne_exit(
const char *func,
int line,
const char *format, ...)
370 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2))
371 __attribute__((cold))
374 __attribute__((noreturn)) __attribute__((format(printf, 3, 4)));
CNDP_API int cne_vlog(uint32_t level, const char *func, int line, const char *format, va_list ap)
CNDP_API int cne_log(uint32_t level, const char *func, int line, const char *format,...)
CNDP_API void __cne_panic(const char *funcname, int line, const char *format,...)
CNDP_API int cne_log_set_level_str(char *log_level)
CNDP_API uint32_t cne_log_get_level(void)
CNDP_API int cne_print(const char *format,...)
CNDP_API void cne_dump_stack(void)
CNDP_API void cne_log_set_level(uint32_t level)
CNDP_API void __cne_exit(const char *func, int line, const char *format,...)