未验证 提交 157fb8b2 编写于 作者: S shenchenkai 提交者: Gitee

reduce print log if hilog ringbuffer is full

Signed-off-by: Nshenchenkai <shenchenkai@huawei.com>
上级 95f7cf16
...@@ -238,7 +238,7 @@ static void HiLogHeadInit(struct HiLogEntry *header, size_t len) ...@@ -238,7 +238,7 @@ static void HiLogHeadInit(struct HiLogEntry *header, size_t len)
ret = clock_gettime(CLOCK_REALTIME, &now); ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) { 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; return;
} }
...@@ -255,7 +255,9 @@ static void HiLogCoverOldLog(size_t bufLen) ...@@ -255,7 +255,9 @@ static void HiLogCoverOldLog(size_t bufLen)
int retval; int retval;
struct HiLogEntry header; struct HiLogEntry header;
size_t totalSize = bufLen + sizeof(struct HiLogEntry); 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) { while (totalSize + g_hiLogDev.size > HILOG_BUFFER) {
retval = HiLogReadRingBuffer((unsigned char *)&header, sizeof(header)); retval = HiLogReadRingBuffer((unsigned char *)&header, sizeof(header));
...@@ -264,11 +266,18 @@ static void HiLogCoverOldLog(size_t bufLen) ...@@ -264,11 +266,18 @@ static void HiLogCoverOldLog(size_t bufLen)
} }
dropLogLines++; dropLogLines++;
isThisTimeFull = 1;
isLastTimeFull = 1;
HiLogBufferDec(sizeof(header)); HiLogBufferDec(sizeof(header));
HiLogBufferDec(header.len); HiLogBufferDec(header.len);
} }
if (dropLogLines > 0) { if (isLastTimeFull == 1 && isThisTimeFull == 0) {
dprintf("hilog ringbuffer full, drop %d line(s) log", dropLogLines); /* 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) ...@@ -330,7 +339,7 @@ static void HiLogDeviceInit(void)
{ {
g_hiLogDev.buffer = LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, HILOG_BUFFER); g_hiLogDev.buffer = LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, HILOG_BUFFER);
if (g_hiLogDev.buffer == NULL) { 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); init_waitqueue_head(&g_hiLogDev.wq);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册