Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
67baf759
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
1 年多 前同步成功
通知
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看板
提交
67baf759
编写于
3月 29, 2022
作者:
X
xionglei6
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix log
Signed-off-by:
N
xionglei6
<
xionglei6@huawei.com
>
上级
779e1987
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
110 addition
and
266 deletion
+110
-266
device_info/BUILD.gn
device_info/BUILD.gn
+0
-1
initsync/BUILD.gn
initsync/BUILD.gn
+1
-1
interfaces/innerkits/BUILD.gn
interfaces/innerkits/BUILD.gn
+5
-5
interfaces/innerkits/fd_holder/BUILD.gn
interfaces/innerkits/fd_holder/BUILD.gn
+0
-4
interfaces/innerkits/file/BUILD.gn
interfaces/innerkits/file/BUILD.gn
+1
-1
interfaces/innerkits/include/beget_ext.h
interfaces/innerkits/include/beget_ext.h
+11
-84
interfaces/innerkits/plugin/BUILD.gn
interfaces/innerkits/plugin/BUILD.gn
+0
-1
interfaces/innerkits/sandbox/BUILD.gn
interfaces/innerkits/sandbox/BUILD.gn
+1
-3
interfaces/innerkits/socket/BUILD.gn
interfaces/innerkits/socket/BUILD.gn
+1
-1
services/begetctl/BUILD.gn
services/begetctl/BUILD.gn
+4
-0
services/begetctl/shell/shell_utils.h
services/begetctl/shell/shell_utils.h
+3
-3
services/log/BUILD.gn
services/log/BUILD.gn
+3
-0
services/log/init_log.c
services/log/init_log.c
+52
-73
services/log/init_log.h
services/log/init_log.h
+9
-46
services/loopevent/BUILD.gn
services/loopevent/BUILD.gn
+2
-10
services/loopevent/utils/le_utils.h
services/loopevent/utils/le_utils.h
+3
-4
services/param/BUILD.gn
services/param/BUILD.gn
+1
-2
services/param/include/param_utils.h
services/param/include/param_utils.h
+3
-4
services/param/watcher/BUILD.gn
services/param/watcher/BUILD.gn
+0
-4
services/param/watcher/include/watcher_utils.h
services/param/watcher/include/watcher_utils.h
+3
-4
services/plugin/plugin_adapter.h
services/plugin/plugin_adapter.h
+3
-4
services/utils/BUILD.gn
services/utils/BUILD.gn
+2
-9
ueventd/BUILD.gn
ueventd/BUILD.gn
+2
-2
未找到文件。
device_info/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -28,7 +28,6 @@ ohos_shared_library("deviceinfoservice") {
sources = [ "device_info_stub.cpp" ]
defines = [
"INIT_AGENT",
"DINFO_LABEL=\"DeviceInfoService\"",
]
include_dirs = [
...
...
initsync/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -27,7 +27,7 @@ shared_library("libinitsync_shared") {
"//base/startup/init_lite/interfaces/innerkits/include",
]
public_deps = [
"//base/startup/init_lite/services/log:
ini
t_log",
"//base/startup/init_lite/services/log:
agen
t_log",
"//third_party/bounds_checking_function:libsec_shared",
]
}
...
...
interfaces/innerkits/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -27,6 +27,7 @@ fs_manager_sources = [
ohos_shared_library("libbegetutil") {
sources = [
"fd_holder/fd_holder.c",
"fd_holder/fd_holder_internal.c",
"file/init_file.c",
"reboot/init_reboot_innerkits.c",
"service_control/service_control.c",
...
...
@@ -42,18 +43,17 @@ ohos_shared_library("libbegetutil") {
"//base/startup/init_lite/services/include/param",
"//base/startup/init_lite/interfaces/innerkits/fd_holder",
]
defines = [ "INIT_AGENT" ]
deps = [
"//base/startup/init_lite/interfaces/innerkits/fd_holder:libfdholder_internal_static",
"//base/startup/init_lite/services/log:agent_log",
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/services/param:param_client",
"//base/startup/init_lite/services/utils:libinit_tools",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_shared",
"//third_party/openssl:libcrypto_static",
"//utils/native/base:utils",
]
deps += [ "//base/startup/init_lite/services/log:init_log" ]
public_configs = [ ":exported_header_files" ]
part_name = "init"
install_images = [
...
...
@@ -106,6 +106,6 @@ ohos_static_library("libfsmanager_static") {
"//base/startup/init_lite/services/log",
"//base/startup/init_lite/services/include",
]
deps = [ "//base/startup/init_lite/services/log:init_log" ]
part_name = "init"
}
interfaces/innerkits/fd_holder/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -21,9 +21,5 @@ ohos_static_library("libfdholder_internal_static") {
"//base/startup/init_lite/services/log",
"//base/startup/init_lite/interfaces/innerkits/include",
]
deps = [ "//base/startup/init_lite/services/log:init_log" ]
defines = [ "INIT_AGENT" ]
part_name = "init"
}
interfaces/innerkits/file/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -20,7 +20,7 @@ service_file_include = [
"//third_party/bounds_checking_function/include",
]
service_file_deps = [
"//base/startup/init_lite/services/log:
ini
t_log",
"//base/startup/init_lite/services/log:
agen
t_log",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_static",
]
...
...
interfaces/innerkits/include/beget_ext.h
浏览文件 @
67baf759
...
...
@@ -22,12 +22,6 @@ extern "C" {
#endif
#endif
#if defined(ENABLE_HILOG) || defined(OHOS_LITE)
#include "hilog/log.h"
#undef LOG_DOMAIN
#define LOG_DOMAIN 0xD000719
#endif
typedef
enum
InitLogLevel
{
INIT_DEBUG
=
0
,
INIT_INFO
,
...
...
@@ -36,88 +30,21 @@ typedef enum InitLogLevel {
INIT_FATAL
}
InitLogLevel
;
#ifndef INIT_LOG_PATH
#define INIT_LOG_PATH "/data/init_agent/"
#endif
#define FILE_NAME (strrchr((__FILE__), '/') ? strrchr((__FILE__), '/') + 1 : (__FILE__))
void
InitLogInit
(
const
char
*
outFileName
,
InitLogLevel
logLevel
,
const
char
*
kLevel
,
const
char
*
fmt
,
...);
void
InitLogAgent
(
const
char
*
outFileName
,
InitLogLevel
logLevel
,
const
char
*
kLevel
,
const
char
*
fmt
,
...);
void
OpenLogDevice
(
void
);
#ifndef INIT_AGENT
#define InitLogPrint InitLogInit
#else
#define InitLogPrint InitLogAgent
#endif
#ifndef OHOS_LITE
#ifndef ENABLE_HILOG
#define STARTUP_LOGV(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_DEBUG, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#define STARTUP_LOGI(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_INFO, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#define STARTUP_LOGE(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_ERROR, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
void
SetInitLogLevel
(
InitLogLevel
logLevel
);
void
InitLog
(
InitLogLevel
logLevel
,
const
char
*
domain
,
const
char
*
fileName
,
int
line
,
const
char
*
fmt
,
...);
#define STARTUP_LOGW(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_WARN, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#else
#define STARTUP_LOGV(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_DEBUG, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
(void)HiLogPrint(LOG_APP, LOG_DEBUG, LOG_DOMAIN, LABEL, "[%{public}s(%{public}d)] " fmt, \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#define STARTUP_LOGI(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_INFO, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
(void)HiLogPrint(LOG_APP, LOG_INFO, LOG_DOMAIN, LABEL, "[%{public}s(%{public}d)] " fmt, \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#define STARTUP_LOGE(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_ERROR, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
(void)HiLogPrint(LOG_APP, LOG_ERROR, LOG_DOMAIN, LABEL, "[%{public}s(%{public}d)] " fmt, \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#define STARTUP_LOGW(logFile, LABEL, fmt, ...) \
do { \
InitLogPrint(INIT_LOG_PATH logFile, INIT_WARN, LABEL, "[%s:%d)] " fmt "\n", \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
(void)HiLogPrint(LOG_APP, LOG_WARN, LOG_DOMAIN, LABEL, "[%{public}s(%{public}d)] " fmt, \
(FILE_NAME), (__LINE__), ##__VA_ARGS__); \
} while (0)
#endif
#endif
#define STARTUP_LOGV(domain, fmt, ...) InitLog(INIT_DEBUG, domain, (FILE_NAME), (__LINE__), fmt, ##__VA_ARGS__)
#define STARTUP_LOGI(domain, fmt, ...) InitLog(INIT_INFO, domain, (FILE_NAME), (__LINE__), fmt, ##__VA_ARGS__)
#define STARTUP_LOGW(domain, fmt, ...) InitLog(INIT_WARN, domain, (FILE_NAME), (__LINE__), fmt, ##__VA_ARGS__)
#define STARTUP_LOGE(domain, fmt, ...) InitLog(INIT_ERROR, domain, (FILE_NAME), (__LINE__), fmt, ##__VA_ARGS__)
#define STARTUP_LOGF(domain, fmt, ...) InitLog(INIT_FATAL, domain, (FILE_NAME), (__LINE__), fmt, ##__VA_ARGS__)
#define BEGET_LOG_FILE "begetctrl.log"
#define BEGET_LABEL "BEGET"
#define BEGET_LOGI(fmt, ...) STARTUP_LOGI(BEGET_L
OG_FILE, BEGET_L
ABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGE(fmt, ...) STARTUP_LOGE(BEGET_L
OG_FILE, BEGET_L
ABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGV(fmt, ...) STARTUP_LOGV(BEGET_L
OG_FILE, BEGET_L
ABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGW(fmt, ...) STARTUP_LOGW(BEGET_L
OG_FILE, BEGET_L
ABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGI(fmt, ...) STARTUP_LOGI(BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGE(fmt, ...) STARTUP_LOGE(BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGV(fmt, ...) STARTUP_LOGV(BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGW(fmt, ...) STARTUP_LOGW(BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_ERROR_CHECK(ret, statement, format, ...) \
if (!(ret)) { \
...
...
interfaces/innerkits/plugin/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -22,7 +22,6 @@ ohos_shared_library("libplugin") {
]
deps = [
"//base/startup/init_lite/services/log:init_log",
"//third_party/bounds_checking_function:libsec_static",
]
install_enable = true
...
...
interfaces/innerkits/sandbox/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -31,14 +31,13 @@ ohos_shared_library("libsandbox") {
"//base/startup/init_lite/interfaces/innerkits/include",
"//third_party/cJSON",
]
defines = [ "INIT_AGENT" ]
deps = [
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_shared",
"//third_party/cJSON:cjson_static",
]
deps += [ "//base/startup/init_lite/services/log:
ini
t_log" ]
deps += [ "//base/startup/init_lite/services/log:
agen
t_log" ]
part_name = "init"
install_images = [ "system" ]
...
...
@@ -62,6 +61,5 @@ ohos_static_library("libsandbox_static") {
"//third_party/bounds_checking_function:libsec_static",
"//third_party/cJSON:cjson_static",
]
deps += [ "//base/startup/init_lite/services/log:init_log" ]
part_name = "init"
}
interfaces/innerkits/socket/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -19,7 +19,7 @@ service_socket_include = [
"//third_party/bounds_checking_function/include",
]
service_socket_deps = [
"//base/startup/init_lite/services/log:
ini
t_log",
"//base/startup/init_lite/services/log:
agen
t_log",
"//third_party/bounds_checking_function:libsec_static",
]
...
...
services/begetctl/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -60,6 +60,8 @@ ohos_executable("begetctl") {
"//base/startup/init_lite/interfaces/innerkits:libbeget_proxy",
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/services/param/watcher:param_watcheragent",
"//base/startup/init_lite/services/utils:libinit_tools",
"//base/startup/init_lite/services/utils:libinit_utils",
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",
]
defines += [
...
...
@@ -129,6 +131,8 @@ ohos_executable("paramshell") {
"//base/startup/init_lite/interfaces/innerkits:libbeget_proxy",
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/services/param/watcher:param_watcheragent",
"//base/startup/init_lite/services/utils:libinit_tools",
"//base/startup/init_lite/services/utils:libinit_utils",
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",
]
defines += [
...
...
services/begetctl/shell/shell_utils.h
浏览文件 @
67baf759
...
...
@@ -24,9 +24,9 @@
#define BSH_LOG_FILE "begetctrl.log"
#define BSH_LABEL "SHELL"
#define BSH_LOGI(fmt, ...) STARTUP_LOGI(BSH_L
OG_FILE, BSH_L
ABEL, fmt, ##__VA_ARGS__)
#define BSH_LOGE(fmt, ...) STARTUP_LOGE(BSH_L
OG_FILE, BSH_L
ABEL, fmt, ##__VA_ARGS__)
#define BSH_LOGV(fmt, ...) STARTUP_LOGV(BSH_L
OG_FILE, BSH_L
ABEL, fmt, ##__VA_ARGS__)
#define BSH_LOGI(fmt, ...) STARTUP_LOGI(BSH_LABEL, fmt, ##__VA_ARGS__)
#define BSH_LOGE(fmt, ...) STARTUP_LOGE(BSH_LABEL, fmt, ##__VA_ARGS__)
#define BSH_LOGV(fmt, ...) STARTUP_LOGV(BSH_LABEL, fmt, ##__VA_ARGS__)
#define BSH_CHECK(ret, exper, ...) \
if
(
!
(
ret
))
{
\
...
...
services/log/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -13,6 +13,7 @@
if (defined(ohos_lite)) {
static_library("init_log") {
sources = [ "init_log.c" ]
defines = [ "OHOS_LITE" ]
public_deps = [ "//third_party/bounds_checking_function:libsec_static" ]
include_dirs = [
"//base/hiviewdfx/hilog_lite/interfaces/native/kits",
...
...
@@ -24,6 +25,7 @@ if (defined(ohos_lite)) {
import("//build/ohos.gni")
ohos_static_library("init_log") {
sources = [ "init_log.c" ]
defines = [ "INIT_DMESG" ]
deps = [ "//third_party/bounds_checking_function:libsec_static" ]
include_dirs = [ "//base/startup/init_lite/interfaces/innerkits/include" ]
part_name = "startup"
...
...
@@ -40,6 +42,7 @@ if (defined(ohos_lite)) {
"system",
"updater",
]
external_deps = [ "hilog_native:libhilog_base" ]
relative_install_dir = "platform-vndk"
install_enable = true
part_name = "init"
...
...
services/log/init_log.c
浏览文件 @
67baf759
...
...
@@ -22,61 +22,45 @@
#include <time.h>
#include "securec.h"
#define UNUSED(x) \
do
{
\
(
void
)(
x
)
\
}
while
(
0
)
#ifdef OHOS_LITE
#include "hilog/log.h"
#endif
#ifdef INIT_AGENT
#include "hilog_base/log_base.h"
#endif
#define MAX_LOG_SIZE 1024
#define BASE_YEAR 1900
static
InitLogLevel
g_logLevel
=
INIT_INFO
;
static
const
char
*
LOG_LEVEL_STR
[]
=
{
"DEBUG"
,
"INFO"
,
"WARNING"
,
"ERROR"
,
"FATAL"
};
void
SetInitLogLevel
(
InitLogLevel
logLevel
)
{
g_logLevel
=
logLevel
;
}
#ifdef
OHOS_LIT
E
static
LogLevel
ConvertToHiLog
(
InitLogLevel
level
)
#ifdef
INIT_FIL
E
static
void
LogToFile
(
const
char
*
logFile
,
const
char
*
fileName
,
int
line
,
const
char
*
info
)
{
switch
(
level
)
{
case
INIT_DEBUG
:
return
LOG_DEBUG
;
case
INIT_INFO
:
return
LOG_INFO
;
case
INIT_WARN
:
return
LOG_WARN
;
case
INIT_ERROR
:
return
LOG_ERROR
;
case
INIT_FATAL
:
return
LOG_FATAL
;
// Unexpected log level, set level as lowest
default:
return
LOG_DEBUG
;
}
}
void
InitToHiLog
(
InitLogLevel
logLevel
,
const
char
*
fmt
,
...)
{
if
(
logLevel
<
g_logLevel
)
{
time_t
second
=
time
(
0
);
if
(
second
<=
0
)
{
return
;
}
va_list
list
;
va_start
(
list
,
fmt
);
char
tmpFmt
[
MAX_LOG_SIZE
];
if
(
vsnprintf_s
(
tmpFmt
,
MAX_LOG_SIZE
,
MAX_LOG_SIZE
-
1
,
fmt
,
list
)
==
-
1
)
{
va_end
(
list
);
struct
tm
*
t
=
localtime
(
&
second
);
FILE
*
outfile
=
fopen
(
logFile
,
"a+"
);
if
(
t
==
NULL
||
outfile
==
NULL
)
{
return
;
}
(
void
)
HiLogPrint
(
LOG_CORE
,
ConvertToHiLog
(
logLevel
),
LOG_DOMAIN
,
INIT_LOG_TAG
,
"%{public}s"
,
tmpFmt
);
va_end
(
list
);
(
void
)
fprintf
(
outfile
,
"[%d-%d-%d %d:%d:%d][pid=%d][%s:%d]%s
\n
"
,
(
t
->
tm_year
+
BASE_YEAR
),
(
t
->
tm_mon
+
1
),
t
->
tm_mday
,
t
->
tm_hour
,
t
->
tm_min
,
t
->
tm_sec
,
getpid
(),
fileName
,
line
,
info
);
(
void
)
fflush
(
outfile
);
fclose
(
outfile
);
return
;
}
#endif
#ifdef INIT_DMESG
#ifndef OHOS_LITE
static
int
g_fd
=
-
1
;
void
OpenLogDevice
(
void
)
{
...
...
@@ -87,11 +71,10 @@ void OpenLogDevice(void)
return
;
}
void
InitLogInit
(
const
char
*
outFileName
,
InitLogLevel
logLevel
,
const
char
*
kLevel
,
const
char
*
fmt
,
...
)
void
LogToDmesg
(
InitLogLevel
logLevel
,
const
char
*
domain
,
const
char
*
fileName
,
int
line
,
const
char
*
info
)
{
if
(
logLevel
<
g_logLevel
)
{
return
;
}
static
const
char
*
LOG_LEVEL_STR
[]
=
{
"DEBUG"
,
"INFO"
,
"WARNING"
,
"ERROR"
,
"FATAL"
};
static
const
char
*
LOG_KLEVEL_STR
[]
=
{
"<7>"
,
"<6>"
,
"<4>"
,
"<3>"
,
"<3>"
};
if
(
UNLIKELY
(
g_fd
<
0
))
{
OpenLogDevice
();
...
...
@@ -99,52 +82,48 @@ void InitLogInit(const char *outFileName, InitLogLevel logLevel, const char *kLe
return
;
}
}
va_list
vargs
;
va_start
(
vargs
,
fmt
);
char
tmpFmt
[
MAX_LOG_SIZE
];
if
(
vsnprintf_s
(
tmpFmt
,
MAX_LOG_SIZE
,
MAX_LOG_SIZE
-
1
,
fmt
,
vargs
)
==
-
1
)
{
close
(
g_fd
);
g_fd
=
-
1
;
va_end
(
vargs
);
return
;
}
char
logInfo
[
MAX_LOG_SIZE
];
if
(
snprintf_s
(
logInfo
,
MAX_LOG_SIZE
,
MAX_LOG_SIZE
-
1
,
"%s[pid=%d
][%s][%s]
%s"
,
kLevel
,
getpid
(),
"INIT"
,
LOG_LEVEL_STR
[
logLevel
],
tmpFmt
)
==
-
1
)
{
if
(
snprintf_s
(
logInfo
,
MAX_LOG_SIZE
,
MAX_LOG_SIZE
-
1
,
"%s[pid=%d
%d][%s][%s][%s:%d]
%s"
,
LOG_KLEVEL_STR
[
logLevel
],
getpid
(),
getppid
(),
domain
,
LOG_LEVEL_STR
[
logLevel
],
fileName
,
line
,
info
)
==
-
1
)
{
close
(
g_fd
);
g_fd
=
-
1
;
va_end
(
vargs
);
return
;
}
va_end
(
vargs
);
if
(
write
(
g_fd
,
logInfo
,
strlen
(
logInfo
))
<
0
)
{
close
(
g_fd
);
g_fd
=
-
1
;
}
return
;
}
#endif
#endif
void
InitLog
Agent
(
const
char
*
outFileName
,
InitLogLevel
logLevel
,
const
char
*
kLevel
,
const
char
*
fmt
,
...)
void
InitLog
(
InitLogLevel
logLevel
,
const
char
*
domain
,
const
char
*
fileName
,
int
line
,
const
char
*
fmt
,
...)
{
if
(
logLevel
<
g_logLevel
)
{
va_list
vargs
;
va_start
(
vargs
,
fmt
);
char
tmpFmt
[
MAX_LOG_SIZE
];
if
(
vsnprintf_s
(
tmpFmt
,
MAX_LOG_SIZE
,
MAX_LOG_SIZE
-
1
,
fmt
,
vargs
)
==
-
1
)
{
va_end
(
vargs
);
return
;
}
time_t
second
=
time
(
0
);
INIT_CHECK_ONLY_RETURN
(
second
>=
0
&&
outFileName
!=
NULL
);
struct
tm
*
t
=
localtime
(
&
second
);
INIT_CHECK_ONLY_RETURN
(
t
!=
NULL
);
FILE
*
outfile
=
fopen
(
outFileName
,
"a+"
);
INIT_CHECK_ONLY_RETURN
(
outfile
!=
NULL
);
(
void
)
fprintf
(
outfile
,
"[%d-%d-%d %d:%d:%d][pid=%d][%s][%s] "
,
(
t
->
tm_year
+
BASE_YEAR
),
(
t
->
tm_mon
+
1
),
t
->
tm_mday
,
t
->
tm_hour
,
t
->
tm_min
,
t
->
tm_sec
,
getpid
(),
kLevel
,
LOG_LEVEL_STR
[
logLevel
]);
va_list
list
;
va_start
(
list
,
fmt
);
(
void
)
vfprintf
(
outfile
,
fmt
,
list
);
va_end
(
list
);
(
void
)
fflush
(
outfile
);
fclose
(
outfile
);
return
;
va_end
(
vargs
);
#ifdef OHOS_LITE
static
LogLevel
LOG_LEVEL
[]
=
{
LOG_DEBUG
,
LOG_INFO
,
LOG_WARN
,
LOG_ERROR
,
LOG_FATAL
};
(
void
)
HiLogPrint
(
LOG_CORE
,
LOG_LEVEL
[
logLevel
],
domain
,
INIT_LOG_TAG
,
"[%{public}s:%{public}d]%{public}s"
,
fileName
,
line
,
tmpFmt
);
#else
#ifdef INIT_DMESG
LogToDmesg
(
logLevel
,
domain
,
fileName
,
line
,
tmpFmt
);
#endif
#endif
#ifdef INIT_AGENT
static
LogLevel
LOG_LEVEL
[]
=
{
LOG_DEBUG
,
LOG_INFO
,
LOG_WARN
,
LOG_ERROR
,
LOG_FATAL
};
HiLogBasePrint
(
LOG_CORE
,
LOG_LEVEL
[
logLevel
],
0
,
domain
,
"[%{public}s:%d]%{public}s"
,
fileName
,
line
,
tmpFmt
);
#ifdef INIT_FILE
LogToFile
(
"/data/init_agent/begetctl.log"
,
fileName
,
line
,
tmpFmt
);
#endif
#endif
}
services/log/init_log.h
浏览文件 @
67baf759
...
...
@@ -28,58 +28,21 @@ extern "C" {
#endif
#endif
void
SetInitLogLevel
(
InitLogLevel
logLevel
);
#ifndef INIT_LOG_TAG
#define INIT_LOG_TAG "Init"
#endif
#ifdef OHOS_LITE
#define INIT_LOGV(fmt, ...) InitToHiLog(INIT_DEBUG, "%s : "fmt, (__FUNCTION__), ##__VA_ARGS__)
#define INIT_LOGI(fmt, ...) InitToHiLog(INIT_INFO, "%s : "fmt, (__FUNCTION__), ##__VA_ARGS__)
#define INIT_LOGW(fmt, ...) InitToHiLog(INIT_WARN, "%s : "fmt, (__FUNCTION__), ##__VA_ARGS__)
#define INIT_LOGE(fmt, ...) InitToHiLog(INIT_ERROR, "%s : "fmt, (__FUNCTION__), ##__VA_ARGS__)
#define INIT_LOGF(fmt, ...) InitToHiLog(INIT_FATAL, "%s : "fmt, (__FUNCTION__), ##__VA_ARGS__)
#define STARTUP_LOGV(logFIle, LABEL, fmt, ...) InitToHiLog(LABEL, INIT_DEBUG, "%s : "fmt, (__FUNCTION__), ##__VA_ARGS__)
#define STARTUP_LOGI(logFIle, LABEL, fmt, ...) InitToHiLog(INIT_INFO, "%s : "fmt, (__FUNCTION__), ##__VA_ARGS__)
#define STARTUP_LOGE(logFIle, LABEL, fmt, ...) InitToHiLog(INIT_ERROR, "%s : "fmt, (__FUNCTION__), ##__VA_ARGS__)
void
InitToHiLog
(
InitLogLevel
logLevel
,
const
char
*
fmt
,
...);
#else
#define INIT_LOGV(fmt, ...) \
do
{
\
InitLogPrint
(
INIT_LOG_PATH
"init_agent.log"
,
INIT_DEBUG
,
"<7>"
,
"[%s:%d)] "
fmt
"
\n
"
,
\
(
FILE_NAME
),
(
__LINE__
),
##
__VA_ARGS__
);
\
}
while
(
0
)
#define INIT_LOGI(fmt, ...) \
do
{
\
InitLogPrint
(
INIT_LOG_PATH
"init_agent.log"
,
INIT_INFO
,
"<6>"
,
"[%s:%d)] "
fmt
"
\n
"
,
\
(
FILE_NAME
),
(
__LINE__
),
##
__VA_ARGS__
);
\
}
while
(
0
)
#define INIT_LOGW(fmt, ...) \
do
{
\
InitLogPrint
(
INIT_LOG_PATH
"init_agent.log"
,
INIT_WARN
,
"<4>"
,
"[%s:%d)] "
fmt
"
\n
"
,
\
(
FILE_NAME
),
(
__LINE__
),
##
__VA_ARGS__
);
\
}
while
(
0
)
#define INIT_LOGE(fmt, ...) \
do
{
\
InitLogPrint
(
INIT_LOG_PATH
"init_agent.log"
,
INIT_ERROR
,
"<3>"
,
"[%s:%d)] "
fmt
"
\n
"
,
\
(
FILE_NAME
),
(
__LINE__
),
##
__VA_ARGS__
);
\
}
while
(
0
)
#ifndef INIT_DOMAIN
#define INIT_DOMAIN "Init"
#endif
#define INIT_LOGF(fmt, ...) \
do
{
\
InitLogPrint
(
INIT_LOG_PATH
"init_agent.log"
,
INIT_FATAL
,
"<3>"
,
"[%s:%d)] "
fmt
"
\n
"
,
\
(
FILE_NAME
),
(
__LINE__
),
##
__VA_ARGS__
);
\
}
while
(
0
)
void
OpenLogDevice
(
void
);
#endif
#define INIT_LOGV(fmt, ...) InitLog(INIT_DEBUG, INIT_DOMAIN, (FILE_NAME), (__LINE__), fmt, ##__VA_ARGS__)
#define INIT_LOGI(fmt, ...) InitLog(INIT_INFO, INIT_DOMAIN, (FILE_NAME), (__LINE__), fmt, ##__VA_ARGS__)
#define INIT_LOGW(fmt, ...) InitLog(INIT_WARN, INIT_DOMAIN, (FILE_NAME), (__LINE__), fmt, ##__VA_ARGS__)
#define INIT_LOGE(fmt, ...) InitLog(INIT_ERROR, INIT_DOMAIN, (FILE_NAME), (__LINE__), fmt, ##__VA_ARGS__)
#define INIT_LOGF(fmt, ...) InitLog(INIT_FATAL, INIT_DOMAIN, (FILE_NAME), (__LINE__), fmt, ##__VA_ARGS__)
#ifndef UNLIKELY
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
...
...
services/loopevent/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -43,11 +43,7 @@ if (defined(ohos_lite)) {
include_dirs = common_include
defines = [ "_GNU_SOURCE" ]
deps = [
"//base/startup/init_lite/services/log:init_log",
"//base/startup/init_lite/services/utils:libinit_tools",
"//third_party/bounds_checking_function:libsec_static",
]
deps = [ "//third_party/bounds_checking_function:libsec_static" ]
}
} else {
import("//build/ohos.gni")
...
...
@@ -57,11 +53,7 @@ if (defined(ohos_lite)) {
include_dirs = common_include
defines = [ "_GNU_SOURCE" ]
deps = [
"//base/startup/init_lite/services/log:init_log",
"//base/startup/init_lite/services/utils:libinit_tools",
"//third_party/bounds_checking_function:libsec_static",
]
deps = [ "//third_party/bounds_checking_function:libsec_static" ]
part_name = "init"
subsystem_name = "startup"
}
...
...
services/loopevent/utils/le_utils.h
浏览文件 @
67baf759
...
...
@@ -27,11 +27,10 @@
#define LE_SET_FLAGS(flags, flag) ((flags) |= (flag))
#define LE_CLEAR_FLAGS(flags, flag) ((flags) &= ~(flag))
#define LE_LOG_FILE "loopevent.log"
#define LE_LABEL "LoopEvent"
#define LE_LOGI(fmt, ...) STARTUP_LOGI(LE_L
OG_FILE, LE_L
ABEL, fmt, ##__VA_ARGS__)
#define LE_LOGE(fmt, ...) STARTUP_LOGE(LE_L
OG_FILE, LE_L
ABEL, fmt, ##__VA_ARGS__)
#define LE_LOGV(fmt, ...) STARTUP_LOGV(LE_L
OG_FILE, LE_L
ABEL, fmt, ##__VA_ARGS__)
#define LE_LOGI(fmt, ...) STARTUP_LOGI(LE_LABEL, fmt, ##__VA_ARGS__)
#define LE_LOGE(fmt, ...) STARTUP_LOGE(LE_LABEL, fmt, ##__VA_ARGS__)
#define LE_LOGV(fmt, ...) STARTUP_LOGV(LE_LABEL, fmt, ##__VA_ARGS__)
#define LE_CHECK(ret, exper, ...) \
if
(
!
(
ret
))
{
\
...
...
services/param/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -98,8 +98,7 @@ ohos_shared_library("param_client") {
"//base/startup/init_lite/services/loopevent/include",
]
defines = [ "INIT_AGENT" ]
defines += [ "_GNU_SOURCE" ]
defines = [ "_GNU_SOURCE" ]
if (build_selinux) {
defines += [ "WITH_SELINUX" ]
...
...
services/param/include/param_utils.h
浏览文件 @
67baf759
...
...
@@ -80,11 +80,10 @@ typedef enum {
#define PARAM_CLEAR_FLAG(node, flag) ((node) &= ~(flag))
#define PARAM_TEST_FLAG(node, flag) (((node) & (flag)) == (flag))
#define PARAN_LOG_FILE "param.log"
#define PARAN_LABEL "PARAM"
#define PARAM_LOGI(fmt, ...) STARTUP_LOGI(PARAN_L
OG_FILE, PARAN_L
ABEL, fmt, ##__VA_ARGS__)
#define PARAM_LOGE(fmt, ...) STARTUP_LOGE(PARAN_L
OG_FILE, PARAN_L
ABEL, fmt, ##__VA_ARGS__)
#define PARAM_LOGV(fmt, ...) STARTUP_LOGV(PARAN_L
OG_FILE, PARAN_L
ABEL, fmt, ##__VA_ARGS__)
#define PARAM_LOGI(fmt, ...) STARTUP_LOGI(PARAN_LABEL, fmt, ##__VA_ARGS__)
#define PARAM_LOGE(fmt, ...) STARTUP_LOGE(PARAN_LABEL, fmt, ##__VA_ARGS__)
#define PARAM_LOGV(fmt, ...) STARTUP_LOGV(PARAN_LABEL, fmt, ##__VA_ARGS__)
#define PARAM_CHECK(retCode, exper, ...) \
if
(
!
(
retCode
))
{
\
...
...
services/param/watcher/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -37,8 +37,6 @@ ohos_shared_library("param_watcheragent") {
"//base/startup/init_lite/services/loopevent/include",
]
defines = [ "INIT_AGENT" ]
deps = [
"//base/startup/init_lite/services/log:agent_log",
"//base/startup/init_lite/services/param:param_client",
...
...
@@ -83,8 +81,6 @@ ohos_shared_library("param_watcher") {
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include",
]
defines = [ "INIT_AGENT" ]
deps = [
"//base/startup/init_lite/services/log:agent_log",
"//base/startup/init_lite/services/param:param_client",
...
...
services/param/watcher/include/watcher_utils.h
浏览文件 @
67baf759
...
...
@@ -26,11 +26,10 @@
namespace
OHOS
{
namespace
init_param
{
#define UNUSED(x) (void)(x)
#define WATCHER_LOG_FILE "param_watcher.log"
#define WATCHER_LABEL "PARAM_WATCHER"
#define WATCHER_LOGI(fmt, ...) STARTUP_LOGI(WATCHER_L
OG_FILE, WATCHER_L
ABEL, fmt, ##__VA_ARGS__)
#define WATCHER_LOGE(fmt, ...) STARTUP_LOGE(WATCHER_L
OG_FILE, WATCHER_L
ABEL, fmt, ##__VA_ARGS__)
#define WATCHER_LOGV(fmt, ...) STARTUP_LOGV(WATCHER_L
OG_FILE, WATCHER_L
ABEL, fmt, ##__VA_ARGS__)
#define WATCHER_LOGI(fmt, ...) STARTUP_LOGI(WATCHER_LABEL, fmt, ##__VA_ARGS__)
#define WATCHER_LOGE(fmt, ...) STARTUP_LOGE(WATCHER_LABEL, fmt, ##__VA_ARGS__)
#define WATCHER_LOGV(fmt, ...) STARTUP_LOGV(WATCHER_LABEL, fmt, ##__VA_ARGS__)
#define WATCHER_CHECK(retCode, exper, ...) \
if (!(retCode)) { \
...
...
services/plugin/plugin_adapter.h
浏览文件 @
67baf759
...
...
@@ -29,11 +29,10 @@ typedef struct {
}
PluginCmd
;
#define READ_DURATION 100000
#define PLUGIN_LOG_FILE "plugintest.log"
#define PLUGIN_LABEL "PLUGIN"
#define PLUGIN_LOGI(fmt, ...) STARTUP_LOGI(PLUGIN_L
OG_FILE, PLUGIN_L
ABEL, fmt, ##__VA_ARGS__)
#define PLUGIN_LOGE(fmt, ...) STARTUP_LOGE(PLUGIN_L
OG_FILE, PLUGIN_L
ABEL, fmt, ##__VA_ARGS__)
#define PLUGIN_LOGV(fmt, ...) STARTUP_LOGV(PLUGIN_L
OG_FILE, PLUGIN_L
ABEL, fmt, ##__VA_ARGS__)
#define PLUGIN_LOGI(fmt, ...) STARTUP_LOGI(PLUGIN_LABEL, fmt, ##__VA_ARGS__)
#define PLUGIN_LOGE(fmt, ...) STARTUP_LOGE(PLUGIN_LABEL, fmt, ##__VA_ARGS__)
#define PLUGIN_LOGV(fmt, ...) STARTUP_LOGV(PLUGIN_LABEL, fmt, ##__VA_ARGS__)
#define PLUGIN_CHECK(ret, exper, ...) \
if
(
!
(
ret
))
{
\
...
...
services/utils/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -26,7 +26,6 @@ if (defined(ohos_lite)) {
]
deps = [
"//base/startup/init_lite/services/log:init_log",
"//third_party/bounds_checking_function:libsec_static",
]
defines = [ "_GNU_SOURCE" ]
...
...
@@ -47,10 +46,7 @@ if (defined(ohos_lite)) {
"//base/startup/init_lite/services/include",
]
deps = [
"//base/startup/init_lite/services/log:init_log",
"//third_party/bounds_checking_function:libsec_static",
]
deps = [ "//third_party/bounds_checking_function:libsec_static" ]
defines = [ "_GNU_SOURCE" ]
part_name = "init"
}
...
...
@@ -65,10 +61,7 @@ if (defined(ohos_lite)) {
"//base/startup/init_lite/services/include",
]
deps = [
"//base/startup/init_lite/services/log:init_log",
"//third_party/bounds_checking_function:libsec_static",
]
deps = [ "//third_party/bounds_checking_function:libsec_static" ]
defines = [ "_GNU_SOURCE" ]
part_name = "init"
}
...
...
ueventd/BUILD.gn
浏览文件 @
67baf759
...
...
@@ -24,6 +24,7 @@ if (defined(ohos_lite)) {
"//base/startup/init_lite/ueventd/ueventd_main.c",
"//base/startup/init_lite/ueventd/ueventd_read_cfg.c",
"//base/startup/init_lite/ueventd/ueventd_socket.c",
"//base/startup/init_lite/interfaces/innerkits/socket/init_socket.c"
]
defines = [ "__MUSL__" ]
...
...
@@ -39,7 +40,6 @@ if (defined(ohos_lite)) {
]
deps = [
"//base/startup/init_lite/interfaces/innerkits/socket:libsocket_static",
"//base/startup/init_lite/services/log:init_log",
"//third_party/bounds_checking_function:libsec_static",
]
...
...
@@ -69,6 +69,7 @@ if (defined(ohos_lite)) {
"//base/startup/init_lite/ueventd/ueventd_firmware_handler.c",
"//base/startup/init_lite/ueventd/ueventd_read_cfg.c",
"//base/startup/init_lite/ueventd/ueventd_socket.c",
"//base/startup/init_lite/interfaces/innerkits/socket/init_socket.c"
]
service_ueventd_include = [
...
...
@@ -81,7 +82,6 @@ if (defined(ohos_lite)) {
]
service_ueventd_deps = [
"//base/startup/init_lite/interfaces/innerkits/socket:libsocket_static",
"//base/startup/init_lite/services/log:init_log",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_static",
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录