Looking at the code of function nrf_log_frontend_dequeue, in nRF5_SDK_17.0.2_d674dde/components/libraries/log/src/nrf_log_frontend.c:716, it seems to me that the code chunk at lines 875-891, which is as follows :
if (NRF_LOG_ALLOW_OVERFLOW) { // Read index can be moved forward only if dequeueing process was not interrupt by // skipping procedure. If NRF_LOG_ALLOW_OVERFLOW is set then in case of buffer gets full // and new logger entry occurs, oldest entry is removed. In that case read index is // changed and updating it here would corrupt the internal circular buffer. CRITICAL_REGION_ENTER(); if (m_log_data.log_skipped == 0) { m_log_data.rd_idx = rd_idx; } CRITICAL_REGION_EXIT(); } else { m_log_data.rd_idx = rd_idx; }
Could be moved upwards, and placed at line 838, just before while (p_backend). Because the whole content of the circular buffer has been moved to the memobj p_msg_buf there is no reason why not free space in the circular buffer earlier, in tight memory situation this would allow to avoid some trace loss due to the circular buffer overflow.