rt_ai_log.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-04-01 liqiwen the first version
  9. */
  10. #ifndef __RT_AI_LOG__
  11. #define __RT_AI_LOG__
  12. #include <aiconfig.h>
  13. #include <rtdbg.h>
  14. #undef AI_LOG
  15. #undef AI_LOG_E
  16. #undef AI_LOG_W
  17. #undef AI_LOG_I
  18. #undef ai_log_raw
  19. /* AI LOG level */
  20. #define AI_LOG_ERROR 0
  21. #define AI_LOG_WARNING 1
  22. #define AI_LOG_INFO 2
  23. #define AI_LOG_LOG 3
  24. #ifndef AI_LOG_LEVEL
  25. #define AI_LOG_LEVEL AI_LOG_ERROR
  26. #endif
  27. #define ai_log_raw(...) rt_kprintf(__VA_ARGS__)
  28. #ifdef RT_AI_LOG_ENABLE
  29. #ifdef DBG_ENABLE
  30. #define AI_LOG(_fmt, ...) LOG_RAW("[AI.LOG]" _fmt, ##__VA_ARGS__)
  31. #define AI_LOG_E(_fmt, ...) LOG_E("[AI.E]" _fmt, ##__VA_ARGS__)
  32. #define AI_LOG_W(_fmt, ...) LOG_W("[AI.W]" _fmt, ##__VA_ARGS__)
  33. #define AI_LOG_I(_fmt, ...) LOG_I("[AI.I]" _fmt, ##__VA_ARGS__)
  34. #else
  35. #define AI_LOG(_fmt, ...) ai_log_raw("[AI.LOG]" _fmt, ##__VA_ARGS__)
  36. #if (AI_LOG_LEVEL >= AI_LOG_ERROR)
  37. #define AI_LOG_E(fmt, ...) ai_log_raw("[AI.E]" fmt, ##__VA_ARGS__)
  38. #endif
  39. #if (AI_LOG_LEVEL >= AI_LOG_WARNING)
  40. #define AI_LOG_W(fmt, ...) ai_log_raw("[AI.W]" fmt, ##__VA_ARGS__)
  41. #endif
  42. #if (AI_LOG_LEVEL >= AI_LOG_INFO)
  43. #define AI_LOG_I(fmt, ...) ai_log_raw("[AI.I]" fmt, ##__VA_ARGS__)
  44. #endif
  45. #endif //DBG_ENABLE
  46. #endif //RT_AI_LOG_ENABLE
  47. #ifndef AI_LOG
  48. #define AI_LOG(...)
  49. #endif
  50. #ifndef AI_LOG_E
  51. #define AI_LOG_E(...)
  52. #endif
  53. #ifndef AI_LOG_W
  54. #define AI_LOG_W(...)
  55. #endif
  56. #ifndef AI_LOG_I
  57. #define AI_LOG_I(...)
  58. #endif
  59. #define ai_log ai_log_raw
  60. #endif //END