Logging Interface#

Logging Interface#

Interface for log for sidewalk SDK. For more details, please see Logging Documentation

Modules#

sid_pal_log_buffer

Type definitions

Functions#

void
sid_pal_log(sid_pal_log_severity_t severity, uint32_t num_args, const char *fmt,...)

Printf style logging function.

The function returns current logging level.

void

Flush log function.

char const *
sid_pal_log_push_str(char *string)

String log pushing operation - in the case of JLink RTT logs since these are deferred, they require that a special function be used in order to ensure that strings are copied correctly in order for pushing then at a later time.

bool
sid_pal_log_get_log_buffer(struct sid_pal_log_buffer *const log_buffer)

Allows for retrival of log buffers from sid_pal_log implementation.

void
sid_pal_hexdump(sid_pal_log_severity_t severity, const void *address, int length)

Log raw data bytes.

Macros#

#define

Define the maximum number of bytes per single line of sid_pal_hexdump() logging.

#define

Macro to count the number of arguments in a variadic macro.

#define

Helper macro to count the number of arguments in a variadic macro.

#define
SID_PAL_VA_ARG_N (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, N, ...)

Helper macro to extract the number of arguments.

#define

Macro to define a reverse sequence of numbers from 62 to 0.

#define
SID_PAL_LOG_HIGHEST_SEVIRITY (level, fmt_, ...)

Logs a message with the highest severity level.

#define
SID_PAL_LOG (level_, fmt_, ...)

Logs a message if the severity level is less than or equal to the configured log level.

#define
SID_PAL_HEXDUMP (level_, data_, len_)

Dumps a block of data in hexadecimal format.

#define

Flushes the log buffer.

#define

Pushes a string to the log.

#define
SID_PAL_LOG_ERROR (fmt_, ...)

Logs an error message with the highest severity level.

#define

Logs a warning message if the severity level is greater than or equal to the warning level.

#define
SID_PAL_LOG_INFO (fmt_, ...)

Logs an informational message if the severity level is greater than or equal to the info level.

#define
SID_PAL_LOG_DEBUG (fmt_, ...)

Logs a debug message if the severity level is greater than or equal to the debug level.

#define

Logs a trace message with file name, line number, and function name.

#define
SID_HAL_LOG (level, fmt_, ...)

Logs a message if the severity level is less than or equal to the configured log level.

#define
SID_HAL_LOG_ERROR (fmt_, ...)

Logs an error message with the highest severity level.

#define

Logs a warning message if the severity level is greater than or equal to the warning level.

#define
SID_HAL_LOG_INFO (fmt_, ...)

Logs an informational message if the severity level is greater than or equal to the info level.

#define
SID_HAL_LOG_DEBUG (fmt_, ...)

Logs a debug message if the severity level is greater than or equal to the debug level.

#define
SID_HAL_LOG_FLUSH SID_PAL_LOG_FLUSH

Flushes the log buffer.

#define

Pushes a string to the log.

#define

Dumps a block of data in hexadecimal format with error severity.

#define

Dumps a block of data in hexadecimal format with warning severity.

#define

Dumps a block of data in hexadecimal format with info severity.

#define

Dumps a block of data in hexadecimal format with debug severity.

Function Documentation#

sid_pal_log#

void sid_pal_log (sid_pal_log_severity_t severity, uint32_t num_args, const char * fmt, ... )

Printf style logging function.

Parameters
TypeDirectionArgument NameDescription
sid_pal_log_severity_t[in]severity

Severity of the log

uint32_t[in]num_args

Number of arguments to be logged

const char *[in]fmt

Format string to print with variables

...N/A

sid_log_control_get_current_log_level#

sid_pal_log_severity_t sid_log_control_get_current_log_level (void )

The function returns current logging level.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Implemented in sid_log_control


sid_pal_log_flush#

void sid_pal_log_flush (void )

Flush log function.

Parameters
TypeDirectionArgument NameDescription
voidN/A

The function flushes the log buffers to the output interface


sid_pal_log_push_str#

char const * sid_pal_log_push_str (char * string)

String log pushing operation - in the case of JLink RTT logs since these are deferred, they require that a special function be used in order to ensure that strings are copied correctly in order for pushing then at a later time.

Parameters
TypeDirectionArgument NameDescription
char *[in]string

Pointer to the string that has to be copied.

For platforms that do not use deferred logging, this can remain unimplemented.


sid_pal_log_get_log_buffer#

bool sid_pal_log_get_log_buffer (struct sid_pal_log_buffer *const log_buffer)

Allows for retrival of log buffers from sid_pal_log implementation.

Parameters
TypeDirectionArgument NameDescription
struct sid_pal_log_buffer *const[in]log_buffer

Pointer to log buffer descriptor

OPTIONAL If business logic wants to send logs over an external connection they can use this api to pull out logs from sid_pal_log implementation if implemented. Internally the implementation can use a circular list of buffers to store the logs as they come.


sid_pal_hexdump#

void sid_pal_hexdump (sid_pal_log_severity_t severity, const void * address, int length)

Log raw data bytes.

Parameters
TypeDirectionArgument NameDescription
sid_pal_log_severity_t[in]severity

Severity of the log

const void *[in]address

Pointer to data to be logged

int[in]length

The length of data to be logged (in bytes)


Macro Definition Documentation#

SID_PAL_HEXDUMP_MAX#

#define SID_PAL_HEXDUMP_MAX
Value:
(8)

Define the maximum number of bytes per single line of sid_pal_hexdump() logging.

When the caller requests more bytes then the output will be split into multiple lines using SID_PAL_HEXDUMP_MAX bytes per line, plus eventual remainder in the last line.


SID_PAL_VA_NARG#

#define SID_PAL_VA_NARG
Value:
(...)

Macro to count the number of arguments in a variadic macro.

This macro counts the number of arguments passed to it. It uses a combination of helper macros to achieve this.

Returns

  • The number of arguments passed.


SID_PAL_VA_NARG_#

#define SID_PAL_VA_NARG_
Value:
(...)

Helper macro to count the number of arguments in a variadic macro.

This macro is used internally by SID_PAL_VA_NARG to count the number of arguments.

Returns

  • The number of arguments passed.


SID_PAL_VA_ARG_N#

#define SID_PAL_VA_ARG_N
Value:
(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, N, ...)

Helper macro to extract the number of arguments.

This macro extracts the number of arguments from the list of arguments.

Returns

  • The number of arguments passed.


SID_PAL_RSEQ_N#

#define SID_PAL_RSEQ_N
Value:
62, 61, 60, \
59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \
49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \
39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \
29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
9, 8, 7, 6, 5, 4, 3, 2, 1, 0

Macro to define a reverse sequence of numbers from 62 to 0.

This macro generates a sequence of numbers in descending order starting from 62 down to 0. It can be used in various contexts where such a sequence is required.


SID_PAL_LOG_HIGHEST_SEVIRITY#

#define SID_PAL_LOG_HIGHEST_SEVIRITY

Logs a message with the highest severity level.


SID_PAL_LOG#

#define SID_PAL_LOG

Logs a message if the severity level is less than or equal to the configured log level.


SID_PAL_HEXDUMP#

#define SID_PAL_HEXDUMP

Dumps a block of data in hexadecimal format.


SID_PAL_LOG_FLUSH#

#define SID_PAL_LOG_FLUSH

Flushes the log buffer.

This macro calls the function to flush the log buffer.


SID_PAL_LOG_PUSH_STR#

#define SID_PAL_LOG_PUSH_STR
Value:
(x)

Pushes a string to the log.


SID_PAL_LOG_ERROR#

#define SID_PAL_LOG_ERROR
Value:
(fmt_, ...)

Logs an error message with the highest severity level.


SID_PAL_LOG_WARNING#

#define SID_PAL_LOG_WARNING
Value:
(fmt_, ...)

Logs a warning message if the severity level is greater than or equal to the warning level.


SID_PAL_LOG_INFO#

#define SID_PAL_LOG_INFO
Value:
(fmt_, ...)

Logs an informational message if the severity level is greater than or equal to the info level.


SID_PAL_LOG_DEBUG#

#define SID_PAL_LOG_DEBUG
Value:
(fmt_, ...)

Logs a debug message if the severity level is greater than or equal to the debug level.


SID_PAL_LOG_TRACE#

#define SID_PAL_LOG_TRACE
Value:
()

Logs a trace message with file name, line number, and function name.

This macro logs a trace message at the informational level, including the file name, line number, and function name where the macro is called.


SID_HAL_LOG#

#define SID_HAL_LOG
Value:
do { \
sid_pal_log(level, SID_PAL_VA_NARG(__VA_ARGS__), fmt_, ##__VA_ARGS__); \
} while(0)

Logs a message if the severity level is less than or equal to the configured log level.


SID_HAL_LOG_ERROR#

#define SID_HAL_LOG_ERROR
Value:
(fmt_, ...)

Logs an error message with the highest severity level.


SID_HAL_LOG_WARNING#

#define SID_HAL_LOG_WARNING
Value:
(fmt_, ...)

Logs a warning message if the severity level is greater than or equal to the warning level.


SID_HAL_LOG_INFO#

#define SID_HAL_LOG_INFO
Value:
(fmt_, ...)

Logs an informational message if the severity level is greater than or equal to the info level.


SID_HAL_LOG_DEBUG#

#define SID_HAL_LOG_DEBUG
Value:
(fmt_, ...)

Logs a debug message if the severity level is greater than or equal to the debug level.


SID_HAL_LOG_FLUSH#

#define SID_HAL_LOG_FLUSH
Value:
SID_PAL_LOG_FLUSH

Flushes the log buffer.

This macro calls the function to flush the log buffer.


SID_HAL_LOG_PUSH_STR#

#define SID_HAL_LOG_PUSH_STR
Value:
(x)

Pushes a string to the log.


SID_HAL_LOG_HEXDUMP_ERROR#

#define SID_HAL_LOG_HEXDUMP_ERROR
Value:
(data_, len_)

Dumps a block of data in hexadecimal format with error severity.


SID_HAL_LOG_HEXDUMP_WARNING#

#define SID_HAL_LOG_HEXDUMP_WARNING
Value:
(data_, len_)

Dumps a block of data in hexadecimal format with warning severity.


SID_HAL_LOG_HEXDUMP_INFO#

#define SID_HAL_LOG_HEXDUMP_INFO
Value:
(data_, len_)

Dumps a block of data in hexadecimal format with info severity.


SID_HAL_LOG_HEXDUMP_DEBUG#

#define SID_HAL_LOG_HEXDUMP_DEBUG
Value:
(data_, len_)

Dumps a block of data in hexadecimal format with debug severity.