增加开关显式控制是否记日志

Signed-off-by: chengjinsong2 <chengjinsong2@huawei.com>
This commit is contained in:
chengjinsong2 2023-01-18 10:52:42 +08:00
parent 173285d7c9
commit b9da40de98
4 changed files with 8 additions and 7 deletions

View File

@ -37,6 +37,9 @@ declare_args() {
startup_init_test_performance = true startup_init_test_performance = true
# log display control
config_ohos_startup_init_lite_no_log = false
startup_init_with_param_base = false startup_init_with_param_base = false
if (!use_musl) { if (!use_musl) {
startup_init_with_param_base = true startup_init_with_param_base = true

View File

@ -98,15 +98,9 @@ void LogToDmesg(InitLogLevel logLevel, const char *tag, const char *info)
static void PrintLog(InitLogLevel logLevel, unsigned int domain, const char *tag, const char *logInfo) static void PrintLog(InitLogLevel logLevel, unsigned int domain, const char *tag, const char *logInfo)
{ {
#ifdef OHOS_LITE #ifdef OHOS_LITE
#ifdef __LITEOS_M__
(void)logLevel;
(void)domain;
printf("[%s]%s \n", tag, logInfo);
#else
static const LogLevel LOG_LEVEL[] = { LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL }; static const LogLevel LOG_LEVEL[] = { LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL };
(void)HiLogPrint(INIT_LOG_INIT, LOG_LEVEL[logLevel], domain, tag, "%{public}s", logInfo); (void)HiLogPrint(INIT_LOG_INIT, LOG_LEVEL[logLevel], domain, tag, "%{public}s", logInfo);
#endif #endif
#endif
#ifdef INIT_DMESG #ifdef INIT_DMESG
LogToDmesg(logLevel, tag, logInfo); LogToDmesg(logLevel, tag, logInfo);
#endif #endif

View File

@ -44,7 +44,7 @@ INIT_LOCAL_API void SetInitCommLog(InitCommLog logFunc);
INIT_LOCAL_API void EnableInitLog(InitLogLevel level); INIT_LOCAL_API void EnableInitLog(InitLogLevel level);
INIT_LOCAL_API void EnableInitLogFromCmdline(void); INIT_LOCAL_API void EnableInitLogFromCmdline(void);
#ifdef PARAM_BASE #if defined(INIT_NO_LOG) || defined(PARAM_BASE)
#define INIT_LOGV(fmt, ...) #define INIT_LOGV(fmt, ...)
#define INIT_LOGI(fmt, ...) #define INIT_LOGI(fmt, ...)
#define INIT_LOGW(fmt, ...) #define INIT_LOGW(fmt, ...)

View File

@ -115,6 +115,10 @@ static_library("param_client_lite") {
defines = param_build_defines defines = param_build_defines
public_configs = [ ":exported_header_files" ] public_configs = [ ":exported_header_files" ]
if (config_ohos_startup_init_lite_no_log) {
defines += [ "INIT_NO_LOG" ]
}
if (ohos_kernel_type == "liteos_a") { if (ohos_kernel_type == "liteos_a") {
sources += sources +=
[ "//base/startup/init/services/param/adapter/param_persistadp.c" ] [ "//base/startup/init/services/param/adapter/param_persistadp.c" ]