From e01bd3ce9e9fc63e098f0505711b3398a760ef0c Mon Sep 17 00:00:00 2001 From: shenchenkai Date: Sat, 25 Sep 2021 18:46:57 +0800 Subject: [PATCH] Description:[feature] support customize hilog dir Change-Id: Ic53f6ee330827af6fbcdfd40629e3e6ece9edb34 Signed-off-by: shenchenkai --- services/apphilogcat/BUILD.gn | 82 ++++++++++++------------- services/apphilogcat/hiview_applogcat.c | 7 ++- 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/services/apphilogcat/BUILD.gn b/services/apphilogcat/BUILD.gn index 0d471d4..e722652 100755 --- a/services/apphilogcat/BUILD.gn +++ b/services/apphilogcat/BUILD.gn @@ -13,59 +13,59 @@ import("//build/lite/config/component/lite_component.gni") declare_args() { - ohos_hiviewdfx_hilog_file_size = 2048 - enable_ohos_hiviewdfx_apphilogcat_init_release = false - enable_ohos_hiviewdfx_apphilogcat_init_debug = true - ohos_hiviewdfx_apphilogcat_log_level_release = 5 - ohos_hiviewdfx_apphilogcat_log_level_debug = 3 - apphilogcat_on = 1 - apphilogcat_off = 0 - enable_ohos_hiviewdfx_hilogcat_build = true + ohos_hiviewdfx_hilog_file_size = 2048 + enable_ohos_hiviewdfx_apphilogcat_init_release = false + enable_ohos_hiviewdfx_apphilogcat_init_debug = true + ohos_hiviewdfx_apphilogcat_log_level_release = 5 + ohos_hiviewdfx_apphilogcat_log_level_debug = 3 + apphilogcat_on = 1 + apphilogcat_off = 0 + enable_ohos_hiviewdfx_hilogcat_build = true + ohos_hiviewdfx_apphilogcat_log_dir = "/storage/data/log" } -config("apphilogcat_config"){ - defines = [ "HILOG_MAX_FILELEN = $ohos_hiviewdfx_hilog_file_size" ] +config("apphilogcat_config") { + defines = [ "HILOG_MAX_FILELEN = $ohos_hiviewdfx_hilog_file_size" ] - if(enable_ohos_hiviewdfx_apphilogcat_init_release){ - defines += ["APPHILOGCAT_STATUS_RELEASE = $apphilogcat_on"] - }else{ - defines += ["APPHILOGCAT_STATUS_RELEASE = $apphilogcat_off"] - } + if (enable_ohos_hiviewdfx_apphilogcat_init_release) { + defines += [ "APPHILOGCAT_STATUS_RELEASE = $apphilogcat_on" ] + } else { + defines += [ "APPHILOGCAT_STATUS_RELEASE = $apphilogcat_off" ] + } - if(enable_ohos_hiviewdfx_apphilogcat_init_debug){ - defines += ["APPHILOGCAT_STATUS_DEBUG = $apphilogcat_on"] - }else{ - defines += ["APPHILOGCAT_STATUS_DEBUG = $apphilogcat_off"] - } + if (enable_ohos_hiviewdfx_apphilogcat_init_debug) { + defines += [ "APPHILOGCAT_STATUS_DEBUG = $apphilogcat_on" ] + } else { + defines += [ "APPHILOGCAT_STATUS_DEBUG = $apphilogcat_off" ] + } - defines += ["CONFIG_LOG_LEVEL_RELEASE = $ohos_hiviewdfx_apphilogcat_log_level_release"] + defines += [ + "CONFIG_LOG_LEVEL_RELEASE = $ohos_hiviewdfx_apphilogcat_log_level_release", + ] - defines += ["CONFIG_LOG_LEVEL_DEBUG = $ohos_hiviewdfx_apphilogcat_log_level_debug"] + defines += + [ "CONFIG_LOG_LEVEL_DEBUG = $ohos_hiviewdfx_apphilogcat_log_level_debug" ] + + defines += [ "HILOG_DIR = \"$ohos_hiviewdfx_apphilogcat_log_dir\"" ] } static_library("apphilogcat_static") { - sources = [ - "hiview_applogcat.c", - ] - cflags = [ "-Wall" ] - include_dirs = [ - "//third_party/bounds_checking_function/include", - ] - deps = [ - "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", - "//base/hiviewdfx/hilog_lite/command:hilog_command_static" - ] - public_configs = [":apphilogcat_config"] + sources = [ "hiview_applogcat.c" ] + cflags = [ "-Wall" ] + include_dirs = [ "//third_party/bounds_checking_function/include" ] + deps = [ + "//base/hiviewdfx/hilog_lite/command:hilog_command_static", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + ] + public_configs = [ ":apphilogcat_config" ] - if(enable_ohos_hiviewdfx_hilogcat_build) { - deps += [ "//base/hiviewdfx/hilog_lite/services/hilogcat:hilogcat" ] - } + if (enable_ohos_hiviewdfx_hilogcat_build) { + deps += [ "//base/hiviewdfx/hilog_lite/services/hilogcat:hilogcat" ] + } } lite_component("apphilogcat") { - target_type = "executable" + target_type = "executable" - features = [ - ":apphilogcat_static", - ] + features = [ ":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