未验证 提交 9d3af38b 编写于 作者: O openharmony_ci 提交者: Gitee

!1408 调整 init log 不对外开放的接口改为 INIT_LOCAL_API

Merge pull request !1408 from cheng_jinsong/init1020
...@@ -49,15 +49,10 @@ typedef enum InitLogLevel { ...@@ -49,15 +49,10 @@ typedef enum InitLogLevel {
INIT_FATAL INIT_FATAL
} InitLogLevel; } InitLogLevel;
typedef void (*InitCommLog)(int logLevel, uint32_t domain, const char *tag, const char *fmt, va_list vargs);
#define FILE_NAME (strrchr((__FILE__), '/') ? strrchr((__FILE__), '/') + 1 : (__FILE__)) #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 StartupLog(InitLogLevel logLevel, uint32_t domain, const char *tag, const char *fmt, ...);
INIT_PUBLIC_API void EnableInitLog(InitLogLevel level);
INIT_PUBLIC_API void SetInitLogLevel(InitLogLevel level); 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);
#define STARTUP_LOGV(domain, tag, fmt, ...) \ #define STARTUP_LOGV(domain, tag, fmt, ...) \
StartupLog(INIT_DEBUG, domain, tag, "[%s:%d]" fmt, (FILE_NAME), (__LINE__), ##__VA_ARGS__) StartupLog(INIT_DEBUG, domain, tag, "[%s:%d]" fmt, (FILE_NAME), (__LINE__), ##__VA_ARGS__)
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "begetctl.h" #include "begetctl.h"
#include "init_log.h"
#include "init_utils.h" #include "init_utils.h"
#include "init_param.h" #include "init_param.h"
#include "securec.h" #include "securec.h"
...@@ -53,9 +54,9 @@ static int32_t GetInitLogLevelFromParam(BShellHandle shell, int argc, char **arg ...@@ -53,9 +54,9 @@ static int32_t GetInitLogLevelFromParam(BShellHandle shell, int argc, char **arg
uint32_t len = sizeof(logLevel); uint32_t len = sizeof(logLevel);
int ret = SystemReadParam("persist.init.debug.loglevel", logLevel, &len); int ret = SystemReadParam("persist.init.debug.loglevel", logLevel, &len);
if (ret == 0) { if (ret == 0) {
printf("Success to get init log level: %s from param \"persist.init.debug.loglevel\" \n", logLevel); printf("Success to get init log level: %s from param \"persist.init.debug.loglevel\". \n", logLevel);
} else { } else {
printf("Failed to get init log level from param, keep the system origin log level: %d.\n", GetInitLogLevel()); printf("Failed to get init log level from param, keep the system origin log level. \n");
} }
return 0; return 0;
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "init_log.h" #include "init_log.h"
static InitCommLog g_initCommLog = NULL; static InitCommLog g_initCommLog = NULL;
INIT_PUBLIC_API void SetInitCommLog(InitCommLog logFunc) INIT_LOCAL_API void SetInitCommLog(InitCommLog logFunc)
{ {
g_initCommLog = logFunc; g_initCommLog = logFunc;
} }
......
...@@ -140,18 +140,13 @@ INIT_PUBLIC_API void SetInitLogLevel(InitLogLevel level) ...@@ -140,18 +140,13 @@ INIT_PUBLIC_API void SetInitLogLevel(InitLogLevel level)
return; return;
} }
INIT_PUBLIC_API int GetInitLogLevel(void) INIT_LOCAL_API void EnableInitLog(InitLogLevel level)
{
return g_logLevel;
}
INIT_PUBLIC_API void EnableInitLog(InitLogLevel level)
{ {
g_logLevel = level; g_logLevel = level;
SetInitCommLog(InitLog); SetInitCommLog(InitLog);
} }
INIT_PUBLIC_API void EnableInitLogFromCmdline(void) INIT_LOCAL_API void EnableInitLogFromCmdline(void)
{ {
SetInitCommLog(InitLog); SetInitCommLog(InitLog);
char level[MAX_BUFFER_LEN] = {0}; char level[MAX_BUFFER_LEN] = {0};
......
...@@ -36,8 +36,13 @@ extern "C" { ...@@ -36,8 +36,13 @@ extern "C" {
#define INIT_LOG_DOMAIN (BASE_DOMAIN + 1) #define INIT_LOG_DOMAIN (BASE_DOMAIN + 1)
#endif #endif
typedef void (*InitCommLog)(int logLevel, uint32_t domain, const char *tag, const char *fmt, va_list vargs);
INIT_LOCAL_API void OpenLogDevice(void); INIT_LOCAL_API void OpenLogDevice(void);
INIT_LOCAL_API void InitLog(int logLevel, unsigned int domain, const char *tag, const char *fmt, va_list vargs); INIT_LOCAL_API void InitLog(int logLevel, unsigned int domain, const char *tag, const char *fmt, va_list vargs);
INIT_LOCAL_API void SetInitCommLog(InitCommLog logFunc);
INIT_LOCAL_API void EnableInitLog(InitLogLevel level);
INIT_LOCAL_API void EnableInitLogFromCmdline(void);
#ifdef PARAM_BASE #ifdef PARAM_BASE
#define INIT_LOGV(fmt, ...) #define INIT_LOGV(fmt, ...)
......
...@@ -21,9 +21,7 @@ ...@@ -21,9 +21,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h> #include <unistd.h>
#ifdef PARAM_BASE_LOG
#include "init_log.h" #include "init_log.h"
#endif
#include "init_utils.h" #include "init_utils.h"
#include "param_base.h" #include "param_base.h"
#include "param_manager.h" #include "param_manager.h"
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "init_log.h"
#include "init_param.h" #include "init_param.h"
#include "param_manager.h" #include "param_manager.h"
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include "init_log.h"
#include "init_param.h" #include "init_param.h"
#include "init_utils.h" #include "init_utils.h"
#include "param_manager.h" #include "param_manager.h"
......
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include "beget_ext.h"
#include "cJSON.h" #include "cJSON.h"
#include "init_cmds.h" #include "init_cmds.h"
#include "init_jobs_internal.h" #include "init_jobs_internal.h"
#include "init_log.h"
#include "init_service_manager.h" #include "init_service_manager.h"
#include "param_stub.h" #include "param_stub.h"
#include "securec.h" #include "securec.h"
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "param_stub.h" #include "param_stub.h"
#include <dirent.h> #include <dirent.h>
#include "beget_ext.h" #include "init_log.h"
#include "init_param.h" #include "init_param.h"
#include "param_manager.h" #include "param_manager.h"
#include "param_security.h" #include "param_security.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册