1.2.5.4.10 SYS_DEBUG_PRINT Macro

C

#define SYS_DEBUG_PRINT(level, fmt, ...)

Summary

Formats and prints an error message if the system error level is defined at or lower than the level specified.

Description

This macro formats and prints an error message if the system error level is defined at or lower than the level specified.

Precondition

If mapped to the SYS_DEBUG_Print function, then the system debug service must be initialized and running.

Parameters

ParamDescription
levelThe current error level threshold for displaying the message.
formatPointer to a buffer containing the format string for the message to be displayed.
...Zero or more optional parameters to be formated as defined by the format string.

Returns

None.

Example

// In configuration.h file: #define SYS_DEBUG_USE_CONSOLE  1
// In sys_debug.h: #define SYS_DEBUG_PRINT(level, fmt, ...) _SYS_DEBUG_PRINT(level, fmt, ##__VA_ARGS__)

// In source code
int result;

result = SomeOperation();

if (result > MAX_VALUE)
{
    SYS_DEBUG_PRINT(SYS_ERROR_WARNING, "Result of %d exceeds max value\r\n", result);
    // Take appropriate action
}

Remarks

The format string and arguments follow the printf convention.

By default, this macro is defined as nothing, effectively removing all code generated by calls to it. To process SYS_DEBUG_PRINT calls, this macro must be defined in a way that maps calls to it to the desired implementation (see example, above).

This macro can be mapped to the system console service (along with other system debug macros) by defining SYS_DEBUG_USE_CONSOLE in the system configuration (configuration.h) instead of defining it individually.