Common API Functions#

Common logging API functions available to all users.

These functions provide the main interface for initializing, configuring, and using the logging system. They are designed to work across all supported platforms and backends.

Functions#

void

Pre-initializes the log component.

sl_status_t

Starts the timestamp timer, initializes the backend Appends timestamp to early logs and flushes them to the backend.

sl_status_t
sl_log_set_loglevel(sl_log_level_t level)

Set the log level for the logger.

Get the current log level of the logger.

sl_status_t
sl_log_sync_timestamp(uint8_t core_id, void *args)

Synchronize the timestamp between the host and captive core.

void
sl_log_send_no_args(uint32_t event_id, uint8_t log_level)

Send a log event with no arguments.

void
sl_log_send_arg1(uint32_t event_id, uint8_t log_level, uint32_t arg1)

Send a log event with one argument.

void
sl_log_send_arg2(uint32_t event_id, uint8_t log_level, uint32_t arg1, uint32_t arg2)

Send a log event with two arguments.

void
sl_log_send_arg3(uint32_t event_id, uint8_t log_level, uint32_t arg1, uint32_t arg2, uint32_t arg3)

Send a log event with three arguments.

void
sl_log_vprint_target_ex(uint32_t options, const char *fmt, va_list ap)

va_list variant of SL_LOG_PRINT_TARGET_EX.

sl_status_t

Flush the logger buffer.

Macros#

#define
SL_LOG_PRINT_TARGET_EX (options, fmt, ...)

Function Documentation#

sl_log_init_stage1#

void sl_log_init_stage1 (void )

Pre-initializes the log component.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Called before the backend and timestamp timer are ready. Initializes the ring buffer configuration.


sl_log_init_stage2#

sl_status_t sl_log_init_stage2 (void )

Starts the timestamp timer, initializes the backend Appends timestamp to early logs and flushes them to the backend.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • sl_status_t Status code indicating the result of the operation.

    • SL_STATUS_OK: Initialization successful.

    • SL_STATUS_NOT_INITIALIZED: Logger not properly initialized.

    • SL_STATUS_FAIL: Initialization failed.


sl_log_set_loglevel#

sl_status_t sl_log_set_loglevel (sl_log_level_t level)

Set the log level for the logger.

Parameters
TypeDirectionArgument NameDescription
sl_log_level_t[in]level

Log level to be set.

Returns

  • sl_status_t Status code indicating the result of the operation.

    • SL_STATUS_OK: Log level set successfully.

    • SL_STATUS_INVALID_PARAMETER: Invalid log level parameter.


sl_log_get_loglevel#

sl_log_level_t sl_log_get_loglevel (void )

Get the current log level of the logger.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • sl_log_level_t Current log level.


sl_log_sync_timestamp#

sl_status_t sl_log_sync_timestamp (uint8_t core_id, void * args)

Synchronize the timestamp between the host and captive core.

Parameters
TypeDirectionArgument NameDescription
uint8_t[in]core_id

Core identifier.

void *[in]args

Pointer to additional arguments if needed.

Returns

  • sl_status_t Status code indicating the result of the operation.

    • SL_STATUS_OK: Synchronization successful.

    • SL_STATUS_FAIL: Synchronization failed.

    • SL_STATUS_INVALID_PARAMETER: Invalid parameters provided.

    • any other error codes as defined by the underlying implementation.


sl_log_send_no_args#

void sl_log_send_no_args (uint32_t event_id, uint8_t log_level)

Send a log event with no arguments.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]event_id

Event identifier (format string pointer or numeric ID)

uint8_t[in]log_level

Log level combined with event type flags

Logs an event containing only an event ID and level information. This is the most efficient logging function as it requires minimal memory and processing overhead.

Note

  • This function is typically called by higher-level logging macros rather than directly by application code.


sl_log_send_arg1#

void sl_log_send_arg1 (uint32_t event_id, uint8_t log_level, uint32_t arg1)

Send a log event with one argument.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]event_id

Event identifier (format string pointer or numeric ID)

uint8_t[in]log_level

Log level combined with event type flags

uint32_t[in]arg1

First argument for the log event

Logs an event with a single 32-bit argument. Suitable for logging simple values like integers, pointers, or status codes.

Note

  • Arguments are stored as 32-bit values. Larger data types should be cast or split across multiple arguments.


sl_log_send_arg2#

void sl_log_send_arg2 (uint32_t event_id, uint8_t log_level, uint32_t arg1, uint32_t arg2)

Send a log event with two arguments.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]event_id

Event identifier (format string pointer or numeric ID)

uint8_t[in]log_level

Log level combined with event type flags

uint32_t[in]arg1

First argument for the log event

uint32_t[in]arg2

Second argument for the log event

Logs an event with two 32-bit arguments. Useful for logging pairs of related values or more complex data structures.


sl_log_send_arg3#

void sl_log_send_arg3 (uint32_t event_id, uint8_t log_level, uint32_t arg1, uint32_t arg2, uint32_t arg3)

Send a log event with three arguments.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]event_id

Event identifier (format string pointer or numeric ID)

uint8_t[in]log_level

Log level combined with event type flags

uint32_t[in]arg1

First argument for the log event

uint32_t[in]arg2

Second argument for the log event

uint32_t[in]arg3

Third argument for the log event

Logs an event with three 32-bit arguments. Use sl_log_send_arg4 through sl_log_send_arg10 for more arguments (when SL_LOG_CONFIG_ARG is configured accordingly).


sl_log_vprint_target_ex#

void sl_log_vprint_target_ex (uint32_t options, const char * fmt, va_list ap)

va_list variant of SL_LOG_PRINT_TARGET_EX.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]options

Message-type flag (see Backend-Agnostic Print Options).

const char *[in]fmt

printf-style format string. NULL is treated as a no-op.

va_list[in]ap

Variadic argument list previously initialised by the caller via va_start. The callee consumes ap; use va_copy if the caller needs to reuse it.

Backend implementations override this function; sli_log_print_target_ex forwards to it after va_start. Callers that already hold a va_list (e.g. when implementing their own printf-style helpers) should call this directly.

Note


sl_log_flush#

sl_status_t sl_log_flush (void )

Flush the logger buffer.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Forces immediate transmission of all pending log events in the ring buffer to the selected backend. This function blocks until all events are sent or an error occurs.

Returns

  • sl_status_t Status code indicating the result of the operation.

    • SL_STATUS_OK: All events flushed successfully

    • SL_STATUS_FAIL: Flush operation failed

    • SL_STATUS_INVALID_STATE: Logger not properly initialized

Note

  • This function is useful before entering sleep mode or at critical points where log data must be preserved.