Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
ea20e0d4
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
接近 2 年 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
ea20e0d4
编写于
9月 26, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1302 init log等级设置
Merge pull request !1302 from cheng_jinsong/initsf0923
上级
4caf0038
9d9c0350
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
67 addition
and
19 deletion
+67
-19
interfaces/innerkits/include/beget_ext.h
interfaces/innerkits/include/beget_ext.h
+2
-1
services/init/main.c
services/init/main.c
+1
-1
services/log/BUILD.gn
services/log/BUILD.gn
+1
-0
services/log/init_log.c
services/log/init_log.c
+21
-2
services/modules/bootevent/bootevent.c
services/modules/bootevent/bootevent.c
+1
-1
services/modules/init_hook/init_hook.c
services/modules/init_hook/init_hook.c
+31
-4
services/modules/init_hook/param_hook.c
services/modules/init_hook/param_hook.c
+1
-0
services/param/linux/param_request.c
services/param/linux/param_request.c
+1
-1
services/param/liteos/param_client.c
services/param/liteos/param_client.c
+1
-1
services/param/liteos/param_service.c
services/param/liteos/param_service.c
+1
-2
services/param/manager/param_manager.c
services/param/manager/param_manager.c
+3
-3
test/unittest/lite/cmd_func_test.cpp
test/unittest/lite/cmd_func_test.cpp
+1
-1
test/unittest/param/param_stub.cpp
test/unittest/param/param_stub.cpp
+1
-1
ueventd/ueventd_main.c
ueventd/ueventd_main.c
+1
-1
未找到文件。
interfaces/innerkits/include/beget_ext.h
浏览文件 @
ea20e0d4
...
...
@@ -51,7 +51,8 @@ typedef void (*InitCommLog)(int logLevel, uint32_t domain, const char *tag, cons
#define FILE_NAME (strrchr((__FILE__), '/') ? strrchr((__FILE__), '/') + 1 : (__FILE__))
INIT_PUBLIC_API
void
StartupLog
(
InitLogLevel
logLevel
,
uint32_t
domain
,
const
char
*
tag
,
const
char
*
fmt
,
...);
INIT_PUBLIC_API
void
EnableInitLog
(
InitLogLevel
level
);
INIT_PUBLIC_API
void
EnableInitLog
(
void
);
INIT_PUBLIC_API
void
SetInitLogLevel
(
InitLogLevel
level
);
INIT_PUBLIC_API
void
SetInitCommLog
(
InitCommLog
logFunc
);
#define STARTUP_LOGV(domain, tag, fmt, ...) \
...
...
services/init/main.c
浏览文件 @
ea20e0d4
...
...
@@ -30,7 +30,7 @@ int main(int argc, char * const argv[])
INIT_LOGE
(
"Process id error %d!"
,
getpid
());
return
0
;
}
EnableInitLog
(
INIT_INFO
);
EnableInitLog
();
if
(
isSecondStage
==
0
)
{
SystemPrepare
();
}
else
{
...
...
services/log/BUILD.gn
浏览文件 @
ea20e0d4
...
...
@@ -17,6 +17,7 @@ config("exported_header_files") {
include_dirs = [
"//base/startup/init/interfaces/innerkits/include",
"//base/startup/init/services/log",
"//base/startup/init/services/include",
]
}
...
...
services/log/init_log.c
浏览文件 @
ea20e0d4
...
...
@@ -22,6 +22,7 @@
#include <time.h>
#include <sys/time.h>
#include "param/init_param.h"
#include "securec.h"
#ifdef OHOS_LITE
#ifndef INIT_LOG_INIT
...
...
@@ -131,8 +132,26 @@ INIT_LOCAL_API void InitLog(int logLevel, unsigned int domain, const char *tag,
PrintLog
(
logLevel
,
domain
,
tag
,
tmpFmt
);
}
INIT_PUBLIC_API
void
EnableInitLog
(
InitLogLevel
level
)
INIT_PUBLIC_API
void
SetInitLogLevel
(
InitLogLevel
level
)
{
if
((
level
>=
INIT_DEBUG
)
&&
(
level
<=
INIT_FATAL
))
{
g_logLevel
=
level
;
}
return
;
}
INIT_PUBLIC_API
void
EnableInitLog
(
void
)
{
g_logLevel
=
level
;
SetInitCommLog
(
InitLog
);
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
);
if
((
level
>=
INIT_DEBUG
)
&&
(
level
<=
INIT_FATAL
))
{
g_logLevel
=
level
;
}
return
;
}
services/modules/bootevent/bootevent.c
浏览文件 @
ea20e0d4
...
...
@@ -342,7 +342,7 @@ static void SetServiceBootEventFork(SERVICE_INFO_CTX *serviceCtx)
MODULE_CONSTRUCTOR
(
void
)
{
EnableInitLog
(
INIT_DEBUG
);
EnableInitLog
();
InitAddServiceHook
(
SetServiceBootEventFork
,
INIT_SERVICE_FORK_BEFORE
);
InitAddServiceHook
(
ClearServiceBootEvent
,
INIT_SERVICE_CLEAR
);
InitAddServiceHook
(
DumpServiceBootEvent
,
INIT_SERVICE_DUMP
);
...
...
services/modules/init_hook/init_hook.c
浏览文件 @
ea20e0d4
...
...
@@ -122,9 +122,27 @@ static int CmdClear(int id, const char *name, int argc, const char **argv)
return
0
;
}
static
int
ParamSetBootEventHook
(
const
HOOK_INFO
*
hookInfo
,
void
*
cookie
)
static
int
CmdSetLogLevel
(
int
id
,
const
char
*
name
,
int
argc
,
const
char
**
argv
)
{
UNUSED
(
id
);
if
((
name
==
NULL
)
||
(
argv
==
NULL
)
||
(
argc
<
1
))
{
PLUGIN_LOGE
(
"Failed get log level from parameter."
);
return
-
1
;
}
char
*
value
=
strrchr
(
argv
[
0
],
'.'
);
PLUGIN_CHECK
(
value
!=
NULL
,
return
-
1
,
"Failed get
\'
.
\'
from string %s"
,
argv
[
0
]);
unsigned
int
level
;
int
ret
=
StringToUint
(
value
+
1
,
&
level
);
PLUGIN_CHECK
(
ret
==
0
,
return
-
1
,
"Failed make string to unsigned int"
);
PLUGIN_LOGI
(
"level is %d"
,
level
);
SetInitLogLevel
(
level
);
return
0
;
}
static
int
ParamSetInitCmdHook
(
const
HOOK_INFO
*
hookInfo
,
void
*
cookie
)
{
AddCmdExecutor
(
"clear"
,
CmdClear
);
AddCmdExecutor
(
"setinitloglevel"
,
CmdSetLogLevel
);
return
0
;
}
...
...
@@ -137,7 +155,7 @@ static int DumpTrigger(const char *fmt, ...)
return
0
;
}
static
int
DumpServiceHook
(
const
HOOK_INFO
*
info
,
void
*
cookie
)
static
void
DumpServiceHook
(
void
)
{
// check and dump all jobs
char
dump
[
8
]
=
{
0
};
// 8 len
...
...
@@ -147,12 +165,21 @@ static int DumpServiceHook(const HOOK_INFO *info, void *cookie)
if
(
ret
==
0
&&
strcmp
(
dump
,
"1"
)
==
0
)
{
SystemDumpTriggers
(
1
,
DumpTrigger
);
}
return
;
}
static
int
InitDebugHook
(
const
HOOK_INFO
*
info
,
void
*
cookie
)
{
UNUSED
(
info
);
UNUSED
(
cookie
);
EnableInitLog
();
DumpServiceHook
();
return
0
;
}
MODULE_CONSTRUCTOR
(
void
)
{
InitAddGlobalInitHook
(
0
,
ParamSet
BootEvent
Hook
);
InitAddGlobalInitHook
(
0
,
ParamSet
InitCmd
Hook
);
// Depends on parameter service
InitAddPostPersistParamLoadHook
(
0
,
DumpService
Hook
);
InitAddPostPersistParamLoadHook
(
0
,
InitDebug
Hook
);
}
services/modules/init_hook/param_hook.c
浏览文件 @
ea20e0d4
...
...
@@ -62,6 +62,7 @@ const ParamCmdInfo *GetOtherSpecial(size_t *size)
{
static
const
ParamCmdInfo
other
[]
=
{
{
"bootevent."
,
"bootevent."
,
"bootevent"
},
{
"persist.init.debug."
,
"persist.init.debug."
,
"setinitloglevel"
}
};
*
size
=
ARRAY_LENGTH
(
other
);
return
other
;
...
...
services/param/linux/param_request.c
浏览文件 @
ea20e0d4
...
...
@@ -41,7 +41,6 @@ __attribute__((constructor)) static void ParameterInit(void)
if
(
getpid
()
==
1
)
{
return
;
}
EnableInitLog
(
INIT_ERROR
);
PARAM_WORKSPACE_OPS
ops
=
{
0
};
ops
.
updaterMode
=
0
;
#ifdef PARAM_BASE_LOG
...
...
@@ -51,6 +50,7 @@ __attribute__((constructor)) static void ParameterInit(void)
ops
.
setfilecon
=
NULL
;
#endif
InitParamWorkSpace
(
1
,
&
ops
);
EnableInitLog
();
}
__attribute__
((
destructor
))
static
void
ParameterDeinit
(
void
)
...
...
services/param/liteos/param_client.c
浏览文件 @
ea20e0d4
...
...
@@ -26,13 +26,13 @@ static int InitParamClient(void)
if
(
PARAM_TEST_FLAG
(
g_flags
,
WORKSPACE_FLAGS_INIT
))
{
return
0
;
}
EnableInitLog
(
INIT_INFO
);
PARAM_LOGV
(
"InitParamClient"
);
int
ret
=
InitParamWorkSpace
(
1
,
NULL
);
PARAM_CHECK
(
ret
==
0
,
return
-
1
,
"Failed to init param workspace"
);
PARAM_SET_FLAG
(
g_flags
,
WORKSPACE_FLAGS_INIT
);
// init persist to save
InitPersistParamWorkSpace
();
EnableInitLog
();
return
0
;
}
...
...
services/param/liteos/param_service.c
浏览文件 @
ea20e0d4
...
...
@@ -132,12 +132,11 @@ static void ParamServiceTask(int *arg)
void
LiteParamService
(
void
)
{
EnableInitLog
(
INIT_INFO
);
PARAM_LOGI
(
"LiteParamService"
);
InitParamService
();
// get persist param
LoadPersistParams
();
EnableInitLog
();
osThreadAttr_t
attr
;
attr
.
name
=
"ParamServiceTask"
;
attr
.
attr_bits
=
0U
;
...
...
services/param/manager/param_manager.c
浏览文件 @
ea20e0d4
...
...
@@ -300,7 +300,7 @@ INIT_LOCAL_API int GetServiceCtrlInfo(const char *name, const char *value, Servi
for
(
size_t
i
=
0
;
i
<
size
;
i
++
)
{
if
(
strcmp
(
name
,
ctrlParam
[
i
].
name
)
==
0
)
{
uint32_t
valueOffset
=
strlen
(
OHOS_SERVICE_CTRL_PREFIX
)
+
strlen
(
ctrlParam
[
i
].
replace
)
+
1
;
return
CreateCtrlInfo
(
ctrlInfo
,
ctrlParam
[
i
].
cmd
,
valueOffset
,
1
,
return
CreateCtrlInfo
(
ctrlInfo
,
ctrlParam
[
i
].
cmd
,
valueOffset
,
1
,
"%s%s.%s"
,
OHOS_SERVICE_CTRL_PREFIX
,
ctrlParam
[
i
].
replace
,
value
);
}
}
...
...
@@ -309,14 +309,14 @@ INIT_LOCAL_API int GetServiceCtrlInfo(const char *name, const char *value, Servi
const
ParamCmdInfo
*
installParam
=
GetServiceCtl
(
&
size
);
for
(
size_t
i
=
0
;
i
<
size
;
i
++
)
{
if
(
strncmp
(
name
,
installParam
[
i
].
name
,
strlen
(
installParam
[
i
].
name
))
==
0
)
{
return
CreateCtrlInfo
(
ctrlInfo
,
installParam
[
i
].
cmd
,
strlen
(
name
)
+
1
,
1
,
"%s.%s"
,
name
,
value
);
return
CreateCtrlInfo
(
ctrlInfo
,
installParam
[
i
].
cmd
,
strlen
(
name
)
+
1
,
1
,
"%s.%s"
,
name
,
value
);
}
}
}
const
ParamCmdInfo
*
other
=
GetOtherSpecial
(
&
size
);
for
(
size_t
i
=
0
;
i
<
size
;
i
++
)
{
if
(
strncmp
(
name
,
other
[
i
].
name
,
strlen
(
other
[
i
].
name
))
==
0
)
{
return
CreateCtrlInfo
(
ctrlInfo
,
other
[
i
].
cmd
,
strlen
(
other
[
i
].
name
),
0
,
"%s.%s"
,
name
,
value
);
return
CreateCtrlInfo
(
ctrlInfo
,
other
[
i
].
cmd
,
strlen
(
other
[
i
].
name
),
0
,
"%s.%s"
,
name
,
value
);
}
}
return
0
;
...
...
test/unittest/lite/cmd_func_test.cpp
浏览文件 @
ea20e0d4
...
...
@@ -124,7 +124,7 @@ public:
}
void
SetUp
()
{
EnableInitLog
(
INIT_FATAL
);
EnableInitLog
();
}
void
TearDown
()
{}
};
...
...
test/unittest/param/param_stub.cpp
浏览文件 @
ea20e0d4
...
...
@@ -434,7 +434,7 @@ int TestFreeLocalSecurityLabel(ParamSecurityLabel *srcLabel)
static
__attribute__
((
constructor
(
101
)))
void
ParamTestStubInit
(
void
)
{
EnableInitLog
(
INIT_DEBUG
);
EnableInitLog
();
PARAM_LOGI
(
"ParamTestStubInit"
);
PrepareInitUnitTestEnv
();
}
...
...
ueventd/ueventd_main.c
浏览文件 @
ea20e0d4
...
...
@@ -50,7 +50,7 @@ static void PollUeventdSocketTimeout(int ueventSockFd, bool ondemand)
int
main
(
int
argc
,
char
**
argv
)
{
// start log
EnableInitLog
(
INIT_INFO
);
EnableInitLog
();
char
*
ueventdConfigs
[]
=
{
"/etc/ueventd.config"
,
"/vendor/etc/ueventd.config"
,
NULL
};
int
i
=
0
;
while
(
ueventdConfigs
[
i
]
!=
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录