summaryrefslogtreecommitdiff
path: root/log.h
blob: 6ee157230c1545a32ae1964bdd244b5c040720ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 */