From 781f5b05b720388dc9882423fbc256f550676a74 Mon Sep 17 00:00:00 2001 From: shenchenkai Date: Sat, 25 Sep 2021 18:46:57 +0800 Subject: [PATCH 1/2] Description:[feature] support customize hilog dir Change-Id: Ic53f6ee330827af6fbcdfd40629e3e6ece9edb34 Signed-off-by: shenchenkai --- services/apphilogcat/BUILD.gn | 3 +++ services/apphilogcat/hiview_applogcat.c | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/services/apphilogcat/BUILD.gn b/services/apphilogcat/BUILD.gn index 0d471d4..6d314e5 100755 --- a/services/apphilogcat/BUILD.gn +++ b/services/apphilogcat/BUILD.gn @@ -21,6 +21,7 @@ declare_args() { apphilogcat_on = 1 apphilogcat_off = 0 enable_ohos_hiviewdfx_hilogcat_build = true + ohos_hiviewdfx_apphilogcat_log_dir = "/storage/data/log" } config("apphilogcat_config"){ @@ -41,6 +42,8 @@ config("apphilogcat_config"){ defines += ["CONFIG_LOG_LEVEL_RELEASE = $ohos_hiviewdfx_apphilogcat_log_level_release"] defines += ["CONFIG_LOG_LEVEL_DEBUG = $ohos_hiviewdfx_apphilogcat_log_level_debug"] + + defines += ["HILOG_DIR = $ohos_hiviewdfx_apphilogcat_log_dir"] } static_library("apphilogcat_static") { diff --git a/services/apphilogcat/hiview_applogcat.c b/services/apphilogcat/hiview_applogcat.c index 696d422..3bf2ff9 100755 --- a/services/apphilogcat/hiview_applogcat.c +++ b/services/apphilogcat/hiview_applogcat.c @@ -20,8 +20,11 @@ #include "hilog_command.h" #define HILOG_LOGBUFFER 2048 -#define HILOG_PATH1 "/storage/data/log/hilog1.txt" -#define HILOG_PATH2 "/storage/data/log/hilog2.txt" +#ifndef HILOG_DIR +#define HILOG_DIR "/storage/data/log" +#endif +#define HILOG_PATH1 HILOG_DIR "/hilog1.txt" +#define HILOG_PATH2 HILOG_DIR "/hilog2.txt" #undef LOG_TAG #define LOG_TAG "apphilogcat" -- Gitee From fe4a2a0ffaf0edc5a9d61debd5f8d09a5f0552e8 Mon Sep 17 00:00:00 2001 From: shenchenkai Date: Sat, 25 Sep 2021 18:53:52 +0800 Subject: [PATCH 2/2] Description:[feature] hilog parameter support negative integer Change-Id: I7a5ffbfc7d4c6f1338b54660f35e7e730604e224 Signed-off-by: shenchenkai --- frameworks/mini/hiview_log.c | 8 ++++---- frameworks/mini/hiview_output_log.c | 6 +++--- interfaces/native/kits/hilog_lite/hiview_log.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/frameworks/mini/hiview_log.c b/frameworks/mini/hiview_log.c index 57894c5..5950692 100755 --- a/frameworks/mini/hiview_log.c +++ b/frameworks/mini/hiview_log.c @@ -130,11 +130,11 @@ void HiLogPrintf(uint8 module, uint8 level, const char *nums, const char *fmt, . va_list args; va_start(args, fmt); while (i < argsNum) { - logContent.values[i++] = va_arg(args, uint32); + logContent.values[i++] = va_arg(args, int32); } va_end(args); - OutputLog((uint8 *)&logContent, sizeof(HiLogCommon) + sizeof(uint32) * argsNum); + OutputLog((uint8 *)&logContent, sizeof(HiLogCommon) + sizeof(int32) * argsNum); } void HILOG_HashPrintf(uint8 module, uint8 level, const char *nums, uint32 hash, ...) @@ -163,11 +163,11 @@ void HILOG_HashPrintf(uint8 module, uint8 level, const char *nums, uint32 hash, va_list args; va_start(args, hash); while (i < argsNum) { - logContent.values[i++] = va_arg(args, uint32); + logContent.values[i++] = va_arg(args, int32); } va_end(args); - OutputLog((uint8 *)&logContent, sizeof(HiLogCommon) + sizeof(uint32) * argsNum); + OutputLog((uint8 *)&logContent, sizeof(HiLogCommon) + sizeof(int32) * argsNum); } void HiLogFlush(boolean syncFlag) diff --git a/frameworks/mini/hiview_output_log.c b/frameworks/mini/hiview_output_log.c index d557ae1..fdc281d 100755 --- a/frameworks/mini/hiview_output_log.c +++ b/frameworks/mini/hiview_output_log.c @@ -216,7 +216,7 @@ static void OutputLogRealtime(const Request *req) HIVIEW_UartPrint("Discard cache[LOG_CACHE] data."); break; } - len = logContent.commonContent.valueNumber * sizeof(uint32); + len = logContent.commonContent.valueNumber * sizeof(int32); if (len > 0 && ReadFromCache(&g_logCache, (uint8 *)&(logContent.values), len) != len) { continue; } @@ -249,7 +249,7 @@ static void OutputLog2TextFile(const Request *req) HIVIEW_UartPrint("Discard cache[LOG_CACHE] data."); break; } - len = logContent.commonContent.valueNumber * sizeof(uint32); + len = logContent.commonContent.valueNumber * sizeof(int32); if (len > 0 && ReadFromCache(&g_logCache, (uint8 *)&(logContent.values), len) != len) { continue; } @@ -497,7 +497,7 @@ static int32 LogValuesFmtHash(char *desStrPtr, int32 desLen, const HiLogContent for (uint32 i = 0; i < paraNum && i < LOG_MULTI_PARA_MAX; i++) { len = snprintf_s(&desStrPtr[outLen], desLen - outLen, desLen - outLen - 1, - "%u ", logContentPtr->values[i]); + "%d ", logContentPtr->values[i]); if (len < 0) { return len; } diff --git a/interfaces/native/kits/hilog_lite/hiview_log.h b/interfaces/native/kits/hilog_lite/hiview_log.h index 90892e2..0e22dd7 100755 --- a/interfaces/native/kits/hilog_lite/hiview_log.h +++ b/interfaces/native/kits/hilog_lite/hiview_log.h @@ -145,7 +145,7 @@ typedef struct { typedef struct { HiLogCommon commonContent; - uint32 values[LOG_MULTI_PARA_MAX]; + int32 values[LOG_MULTI_PARA_MAX]; } HiLogContent; #pragma pack() -- Gitee