hv_vos_Log.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * @file hv_vos_Log.h
  3. * @brief Header file of vos log.
  4. *
  5. * @verbatim
  6. * ==============================================================================
  7. * ##### How to use #####
  8. * ==============================================================================
  9. * (+) Use ()
  10. *
  11. * @endverbatim
  12. * @author HiView SoC Software Team
  13. * @version 1.0.0
  14. * @date 2023-03-01
  15. */
  16. #ifndef _HV_VOS_LOG_H
  17. #define _HV_VOS_LOG_H
  18. #include "hv_vos_Types.h"
  19. VOS_EXTERN_C_BEGIN
  20. /** @defgroup VOS_LOG VOS_LOG
  21. * VOS log functions
  22. * @{
  23. */
  24. #define HV_LOG_LEVEL_VERBOSE 0
  25. #define HV_LOG_LEVEL_INFO 1
  26. #define HV_LOG_LEVEL_WARN 2
  27. #define HV_LOG_LEVEL_ERROR 3
  28. #define HV_LOG_LEVEL_FATAL 4
  29. #define HV_LOG_LEVEL_ALWAYS 5
  30. #define HV_LOG_LEVEL_NONE 6
  31. #define HV_LOG_SHOW_TASK_ID 0x0001
  32. #define HV_LOG_SHOW_FILENAME 0x0002
  33. #define HV_LOG_SHOW_FUNCTION 0x0004
  34. #define HV_LOG_SHOW_TIMESTAMP 0x0008
  35. #define HV_LOG_SHOW_LINE 0x0010
  36. #define HV_LOG_ENABLED(lvl) ((lvl) >= _HV_LOG_OUTPUT_LEVEL)
  37. #define HV_LOG_ENABLED_VERBOSE HV_LOG_ENABLED(HV_LOG_LEVEL_VERBOSE)
  38. #define HV_LOG_ENABLED_INFO HV_LOG_ENABLED(HV_LOG_LEVEL_INFO)
  39. #define HV_LOG_ENABLED_WARN HV_LOG_ENABLED(HV_LOG_LEVEL_WARN)
  40. #define HV_LOG_ENABLED_ERROR HV_LOG_ENABLED(HV_LOG_LEVEL_ERROR)
  41. #define HV_LOG_ENABLED_FATAL HV_LOG_ENABLED(HV_LOG_LEVEL_FATAL)
  42. #define HV_LOG_ON(lvl) HV_LOG_ENABLED(lvl)
  43. #ifdef HV_SCALER_DEBUG_VERSION
  44. extern UINT32 g_uiLogOutputLevel;
  45. #define _HV_LOG_OUTPUT_LEVEL g_uiLogOutputLevel
  46. #else
  47. #define _HV_LOG_OUTPUT_LEVEL HV_LOG_LEVEL_ERROR
  48. #endif
  49. #ifdef HV_CONFIG_ENABLE_PRINT
  50. extern void Hv_Vos_LOG_Write(int level, int raw, const char *func,
  51. int line,
  52. const char *fmt, ...);
  53. #else
  54. #define Hv_Vos_LOG_Write(...)
  55. #endif
  56. #define HV_LOG_WRITE(level, ...) \
  57. do { \
  58. if (HV_LOG_ON(level)){ \
  59. Hv_Vos_LOG_Write(level, 0, __FUNCTION__, __LINE__, __VA_ARGS__); \
  60. } \
  61. } while (0)
  62. #define HV_RAW_LOG_WRITE(level, ...) \
  63. do { \
  64. if (HV_LOG_ON(level)){ \
  65. Hv_Vos_LOG_Write(level, 1, __FUNCTION__, __LINE__, __VA_ARGS__); \
  66. } \
  67. } while (0)
  68. #define HV_LOGV(...) HV_LOG_WRITE(HV_LOG_LEVEL_VERBOSE, __VA_ARGS__)
  69. #define HV_LOGI(...) HV_LOG_WRITE(HV_LOG_LEVEL_INFO, __VA_ARGS__)
  70. #define HV_LOGW(...) HV_LOG_WRITE(HV_LOG_LEVEL_WARN, __VA_ARGS__)
  71. #define HV_LOGE(...) HV_LOG_WRITE(HV_LOG_LEVEL_ERROR, __VA_ARGS__)
  72. #define HV_LOGF(...) HV_LOG_WRITE(HV_LOG_LEVEL_FATAL, __VA_ARGS__)
  73. #define HV_LOGA(...) HV_LOG_WRITE(HV_LOG_LEVEL_ALWAYS, __VA_ARGS__)
  74. #define HV_RAW_LOGV(...) HV_RAW_LOG_WRITE(HV_LOG_LEVEL_VERBOSE, __VA_ARGS__)
  75. #define HV_RAW_LOGI(...) HV_RAW_LOG_WRITE(HV_LOG_LEVEL_INFO, __VA_ARGS__)
  76. #define HV_RAW_LOGW(...) HV_RAW_LOG_WRITE(HV_LOG_LEVEL_WARN, __VA_ARGS__)
  77. #define HV_RAW_LOGE(...) HV_RAW_LOG_WRITE(HV_LOG_LEVEL_ERROR, __VA_ARGS__)
  78. #define HV_RAW_LOGF(...) HV_RAW_LOG_WRITE(HV_LOG_LEVEL_FATAL, __VA_ARGS__)
  79. #define HV_RAW_LOGA(...) HV_RAW_LOG_WRITE(HV_LOG_LEVEL_ALWAYS, __VA_ARGS__)
  80. void Hv_Vos_LOG_DumpBuffer(const char *func,
  81. int line, const char *name, const void *buf, int buf_length);
  82. #define HV_LOG_BUF(level, ...) \
  83. do {\
  84. if (HV_LOG_ON(level)){ \
  85. Hv_Vos_LOG_DumpBuffer(__FUNCTION__, __LINE__, __VA_ARGS__); \
  86. }\
  87. } while (0)
  88. #define HV_LOG_BUF_INFO(...) HV_LOG_BUF(HV_LOG_LEVEL_INFO, __VA_ARGS__)
  89. #define HV_LOG_BUF_VERBOSE(...) HV_LOG_BUF(HV_LOG_LEVEL_VERBOSE, __VA_ARGS__)
  90. void Hv_Vos_LOG_SetLevel(int level);
  91. void Hv_Vos_LOG_SetFlag(UINT32 flag);
  92. void Hv_Vos_FlushLogBuf(void);
  93. /** @} */
  94. VOS_EXTERN_C_END
  95. #endif