1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #ifndef WL_MSG_H
- #define WL_MSG_H
- #include <stdio.h>
- #include <stdarg.h>
- #include "misc.h"
- enum {
- MSG_ERROR = 0,
- MSG_WARNING,
- MSG_INFO,
- MSG_DEBUG,
- MSG_LEVEL_MAX
- };
- void msg(int level, const char *format, ...);
- void set_loglevel(int level);
- void hexdump(const char *p, unsigned int len);
- static inline void debug_printf(const char* fmt, ...)
- {
- va_list arg_list;
- va_start(arg_list, fmt);
- msg(MSG_INFO, fmt);
- va_end(arg_list);
- }
- #define ASSERT(cond) ASSERT_((cond), __FILE__, __LINE__)
- #define ASSERT_(cond, file, line) ASSERT__(cond, file, line)
- #define ASSERT__(cond, file, line) \
- do { \
- if (!(cond)) { \
- msg(MSG_ERROR, "assert failure in: " \
- #file " line:" #line \
- " for: " #cond "\n"); \
- for (;;) { \
- } \
- } \
- } while (0)
- #define DP(on, varformat) (on) ? debug_printf varformat : (void) 0
- #define DX() DP(1, ("X %s line %d (%s())\n", __BASE_FILE__, __LINE__, __FUNCTION__))
- #endif
|