logging.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_log_output;
  20. extern bool opt_realquiet;
  21. extern bool want_per_device_stats;
  22. /* global log_level, messages with lower or equal prio are logged */
  23. extern int opt_log_level;
  24. /* low-level logging functions with priority parameter */
  25. extern void vapplog(int prio, const char *fmt, va_list ap);
  26. extern void _applog(int prio, const char *fmt, ...);
  27. #define applog(prio, fmt, ...) do { \
  28. char *tmp42; \
  29. if (0) \
  30. sprintf(tmp42, fmt, ##__VA_ARGS__); \
  31. else \
  32. _applog(prio, fmt, ##__VA_ARGS__); \
  33. } while (0)
  34. /* high-level logging functions with implicit priority */
  35. extern void log_error(const char *fmt, ...);
  36. extern void log_warning(const char *fmt, ...);
  37. extern void log_notice(const char *fmt, ...);
  38. extern void log_info(const char *fmt, ...);
  39. extern void log_debug(const char *fmt, ...);
  40. #endif /* __LOGGING_H__ */