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? */
13 extern void fatal(const char *fmt
, ...);
14 extern void error(const char *fmt
, ...);
15 extern void warn(const char *fmt
, ...);
16 extern void info(const char *fmt
, ...);
18 typedef void (*errfn_t
)(const char *fmt
, ...);
20 static inline void grammar(const char *cmd
,
21 const char *filename
, unsigned int line
)
23 warn("%s line %u: ignoring bad line starting with '%s'\n",
27 #define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__, #ptr)
29 #define nofail_asprintf(ptr, ...) \
30 do { if (asprintf((ptr), __VA_ARGS__) < 0) \
31 do_nofail(NULL, __FILE__, __LINE__, #ptr); \
34 static inline void *do_nofail(void *ptr
, const char *file
, int line
, const char *expr
)
37 fatal("Memory allocation failure %s line %d: %s.\n",
43 #endif /* MODINITTOOLS_LOGGING_H */