AWS IoT Device SDK C: Logging
Generate and print log messages
Return to main page ↑
IotLog_PrintBuffer

Log the contents of buffer as bytes. Only available when LIBRARY_LOG_LEVEL is IOT_LOG_DEBUG.

void IotLog_GenericPrintBuffer( const char * const pLibraryName,
const char * const pHeader,
const uint8_t * const pBuffer,
size_t bufferSize );

This function prints the bytes located at a given memory address. It is intended for debugging only, and is therefore only available when LIBRARY_LOG_LEVEL is IOT_LOG_DEBUG.

Log messages printed by this function always include the log level, library name, and time. In addition, this function may print an optional header pHeader before it prints the contents of the buffer. This function does not have an IotLogConfig_t parameter.

The logging library must be set up before this function may be called. See Setup and use for more information.

Parameters
[in]pHeaderA message to log before the buffer. Optional; pass NULL to ignore.
[in]pBufferPointer to start of buffer.
[in]bufferSizeSize of pBuffer.
Returns
No return value. On errors, it prints nothing.
Note
This function may be implemented as a macro.
To conserve memory, IotLog_PrintBuffer (the underlying implementation) only allocates enough memory for a single line of output. Therefore, in multithreaded systems, its output may appear "fragmented" if other threads are logging simultaneously.
See also
IotLog_PrintBuffer for the generic (not library-specific) buffer logging function.

Example

const uint8_t pBuffer[] = { 0x00, 0x01, 0x02, 0x03 };
IotLog_PrintBuffer( "This buffer contains:",
pBuffer,
4 );

The code above prints something like the following:

[DEBUG][LIB_NAME][2018-01-01 12:00:00] This buffer contains:
00 01 02 03