log.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_LOG_H
  3. #define NETDATA_LOG_H 1
  4. # ifdef __cplusplus
  5. extern "C" {
  6. # endif
  7. #include "../libnetdata.h"
  8. #define D_WEB_BUFFER 0x0000000000000001
  9. #define D_WEB_CLIENT 0x0000000000000002
  10. #define D_LISTENER 0x0000000000000004
  11. #define D_WEB_DATA 0x0000000000000008
  12. #define D_OPTIONS 0x0000000000000010
  13. #define D_PROCNETDEV_LOOP 0x0000000000000020
  14. #define D_RRD_STATS 0x0000000000000040
  15. #define D_WEB_CLIENT_ACCESS 0x0000000000000080
  16. #define D_TC_LOOP 0x0000000000000100
  17. #define D_DEFLATE 0x0000000000000200
  18. #define D_CONFIG 0x0000000000000400
  19. #define D_PLUGINSD 0x0000000000000800
  20. #define D_CHILDS 0x0000000000001000
  21. #define D_EXIT 0x0000000000002000
  22. #define D_CHECKS 0x0000000000004000
  23. #define D_NFACCT_LOOP 0x0000000000008000
  24. #define D_PROCFILE 0x0000000000010000
  25. #define D_RRD_CALLS 0x0000000000020000
  26. #define D_DICTIONARY 0x0000000000040000
  27. #define D_MEMORY 0x0000000000080000
  28. #define D_CGROUP 0x0000000000100000
  29. #define D_REGISTRY 0x0000000000200000
  30. #define D_VARIABLES 0x0000000000400000
  31. #define D_HEALTH 0x0000000000800000
  32. #define D_CONNECT_TO 0x0000000001000000
  33. #define D_RRDHOST 0x0000000002000000
  34. #define D_LOCKS 0x0000000004000000
  35. #define D_EXPORTING 0x0000000008000000
  36. #define D_STATSD 0x0000000010000000
  37. #define D_POLLFD 0x0000000020000000
  38. #define D_STREAM 0x0000000040000000
  39. #define D_ANALYTICS 0x0000000080000000
  40. #define D_RRDENGINE 0x0000000100000000
  41. #define D_ACLK 0x0000000200000000
  42. #define D_METADATALOG 0x0000000400000000
  43. #define D_ACLK_SYNC 0x0000000800000000
  44. #define D_SYSTEM 0x8000000000000000
  45. //#define DEBUG (D_WEB_CLIENT_ACCESS|D_LISTENER|D_RRD_STATS)
  46. //#define DEBUG 0xffffffff
  47. #define DEBUG (0)
  48. extern int web_server_is_multithreaded;
  49. extern uint64_t debug_flags;
  50. extern const char *program_name;
  51. extern int stdaccess_fd;
  52. extern FILE *stdaccess;
  53. extern const char *stdaccess_filename;
  54. extern const char *stderr_filename;
  55. extern const char *stdout_filename;
  56. extern const char *facility_log;
  57. extern int access_log_syslog;
  58. extern int error_log_syslog;
  59. extern int output_log_syslog;
  60. extern time_t error_log_throttle_period;
  61. extern unsigned long error_log_errors_per_period, error_log_errors_per_period_backup;
  62. extern int error_log_limit(int reset);
  63. extern void open_all_log_files();
  64. extern void reopen_all_log_files();
  65. static inline void debug_dummy(void) {}
  66. #define error_log_limit_reset() do { error_log_errors_per_period = error_log_errors_per_period_backup; error_log_limit(1); } while(0)
  67. #define error_log_limit_unlimited() do { \
  68. error_log_limit_reset(); \
  69. error_log_errors_per_period = ((error_log_errors_per_period_backup * 10) < 10000) ? 10000 : (error_log_errors_per_period_backup * 10); \
  70. } while(0)
  71. #ifdef NETDATA_INTERNAL_CHECKS
  72. #define debug(type, args...) do { if(unlikely(debug_flags & type)) debug_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0)
  73. #else
  74. #define debug(type, args...) debug_dummy()
  75. #endif
  76. #define info(args...) info_int(__FILE__, __FUNCTION__, __LINE__, ##args)
  77. #define infoerr(args...) error_int("INFO", __FILE__, __FUNCTION__, __LINE__, ##args)
  78. #define error(args...) error_int("ERROR", __FILE__, __FUNCTION__, __LINE__, ##args)
  79. #define fatal(args...) fatal_int(__FILE__, __FUNCTION__, __LINE__, ##args)
  80. #define fatal_assert(expr) ((expr) ? (void)(0) : fatal_int(__FILE__, __FUNCTION__, __LINE__, "Assertion `%s' failed", #expr))
  81. extern void send_statistics(const char *action, const char *action_result, const char *action_data);
  82. extern void debug_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) PRINTFLIKE(4, 5);
  83. extern void info_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) PRINTFLIKE(4, 5);
  84. extern void error_int( const char *prefix, const char *file, const char *function, const unsigned long line, const char *fmt, ... ) PRINTFLIKE(5, 6);
  85. extern void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) NORETURN PRINTFLIKE(4, 5);
  86. extern void log_access( const char *fmt, ... ) PRINTFLIKE(1, 2);
  87. # ifdef __cplusplus
  88. }
  89. # endif
  90. #endif /* NETDATA_LOG_H */