41 lines
1.1 KiB
C
41 lines
1.1 KiB
C
#ifndef _MOON_CLOG_H
|
|
#define _MOON_CLOG_H
|
|
|
|
enum log_level
|
|
{
|
|
LOG_DEBUG,
|
|
LOG_INFO,
|
|
LOG_WARN,
|
|
LOG_ERROR
|
|
};
|
|
|
|
#define PRINTF_LIKE(n, m) __attribute__((format(printf, n, m)))
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
void clog_log(const char* function, enum log_level level, const char* message, ...) PRINTF_LIKE(3, 4);
|
|
void clog_logln(const char* function, enum log_level level, const char* message, ...) PRINTF_LIKE(3, 4);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#ifndef MODULE
|
|
#define kcommonlog(function, level, ...) clog_##function(__FUNCTION__, level, __VA_ARGS__)
|
|
#else
|
|
#define kcommonlog(function, level, ...) clog_##function(MODULE, level, __VA_ARGS__)
|
|
#endif
|
|
|
|
#define kdbg(...) kcommonlog(log, LOG_DEBUG, __VA_ARGS__)
|
|
#define kdbgln(...) kcommonlog(logln, LOG_DEBUG, __VA_ARGS__)
|
|
#define kinfo(...) kcommonlog(log, LOG_INFO, __VA_ARGS__)
|
|
#define kinfoln(...) kcommonlog(logln, LOG_INFO, __VA_ARGS__)
|
|
#define kwarn(...) kcommonlog(log, LOG_WARN, __VA_ARGS__)
|
|
#define kwarnln(...) kcommonlog(logln, LOG_WARN, __VA_ARGS__)
|
|
#define kerror(...) kcommonlog(log, LOG_ERROR, __VA_ARGS__)
|
|
#define kerrorln(...) kcommonlog(logln, LOG_ERROR, __VA_ARGS__)
|
|
|
|
#endif |