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.

45 lines
1.9 KiB

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 ZARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
  36. void zlog(const char* fmt, ...);
  37. void zlog_raw(const char* info);
  38. void zlog_enable(bool enable);