diff --git a/platform/Kconfig b/platform/Kconfig index 39357095131fb18ad67397f820457636b98dd4ce..937c0bcb80aa87e0ad42d922abe12622c2601d37 100644 --- a/platform/Kconfig +++ b/platform/Kconfig @@ -80,3 +80,19 @@ config HRTIMER_ENABLE help Enable High-resolution timer support +config HILOG + tristate "Hilog support" + default y + help + hilog buffer manager. + + Hilog is a simple log manager for OpenHarmonyOS. + log string write to /dev/hilog, and the hilog driver copy it + to the ring buffer. Ring buffer can be read from userspace. + +config HILOG_BUFFER_SIZE + int "hilog buffer size" + default 4096 + help + Define the default ring buffer size of hilog + diff --git a/platform/los_hilog.c b/platform/los_hilog.c index 6d9fbc6fb284463107ae140ce1370e69a40ccae1..22485d75fc21d88d3b256c53c45a0470f9b12b05 100644 --- a/platform/los_hilog.c +++ b/platform/los_hilog.c @@ -41,7 +41,7 @@ #include "los_vm_lock.h" #include "user_copy.h" -#define HILOG_BUFFER 4096 +#define HILOG_BUFFER LOSCFG_HILOG_BUFFER_SIZE #define DRIVER_MODE 0666 #define HILOG_DRIVER "/dev/hilog" @@ -255,6 +255,7 @@ static void HiLogCoverOldLog(size_t bufLen) int retval; struct HiLogEntry header; size_t totalSize = bufLen + sizeof(struct HiLogEntry); + int dropLogLines = 0; while (totalSize + g_hiLogDev.size > HILOG_BUFFER) { retval = HiLogReadRingBuffer((unsigned char *)&header, sizeof(header)); @@ -262,9 +263,13 @@ static void HiLogCoverOldLog(size_t bufLen) break; } + dropLogLines++; HiLogBufferDec(sizeof(header)); HiLogBufferDec(header.len); } + if (dropLogLines > 0) { + dprintf("hilog ringbuffer full, drop %d line(s) log", dropLogLines); + } } int HiLogWriteInternal(const char *buffer, size_t bufLen)