You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.8 KiB

2 years ago
  1. #pragma once
  2. #include "xs_basic.h"
  3. #include "xs_delay.h"
  4. extern bool g_xs_enable_log;
  5. #define XS_LOG_RELEASE(TAG, fmt, ...) \
  6. if (g_xs_enable_log) { \
  7. xs_log(TAG "" fmt "\n", ##__VA_ARGS__); \
  8. }
  9. #define XS_LOGI(TAG, fmt, ...) \
  10. if (g_xs_enable_log) { \
  11. xs_log("%08lu INFO [%-8s] " fmt "\n", xs_get_ticket(), TAG, ##__VA_ARGS__); \
  12. }
  13. #define XS_LOGD(TAG, fmt, ...) \
  14. if (g_xs_enable_log) { \
  15. xs_log("%08lu DEBU [%-8s] " fmt "\n", xs_get_ticket(), TAG, ##__VA_ARGS__); \
  16. }
  17. #define XS_LOGE(TAG, fmt, ...) \
  18. if (g_xs_enable_log) { \
  19. xs_log("%08lu ERRO [%-8s] " fmt "\n", xs_get_ticket(), TAG, ##__VA_ARGS__); \
  20. }
  21. #define XS_LOGW(TAG, fmt, ...) \
  22. if (g_xs_enable_log) { \
  23. xs_log("%08lu WARN [%-8s] " fmt "\n", xs_get_ticket(), TAG, ##__VA_ARGS__); \
  24. }
  25. #define XS_ASSERT(cond) \
  26. if (!(cond)) { \
  27. while (1) { \
  28. xs_log("ASSERT: %s [%s:%d]\n", #cond, __FILE__, __LINE__); \
  29. xs_delay_ms(1000); \
  30. } \
  31. }
  32. void xs_log(const char* fmt, ...);
  33. void xs_log_enable(bool enable);