logging: Fix silent logs dropping when LOG_MODE_OVERFLOW disabled

There was no notification about dropped logs When logger operated
in the mode where message is dropped when logger has no space to
store the message. Notification was printed only if logger operated
in the mode which overwrites oldest log.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2019-02-26 14:33:47 +01:00 committed by Kumar Gala
commit e64cd5c74d
3 changed files with 12 additions and 2 deletions

View file

@ -540,6 +540,10 @@ bool log_is_strdup(void *buf);
*/ */
void log_free(void *buf); void log_free(void *buf);
/** @brief Indicate to the log core that one log message has been dropped.
*/
void log_dropped(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -439,8 +439,6 @@ static void msg_process(struct log_msg *msg, bool bypass)
log_backend_put(backend, msg); log_backend_put(backend, msg);
} }
} }
} else {
atomic_inc(&dropped_cnt);
} }
log_msg_put(msg); log_msg_put(msg);
@ -488,6 +486,11 @@ u32_t log_buffered_cnt(void)
return buffered_cnt; return buffered_cnt;
} }
void log_dropped(void)
{
atomic_inc(&dropped_cnt);
}
u32_t log_src_cnt_get(u32_t domain_id) u32_t log_src_cnt_get(u32_t domain_id)
{ {
return log_sources_count(); return log_sources_count();

View file

@ -74,10 +74,13 @@ union log_msg_chunk *log_msg_no_space_handle(void)
if (IS_ENABLED(CONFIG_LOG_MODE_OVERFLOW)) { if (IS_ENABLED(CONFIG_LOG_MODE_OVERFLOW)) {
do { do {
more = log_process(true); more = log_process(true);
log_dropped();
err = k_mem_slab_alloc(&log_msg_pool, err = k_mem_slab_alloc(&log_msg_pool,
(void **)&msg, (void **)&msg,
K_NO_WAIT); K_NO_WAIT);
} while ((err != 0) && more); } while ((err != 0) && more);
} else {
log_dropped();
} }
return msg; return msg;