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:
Aastha Grover 2022-01-27 13:20:59 -08:00 committed by Maureen Helm
commit e4e675dc37
2 changed files with 22 additions and 0 deletions

View file

@ -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)