提交 67baf759 编写于 作者: X xionglei6

fix log

Signed-off-by: Nxionglei6 <xionglei6@huawei.com>
上级 779e1987
......@@ -28,7 +28,6 @@ ohos_shared_library("deviceinfoservice") {
sources = [ "device_info_stub.cpp" ]
defines = [
"INIT_AGENT",
"DINFO_LABEL=\"DeviceInfoService\"",
]
include_dirs = [
......
......@@ -27,7 +27,7 @@ shared_library("libinitsync_shared") {
"//base/startup/init_lite/interfaces/innerkits/include",
]
public_deps = [
"//base/startup/init_lite/services/log:init_log",
"//base/startup/init_lite/services/log:agent_log",
"//third_party/bounds_checking_function:libsec_shared",
]
}
......
......@@ -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"
}
......@@ -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"
}
......@@ -20,7 +20,7 @@ service_file_include = [
"//third_party/bounds_checking_function/include",
]
service_file_deps = [
"//base/startup/init_lite/services/log:init_log",
"//base/startup/init_lite/services/log:agent_log",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_static",
]
......
......@@ -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_LOG_FILE, BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGE(fmt, ...) STARTUP_LOGE(BEGET_LOG_FILE, BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGV(fmt, ...) STARTUP_LOGV(BEGET_LOG_FILE, BEGET_LABEL, fmt, ##__VA_ARGS__)
#define BEGET_LOGW(fmt, ...) STARTUP_LOGW(BEGET_LOG_FILE, BEGET_LABEL, 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)) { \
......
......@@ -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
......
......@@ -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:init_log" ]
deps += [ "//base/startup/init_lite/services/log:agent_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"
}
......@@ -19,7 +19,7 @@ service_socket_include = [
"//third_party/bounds_checking_function/include",
]
service_socket_deps = [
"//base/startup/init_lite/services/log:init_log",
"//base/startup/init_lite/services/log:agent_log",
"//third_party/bounds_checking_function:libsec_static",
]
......
......@@ -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 += [
......
......@@ -24,9 +24,9 @@
#define BSH_LOG_FILE "begetctrl.log"
#define BSH_LABEL "SHELL"
#define BSH_LOGI(fmt, ...) STARTUP_LOGI(BSH_LOG_FILE, BSH_LABEL, fmt, ##__VA_ARGS__)
#define BSH_LOGE(fmt, ...) STARTUP_LOGE(BSH_LOG_FILE, BSH_LABEL, fmt, ##__VA_ARGS__)
#define BSH_LOGV(fmt, ...) STARTUP_LOGV(BSH_LOG_FILE, BSH_LABEL, 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)) { \
......
......@@ -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"
......
......@@ -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_LITE
static LogLevel ConvertToHiLog(InitLogLevel level)
#ifdef INIT_FILE
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 InitLogAgent(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
}
......@@ -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)
......
......@@ -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"
}
......
......@@ -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_LOG_FILE, LE_LABEL, fmt, ##__VA_ARGS__)
#define LE_LOGE(fmt, ...) STARTUP_LOGE(LE_LOG_FILE, LE_LABEL, fmt, ##__VA_ARGS__)
#define LE_LOGV(fmt, ...) STARTUP_LOGV(LE_LOG_FILE, LE_LABEL, 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)) { \
......
......@@ -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" ]
......
......@@ -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_LOG_FILE, PARAN_LABEL, fmt, ##__VA_ARGS__)
#define PARAM_LOGE(fmt, ...) STARTUP_LOGE(PARAN_LOG_FILE, PARAN_LABEL, fmt, ##__VA_ARGS__)
#define PARAM_LOGV(fmt, ...) STARTUP_LOGV(PARAN_LOG_FILE, PARAN_LABEL, 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)) { \
......
......@@ -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",
......
......@@ -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_LOG_FILE, WATCHER_LABEL, fmt, ##__VA_ARGS__)
#define WATCHER_LOGE(fmt, ...) STARTUP_LOGE(WATCHER_LOG_FILE, WATCHER_LABEL, fmt, ##__VA_ARGS__)
#define WATCHER_LOGV(fmt, ...) STARTUP_LOGV(WATCHER_LOG_FILE, WATCHER_LABEL, 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)) { \
......
......@@ -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_LOG_FILE, PLUGIN_LABEL, fmt, ##__VA_ARGS__)
#define PLUGIN_LOGE(fmt, ...) STARTUP_LOGE(PLUGIN_LOG_FILE, PLUGIN_LABEL, fmt, ##__VA_ARGS__)
#define PLUGIN_LOGV(fmt, ...) STARTUP_LOGV(PLUGIN_LOG_FILE, PLUGIN_LABEL, 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)) { \
......
......@@ -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"
}
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册