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.

55 lines
2.3 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdio.h>
  4. #include "cmsis_os.h"
  5. #include "main.h"
  6. extern bool g_enable_log;
  7. #define ZLOG_RELEASE(TAG, fmt, ...) \
  8. if (g_enable_log) { \
  9. zlog(TAG "" fmt "\n", ##__VA_ARGS__); \
  10. }
  11. #define ZLOGI(TAG, fmt, ...) \
  12. if (g_enable_log) { \
  13. zlog("%08lu INFO [%-8s] " fmt "\n", HAL_GetTick(), TAG, ##__VA_ARGS__); \
  14. }
  15. #define ZLOGD(TAG, fmt, ...) \
  16. if (g_enable_log) { \
  17. zlog("%08lu DEBU [%-8s] " fmt "\n", HAL_GetTick(), TAG, ##__VA_ARGS__); \
  18. }
  19. #define ZLOGE(TAG, fmt, ...) \
  20. if (g_enable_log) { \
  21. zlog("%08lu ERRO [%-8s] " fmt "\n", HAL_GetTick(), TAG, ##__VA_ARGS__); \
  22. }
  23. #define ZLOGW(TAG, fmt, ...) \
  24. if (g_enable_log) { \
  25. zlog("%08lu WARN [%-8s] " fmt "\n", HAL_GetTick(), TAG, ##__VA_ARGS__); \
  26. }
  27. #define ZASSERT(cond) \
  28. if (!(cond)) { \
  29. while (1) { \
  30. zlog("ASSERT: %s [%s:%d]\n", #cond, __FILE__, __LINE__); \
  31. osDelay(1000); \
  32. } \
  33. }
  34. #define ZASSERT_INFO(cond, info) \
  35. if (!(cond)) { \
  36. while (1) { \
  37. zlog("ASSERT: %s [%s:%d] %s\n", #cond, __FILE__, __LINE__, info); \
  38. osDelay(1000); \
  39. } \
  40. }
  41. #define ZEARLY_ASSERT(cond) \
  42. if (!(cond)) { \
  43. while (1) { \
  44. } \
  45. }
  46. void zlog(const char* fmt, ...);
  47. void zlog_raw(const char* info);
  48. void zlog_init(UART_HandleTypeDef* huart);
  49. void zlog_enable(bool enable);