X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=bertos%2Fcfg%2Fdebug.h;fp=bertos%2Fcfg%2Fdebug.h;h=2fbedc51c5e999208b9416a9fdd21df7186d436d;hb=fc1c829d69a2731429d3b884294f918019d8fb95;hp=60a9e7fba43d31c6f2a595c0ee60e2a3e8bc3a41;hpb=ae49992feaf10bde38755c613644113d8dadc218;p=bertos.git diff --git a/bertos/cfg/debug.h b/bertos/cfg/debug.h index 60a9e7fb..2fbedc51 100644 --- a/bertos/cfg/debug.h +++ b/bertos/cfg/debug.h @@ -46,6 +46,7 @@ #include #include + /* * Defaults for rarely used config stuff. */ @@ -185,6 +186,72 @@ #define TRACEMSG(...) do {} while(0) #endif + /** + * Multi level logging system. + * + * You can use these macro directy or using the cfg/log.h module + * that provide a simple interface for using the logging multilevel system. + * The priority level is order form error messages (hight priority) to info messages + * (low priority), so if you choose a low level log message you can see also all message + * that have a hight priority. + * + * \{ + */ + /// Logging level definition + #define DBG_LOG_ERROR 0 + #define DBG_LOG_WARNING 1 + #define DBG_LOG_INFO 2 + + /// Logging verbose mode + #define DBG_LOG_VERBOSE 1 + #define DBG_LOG_SILENT 0 + + #define DBG_ERROR(debug_level, mode, str,...) \ + do { \ + if(debug_level >= DBG_LOG_ERROR) \ + { \ + if (mode == DBG_LOG_VERBOSE)\ + kprintf("Error(%s():%d): "str, __func__, __LINE__, ## __VA_ARGS__); \ + else \ + kprintf("Error: "str, ## __VA_ARGS__); \ + } \ + else \ + { \ + /* NONE */ \ + } \ + } while (0) + + #define DBG_WARNING(debug_level, mode, str,...) \ + do { \ + if(debug_level >= DBG_LOG_WARNING) \ + { \ + if (mode == DBG_LOG_VERBOSE) \ + kprintf("Warning(%s():%d): "str, __func__, __LINE__, ## __VA_ARGS__); \ + else \ + kprintf("Warning: "str, ## __VA_ARGS__); \ + } \ + else \ + { \ + /* NONE */ \ + } \ + } while (0) + + #define DBG_INFO(debug_level, mode, str,...) \ + do { \ + if(debug_level >= DBG_LOG_INFO) \ + { \ + if (mode == DBG_LOG_VERBOSE) \ + kprintf("Info(%s():%d): "str, __func__, __LINE__, ## __VA_ARGS__); \ + else \ + kprintf("Info: "str, ## __VA_ARGS__); \ + } \ + else \ + { \ + /* NONE */ \ + } \ + } while (0) + /* \} */ + /** * \name Walls to detect data corruption * \{