logging: Add API to get log_backend instance by name.
Added helper API to the logging backend interface to get the log backend instance by name. Signed-off-by: Aastha Grover <aastha.grover@intel.com>
This commit is contained in:
parent
134c0c3562
commit
e4e675dc37
2 changed files with 22 additions and 0 deletions
|
@ -170,6 +170,15 @@ void log_backend_enable(struct log_backend const *const backend,
|
|||
*/
|
||||
void log_backend_disable(struct log_backend const *const backend);
|
||||
|
||||
/**
|
||||
* @brief Get backend by name.
|
||||
*
|
||||
* @param[in] backend_name Name of the backend as defined by the LOG_BACKEND_DEFINE.
|
||||
*
|
||||
* @retval Pointer to the backend instance if found, NULL if backend is not found.
|
||||
*/
|
||||
const struct log_backend *log_backend_get_by_name(const char *backend_name);
|
||||
|
||||
/**
|
||||
* @brief Get current number of allocated buffers for string duplicates.
|
||||
*/
|
||||
|
|
|
@ -160,6 +160,19 @@ static void backend_filter_set(struct log_backend const *const backend,
|
|||
}
|
||||
}
|
||||
|
||||
const struct log_backend *log_backend_get_by_name(const char *backend_name)
|
||||
{
|
||||
const struct log_backend *ptr = __log_backends_start;
|
||||
|
||||
while (ptr < __log_backends_end) {
|
||||
if (strcmp(backend_name, ptr->name) == 0) {
|
||||
return ptr;
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void log_backend_enable(struct log_backend const *const backend,
|
||||
void *ctx,
|
||||
uint32_t level)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue