-
Notifications
You must be signed in to change notification settings - Fork 17
/
log.h
31 lines (25 loc) · 1017 Bytes
/
log.h
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
#ifndef _UWIFI_LOG_H
#define _UWIFI_LOG_H
/* these conincide with syslog levels for convenience */
enum loglevel { LL_CRIT = 2, LL_ERR, LL_WARN, LL_NOTICE, LL_INFO, LL_DEBUG };
/* application needs to provide */
void __attribute__((format(printf, 2, 3)))
log_out(enum loglevel, const char* fmt, ...);
void log_open(const char* name);
void log_close(void);
#ifndef DEBUG
#define DEBUG 0
#endif
#undef LOG_CRIT
#undef LOG_ERR
#define LOG_CRIT(...) log_out(LL_CRIT, __VA_ARGS__)
#define LOG_ERR(...) log_out(LL_ERR, __VA_ARGS__)
#define LOG_WARN(...) log_out(LL_WARN, __VA_ARGS__)
#define LOG_NOTI(...) log_out(LL_NOTICE, __VA_ARGS__)
#define LOG_INF(...) log_out(LL_INFO, __VA_ARGS__)
#define LOG_DBG(...) \
do { \
if (DEBUG) \
log_out(LL_DEBUG, __VA_ARGS__); \
} while (0)
#endif