Debug support¶
Middleware has extended debugging capabilities. These consist of different debugging levels and types of debug messages, allowing to track and catch different types of warnings, severe problems or simply output messages program flow messages (trace messages).
Module is highly configurable using library configuration methods. Application must enable some options to decide what type of messages and for which modules it would like to output messages.
With default configuration, printf
is used as output function.
This behavior can be changed with LWESP_CFG_DBG_OUT
configuration.
For successful debugging, application must:
Enable global debugging by setting
LWESP_CFG_DBG
toLWESP_DBG_ON
Configure which types of messages to output
Configure debugging level, from all messages to severe only
Enable specific modules to debug, by setting its configuration value to
LWESP_DBG_ON
Tip
Check Configuration for all modules with debug implementation.
An example code with config and latter usage:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* Modifications of lwesp_opts.h file for configuration */
/* Enable global debug */
#define LWESP_CFG_DBG LWESP_DBG_ON
/*
* Enable debug types.
* Application may use bitwise OR | to use multiple types:
* LWESP_DBG_TYPE_TRACE | LWESP_DBG_TYPE_STATE
*/
#define LWESP_CFG_DBG_TYPES_ON LWESP_DBG_TYPE_TRACE
/* Enable debug on custom module */
#define MY_DBG_MODULE LWESP_DBG_ON
|
1 2 3 4 5 6 7 8 9 | #include "lwesp/lwesp_debug.h"
/*
* Print debug message to the screen
* Trace message will be printed as it is enabled in types
* while state message will not be printed.
*/
LWESP_DEBUGF(MY_DBG_MODULE | LWESP_DBG_TYPE_TRACE, "This is trace message on my program\r\n");
LWESP_DEBUGF(MY_DBG_MODULE | LWESP_DBG_TYPE_STATE, "This is state message on my program\r\n");
|
-
group
LWESP_DEBUG
Debug support module to track library flow.
Debug levels
List of debug levels
-
LWESP_DBG_LVL_ALL
¶ Print all messages of all types
-
LWESP_DBG_LVL_WARNING
¶ Print warning and upper messages
-
LWESP_DBG_LVL_DANGER
¶ Print danger errors
-
LWESP_DBG_LVL_SEVERE
¶ Print severe problems affecting program flow
-
LWESP_DBG_LVL_MASK
¶ Mask for getting debug level
Debug types
List of debug types
-
LWESP_DBG_TYPE_TRACE
¶ Debug trace messages for program flow
-
LWESP_DBG_TYPE_STATE
¶ Debug state messages (such as state machines)
-
LWESP_DBG_TYPE_ALL
¶ All debug types
Defines
-
LWESP_DBG_ON
¶ Indicates debug is enabled
-
LWESP_DBG_OFF
¶ Indicates debug is disabled
-
LWESP_DEBUGF
(c, fmt, ...)¶ Print message to the debug “window” if enabled.
- Parameters
[in] c
: Condition if debug of specific type is enabled[in] fmt
: Formatted string for debug[in] ...
: Variable parameters for formatted string
-
LWESP_DEBUGW
(c, cond, fmt, ...)¶ Print message to the debug “window” if enabled when specific condition is met.
- Parameters
[in] c
: Condition if debug of specific type is enabled[in] cond
: Debug only if this condition is true[in] fmt
: Formatted string for debug[in] ...
: Variable parameters for formatted string
-