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 /* Number of times warn() has been called */
13 /* Do we want informative messages as well as errors? */
16 extern void fatal(const char *fmt
, ...);
17 extern void error(const char *fmt
, ...);
18 extern void warn(const char *fmt
, ...);
19 extern void info(const char *fmt
, ...);
21 static inline void grammar(const char *cmd
,
22 const char *filename
, unsigned int line
)
24 warn("%s line %u: ignoring bad line starting with '%s'\n",
28 #define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__, #ptr)
30 #define nofail_asprintf(ptr, ...) \
31 { if (asprintf((ptr), __VA_ARGS__) < 0) do_nofail(NULL, __FILE__, __LINE__, #ptr); }
33 static inline void *do_nofail(void *ptr
, const char *file
, int line
, const char *expr
)
36 fatal("Memory allocation failure %s line %d: %s.\n",
42 #endif /* MODINITTOOLS_LOGGING_H */