diff options
| -rw-r--r-- | log.h | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -0,0 +1,17 @@ +#ifndef LOG_H +#define LOG_H + +#include <stdlib.h> +#include <syslog.h> + +#define info(m,...) message (LOG_INFO, "info[%s:%u]: " m, __func__, __LINE__, ##__VA_ARGS__); +#define warning(m,...) message (LOG_WARNING, "warning[%s:%u]: " m, __func__, __LINE__, ##__VA_ARGS__); +#define error(m,...) message (LOG_ERR, "error[%s:%u]: " m, __func__, __LINE__, ##__VA_ARGS__); +#define fatal(m,...) do { \ + message (LOG_EMERG, "fatal[%s:%u]: " m, __func__, __LINE__, ##__VA_ARGS__); \ + exit (EXIT_FAILURE); \ + } while (0); + +void message (int level, char *const m, ...); + +#endif /* LOG_H */ |
