log.h 687 B

123456789101112131415161718192021222324
  1. #ifndef LOG_H
  2. #define LOG_H
  3. #include "zlog.h"
  4. #include <syslog.h>
  5. extern zlog_category_t *zlog_c;
  6. void log_to_mqtt(const char *fmt, ...);
  7. int log_init();
  8. // #ifndef DEBUG
  9. #define log_info(format, ...) zlog_debug(zlog_c, format, ##__VA_ARGS__)
  10. #define log_crit(format, ...) zlog_notice(zlog_c, format, ##__VA_ARGS__)
  11. #define log_dbg(format, ...) \
  12. log_to_mqtt(format, ##__VA_ARGS__); \
  13. zlog_debug(zlog_c, format, ##__VA_ARGS__)
  14. #define log_err(format, ...) zlog_error(zlog_c, format, ##__VA_ARGS__)
  15. // #else
  16. // #define log_info(format, ...)
  17. // #define log_crit(format, ...)
  18. // #define log_dbg(format, ...)
  19. // #define log_err(format, ...)
  20. // #endif
  21. #endif /* LOG_H */