2016-07-12 19:59:43 +00:00
|
|
|
#ifndef _LOG_H_
|
|
|
|
#define _LOG_H_
|
|
|
|
|
2022-08-05 06:52:03 +00:00
|
|
|
#include <err.h>
|
2018-06-14 14:36:34 +00:00
|
|
|
#include "kpatch.h"
|
2017-01-23 20:42:35 +00:00
|
|
|
|
2016-07-12 19:59:43 +00:00
|
|
|
/* Files that include log.h must define loglevel and childobj */
|
|
|
|
extern enum loglevel loglevel;
|
|
|
|
extern char *childobj;
|
|
|
|
|
|
|
|
#define ERROR(format, ...) \
|
2022-11-22 20:53:09 +00:00
|
|
|
errx(EXIT_STATUS_ERROR, "ERROR: %s: %s: %d: " format, childobj, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
2016-07-12 19:59:43 +00:00
|
|
|
|
|
|
|
#define log_debug(format, ...) log(DEBUG, format, ##__VA_ARGS__)
|
|
|
|
#define log_normal(format, ...) log(NORMAL, "%s: " format, childobj, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
#define log(level, format, ...) \
|
|
|
|
({ \
|
|
|
|
if (loglevel <= (level)) \
|
|
|
|
printf(format, ##__VA_ARGS__); \
|
|
|
|
})
|
|
|
|
|
|
|
|
enum loglevel {
|
|
|
|
DEBUG,
|
|
|
|
NORMAL
|
|
|
|
};
|
|
|
|
#endif /* _LOG_H_ */
|