1 #ifndef LOGGER_H
2 #define LOGGER_H
3 /**
4  * Logger
5  *
6  * @link http://en.wikipedia.org/wiki/Syslog
7  */
8 
9 #include "compat.h"
10 
11 #ifndef _WIN32
12 #include <syslog.h>
13 #undef SYSLOG_NAMES
14 #else
15 #define	LOG_EMERG	0           /* system is unusable */
16 #define	LOG_ALERT	1           /* action must be taken immediately */
17 #define	LOG_CRIT	2           /* critical conditions */
18 #define	LOG_ERR		3           /* error conditions */
19 #define	LOG_WARNING	4           /* warning conditions */
20 #define	LOG_NOTICE	5           /* normal but significant condition */
21 #define	LOG_INFO	6           /* informational */
22 #define	LOG_DEBUG	7           /* debug-level messages */
23 #endif
24 
25 #define LOGGER_MAXLEN 8192
26 
27 /* Configurations. */
28 extern int logger_verbosity;
29 extern char *logger_logfile;
30 
31 /* Global Variables. */
32 extern int logger_fd;
33 
34 // see http://stackoverflow.com/q/5588855/288089
35 #define logger(p, fmt, ...) _logger_with_fileline((p), (fmt), __FILE__, __LINE__, ##__VA_ARGS__)
36 void _logger(int priority, const char *fmt, ...);
37 void _logger_with_fileline(int priority, const char *fmt, const char *file, int line, ...);
38 void logger_lograw(int priority, const char *msg);
39 void logger_reopen(void);
40 void logger_close(void);
41 
42 #endif
43