From 139393a2944e9fba906417a318290e6980ad75b2 Mon Sep 17 00:00:00 2001 From: shenchenkai Date: Tue, 2 Nov 2021 20:39:52 +0800 Subject: [PATCH 1/4] Description:[feature] support set log level interface for L0 Change-Id: I561e0013b092522e0c35e5649ac4f791d71333de Signed-off-by: shenchenkai --- frameworks/mini/hiview_log.c | 20 +++++++++++++++++-- .../native/kits/hilog_lite/hiview_log.h | 13 ++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/frameworks/mini/hiview_log.c b/frameworks/mini/hiview_log.c index 76c8927..ba6f5b8 100755 --- a/frameworks/mini/hiview_log.c +++ b/frameworks/mini/hiview_log.c @@ -13,8 +13,9 @@ * limitations under the License. */ -#include "string.h" -#include "stdarg.h" +#include +#include +#include #include "ohos_init.h" #include "hiview_def.h" #include "hiview_util.h" @@ -218,3 +219,18 @@ void HiLogOutputFileUnLock(void) { HiLogOutputFileUnLockImp(); } + +uint32 HiLogGetLogLevel(void) +{ + return g_hiviewConfig.level; +} + +boolean HiLogSetLogLevel(uint8 level) +{ + if (level >= HILOG_LV_DEBUG && level < HILOG_LV_MAX) { + g_hiviewConfig.level = level; + printf("Set log level: %d\n", level); + return TRUE; + } + return FALSE; +} diff --git a/interfaces/native/kits/hilog_lite/hiview_log.h b/interfaces/native/kits/hilog_lite/hiview_log.h index 7dc7798..fffe0ca 100755 --- a/interfaces/native/kits/hilog_lite/hiview_log.h +++ b/interfaces/native/kits/hilog_lite/hiview_log.h @@ -481,6 +481,19 @@ void HILOG_HashPrintf(uint8 module, uint8 level, const char *nums, uint32 hash, #define HILOG_FATAL_HASH(mod, hash, ...) #endif +/* + * Interface for get hilog level + * @return Returns current hilog level. + */ +uint32 HiLogGetLogLevel(void); + +/* + * Interface for set hilog level + * @param level identifies the level to be set + * @return Returns TRUE if setting log level is successful; returns FALSE otherwise. + */ +boolean HiLogSetLogLevel(uint8 level); + #ifdef __cplusplus #if __cplusplus } -- Gitee From e82f9ab9d19f4a4f4c22029d21312211e8e458df Mon Sep 17 00:00:00 2001 From: shenchenkai Date: Wed, 3 Nov 2021 14:28:54 +0800 Subject: [PATCH 2/4] Description:[fix] sync file after flush log Change-Id: Id03d4d7d14a02c69f0d0de444a1ffdae27219527 Signed-off-by: shenchenkai --- frameworks/mini/hiview_output_log.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/frameworks/mini/hiview_output_log.c b/frameworks/mini/hiview_output_log.c index 3735b7d..560b305 100755 --- a/frameworks/mini/hiview_output_log.c +++ b/frameworks/mini/hiview_output_log.c @@ -234,7 +234,6 @@ static void OutputLog2TextFile(const Request *req) HIVIEW_MutexLock(g_logFlushInfo.mutex); HiLogContent logContent; char tempOutStr[LOG_FMT_MAX_LEN] = {0}; - (void)req; if (g_logCache.usedSize < sizeof(HiLogCommon)) { HIVIEW_MutexUnlock(g_logFlushInfo.mutex); @@ -263,6 +262,9 @@ static void OutputLog2TextFile(const Request *req) } } HIVIEW_MutexUnlock(g_logFlushInfo.mutex); + if (req != NULL && req->msgValue == SYNC_FILE) { + HIVIEW_FileSync(g_logFile.fhandle); + } } static void OutputLog2BinFile(const Request *req) @@ -273,7 +275,6 @@ static void OutputLog2BinFile(const Request *req) uint16 valueLen; uint8 *tmpBuffer = NULL; uint16 outputSize = g_logCache.usedSize; - (void)req; if (outputSize < sizeof(HiLogCommon)) { HIVIEW_MutexUnlock(g_logFlushInfo.mutex); @@ -309,6 +310,9 @@ static void OutputLog2BinFile(const Request *req) } HIVIEW_MemFree(MEM_POOL_HIVIEW_ID, tmpBuffer); HIVIEW_MutexUnlock(g_logFlushInfo.mutex); + if (req != NULL && req->msgValue == SYNC_FILE) { + HIVIEW_FileSync(g_logFile.fhandle); + } } uint32 GetLogFileSize(void) @@ -512,24 +516,26 @@ void FlushLog(boolean syncFlag) if (syncFlag == FALSE) { switch (opt) { case OUTPUT_OPTION_TEXT_FILE: - HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_LOG_TEXT_FILE, 0); + HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_LOG_TEXT_FILE, SYNC_FILE); break; case OUTPUT_OPTION_BIN_FILE: - HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_LOG_BIN_FILE, 0); + HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_LOG_BIN_FILE, SYNC_FILE); break; case OUTPUT_OPTION_FLOW: - HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_LOG_FLOW, 0); + HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_LOG_FLOW, SYNC_FILE); break; default: break; } } else { + Request request = {0}; + request.msgValue = SYNC_FILE; switch (opt) { case OUTPUT_OPTION_TEXT_FILE: - OutputLog2TextFile(NULL); + OutputLog2TextFile(&request); break; case OUTPUT_OPTION_BIN_FILE: - OutputLog2BinFile(NULL); + OutputLog2BinFile(&request); break; case OUTPUT_OPTION_FLOW: OutputLogRealtime(NULL); -- Gitee From 63526ddaa5ec8b6b894d41d4a7b8f4e9c1093e10 Mon Sep 17 00:00:00 2001 From: wangtiantian Date: Wed, 3 Nov 2021 06:59:31 +0000 Subject: [PATCH 3/4] IssueNo:https://gitee.com/openharmony/hiviewdfx_hilog_lite/issues/I4GP5H Description:HILog add uikit module Sig:graphic Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wangtiantian --- frameworks/mini/hiview_log.c | 3 ++- interfaces/native/kits/hilog_lite/hiview_log.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/frameworks/mini/hiview_log.c b/frameworks/mini/hiview_log.c index ba6f5b8..b8d5022 100755 --- a/frameworks/mini/hiview_log.c +++ b/frameworks/mini/hiview_log.c @@ -51,7 +51,8 @@ static void HiLogInit(void) HiLogRegisterModule(HILOG_MODULE_SEN, "SEN") == FALSE || HiLogRegisterModule(HILOG_MODULE_SCY, "SCY") == FALSE || HiLogRegisterModule(HILOG_MODULE_SOFTBUS, "SOFTBUS") == FALSE || - HiLogRegisterModule(HILOG_MODULE_POWERMGR, "POWERMGR") == FALSE) { + HiLogRegisterModule(HILOG_MODULE_POWERMGR, "POWERMGR") == FALSE || + HiLogRegisterModule(HILOG_MODULE_UIKIT, "UIKIT") == FALSE) { return; } diff --git a/interfaces/native/kits/hilog_lite/hiview_log.h b/interfaces/native/kits/hilog_lite/hiview_log.h index fffe0ca..af98d87 100755 --- a/interfaces/native/kits/hilog_lite/hiview_log.h +++ b/interfaces/native/kits/hilog_lite/hiview_log.h @@ -116,6 +116,8 @@ typedef enum { HILOG_MODULE_SOFTBUS, /** PowerMgr */ HILOG_MODULE_POWERMGR, + /** UIKit */ + HILOG_MODULE_UIKIT, /** OEM Customize */ HILOG_MODULE_OEM_CUSTOMIZE = 32, /** Maximum number of modules */ -- Gitee From 8c5491e66658b031bb7b0f793b298a99f8d9160e Mon Sep 17 00:00:00 2001 From: shenchenkai Date: Tue, 9 Nov 2021 23:05:55 +0800 Subject: [PATCH 4/4] Description:[fix] support customize LOG_STATIC_CACHE_SIZE and HIVIEW_HILOG_FILE_BUF_SIZE Change-Id: I8b481c6d5801b4395002c38103871d098b259042 Signed-off-by: shenchenkai --- frameworks/mini/BUILD.gn | 75 ++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/frameworks/mini/BUILD.gn b/frameworks/mini/BUILD.gn index 4ac2d4f..b450910 100755 --- a/frameworks/mini/BUILD.gn +++ b/frameworks/mini/BUILD.gn @@ -14,50 +14,51 @@ import("//build/lite/ndk/ndk.gni") declare_args() { - ohos_hiviewdfx_hilog_lite_file_size = 8192 - ohos_hiviewdfx_hilog_lite_disable_cache = false - ohos_hiviewdfx_hilog_lite_limit_level_default = 30 - ohos_hiviewdfx_hilog_lite_disable_print_limit = false + ohos_hiviewdfx_hilog_lite_file_size = 8192 + ohos_hiviewdfx_hilog_lite_disable_cache = false + ohos_hiviewdfx_hilog_lite_limit_level_default = 30 + ohos_hiviewdfx_hilog_lite_disable_print_limit = false + ohos_hiviewdfx_log_static_cache_size = 1024 + ohos_hiviewdfx_hiview_hilog_file_buf_size = 512 } config("hilog_lite_config") { - include_dirs = [ - "//base/hiviewdfx/hiview_lite", - "//utils/native/lite/include", - "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - ] + include_dirs = [ + "//base/hiviewdfx/hiview_lite", + "//utils/native/lite/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + ] } static_library("hilog_lite") { - sources = [ - "hiview_log.c", - "hiview_log_limit.c", - "hiview_output_log.c", - ] - cflags = [ "-Wall" ] - defines = [ - "HIVIEW_LOG_FILE_SIZE = $ohos_hiviewdfx_hilog_lite_file_size", - "LOG_LIMIT_DEFAULT = $ohos_hiviewdfx_hilog_lite_limit_level_default" - ] - if (ohos_hiviewdfx_hilog_lite_disable_cache) { - defines += ["DISABLE_HILOG_CACHE"] - } - if(ohos_hiviewdfx_hilog_lite_disable_print_limit) { - defines += ["DISABLE_HILOG_LITE_PRINT_LIMIT"] - } - public_configs = [ - "//base/hiviewdfx/hiview_lite:hiview_lite_config", - ":hilog_lite_config" - ] - deps = ["//base/hiviewdfx/hiview_lite"] + sources = [ + "hiview_log.c", + "hiview_log_limit.c", + "hiview_output_log.c", + ] + cflags = [ "-Wall" ] + defines = [ + "HIVIEW_LOG_FILE_SIZE = $ohos_hiviewdfx_hilog_lite_file_size", + "LOG_LIMIT_DEFAULT = $ohos_hiviewdfx_hilog_lite_limit_level_default", + "LOG_STATIC_CACHE_SIZE = $ohos_hiviewdfx_log_static_cache_size", + "HIVIEW_HILOG_FILE_BUF_SIZE = $ohos_hiviewdfx_hiview_hilog_file_buf_size", + ] + if (ohos_hiviewdfx_hilog_lite_disable_cache) { + defines += [ "DISABLE_HILOG_CACHE" ] + } + if (ohos_hiviewdfx_hilog_lite_disable_print_limit) { + defines += [ "DISABLE_HILOG_LITE_PRINT_LIMIT" ] + } + public_configs = [ + "//base/hiviewdfx/hiview_lite:hiview_lite_config", + ":hilog_lite_config", + ] + deps = [ "//base/hiviewdfx/hiview_lite" ] } ndk_lib("hilog_lite_ndk") { - deps = [ - ":hilog_lite" - ] - head_files = [ - "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite", - ] + deps = [ ":hilog_lite" ] + head_files = + [ "//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog_lite" ] } -- Gitee