log.h 3.8 KB

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