From 67188c869205ff5d03fc6dbbb4929c8223c1def0 Mon Sep 17 00:00:00 2001 From: armink Date: Fri, 25 May 2018 16:06:06 +0800 Subject: [PATCH 1/2] [rtdbg] Add simple API to rtdbg.h. Such as LOG_D, LOG_E. --- include/rtdbg.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/include/rtdbg.h b/include/rtdbg.h index 26e289eff..8cecd8de2 100644 --- a/include/rtdbg.h +++ b/include/rtdbg.h @@ -20,6 +20,7 @@ * Change Logs: * Date Author Notes * 2016-11-12 Bernard The first version + * 2018-05-25 armink Add simple API, such as LOG_D, LOG_E */ /* @@ -31,6 +32,11 @@ * In your C/C++ file, enable/disable DEBUG_ENABLE macro, and then include this * header file. * + * #undef DBG_SECTION_NAME // avoid the macro is already defined + * #undef DBG_LEVEL + * #undef DBG_COLOR + * #undef DBG_ENABLE + * * #define DBG_SECTION_NAME "[ MOD]" * #define DBG_ENABLE // enable debug macro * #define DBG_LEVEL DBG_INFO @@ -39,7 +45,11 @@ * Then in your C/C++ file, you can use dbg_log macro to print out logs: * dbg_log(DBG_INFO, "this is a log!\n"); * - * Or if you want to use different color for different kinds log, you can + * Or if you want to using the simple API, you can + * LOG_D("this is a debug log!"); + * LOG_E("this is a error log!"); + * + * If you want to use different color for different kinds log, you can * #define DBG_COLOR */ @@ -120,12 +130,23 @@ _DBG_COLOR(0); \ } +#define dbg_log_line(level, ...) \ + dbg_log(level, __VA_ARGS__); \ + if ((level) >= DBG_LEVEL) { \ + rt_kprintf("\n"); \ + } + #else #define dbg_log(level, fmt, ...) #define dbg_here #define dbg_enter #define dbg_exit +#define dbg_log_line(level, ...) #endif -#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__) +#endif /* RT_DBG_H__ */ From 72316a6e6d5cd4a091062d5ae4a61285551354b6 Mon Sep 17 00:00:00 2001 From: armink Date: Mon, 28 May 2018 09:29:49 +0800 Subject: [PATCH 2/2] [rtdbg] Update some comments on rtdbg.h. --- include/rtdbg.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/rtdbg.h b/include/rtdbg.h index 8cecd8de2..4d9f760c0 100644 --- a/include/rtdbg.h +++ b/include/rtdbg.h @@ -32,11 +32,6 @@ * In your C/C++ file, enable/disable DEBUG_ENABLE macro, and then include this * header file. * - * #undef DBG_SECTION_NAME // avoid the macro is already defined - * #undef DBG_LEVEL - * #undef DBG_COLOR - * #undef DBG_ENABLE - * * #define DBG_SECTION_NAME "[ MOD]" * #define DBG_ENABLE // enable debug macro * #define DBG_LEVEL DBG_INFO