debug_print.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * @file debug_print.c
  3. * @brief 打印头文件
  4. * @author lch (lch_work@foxmail.com)
  5. * @version 1.0
  6. * @date 20251022
  7. *
  8. * @copyright Copyright (c) 2025 by OLE, All Rights Reserved.
  9. *
  10. * @par 修改日志:
  11. * <table>
  12. * <tr><th>Date <th>Version <th>Author <th>Description
  13. * <tr><td>20251022 <td>1.0 <td>lch <td>内容
  14. * </table>
  15. */
  16. #ifndef DEF_DEBUG_PRINT_H
  17. #define DEF_DEBUG_PRINT_H
  18. /***** 宏定义 *****/
  19. #define DP_COLOR_NONE "\033[0m"
  20. #define DP_COLOR_RED "\033[31m"
  21. #define DP_COLOR_GREEN "\033[32m"
  22. #define DP_COLOR_YELLOW "\033[33m"
  23. #define DP_COLOR_BLUE "\033[34m"
  24. #define DP_COLOR_PURPLE "\033[35m" // 紫色
  25. #define DP_COLOR_WATHET "\033[36m" // 浅蓝
  26. #define DP_COLOR_WHITE "\033[37m"
  27. /* 信息提示 nt整行不带[tag] h只有[tag]显示浅蓝色 n[tag]显示为浅蓝色内容为蓝色 a[tag]整行为浅蓝色 */
  28. #define dp_info_nt(fmt, args...) \
  29. printf(DP_COLOR_WATHET fmt DP_COLOR_NONE "\r\n", ##args)
  30. #define dp_info_h_s(fmt, args...) \
  31. printf(DP_COLOR_WATHET "[INFO] " DP_COLOR_NONE fmt "\r\n", ##args)
  32. #define dp_info_h_c(fmt, args...) \
  33. printf(DP_COLOR_WATHET "[INFO][%s:%d] " DP_COLOR_NONE fmt "\r\n", __func__, __LINE__, ##args)
  34. #define dp_info_n_s(fmt, args...) \
  35. printf(DP_COLOR_WATHET "[INFO] " DP_COLOR_NONE DP_COLOR_BLUE fmt DP_COLOR_NONE "\r\n", ##args)
  36. #define dp_info_n_c(fmt, args...) \
  37. printf(DP_COLOR_WATHET "[INFO][%s:%d] " DP_COLOR_NONE DP_COLOR_BLUE fmt DP_COLOR_NONE "\r\n", __func__, __LINE__, ##args)
  38. #define dp_info_a_s(fmt, args...) \
  39. printf(DP_COLOR_WATHET "[INFO] " fmt DP_COLOR_NONE "\r\n", ##args)
  40. #define dp_info_a_c(fmt, args...) \
  41. printf(DP_COLOR_WATHET "[INFO][%s:%d] " fmt DP_COLOR_NONE "\r\n", __func__, __LINE__, ##args)
  42. /* 错误提示 nt整行不带[tag] h只有[tag]显示红色 n[tag]显示为红色内容为蓝色 a[tag]整行为红色 */
  43. #define dp_err_nt(fmt, args...) \
  44. printf(DP_COLOR_RED fmt DP_COLOR_NONE "\r\n", ##args)
  45. #define dp_err_h_s(fmt, args...) \
  46. printf(DP_COLOR_RED "[ERR] " DP_COLOR_NONE fmt "\r\n", ##args)
  47. #define dp_err_h_c(fmt, args...) \
  48. printf(DP_COLOR_RED "[ERR][%s:%d] " DP_COLOR_NONE fmt "\r\n", __func__, __LINE__, ##args)
  49. #define dp_err_n_s(fmt, args...) \
  50. printf(DP_COLOR_RED "[ERR] " DP_COLOR_NONE DP_COLOR_BLUE fmt DP_COLOR_NONE "\r\n", ##args)
  51. #define dp_err_n_c(fmt, args...) \
  52. printf(DP_COLOR_RED "[ERR][%s:%d] " DP_COLOR_NONE DP_COLOR_BLUE fmt DP_COLOR_NONE "\r\n", __func__, __LINE__, ##args)
  53. #define dp_err_a_s(fmt, args...) \
  54. printf(DP_COLOR_RED "[ERR] " fmt DP_COLOR_NONE "\r\n", ##args)
  55. #define dp_err_a_c(fmt, args...) \
  56. printf(DP_COLOR_RED "[ERR][%s:%d] " fmt DP_COLOR_NONE "\r\n", __func__, __LINE__, ##args)
  57. #define dp_info_nt_rt(fmt, args...) \
  58. rt_printf(DP_COLOR_WATHET fmt DP_COLOR_NONE "\r\n", ##args)
  59. #define dp_err_nt_rt(fmt, args...) \
  60. rt_printf(DP_COLOR_RED fmt DP_COLOR_NONE "\r\n", ##args)
  61. #define dp_err_n_s_rt(fmt, args...) \
  62. rt_printf(DP_COLOR_RED "[ERR] " DP_COLOR_NONE DP_COLOR_BLUE fmt DP_COLOR_NONE "\r\n", ##args)
  63. #define dp_err_n_c_rt(fmt, args...) \
  64. rt_printf(DP_COLOR_RED "[ERR][%s:%d] " DP_COLOR_NONE DP_COLOR_BLUE fmt DP_COLOR_NONE "\r\n", __func__, __LINE__, ##args)
  65. #define dp_info_nt_pk(fmt, args...) \
  66. printk(DP_COLOR_WATHET fmt DP_COLOR_NONE "\r\n", ##args)
  67. #define dp_err_n_s_pk(fmt, args...) \
  68. printk(DP_COLOR_RED "[ERR] " DP_COLOR_NONE DP_COLOR_BLUE fmt DP_COLOR_NONE "\r\n", ##args)
  69. #define dp_err_n_c_pk(fmt, args...) \
  70. printk(DP_COLOR_RED "[ERR][%s:%d] " DP_COLOR_NONE DP_COLOR_BLUE fmt DP_COLOR_NONE "\r\n", __func__, __LINE__, ##args)
  71. /***** 头文件 *****/
  72. /***** 枚举 *****/
  73. /***** 结构体 *****/
  74. /***** 变量对外声明 *****/
  75. /***** 函数对外声明 *****/
  76. #endif /* end of file */