hc
2024-03-26 e9199a72d842cbda78ac614eee5db7cdaa6f2530
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef __WL_DEBUG_H__
#define __WL_DEBUG_H__
#include <pthread.h>
 
extern pthread_mutex_t wl_dbg_mutex;
 
#define    WL_LOG_NONE     0
#define    WL_LOG_ERROR     1
#define    Wl_LOG_INFO     2
#define    WL_LOG_DEBUG     3
#define    WL_LOG_DUMP     4
 
#ifndef WL_LOG_LEVEL
#define WL_LOG_LEVEL    WL_LOG_ERROR    
#endif
 
#if WL_LOG_LEVEL >= WL_LOG_ERROR
#define WL_ERR(fmt, ...) \
           do { \
               pthread_mutex_lock(&wl_dbg_mutex); \
               printf("[WL][ERROR] %s, " fmt, __FUNCTION__, ##__VA_ARGS__); \
               pthread_mutex_unlock(&wl_dbg_mutex); \
           } while(0)
#else
#define WL_ERR(fmt, ...)
#endif
 
#if WL_LOG_LEVEL >= Wl_LOG_INFO
#define WL_INFO(fmt, ...) \
           do { \
               pthread_mutex_lock(&wl_dbg_mutex); \
               printf("[WL][INFO] %s, " fmt, __FUNCTION__, ##__VA_ARGS__); \
               pthread_mutex_unlock(&wl_dbg_mutex); \
           } while(0)
#else
#define WL_INFO(fmt, ...)
#endif
 
#if WL_LOG_LEVEL >= WL_LOG_DEBUG
#define WL_DBG(fmt, ...) \
           do { \
               pthread_mutex_lock(&wl_dbg_mutex); \
               printf("[WL][DEBUG] %s, " fmt, __FUNCTION__, ##__VA_ARGS__); \
               pthread_mutex_unlock(&wl_dbg_mutex); \
           } while(0)
#else
#define WL_DBG(fmt, ...)
#endif
 
#if WL_LOG_LEVEL >= WL_LOG_DUMP
#define WL_DUMP(buf, len) \
           do { \
               int i; \
               uint8_t *tmp = (uint8_t*)buf; \
               pthread_mutex_lock(&wl_dbg_mutex); \
               printf("[WL][DUMP] %s, " #buf "[%d] =", __FUNCTION__, (int)len); \
               for (i = 0; i < len; i++) \
               { \
                   if ((i % 16) == 0) \
                   { \
                       printf("\n"); \
                   } \
                   printf("%02x", tmp[i]); \
               } \
               printf("\n"); \
               pthread_mutex_unlock(&wl_dbg_mutex); \
           } while(0)
#else
#define WL_DUMP(buf, len)
#endif
 
 
#endif /* __WL_DEBUG_H__ */