From 9ec76e302d4584b206e51b52eea27e94daf1b32f Mon Sep 17 00:00:00 2001 From: armink Date: Wed, 11 Jul 2018 10:15:16 +0800 Subject: [PATCH 1/3] [rtdbg] Add LOG_RAW and dbg_raw API to rtdbg.h . --- include/rtdbg.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/rtdbg.h b/include/rtdbg.h index 4d9f760c01..f9106b91ea 100644 --- a/include/rtdbg.h +++ b/include/rtdbg.h @@ -131,17 +131,21 @@ rt_kprintf("\n"); \ } +#define dbg_raw(...) rt_kprintf(__VA_ARGS__); + #else #define dbg_log(level, fmt, ...) #define dbg_here #define dbg_enter #define dbg_exit #define dbg_log_line(level, ...) +#define dbg_raw(...) #endif #define LOG_D(...) dbg_log_line(DBG_LOG , __VA_ARGS__) #define LOG_I(...) dbg_log_line(DBG_INFO , __VA_ARGS__) #define LOG_W(...) dbg_log_line(DBG_WARNING, __VA_ARGS__) #define LOG_E(...) dbg_log_line(DBG_ERROR , __VA_ARGS__) +#define LOG_RAW(...) dbg_raw(__VA_ARGS__) #endif /* RT_DBG_H__ */ From 541925195f0c03fb7feeadf8a593d80516f69a02 Mon Sep 17 00:00:00 2001 From: armink Date: Wed, 11 Jul 2018 10:17:34 +0800 Subject: [PATCH 2/3] [rtdbg] Update dbg log header format. --- include/rtdbg.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/include/rtdbg.h b/include/rtdbg.h index f9106b91ea..84e4b97d3f 100644 --- a/include/rtdbg.h +++ b/include/rtdbg.h @@ -32,7 +32,7 @@ * In your C/C++ file, enable/disable DEBUG_ENABLE macro, and then include this * header file. * - * #define DBG_SECTION_NAME "[ MOD]" + * #define DBG_SECTION_NAME "MOD" * #define DBG_ENABLE // enable debug macro * #define DBG_LEVEL DBG_INFO * #include // must after of DEBUG_ENABLE or some other options @@ -81,10 +81,14 @@ * WHITE 37 */ #ifdef DBG_COLOR -#define _DBG_COLOR(n) rt_kprintf("\033["#n"m") +#define _DBG_COLOR(n) rt_kprintf("\033["#n"m") +#define _DBG_LOG_HDR(lvl_name, color_n) \ + rt_kprintf("\033["#color_n"m["lvl_name"/"DBG_SECTION_NAME"] ") #else #define _DBG_COLOR(n) -#endif +#define _DBG_LOG_HDR(lvl_name, color_n) \ + rt_kprintf("["lvl_name"/"DBG_SECTION_NAME"] ") +#endif /* DBG_COLOR */ /* * static debug routine @@ -94,12 +98,13 @@ { \ switch(level) \ { \ - case DBG_ERROR: _DBG_COLOR(31); break; \ - case DBG_WARNING: _DBG_COLOR(33); break; \ - case DBG_INFO: _DBG_COLOR(32); break; \ + case DBG_ERROR: _DBG_LOG_HDR("E", 31); break; \ + case DBG_WARNING: _DBG_LOG_HDR("W", 33); break; \ + case DBG_INFO: _DBG_LOG_HDR("I", 32); break; \ + case DBG_LOG: _DBG_LOG_HDR("D", 0); break; \ default: break; \ } \ - rt_kprintf(DBG_SECTION_NAME fmt, ##__VA_ARGS__); \ + rt_kprintf(fmt, ##__VA_ARGS__); \ _DBG_COLOR(0); \ } From 6cd8658dadb5e90a42132daa5d738b1f90d11ca8 Mon Sep 17 00:00:00 2001 From: armink Date: Wed, 11 Jul 2018 10:23:19 +0800 Subject: [PATCH 3/3] [rtdbg] Change all DBG_SECTION_NAME to new format. --- bsp/allwinner_tina/drivers/drv_gpio.c | 2 +- bsp/allwinner_tina/drivers/drv_sdio.c | 2 +- bsp/allwinner_tina/drivers/spi/drv_spi.c | 2 +- bsp/allwinner_tina/drivers/spi/drv_spi_flash.c | 2 +- bsp/imxrt1052-evk/drivers/drv_eth.c | 2 +- bsp/imxrt1052-evk/drivers/drv_eth_fire.c | 2 +- bsp/imxrt1052-evk/drivers/fsl_phy_fire.c | 2 +- bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c | 2 +- bsp/x1000/drivers/mmc/drv_mmc.c | 2 +- components/dfs/include/dfs_private.h | 2 +- components/drivers/serial/serial.c | 2 +- components/lwp/lwp.c | 2 +- components/lwp/lwp_mem.c | 2 +- components/lwp/lwp_syscall.c | 2 +- src/signal.c | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bsp/allwinner_tina/drivers/drv_gpio.c b/bsp/allwinner_tina/drivers/drv_gpio.c index cd650ed009..70a4b3a3f1 100644 --- a/bsp/allwinner_tina/drivers/drv_gpio.c +++ b/bsp/allwinner_tina/drivers/drv_gpio.c @@ -28,7 +28,7 @@ #include "interrupt.h" #define DBG_ENABLE -#define DBG_SECTION_NAME "[GPIO]" +#define DBG_SECTION_NAME "GPIO" #define DBG_LEVEL DBG_WARNING #define DBG_COLOR #include diff --git a/bsp/allwinner_tina/drivers/drv_sdio.c b/bsp/allwinner_tina/drivers/drv_sdio.c index 72b43c0e22..08be4c1652 100644 --- a/bsp/allwinner_tina/drivers/drv_sdio.c +++ b/bsp/allwinner_tina/drivers/drv_sdio.c @@ -33,7 +33,7 @@ #include "drv_clock.h" #define DBG_ENABLE -#define DBG_SECTION_NAME "[MMC]" +#define DBG_SECTION_NAME "MMC" // #define DBG_LEVEL DBG_LOG // #define DBG_LEVEL DBG_INFO #define DBG_LEVEL DBG_WARNING diff --git a/bsp/allwinner_tina/drivers/spi/drv_spi.c b/bsp/allwinner_tina/drivers/spi/drv_spi.c index 9f01878ae3..bf5da9de58 100644 --- a/bsp/allwinner_tina/drivers/spi/drv_spi.c +++ b/bsp/allwinner_tina/drivers/spi/drv_spi.c @@ -34,7 +34,7 @@ #define SPI_BUS_MAX_CLK (30 * 1000 * 1000) #define DBG_ENABLE -#define DBG_SECTION_NAME "[SPI]" +#define DBG_SECTION_NAME "SPI" #define DBG_LEVEL DBG_WARNING #define DBG_COLOR #include diff --git a/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c b/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c index 9e2f339df4..6dc1b1b334 100644 --- a/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c +++ b/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c @@ -27,7 +27,7 @@ #include #define DBG_ENABLE -#define DBG_SECTION_NAME "[FLASH]" +#define DBG_SECTION_NAME "FLASH" #define DBG_LEVEL DBG_LOG #define DBG_COLOR #include diff --git a/bsp/imxrt1052-evk/drivers/drv_eth.c b/bsp/imxrt1052-evk/drivers/drv_eth.c index 44b0da7d6a..7e06f67ae1 100644 --- a/bsp/imxrt1052-evk/drivers/drv_eth.c +++ b/bsp/imxrt1052-evk/drivers/drv_eth.c @@ -42,7 +42,7 @@ //#define ETH_TX_DUMP #define DBG_ENABLE -#define DBG_SECTION_NAME "[ETH]" +#define DBG_SECTION_NAME "ETH" #define DBG_COLOR #define DBG_LEVEL DBG_INFO #include diff --git a/bsp/imxrt1052-evk/drivers/drv_eth_fire.c b/bsp/imxrt1052-evk/drivers/drv_eth_fire.c index 69375f5800..673f0061b8 100644 --- a/bsp/imxrt1052-evk/drivers/drv_eth_fire.c +++ b/bsp/imxrt1052-evk/drivers/drv_eth_fire.c @@ -42,7 +42,7 @@ //#define ETH_TX_DUMP #define DBG_ENABLE -#define DBG_SECTION_NAME "[ETH]" +#define DBG_SECTION_NAME "ETH" #define DBG_COLOR #define DBG_LEVEL DBG_LOG #include diff --git a/bsp/imxrt1052-evk/drivers/fsl_phy_fire.c b/bsp/imxrt1052-evk/drivers/fsl_phy_fire.c index 632dcf1d75..b430bb86a2 100644 --- a/bsp/imxrt1052-evk/drivers/fsl_phy_fire.c +++ b/bsp/imxrt1052-evk/drivers/fsl_phy_fire.c @@ -26,7 +26,7 @@ #include #define DBG_ENABLE -#define DBG_SECTION_NAME "[PHY]" +#define DBG_SECTION_NAME "PHY" #define DBG_COLOR #define DBG_LEVEL DBG_LOG #include diff --git a/bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c b/bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c index 10ef50b281..c598c33635 100644 --- a/bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c +++ b/bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c @@ -29,7 +29,7 @@ #include "realview.h" #define DBG_ENABLE -#define DBG_SECTION_NAME "[PL041]" +#define DBG_SECTION_NAME "PL041" // #define DBG_LEVEL DBG_LOG // #define DBG_LEVEL DBG_INFO #define DBG_LEVEL DBG_WARNING diff --git a/bsp/x1000/drivers/mmc/drv_mmc.c b/bsp/x1000/drivers/mmc/drv_mmc.c index 469ed939b2..137c53ad92 100644 --- a/bsp/x1000/drivers/mmc/drv_mmc.c +++ b/bsp/x1000/drivers/mmc/drv_mmc.c @@ -34,7 +34,7 @@ #define PIO_THRESHOLD 64 /* use pio mode if data length < PIO_THRESHOLD */ #define DEBUG_ENABLE -#define DEBUG_SECTION_NAME "[SDIO]" +#define DEBUG_SECTION_NAME "SDIO" #define DEBUG_LEVEL DBG_INFO // #define DEBUG_LEVEL DBG_LOG #define DEBUG_COLOR diff --git a/components/dfs/include/dfs_private.h b/components/dfs/include/dfs_private.h index d5d630b47e..43be0db00e 100644 --- a/components/dfs/include/dfs_private.h +++ b/components/dfs/include/dfs_private.h @@ -4,7 +4,7 @@ #include // #define DBG_ENABLE -#define DBG_SECTION_NAME "[ DFS]" +#define DBG_SECTION_NAME "DFS" #define DBG_COLOR #define DBG_LEVEL DBG_LOG #include diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 5365026724..34f8f621e7 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -43,7 +43,7 @@ // #define DEBUG_ENABLE #define DEBUG_LEVEL DBG_LOG -#define DBG_SECTION_NAME "[UART]" +#define DBG_SECTION_NAME "UART" #define DEBUG_COLOR #include diff --git a/components/lwp/lwp.c b/components/lwp/lwp.c index acd290bc0f..17d5ec0b10 100644 --- a/components/lwp/lwp.c +++ b/components/lwp/lwp.c @@ -32,7 +32,7 @@ #include "lwp.h" #define DBG_ENABLE -#define DBG_SECTION_NAME "[LWP]" +#define DBG_SECTION_NAME "LWP" #define DBG_COLOR #define DBG_LEVEL DBG_WARNING #include diff --git a/components/lwp/lwp_mem.c b/components/lwp/lwp_mem.c index 6092dc6ee5..9b3dcf45a6 100644 --- a/components/lwp/lwp_mem.c +++ b/components/lwp/lwp_mem.c @@ -26,7 +26,7 @@ #include #define DBG_ENABLE -#define DBG_SECTION_NAME "[LWPMEM]" +#define DBG_SECTION_NAME "LWPMEM" #define DBG_COLOR #define DBG_LEVEL DBG_WARNING #include diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index f0d2f0e9eb..d52c3d09f6 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -27,7 +27,7 @@ #include #define DBG_ENABLE -#define DBG_SECTION_NAME "[LWP_CALL]" +#define DBG_SECTION_NAME "LWP_CALL" #define DBG_COLOR #define DBG_LEVEL DBG_WARNING #include diff --git a/src/signal.c b/src/signal.c index 6d7b847c12..5b93c774df 100644 --- a/src/signal.c +++ b/src/signal.c @@ -35,7 +35,7 @@ #endif // #define DBG_ENABLE -#define DBG_SECTION_NAME "[SIGN]" +#define DBG_SECTION_NAME "SIGN" #define DBG_COLOR #define DBG_LEVEL DBG_LOG #include