diff --git a/kernel/extended/hilog/los_hilog.c b/kernel/extended/hilog/los_hilog.c index 9fe43ec63b958c13b8df5f6a1f3f5c336cd60794..3537089239855e54ff1fadcc397d24eca1e6cd28 100644 --- a/kernel/extended/hilog/los_hilog.c +++ b/kernel/extended/hilog/los_hilog.c @@ -238,7 +238,7 @@ static void HiLogHeadInit(struct HiLogEntry *header, size_t len) ret = clock_gettime(CLOCK_REALTIME, &now); if (ret != 0) { - dprintf("In %s line %d,clock_gettime fail", __FUNCTION__, __LINE__); + dprintf("In %s line %d,clock_gettime fail\n", __FUNCTION__, __LINE__); return; } @@ -255,7 +255,9 @@ static void HiLogCoverOldLog(size_t bufLen) int retval; struct HiLogEntry header; size_t totalSize = bufLen + sizeof(struct HiLogEntry); - int dropLogLines = 0; + static int dropLogLines = 0; + static int isLastTimeFull = 0; + int isThisTimeFull = 0; while (totalSize + g_hiLogDev.size > HILOG_BUFFER) { retval = HiLogReadRingBuffer((unsigned char *)&header, sizeof(header)); @@ -264,11 +266,18 @@ static void HiLogCoverOldLog(size_t bufLen) } dropLogLines++; + isThisTimeFull = 1; + isLastTimeFull = 1; HiLogBufferDec(sizeof(header)); HiLogBufferDec(header.len); } - if (dropLogLines > 0) { - dprintf("hilog ringbuffer full, drop %d line(s) log", dropLogLines); + if (isLastTimeFull == 1 && isThisTimeFull == 0) { + /* so we can only print one log if hilog ring buffer is full in a short time */ + if (dropLogLines > 0) { + dprintf("hilog ringbuffer full, drop %d line(s) log\n", dropLogLines); + } + isLastTimeFull = 0; + dropLogLines = 0; } } @@ -330,7 +339,7 @@ static void HiLogDeviceInit(void) { g_hiLogDev.buffer = LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, HILOG_BUFFER); if (g_hiLogDev.buffer == NULL) { - dprintf("In %s line %d,LOS_MemAlloc fail", __FUNCTION__, __LINE__); + dprintf("In %s line %d,LOS_MemAlloc fail\n", __FUNCTION__, __LINE__); } init_waitqueue_head(&g_hiLogDev.wq);