zf_debug.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. *****************************************************************************
  3. * @file zf_debug.h
  4. * @author Zorb
  5. * @version V1.0.0
  6. * @date 2018-06-28
  7. * @brief 调试输出的头文件
  8. *****************************************************************************
  9. * @history
  10. *
  11. * 1. Date:2018-06-28
  12. * Author:Zorb
  13. * Modification:建立文件
  14. *
  15. *****************************************************************************
  16. */
  17. #ifndef __ZF_DEBUG_H__
  18. #define __ZF_DEBUG_H__
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #include "stdio.h"
  23. #include "stdbool.h"
  24. #define LOG_D 0; /* 信息等级:正常 */
  25. #define LOG_W 1; /* 信息等级:告警 */
  26. #define LOG_E 2; /* 信息等级:错误 */
  27. #define _ZF_DEBUG /* 定义调试功能 */
  28. #define ZF_DEBUG_ON true /* 启用调试功能 */
  29. #ifdef _ZF_DEBUG
  30. #if ZF_DEBUG_ON
  31. #define ZF_DEBUG(rank, x...) do \
  32. { \
  33. char code[10] = "[rank=0]"; \
  34. code[6] = '0' + (char)rank; \
  35. if (code[6] != '0') \
  36. { \
  37. printf("\r\n\r\n%s", code); \
  38. } \
  39. printf(x); \
  40. if (code[6] != '0') \
  41. { \
  42. printf("%s\r\n\r\n", code); \
  43. } \
  44. } while(0)
  45. #else
  46. #define ZF_DEBUG(rank, x...)
  47. #endif /* ZF_DEBUG_ON */
  48. #endif /* _ZF_DEBUG */
  49. #define ZF_DEBUG_D(x...) ZF_DEBUG(LOG_D, x)
  50. #define ZF_DEBUG_W(x...) ZF_DEBUG(LOG_W, x)
  51. #define ZF_DEBUG_E(x...) ZF_DEBUG(LOG_E, x)
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif /* __ZF_DEBUG_H__ */
  56. /******************************** END OF FILE ********************************/