logging: Add log initialization to system startup

Log API can be used before user can explicitly initialize the logger.
In order to ensure that logger core is ready to buffer log messages
it must be initialize as early as possible. Initialization does not
include initialization of default backend since driver may not be
ready and backend is needed only when log messages are processed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2018-07-11 12:26:31 +02:00 committed by Anas Nashif
commit 6b01c89935
7 changed files with 72 additions and 34 deletions

View file

@ -29,12 +29,18 @@ extern "C" {
typedef u32_t (*timestamp_get_t)(void);
/**
* @brief Function for initializing logger core.
/** @brief Function system initialization of the logger.
*
* @return 0 on success or error.
* Function is called during start up to allow logging before user can
* explicitly initialize the logger.
*/
int log_init(void);
void log_core_init(void);
/**
* @brief Function for user initialization of the logger.
*
*/
void log_init(void);
/**
* @brief Function for providing timestamp function.
@ -138,7 +144,7 @@ void log_backend_enable(struct log_backend const *const backend,
*/
void log_backend_disable(struct log_backend const *const backend);
#if defined(CONFIG_LOG) && CONFIG_LOG
#if CONFIG_LOG
#define LOG_INIT() log_init()
#define LOG_PANIC() log_panic()
#define LOG_PROCESS() log_process(false)

View file

@ -182,6 +182,9 @@ union log_msg_chunk {
extern struct k_mem_slab log_msg_pool;
/** @brief Function for initialization of the log message pool. */
void log_msg_pool_init(void);
/** @brief Function for indicating that message is in use.
*
* @details Message can be used (read) by multiple users. Internal reference