Blob


1 /*
2 * This is free and unencumbered software released into the public domain.
3 *
4 * Anyone is free to copy, modify, publish, use, compile, sell, or
5 * distribute this software, either in source code form or as a compiled
6 * binary, for any purpose, commercial or non-commercial, and by any
7 * means.
8 */
10 #define LOG_ATTR_PRINTF(A, B) __attribute__((__format__ (printf, A, B)))
11 struct logger {
12 __dead void (*fatal)(int, const char *, ...) LOG_ATTR_PRINTF(2, 3);
13 __dead void (*fatalx)(int, const char *, ...) LOG_ATTR_PRINTF(2, 3);
14 void (*warn)(const char *, ...) LOG_ATTR_PRINTF(1, 2);
15 void (*warnx)(const char *, ...) LOG_ATTR_PRINTF(1, 2);
16 void (*info)(const char *, ...) LOG_ATTR_PRINTF(1, 2);
17 void (*debug)(const char *, ...) LOG_ATTR_PRINTF(1, 2);
18 };
19 #undef LOG_ATTR_PRINTF
21 extern const struct logger *logger, syslogger, dbglogger;
23 #define fatal(...) logger->fatal(1, __VA_ARGS__)
24 #define fatalx(...) logger->fatalx(1, __VA_ARGS__)
25 #define log_warn(...) logger->warn(__VA_ARGS__)
26 #define log_warnx(...) logger->warnx(__VA_ARGS__)
27 #define log_info(...) logger->info(__VA_ARGS__)
28 #define log_debug(...) logger->debug(__VA_ARGS__)
30 void log_init(int, int);
31 void log_setverbose(int);