1 #ifndef MODINITTOOLS_LOGGING_H
2 #define MODINITTOOLS_LOGGING_H
4 /* Do we use syslog for messages or stderr? */
7 /* Do we want to silently drop all warnings? */
10 /* Do we want informative messages as well as errors? */
14 #define _printf __attribute__((format(printf, 1, 2)))
19 extern void _printf
fatal(const char *fmt
, ...);
20 extern void _printf
error(const char *fmt
, ...);
21 extern void _printf
warn(const char *fmt
, ...);
22 extern void _printf
info(const char *fmt
, ...);
24 typedef void _printf (*errfn_t
)(const char *fmt
, ...);
26 static inline void grammar(const char *cmd
,
27 const char *filename
, unsigned int line
)
29 warn("%s line %u: ignoring bad line starting with '%s'\n",
33 #define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__, #ptr)
35 #define nofail_asprintf(ptr, ...) \
36 do { if (asprintf((ptr), __VA_ARGS__) < 0) \
37 do_nofail(NULL, __FILE__, __LINE__, #ptr); \
40 static inline void *do_nofail(void *ptr
, const char *file
, int line
, const char *expr
)
43 fatal("Memory allocation failure %s line %d: %s.\n",
49 #endif /* MODINITTOOLS_LOGGING_H */