| 
                 
                    AWS IoT Device SDK C:
                    Logging
                 
                
                    Generate and print log messages
                 
             | 
        
| Return to main page ↑ | 
Implementation of logging functions from iot_logging.h. More...
#include "iot_config.h"#include <stdarg.h>#include <stdio.h>#include <string.h>#include "platform/iot_clock.h"#include "iot_logging.h"#include "iot_static_memory.h"Macros | |
| #define | IotLogging_Puts puts | 
| Function the logging library uses to print a line.  More... | |
| #define | IotLogging_Malloc Iot_MallocMessageBuffer | 
| Allocate a new logging buffer. This function must have the same signature as malloc.  | |
| #define | IotLogging_Free Iot_FreeMessageBuffer | 
| Free a logging buffer. This function must have the same signature as free.  | |
| #define | IotLogging_StaticBufferSize Iot_MessageBufferSize | 
| Get the size of a logging buffer. Statically-allocated buffers should all have the same size.  | |
| #define | MAX_TIMESTRING_LENGTH ( 64 ) | 
| A guess of the maximum length of a timestring.  More... | |
| #define | MAX_LOG_LEVEL_LENGTH ( 8 ) | 
The longest string in _pLogLevelStrings (below), plus 3 to accommodate [] and a null-terminator.  | |
| #define | BYTES_PER_LINE ( 16 ) | 
| How many bytes IotLog_PrintBuffer should output on each line.  | |
Functions | |
| void | IotLog_Generic (int32_t libraryLogSetting, const char *const pLibraryName, int32_t messageLevel, const IotLogConfig_t *const pLogConfig, const char *const pFormat,...) | 
| Generic logging function that prints a single message.  More... | |
| void | IotLog_GenericPrintBuffer (const char *const pLibraryName, const char *const pHeader, const uint8_t *const pBuffer, size_t bufferSize) | 
| Generic function to log the contents of a buffer as bytes.  More... | |
Variables | |
| static const char *const | _pLogLevelStrings [5] | 
| Lookup table for log levels.  More... | |
Implementation of logging functions from iot_logging.h.
| #define IotLogging_Puts puts | 
Function the logging library uses to print a line.
This function can be set by using a define. By default, the standard library puts function is used.
| #define MAX_TIMESTRING_LENGTH ( 64 ) | 
A guess of the maximum length of a timestring.
There's no way for this logging library to know the length of a timestring before it's generated. Therefore, the logging library will assume a maximum length of any timestring it may get. This value should be generous enough to accommodate the vast majority of timestrings.
| void IotLog_Generic | ( | int32_t | libraryLogSetting, | 
| const char *const | pLibraryName, | ||
| int32_t | messageLevel, | ||
| const IotLogConfig_t *const | pLogConfig, | ||
| const char *const | pFormat, | ||
| ... | |||
| ) | 
Generic logging function that prints a single message.
This function is the generic logging function shared across all libraries. The library-specific logging function IotLog is implemented using this function. Like IotLog, this function is only available when LIBRARY_LOG_LEVEL is IOT_LOG_NONE.
In most cases, the library-specific logging function IotLog should be called instead of this function.
| [in] | libraryLogSetting | The log level setting of the library, used to determine if the log message should be printed. Must be one of the Log levels. | 
| [in] | pLibraryName | The library name to print. See LIBRARY_LOG_NAME. | 
| [in] | messageLevel | The log level of the this message. See LIBRARY_LOG_LEVEL. | 
| [in] | pLogConfig | Pointer to a IotLogConfig_t. Optional; pass NULL to ignore.  | 
| [in] | pFormat | Format string for the log message. | 
| [in] | ... | Arguments for format specification. | 
| void IotLog_GenericPrintBuffer | ( | const char *const | pLibraryName, | 
| const char *const | pHeader, | ||
| const uint8_t *const | pBuffer, | ||
| size_t | bufferSize | ||
| ) | 
Generic function to log the contents of a buffer as bytes.
This function is the generic buffer logging function shared across all libraries. The library-specific buffer logging function IotLog_PrintBuffer is implemented using this function. Like IotLog_PrintBuffer, this function is only available when LIBRARY_LOG_LEVEL is IOT_LOG_DEBUG.
In most cases, the library-specific buffer logging function IotLog_PrintBuffer should be called instead of this function.
| [in] | pLibraryName | The library name to print with the log. See LIBRARY_LOG_NAME. | 
| [in] | pHeader | A message to print before printing the buffer. | 
| [in] | pBuffer | The buffer to print. | 
| [in] | bufferSize | The number of bytes in pBuffer to print. | 
      
  | 
  static | 
Lookup table for log levels.
Converts one of the Log levels to a string.