diff --git a/interfaces/innerkits/include/beget_ext.h b/interfaces/innerkits/include/beget_ext.h index 248126f686132139d2143c910f572986e252dddd..011668f2650bc52ec6ed2f6efbbb1ae73f69d7a1 100644 --- a/interfaces/innerkits/include/beget_ext.h +++ b/interfaces/innerkits/include/beget_ext.h @@ -49,15 +49,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 5778886ef22ede7ca6da5cf522426d9e1c761208..a7337c6dad2e27757b75226e61fb49aa6856d10b 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 7c12587a96fec1e44b110446ee88c3da0613ebac..f6993c214140421fc42faa584ebe2bd5ad08c611 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 453d80faa7d158314a2013b0a4efedfe990c5887..59004dec44f780e32760201e957b1014d896db8c 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 780031ff8f09423ca456419333b6e9f28015ccbb..1d01062ff6ec458a3404487f0d2d51c97886b0b9 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 27568e19c8994c1b8e55bb20a0bdb158976766df..55e7a3aeecd8e0eb45a81e689241b4dc934e7a6d 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 10041c9849bba835254b19cfa9e1b0396debb1cb..4e2c70ab6bfc65cbb385b8e83425c9d140d53190 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 8e6cd18100744cf29c4876301693abdb23d1ba5d..946e406323291fd3745af6dd805080f0ad960203 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 72c5f4111b795a300985ef9dd161f7503d8ac973..e25d449ee71ae151ccaad419245712b6b531dc50 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 53d8cd2aeada5fac0f157d4bbed03a05cfb4f2f3..81cc2eb9f496c43a86a48c9df10288890ed57054 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"