RXI_LOGC_DEFAULT_LEVEL
This commit is contained in:
parent
a804dcb4b6
commit
e44bbdba86
26
src/log.h
26
src/log.h
@ -15,6 +15,11 @@
|
||||
|
||||
#define LOG_VERSION "0.1.0"
|
||||
|
||||
#ifndef RXI_LOGC_DEFAULT_LEVEL
|
||||
# define RXI_LOGC_DEFAULT_LEVEL 0
|
||||
#endif
|
||||
|
||||
|
||||
#if defined __GNUC__
|
||||
# define RXI_LOGC_PRINTF_ATTRIB(n, m) __attribute__((format(printf, n, m)))
|
||||
#else
|
||||
@ -36,14 +41,21 @@ typedef struct {
|
||||
typedef void (*log_LogFn)(log_Event *ev);
|
||||
typedef void (*log_LockFn)(bool lock, void *udata);
|
||||
|
||||
enum { LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL };
|
||||
enum {
|
||||
LOG_DEBUG = -10,
|
||||
LOG_TRACE = 0,
|
||||
LOG_INFO = 32,
|
||||
LOG_WARN = 64,
|
||||
LOG_ERROR = 96,
|
||||
LOG_FATAL = 128,
|
||||
};
|
||||
|
||||
#define log_trace(...) log_log(LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#define log_debug(...) log_log(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#define log_info(...) log_log(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#define log_warn(...) log_log(LOG_WARN, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#define log_error(...) log_log(LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#define log_fatal(...) log_log(LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__)
|
||||
#define log_debug(...) do { if (LOG_DEBUG >= RXI_LOGC_DEFAULT_LEVEL) log_log(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__) } while(0)
|
||||
#define log_trace(...) do { if (LOG_TRACE >= RXI_LOGC_DEFAULT_LEVEL) log_log(LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__) } while(0)
|
||||
#define log_info(...) do { if (LOG_INFO >= RXI_LOGC_DEFAULT_LEVEL) log_log(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__) } while(0)
|
||||
#define log_warn(...) do { if (LOG_WARN >= RXI_LOGC_DEFAULT_LEVEL) log_log(LOG_WARN, __FILE__, __LINE__, __VA_ARGS__) } while(0)
|
||||
#define log_error(...) do { if (LOG_ERROR >= RXI_LOGC_DEFAULT_LEVEL) log_log(LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__) } while(0)
|
||||
#define log_fatal(...) do { if (LOG_FATAL >= RXI_LOGC_DEFAULT_LEVEL) log_log(LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__) } while(0)
|
||||
|
||||
const char* log_level_string(int level);
|
||||
void log_set_lock(log_LockFn fn, void *udata);
|
||||
|
Loading…
Reference in New Issue
Block a user