提交 67e849cd 编写于 作者: C cheng_jinsong

init set log level

Signed-off-by: Ncheng_jinsong <chengjinsong2@huawei.com>
上级 20e669a3
......@@ -56,6 +56,7 @@ INIT_PUBLIC_API void SetInitLogLevel(InitLogLevel level);
INIT_PUBLIC_API int GetInitLogLevel(void);
INIT_PUBLIC_API void SetInitCommLog(InitCommLog logFunc);
INIT_PUBLIC_API void EnableInitLogFromCmdline(void);
INIT_PUBLIC_API void InitLogLevelFromPersist(void);
#define STARTUP_LOGV(domain, tag, fmt, ...) \
StartupLog(INIT_DEBUG, domain, tag, "[%s:%d]" fmt, (FILE_NAME), (__LINE__), ##__VA_ARGS__)
......
......@@ -23,6 +23,7 @@
#include <sys/time.h>
#include "init_utils.h"
#include "param/init_param.h"
#include "securec.h"
#ifdef OHOS_LITE
#ifndef INIT_LOG_INIT
......@@ -172,3 +173,16 @@ INIT_PUBLIC_API void EnableInitLogFromCmdline(void)
SetInitLogLevel(logLevel);
return;
}
INIT_PUBLIC_API void InitLogLevelFromPersist(void)
{
char logLevel[2] = {0}; // 2 is set param "persist.init.debug.loglevel" value length.
uint32_t len = sizeof(logLevel);
int ret = SystemReadParam("persist.init.debug.loglevel", logLevel, &len);
INIT_INFO_CHECK(ret == 0, return, "Can not get log level from param, keep the original loglevel.");
errno = 0;
unsigned int level = (unsigned int)strtoul(logLevel, 0, 10); // 10 is decimal
INIT_INFO_CHECK(errno == 0, return, "Failed strtoul %s, err=%d", logLevel, errno);
SetInitLogLevel(level);
return;
}
......@@ -170,19 +170,6 @@ static void DumpServiceHook(void)
return;
}
static void InitLogLevelFromPersist(void)
{
char logLevel[2] = {0}; // 2 is set param "persist.init.debug.loglevel" value length.
uint32_t len = sizeof(logLevel);
int ret = SystemReadParam("persist.init.debug.loglevel", logLevel, &len);
INIT_INFO_CHECK(ret == 0, return, "Can not get log level from param, keep the original loglevel.");
errno = 0;
unsigned int level = (unsigned int)strtoul(logLevel, 0, 10); // 10 is decimal
INIT_INFO_CHECK(errno == 0, return, "Failed strtoul %s, err=%d", logLevel, errno);
SetInitLogLevel(level);
return;
}
static int InitDebugHook(const HOOK_INFO *info, void *cookie)
{
UNUSED(info);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册