flexda_log_register
Function
Registers a log module. When printing logs, the registered module ID is used as a parameter and the module name string is carried.
Syntax
int flexda_log_register(const char *name);
Parameters
Parameter |
Type |
Input/Output |
Description |
|---|---|---|---|
name |
const char * |
Input |
Name of the log module. |
Return value |
int |
Output |
The function returns the ID of the registered log module upon successful execution; otherwise, it returns an error code. |
- A maximum of 7 distinct log modules can be registered. If this limit is exceeded, any further registration attempts will return an error code and generate an error log.
- The maximum length for a log module name (excluding the null terminator) is 29 characters. Exceeding this limit will result in an error code and an error log.
- Registering the same string repeatedly will return an error code and generate an error log.
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] = {};
// Register the log module and save its ID.
int ret = flexda_log_register("TEST");
if (ret >= 0) {
g_test_log_module[0] = ret;
flexda_log(INFO, g_test_log_module[0], "test log\n");
}
// Print: "dpdk|INFO|[flexda_ovs_adapter]TEST: test log"
Parent topic: Log Interfaces