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#
Pre-initializes the log component.
Starts the timestamp timer, initializes the backend Appends timestamp to early logs and flushes them to the backend.
Set the log level for the logger.
Get the current log level of the logger.
Synchronize the timestamp between the host and captive core.
Send a log event with no arguments.
Send a log event with one argument.
Send a log event with two arguments.
Send a log event with three arguments.
va_list variant of SL_LOG_PRINT_TARGET_EX.
Flush the logger buffer.
Macros#
Function Documentation#
sl_log_init_stage1#
void sl_log_init_stage1 (void )
Pre-initializes the log component.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| 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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| 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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| 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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| 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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| 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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| 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.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| 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 |
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
Output may be suppressed until the backend has been initialised (sl_log_init_stage2()).
sl_log_flush#
sl_status_t sl_log_flush (void )
Flush the logger buffer.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/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.