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.

58 lines
2.7 KiB

1 year ago
2 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 "mutex.hpp"
  4. #include "sdk\basic\logger.hpp"
  5. extern iflytop::zmutex glog_mutex;
  6. extern "C" {
  7. extern bool g_enable_log;
  8. #define ZLOG_RELEASE(TAG, fmt, ...) \
  9. if (g_enable_log) { \
  10. zos_log(TAG "" fmt "\r\n", ##__VA_ARGS__); \
  11. }
  12. #define ZLOGI(TAG, fmt, ...) \
  13. if (g_enable_log) { \
  14. zos_log("%08lu INFO [%-10s] " fmt "\r\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \
  15. }
  16. #define ZLOGI_NOT_END_LINE(TAG, fmt, ...) \
  17. if (g_enable_log) { \
  18. zos_log("%08lu INFO [%-10s] " fmt "", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \
  19. }
  20. #define ZLOGD(TAG, fmt, ...) \
  21. if (g_enable_log) { \
  22. zos_log("%08lu DEBU [%-10s] " fmt "\r\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \
  23. }
  24. #define ZLOGE(TAG, fmt, ...) \
  25. if (g_enable_log) { \
  26. zos_log("%08lu ERRO [%-10s] " fmt "\r\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \
  27. }
  28. #define ZLOGW(TAG, fmt, ...) \
  29. if (g_enable_log) { \
  30. zos_log("%08lu WARN [%-10s] " fmt "\r\n", zchip_clock_get_ticket(), TAG, ##__VA_ARGS__); \
  31. }
  32. #define ZASSERT(cond) \
  33. if (!(cond)) { \
  34. while (1) { \
  35. zos_log("ASSERT: %s [%s:%d]\n", #cond, __FILE__, __LINE__); \
  36. zchip_clock_early_delayus(1000 * 1000); \
  37. } \
  38. }
  39. #define ZASSERT_INFO(cond, info) \
  40. if (!(cond)) { \
  41. while (1) { \
  42. zos_log("ASSERT: %s [%s:%d] %s\n", #cond, __FILE__, __LINE__, info); \
  43. zchip_clock_early_delayus(1000); \
  44. } \
  45. }
  46. void zlog_raw(const char* info);
  47. void zos_log(const char* fmt, ...);
  48. void zos_loggger_init();
  49. }