From bab1b74e3a9d84fa95ba005a3c0a61cb9d8485dd Mon Sep 17 00:00:00 2001 From: shenchenkai Date: Sun, 9 May 2021 12:20:05 +0800 Subject: [PATCH] Description:[feature] make hilog cache disabable Change-Id: Id450bcf2fa9be65bc7edb6fe7b6030c751443c4c --- frameworks/mini/BUILD.gn | 4 ++++ frameworks/mini/hiview_output_log.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/frameworks/mini/BUILD.gn b/frameworks/mini/BUILD.gn index 15f776a..7a12388 100755 --- a/frameworks/mini/BUILD.gn +++ b/frameworks/mini/BUILD.gn @@ -15,6 +15,7 @@ import("//build/lite/ndk/ndk.gni") declare_args() { ohos_hiviewdfx_hilog_lite_file_size = 8192 + ohos_hiviewdfx_hilog_lite_disable_cache = false } static_library("hilog_lite") { sources = [ @@ -24,6 +25,9 @@ static_library("hilog_lite") { ] cflags = [ "-Wall" ] defines = [ "HIVIEW_LOG_FILE_SIZE = $ohos_hiviewdfx_hilog_lite_file_size" ] + if (ohos_hiviewdfx_hilog_lite_disable_cache) { + defines += ["DISABLE_HILOG_CACHE"] + } include_dirs = [ "//base/hiviewdfx/hiview_lite", "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite", diff --git a/frameworks/mini/hiview_output_log.c b/frameworks/mini/hiview_output_log.c index cf3230c..03030f5 100755 --- a/frameworks/mini/hiview_output_log.c +++ b/frameworks/mini/hiview_output_log.c @@ -37,7 +37,9 @@ static char g_logLevelInfo[HILOG_LV_MAX] = { 'F' // "FATAL" }; +#ifndef DISABLE_HILOG_CACHE static uint8 g_logCacheBuffer[LOG_STATIC_CACHE_SIZE]; +#endif static HiviewCache g_logCache = { .size = 0, .buffer = NULL, @@ -67,7 +69,9 @@ static int32 LogValuesFmtHash(char *desStrPtr, int32 desLen, const HiLogContent void InitCoreLogOutput(void) { g_logFlushInfo.mutex = HIVIEW_MutexInit(); +#ifndef DISABLE_HILOG_CACHE InitHiviewStaticCache(&g_logCache, LOG_CACHE, g_logCacheBuffer, sizeof(g_logCacheBuffer)); +#endif HiviewRegisterMsgHandle(HIVIEW_MSG_OUTPUT_LOG_TEXT_FILE, OutputLog2TextFile); HiviewRegisterMsgHandle(HIVIEW_MSG_OUTPUT_LOG_BIN_FILE, OutputLog2BinFile); HiviewRegisterMsgHandle(HIVIEW_MSG_OUTPUT_LOG_FLOW, OutputLogRealtime); @@ -115,7 +119,12 @@ void OutputLog(const uint8 *data, uint32 len) return; } - if (g_hiviewConfig.outputOption == OUTPUT_OPTION_DEBUG) { +#ifdef DISABLE_HILOG_CACHE + boolean isDisableCache = true; +#else + boolean isDisableCache = false; +#endif + if (g_hiviewConfig.outputOption == OUTPUT_OPTION_DEBUG || isDisableCache) { char tempOutStr[LOG_FMT_MAX_LEN] = {0}; if (LogContentFmt(tempOutStr, sizeof(tempOutStr), data) > 0) { HIVIEW_UartPrint(tempOutStr); -- Gitee