logging: Add optional context argument to LOG_BACKEND_DEFINE

Extended LOG_BACKEND_DEFINE to support optional context argument.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2021-04-26 14:25:49 +02:00 committed by Carles Cufí
parent edc3c87c72
commit d9518ce4cc
2 changed files with 7 additions and 2 deletions

View file

@ -76,10 +76,13 @@ extern const struct log_backend __log_backends_end[];
* @param _api Logger backend API.
* @param _autostart If true backend is initialized and activated together
* with the logger subsystem.
* @param ... Optional context.
*/
#define LOG_BACKEND_DEFINE(_name, _api, _autostart) \
#define LOG_BACKEND_DEFINE(_name, _api, _autostart, ...) \
static struct log_backend_control_block UTIL_CAT(backend_cb_, _name) = \
{ \
COND_CODE_0(NUM_VA_ARGS_LESS_1(_, ##__VA_ARGS__), \
(), (.ctx = __VA_ARGS__,)) \
.id = 0, \
.active = false, \
}; \

View file

@ -592,7 +592,9 @@ void log_init(void)
backend->api->init(backend);
}
log_backend_enable(backend, NULL, CONFIG_LOG_MAX_LEVEL);
log_backend_enable(backend,
backend->cb->ctx,
CONFIG_LOG_MAX_LEVEL);
}
}
}