kpatch/kpatch-build/log.h
Josh Poimboeuf 92c178b6a3 create-diff-object: use errx() instead of err()
Otherwise on recent distros it appends the errno to the error message,
like:

  create-diff-object: ERROR: x86.o: kpatch_regenerate_special_section: 2633: Found 1 unsupported static call(s) in the patched code. Use KPATCH_STATIC_CALL() instead.: Success

which is not what we want in most cases.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
2022-11-30 12:58:31 -08:00

28 lines
637 B
C

#ifndef _LOG_H_
#define _LOG_H_
#include <err.h>
#include "kpatch.h"
/* Files that include log.h must define loglevel and childobj */
extern enum loglevel loglevel;
extern char *childobj;
#define ERROR(format, ...) \
errx(EXIT_STATUS_ERROR, "ERROR: %s: %s: %d: " format, childobj, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#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_ */