Skip to content

Commit 22d53f9

Browse files
nordic-krchnashif
authored andcommitted
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 <[email protected]>
1 parent c0808e3 commit 22d53f9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

include/logging/log_ctrl.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <kernel.h>
1010
#include <logging/log_backend.h>
1111
#include <logging/log_msg.h>
12+
#include <logging/log_internal.h>
1213

1314
#ifdef __cplusplus
1415
extern "C" {
@@ -189,6 +190,26 @@ uint32_t log_get_strdup_pool_utilization(void);
189190
*/
190191
uint32_t log_get_strdup_longest_string(void);
191192

193+
/**
194+
* @brief Check if there is pending data to be processed by the logging subsystem.
195+
*
196+
* Function can be used to determine if all logs have been flushed. Function
197+
* returns false when deferred mode is not enabled.
198+
*
199+
* @retval true There is pending data.
200+
* @retval false No pending data to process.
201+
*/
202+
static inline bool log_data_pending(void)
203+
{
204+
if (IS_ENABLED(CONFIG_LOG2_MODE_DEFERRED)) {
205+
return z_log_msg2_pending();
206+
} else if (IS_ENABLED(CONFIG_LOG_MODE_DEFERRED)) {
207+
return log_msg_mem_get_used() > 0;
208+
}
209+
210+
return false;
211+
}
212+
192213
#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_MODE_MINIMAL)
193214
#define LOG_CORE_INIT() log_core_init()
194215
#define LOG_INIT() log_init()

0 commit comments

Comments
 (0)