logging: Add function for checking if there is pending data

Add function which can be used to check if there is any pending
data to process. It can be used to determine if deferred logging
has completed processing.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2021-11-18 12:54:56 +01:00 committed by Anas Nashif
parent c0808e3f59
commit 22d53f9152

View file

@ -9,6 +9,7 @@
#include <kernel.h>
#include <logging/log_backend.h>
#include <logging/log_msg.h>
#include <logging/log_internal.h>
#ifdef __cplusplus
extern "C" {
@ -189,6 +190,26 @@ uint32_t log_get_strdup_pool_utilization(void);
*/
uint32_t log_get_strdup_longest_string(void);
/**
* @brief Check if there is pending data to be processed by the logging subsystem.
*
* Function can be used to determine if all logs have been flushed. Function
* returns false when deferred mode is not enabled.
*
* @retval true There is pending data.
* @retval false No pending data to process.
*/
static inline bool log_data_pending(void)
{
if (IS_ENABLED(CONFIG_LOG2_MODE_DEFERRED)) {
return z_log_msg2_pending();
} else if (IS_ENABLED(CONFIG_LOG_MODE_DEFERRED)) {
return log_msg_mem_get_used() > 0;
}
return false;
}
#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_MODE_MINIMAL)
#define LOG_CORE_INIT() log_core_init()
#define LOG_INIT() log_init()