]> arthur.barton.de Git - netdata.git/blob - src/log.h
Merge remote-tracking branch 'upstream/master' into health
[netdata.git] / src / log.h
1 #ifndef NETDATA_LOG_H
2 #define NETDATA_LOG_H 1
3
4 #define D_WEB_BUFFER        0x00000001
5 #define D_WEB_CLIENT        0x00000002
6 #define D_LISTENER          0x00000004
7 #define D_WEB_DATA          0x00000008
8 #define D_OPTIONS           0x00000010
9 #define D_PROCNETDEV_LOOP   0x00000020
10 #define D_RRD_STATS         0x00000040
11 #define D_WEB_CLIENT_ACCESS 0x00000080
12 #define D_TC_LOOP           0x00000100
13 #define D_DEFLATE           0x00000200
14 #define D_CONFIG            0x00000400
15 #define D_PLUGINSD          0x00000800
16 #define D_CHILDS            0x00001000
17 #define D_EXIT              0x00002000
18 #define D_CHECKS            0x00004000
19 #define D_NFACCT_LOOP       0x00008000
20 #define D_PROCFILE          0x00010000
21 #define D_RRD_CALLS         0x00020000
22 #define D_DICTIONARY        0x00040000
23 #define D_MEMORY            0x00080000
24 #define D_CGROUP            0x00100000
25 #define D_REGISTRY          0x00200000
26 #define D_VARIABLES         0x00400000
27 #define D_HEALTH            0x00800000
28
29 //#define DEBUG (D_WEB_CLIENT_ACCESS|D_LISTENER|D_RRD_STATS)
30 //#define DEBUG 0xffffffff
31 #define DEBUG (0)
32
33 extern unsigned long long debug_flags;
34
35 extern const char *program_name;
36
37 extern int stdaccess_fd;
38 extern FILE *stdaccess;
39
40 extern const char *stdaccess_filename;
41 extern const char *stderr_filename;
42 extern const char *stdout_filename;
43
44 extern int access_log_syslog;
45 extern int error_log_syslog;
46 extern int output_log_syslog;
47
48 extern time_t error_log_throttle_period;
49 extern unsigned long error_log_errors_per_period;
50 extern int error_log_limit(int reset);
51
52 extern void open_all_log_files();
53 extern void reopen_all_log_files();
54
55 #define error_log_limit_reset() do { error_log_limit(1); } while(0)
56 #define error_log_limit_unlimited() do { error_log_throttle_period = 0; } while(0)
57
58 #define debug(type, args...) do { if(unlikely(debug_flags & type)) debug_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0)
59 #define info(args...)    info_int(__FILE__, __FUNCTION__, __LINE__, ##args)
60 #define infoerr(args...) error_int("INFO", __FILE__, __FUNCTION__, __LINE__, ##args)
61 #define error(args...)   error_int("ERROR", __FILE__, __FUNCTION__, __LINE__, ##args)
62 #define fatal(args...)   fatal_int(__FILE__, __FUNCTION__, __LINE__, ##args)
63
64 extern void log_date(FILE *out);
65 extern void debug_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ (( format (printf, 4, 5)));
66 extern void info_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ (( format (printf, 4, 5)));
67 extern void error_int( const char *prefix, const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ (( format (printf, 5, 6)));
68 extern void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ ((noreturn, format (printf, 4, 5)));
69 extern void log_access( const char *fmt, ... ) __attribute__ (( format (printf, 1, 2)));
70
71 #endif /* NETDATA_LOG_H */