sys_log.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef __SYS_LOG_H__
  2. #define __SYS_LOG_H__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdio.h>
  7. #include <stdarg.h>
  8. #include <stdint.h>
  9. #define FW_DEBUG_LEVEL 5
  10. #define FW_INFO_LEVEL 4
  11. #define FW_WARN_LEVEL 3
  12. #define FW_ERROR_LEVEL 2
  13. #define FW_FATAL_LEVEL 1
  14. typedef void (*log_print_callback_fp) (uint8_t* data, uint8_t len);
  15. void Sys_LogPrintCallbackRegister(log_print_callback_fp fp);
  16. void _FW_LogDebug(const char* fmt, ...);
  17. void _FW_LogInfo(const char* fmt, ...);
  18. void _FW_LogWarn(const char* fmt, ...);
  19. void _FW_LogError(const char* fmt, ...);
  20. void _FW_LogFatal(const char* fmt, ...);
  21. int FW_GetFileLine(const int8_t* __file__, const int __line__);
  22. #define DLOG_F(...) if(FW_GetFileLine(__FILE__, __LINE__)) _FW_LogFatal(__VA_ARGS__)
  23. #define DLOG_E(...) if(FW_GetFileLine(__FILE__, __LINE__)) _FW_LogError(__VA_ARGS__)
  24. #define DLOG_W(...) if(FW_GetFileLine(__FILE__, __LINE__)) _FW_LogWarn(__VA_ARGS__)
  25. #define DLOG_I(...) if(FW_GetFileLine(__FILE__, __LINE__)) _FW_LogInfo( __VA_ARGS__)
  26. #define DLOG_D(...) if(FW_GetFileLine(__FILE__, __LINE__)) _FW_LogDebug(__VA_ARGS__)
  27. #ifdef __cplusplus
  28. }
  29. #endif
  30. #endif //__SYS_LOG_H__