logging.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef __LOGGING_H__
  2. #define __LOGGING_H__
  3. #include "config.h"
  4. #include <stdbool.h>
  5. #include <stdarg.h>
  6. #ifdef HAVE_SYSLOG_H
  7. #include <syslog.h>
  8. #else
  9. enum {
  10. LOG_ERR,
  11. LOG_WARNING,
  12. LOG_NOTICE,
  13. LOG_INFO,
  14. LOG_DEBUG,
  15. };
  16. #endif
  17. /* original / legacy debug flags */
  18. extern bool opt_debug;
  19. extern bool opt_debug_console;
  20. extern bool opt_log_output;
  21. extern bool opt_realquiet;
  22. extern bool want_per_device_stats;
  23. /* global log_level, messages with lower or equal prio are logged */
  24. extern int opt_log_level;
  25. /* low-level logging functions with priority parameter */
  26. extern void vapplog(int prio, const char *fmt, va_list ap);
  27. extern void applog(int prio, const char *fmt, ...);
  28. #define applogr(rv, prio, ...) do { \
  29. applog(prio, __VA_ARGS__); \
  30. return rv; \
  31. } while (0)
  32. /* high-level logging functions with implicit priority */
  33. extern void log_error(const char *fmt, ...);
  34. extern void log_warning(const char *fmt, ...);
  35. extern void log_notice(const char *fmt, ...);
  36. extern void log_info(const char *fmt, ...);
  37. extern void log_debug(const char *fmt, ...);
  38. #endif /* __LOGGING_H__ */