2 * Copyright (C) 1997-2009 Andre Noll <maan@tuebingen.mpg.de>
4 * Licensed under the GPL v2. For licencing details see COPYING.
12 #include <time.h> /* time(), localtime() */
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
20 #include <sys/socket.h>
21 #include <sys/un.h> /* needed by create_pf_socket */
24 #include "gcc-compat.h"
26 /** debug loglevel, gets really noisy */
28 /** still noisy, but won't fill your disk */
30 /** normal, but significant event */
32 /** unexpected event that can be handled */
34 /** unhandled error condition */
36 /** system might be unreliable */
38 /** last message before exit */
41 /** Log messages with lower priority than that will not be compiled in. */
42 #define COMPILE_TIME_LOGLEVEL 0
45 #if DEBUG > COMPILE_TIME_LOGLEVEL
46 #define DEBUG_LOG(f,...) __log(DEBUG, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
48 #define DEBUG_LOG(...) do {;} while (0)
51 #if INFO > COMPILE_TIME_LOGLEVEL
52 #define INFO_LOG(f,...) __log(INFO, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
54 #define INFO_LOG(...) do {;} while (0)
57 #if NOTICE > COMPILE_TIME_LOGLEVEL
58 #define NOTICE_LOG(f,...) __log(NOTICE, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
60 #define NOTICE_LOG(...) do {;} while (0)
63 #if WARNING > COMPILE_TIME_LOGLEVEL
64 #define WARNING_LOG(f,...) __log(WARNING, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
66 #define WARNING_LOG(...) do {;} while (0)
69 #if ERROR > COMPILE_TIME_LOGLEVEL
70 #define ERROR_LOG(f,...) __log(ERROR, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
72 #define ERROR_LOG(...) do {;} while (0)
75 #if CRIT > COMPILE_TIME_LOGLEVEL
76 #define CRIT_LOG(f,...) __log(CRIT, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
78 #define CRIT_LOG(...) do {;} while (0)
81 #if EMERG > COMPILE_TIME_LOGLEVEL
82 #define EMERG_LOG(f,...) __log(EMERG, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
84 #define EMERG_LOG(...)
88 __printf_2_3 void __log(int, const char*, ...);