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
SID_PAL_HEXDUMP_MAX (8)

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

#define
SID_PAL_VA_NARG (...)

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

#define
SID_PAL_VA_NARG_ (...)

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
SID_PAL_RSEQ_N ()

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
SID_PAL_LOG_FLUSH ()

Flushes the log buffer.

#define
SID_PAL_LOG_PUSH_STR (x)

Pushes a string to the log.

#define
SID_PAL_LOG_ERROR (fmt_, ...)

Logs an error message with the highest severity level.

#define
SID_PAL_LOG_WARNING (fmt_, ...)

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
SID_PAL_LOG_TRACE ()

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

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)