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.

51 lines
2.1 KiB

12 months ago
12 months ago
12 months ago
9 months ago
12 months ago
12 months ago
  1. #pragma once
  2. #include "zbase.h"
  3. extern bool g_xs_enable_log;
  4. extern uint32_t zget_ticket(void);
  5. extern void zdelay_ms(int ms);
  6. #define ZLOG_RELEASE(TAG, fmt, ...) \
  7. if (g_xs_enable_log) { \
  8. zlog(TAG "" fmt "\n", ##__VA_ARGS__); \
  9. }
  10. #define ZLOGI(TAG, fmt, ...) \
  11. if (g_xs_enable_log) { \
  12. zlog("%08lu INFO [%-8s] " fmt "\n", zget_ticket(), TAG, ##__VA_ARGS__); \
  13. }
  14. #define ZLOGD(TAG, fmt, ...) \
  15. if (g_xs_enable_log) { \
  16. zlog("%08lu DEBU [%-8s] " fmt "\n", zget_ticket(), TAG, ##__VA_ARGS__); \
  17. }
  18. #define ZLOGE(TAG, fmt, ...) \
  19. if (g_xs_enable_log) { \
  20. zlog("%08lu ERRO [%-8s] " fmt "\n", zget_ticket(), TAG, ##__VA_ARGS__); \
  21. }
  22. #define ZLOGW(TAG, fmt, ...) \
  23. if (g_xs_enable_log) { \
  24. zlog("%08lu WARN [%-8s] " fmt "\n", zget_ticket(), TAG, ##__VA_ARGS__); \
  25. }
  26. #define ASSERT(cond, info) \
  27. if (!(cond)) { \
  28. while (1) { \
  29. zlog("ASSERT: %s [%s:%d] %s\n", #cond, __FILE__, __LINE__, info); \
  30. zdelay_ms(1000); \
  31. } \
  32. }
  33. #define ZASSERT(cond) ASSERT(cond, "")
  34. #define ZASSERT_INFO(cond, info) ASSERT(cond, info)
  35. #define HAL_ASSERT(exptr) \
  36. { \
  37. HAL_StatusTypeDef status = (exptr); \
  38. ASSERT(status == HAL_OK, #exptr); \
  39. }
  40. #define ZARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
  41. void zlog_init(UART_HandleTypeDef* uart);
  42. void zlog(const char* fmt, ...);
  43. void zlog_raw(const char* info);
  44. void zlog_enable(bool enable);