From ea6d2155f6ab636c714c9a02988eba93004b099b Mon Sep 17 00:00:00 2001 From: cheng_jinsong Date: Thu, 20 Oct 2022 11:13:13 +0800 Subject: [PATCH] fixed 2d15ff4 from https://gitee.com/chneg-jinsong/startup_init_lite/pulls/1408 set init log local Signed-off-by: cheng_jinsong --- interfaces/innerkits/include/beget_ext.h | 5 ----- services/begetctl/setloglevel.c | 5 +++-- services/log/init_commlog.c | 2 +- services/log/init_log.c | 9 ++------- services/log/init_log.h | 5 +++++ services/param/linux/param_request.c | 2 -- services/param/liteos/param_client.c | 1 + services/param/liteos/param_service.c | 1 + test/unittest/lite/cmd_func_test.cpp | 2 +- test/unittest/param/param_stub.cpp | 2 +- 10 files changed, 15 insertions(+), 19 deletions(-) diff --git a/interfaces/innerkits/include/beget_ext.h b/interfaces/innerkits/include/beget_ext.h index 1b0f0d92..62f6a630 100644 --- a/interfaces/innerkits/include/beget_ext.h +++ b/interfaces/innerkits/include/beget_ext.h @@ -47,15 +47,10 @@ typedef enum InitLogLevel { INIT_FATAL } 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__)) 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 int GetInitLogLevel(void); -INIT_PUBLIC_API void SetInitCommLog(InitCommLog logFunc); -INIT_PUBLIC_API void EnableInitLogFromCmdline(void); #define STARTUP_LOGV(domain, tag, fmt, ...) \ StartupLog(INIT_DEBUG, domain, tag, "[%s:%d]" fmt, (FILE_NAME), (__LINE__), ##__VA_ARGS__) diff --git a/services/begetctl/setloglevel.c b/services/begetctl/setloglevel.c index 5778886e..a7337c6d 100644 --- a/services/begetctl/setloglevel.c +++ b/services/begetctl/setloglevel.c @@ -17,6 +17,7 @@ #include #include "begetctl.h" +#include "init_log.h" #include "init_utils.h" #include "init_param.h" #include "securec.h" @@ -53,9 +54,9 @@ static int32_t GetInitLogLevelFromParam(BShellHandle shell, int argc, char **arg uint32_t len = sizeof(logLevel); int ret = SystemReadParam("persist.init.debug.loglevel", logLevel, &len); 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 { - 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; } diff --git a/services/log/init_commlog.c b/services/log/init_commlog.c index 7c12587a..f6993c21 100644 --- a/services/log/init_commlog.c +++ b/services/log/init_commlog.c @@ -16,7 +16,7 @@ #include "init_log.h" static InitCommLog g_initCommLog = NULL; -INIT_PUBLIC_API void SetInitCommLog(InitCommLog logFunc) +INIT_LOCAL_API void SetInitCommLog(InitCommLog logFunc) { g_initCommLog = logFunc; } diff --git a/services/log/init_log.c b/services/log/init_log.c index 453d80fa..59004dec 100644 --- a/services/log/init_log.c +++ b/services/log/init_log.c @@ -140,18 +140,13 @@ INIT_PUBLIC_API void SetInitLogLevel(InitLogLevel level) return; } -INIT_PUBLIC_API int GetInitLogLevel(void) -{ - return g_logLevel; -} - -INIT_PUBLIC_API void EnableInitLog(InitLogLevel level) +INIT_LOCAL_API void EnableInitLog(InitLogLevel level) { g_logLevel = level; SetInitCommLog(InitLog); } -INIT_PUBLIC_API void EnableInitLogFromCmdline(void) +INIT_LOCAL_API void EnableInitLogFromCmdline(void) { SetInitCommLog(InitLog); char level[MAX_BUFFER_LEN] = {0}; diff --git a/services/log/init_log.h b/services/log/init_log.h index 780031ff..1d01062f 100644 --- a/services/log/init_log.h +++ b/services/log/init_log.h @@ -36,8 +36,13 @@ extern "C" { #define INIT_LOG_DOMAIN (BASE_DOMAIN + 1) #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 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 #define INIT_LOGV(fmt, ...) diff --git a/services/param/linux/param_request.c b/services/param/linux/param_request.c index 27568e19..55e7a3ae 100644 --- a/services/param/linux/param_request.c +++ b/services/param/linux/param_request.c @@ -21,9 +21,7 @@ #include #include -#ifdef PARAM_BASE_LOG #include "init_log.h" -#endif #include "init_utils.h" #include "param_base.h" #include "param_manager.h" diff --git a/services/param/liteos/param_client.c b/services/param/liteos/param_client.c index 10041c98..4e2c70ab 100644 --- a/services/param/liteos/param_client.c +++ b/services/param/liteos/param_client.c @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "init_log.h" #include "init_param.h" #include "param_manager.h" diff --git a/services/param/liteos/param_service.c b/services/param/liteos/param_service.c index 8e6cd181..946e4063 100644 --- a/services/param/liteos/param_service.c +++ b/services/param/liteos/param_service.c @@ -15,6 +15,7 @@ #include #include +#include "init_log.h" #include "init_param.h" #include "init_utils.h" #include "param_manager.h" diff --git a/test/unittest/lite/cmd_func_test.cpp b/test/unittest/lite/cmd_func_test.cpp index 72c5f411..e25d449e 100644 --- a/test/unittest/lite/cmd_func_test.cpp +++ b/test/unittest/lite/cmd_func_test.cpp @@ -21,10 +21,10 @@ #include #include -#include "beget_ext.h" #include "cJSON.h" #include "init_cmds.h" #include "init_jobs_internal.h" +#include "init_log.h" #include "init_service_manager.h" #include "param_stub.h" #include "securec.h" diff --git a/test/unittest/param/param_stub.cpp b/test/unittest/param/param_stub.cpp index 53d8cd2a..81cc2eb9 100644 --- a/test/unittest/param/param_stub.cpp +++ b/test/unittest/param/param_stub.cpp @@ -15,7 +15,7 @@ #include "param_stub.h" #include -#include "beget_ext.h" +#include "init_log.h" #include "init_param.h" #include "param_manager.h" #include "param_security.h" -- GitLab