Distributed Publish & Subscribe for IoT
Debug

Debug and logging macros and functions. More...

Macros

#define DPS_DBG_TAG   NULL
 This can be redefined to include a custom tag in the log message.
 
#define DPS_DBGBYTES(bytes, n)   (DPS_DEBUG_ENABLED() ? DPS_LogBytes(DPS_LOG_DBGPRINT, __FILE__, __LINE__, __FUNCTION__, bytes, n) : (void)0)
 Log an array of bytes at DBGPRINT level.
 
#define DPS_DBGINFO(fmt, ...)   (DPS_INFO_ENABLED() ? DPS_Log(DPS_LOG_INFO, __FILE__, __LINE__, __FUNCTION__, DPS_DBG_TAG, fmt, ##__VA_ARGS__) : (void)0)
 Log a message at DBGINFO level - Like DPS_DBGPRINT but can be turned on in isolation with DPS_DEBUG_CONTROL(DPS_DEBUG_INFO)
 
#define DPS_DBGPRINT(fmt, ...)   (DPS_DEBUG_ENABLED() ? DPS_Log(DPS_LOG_DBGPRINT, __FILE__, __LINE__, __FUNCTION__, DPS_DBG_TAG, fmt, ##__VA_ARGS__) : (void)0)
 Log a message at DBGPRINT level.
 
#define DPS_DBGTRACE()   (DPS_DEBUG_ENABLED() ? DPS_Log(DPS_LOG_DBGTRACE, __FILE__, __LINE__, __FUNCTION__, DPS_DBG_TAG, "\n") : (void)0)
 Log a function name at DBGTRACE level.
 
#define DPS_DBGTRACEA(fmt, ...)   (DPS_DEBUG_ENABLED() ? DPS_Log(DPS_LOG_DBGTRACE, __FILE__, __LINE__, __FUNCTION__, DPS_DBG_TAG, fmt, ##__VA_ARGS__) : (void)0)
 Log a function name and message at DBGTRACE level.
 
#define DPS_DEBUG_ENABLED()   ((DPS_Debug && (__DPS_DebugControl == DPS_DEBUG_ON)) || (__DPS_DebugControl == DPS_DEBUG_FORCE))
 True if DPS debug logging is enabled.
 
#define DPS_DEBUG_FORCE   2
 Force debug logging.
 
#define DPS_DEBUG_INFO   3
 Enable only INFO messages.
 
#define DPS_DEBUG_OFF   0
 Disable debug logging.
 
#define DPS_DEBUG_ON   1
 Enable debug logging.
 
#define DPS_ERRPRINT(fmt, ...)   DPS_Log(DPS_LOG_ERROR, __FILE__, __LINE__, __FUNCTION__, DPS_DBG_TAG, fmt, ##__VA_ARGS__)
 Log a message at ERROR level.
 
#define DPS_INFO_ENABLED()   ((__DPS_DebugControl == DPS_DEBUG_INFO) || DPS_DEBUG_ENABLED())
 True if DPS info logging is enabled.
 
#define DPS_PRINT(fmt, ...)   DPS_Log(DPS_LOG_PRINT, __FILE__, __LINE__, __FUNCTION__, DPS_DBG_TAG, fmt, ##__VA_ARGS__)
 Log a message at PRINT level.
 
#define DPS_PRINTT(fmt, ...)   DPS_Log(DPS_LOG_PRINTT, __FILE__, __LINE__, __FUNCTION__, DPS_DBG_TAG, fmt, ##__VA_ARGS__)
 Same as DPS_PRINT but prepends a system timestamp.
 
#define DPS_WARNPRINT(fmt, ...)   (DPS_DEBUG_ENABLED() ? DPS_Log(DPS_LOG_WARNING, __FILE__, __LINE__, __FUNCTION__, DPS_DBG_TAG, fmt, ##__VA_ARGS__) : (void)0)
 Log a message at WARNING level.
 

Enumerations

enum  DPS_LogLevel {
  DPS_LOG_INFO, DPS_LOG_ERROR, DPS_LOG_WARNING, DPS_LOG_PRINT,
  DPS_LOG_PRINTT, DPS_LOG_DBGTRACE, DPS_LOG_DBGPRINT
}
 Debug logging levels.
 

Functions

void DPS_Log (DPS_LogLevel level, const char *file, int line, const char *function, const char *tag, const char *fmt,...)
 Log a message. More...
 
void DPS_LogBytes (DPS_LogLevel level, const char *file, int line, const char *function, const uint8_t *bytes, size_t n)
 Log an array of bytes. More...
 

Variables

int DPS_Debug
 Debug control value.
 

Detailed Description

Debug and logging macros and functions.

Function Documentation

◆ DPS_Log()

void DPS_Log ( DPS_LogLevel  level,
const char *  file,
int  line,
const char *  function,
const char *  tag,
const char *  fmt,
  ... 
)

Log a message.

Parameters
levelthe logging level
filethe file name of the message
linethe file line of the message
functionthe function name of the message
tagthe custom tag of the message
fmtthe printf style format of the message
...the format parameters

◆ DPS_LogBytes()

void DPS_LogBytes ( DPS_LogLevel  level,
const char *  file,
int  line,
const char *  function,
const uint8_t *  bytes,
size_t  n 
)

Log an array of bytes.

Parameters
levelthe logging level
filethe file name of the message
linethe file line of the message
functionthe function name of the message
bytesthe array of bytes
nthe number of bytes in the array