flexda_log
Function
Prints logs.
Syntax
int flexda_log(uint32_t level, uint32_t module_id, const char *format, ...);
Parameters
Parameter |
Type |
Input/Output |
Description |
|---|---|---|---|
level |
uint32_t |
Input |
The following log levels are supported:
|
module_id |
uint32_t |
Input |
Log module ID. |
format |
const char * |
Input |
Format string. |
... |
... |
Input |
Variadic parameters, representing the values to be formatted and printed. |
Return value |
int |
Output |
The function returns 0 upon successful execution; otherwise, it returns an error code. |
The log module must be successfully registered. Otherwise, an error code is returned and an error log is generated.
Example
Function pointer invocation.
// Ensure that the global libapi library g_api is correctly initialized.
flexda_custom_api_t g_api;
uint32_t g_test_log_module[7] = {};
int ret = flexda_log_register("TEST");
if (ret >= 0) {
g_test_log_module[0] = ret;
}
// Directly call the log function in the global libapi library.
g_api.flexda_log(4, g_test_log_module[0], "This is an err log.\n");
g_api.flexda_log(FLEXDA_LOG_WARNING, g_test_log_module[0], "This is a warning(macro level) log.\n");
g_api.flexda_log(FLEXDA_LOG_ERR, g_test_log_module[0], "This is a err log with variable var = 0x%x.\n", var);
// Use the macro function provided by libapi.h.
flexda_log(ERR, g_test_log_module[0], "This is err log string.\n");
flexda_log(INFO, g_test_log_module[0], "This is a info log with variable var = 0x%x.\n", var);
Parent topic: Log Interfaces