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.

42 lines
1.9 KiB

1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
8 months ago
1 year ago
  1. #pragma once
  2. #include <stdio.h>
  3. #include "basic_h/basic.hpp"
  4. //
  5. #include "clock.hpp"
  6. extern "C" {
  7. extern bool g_enable_log;
  8. #define ZEARLY_LOG_RELEASE(TAG, fmt, ...) \
  9. if (g_enable_log) { \
  10. zchip_log(TAG "" fmt "\r\n", ##__VA_ARGS__); \
  11. }
  12. #define ZEARLY_LOGI(TAG, fmt, ...) \
  13. if (g_enable_log) { \
  14. zchip_log("%08lu INFO [%-8s] " fmt "\r\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \
  15. }
  16. #define ZEARLY_LOGD(TAG, fmt, ...) \
  17. if (g_enable_log) { \
  18. zchip_log("%08lu DEBU [%-8s] " fmt "\r\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \
  19. }
  20. #define ZEARLY_LOGE(TAG, fmt, ...) \
  21. if (g_enable_log) { \
  22. zchip_log("%08lu ERRO [%-8s] " fmt "\r\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \
  23. }
  24. #define ZEARLY_LOGW(TAG, fmt, ...) \
  25. if (g_enable_log) { \
  26. zchip_log("%08lu WARN [%-8s] " fmt "\r\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \
  27. }
  28. #define ZEARLY_ASSERT(cond) \
  29. if (!(cond)) { \
  30. while (1) { \
  31. zchip_log("ASSERT: %s [%s:%d]\r\n", #cond, __FILE__, __LINE__); \
  32. zchip_clock_early_delayus(1000 * 1000); \
  33. } \
  34. }
  35. void zchip_log(const char* fmt, ...) ;
  36. void zchip_loggger_init(zchip_uart_t* huart);
  37. void zchip_loggger_enable(bool enable);
  38. }