diff --git a/services/log/init_log.c b/services/log/init_log.c index 4deeb151a676b2454a9c757c55e7b2419666a51b..140e1e99b653d6aa2b598d691234ec0ed7d692b4 100755 --- a/services/log/init_log.c +++ b/services/log/init_log.c @@ -39,6 +39,25 @@ void SetInitLogLevel(InitLogLevel logLevel) } #ifdef OHOS_LITE +static LogLevel ConvertToHiLog(InitLogLevel level) +{ + switch (level) { + case INIT_DEBUG: + return INIT_DEBUG; + case INIT_INFO: + return INIT_INFO; + case INIT_WARN: + return INIT_WARN; + case INIT_ERROR: + return INIT_ERROR; + case INIT_FATAL: + return INIT_FATAL; + // Unexpected log level, set level as lowest + default: + return INIT_DEBUG; + } +} + void InitToHiLog(InitLogLevel logLevel, const char *fmt, ...) { if (logLevel < g_logLevel) { @@ -52,7 +71,7 @@ void InitToHiLog(InitLogLevel logLevel, const char *fmt, ...) va_end(list); return; } - (void)HiLogPrint(LOG_CORE, logLevel, LOG_DOMAIN, INIT_LOG_TAG, "%{public}s", tmpFmt); + (void)HiLogPrint(LOG_CORE, ConvertToHiLog(logLevel), LOG_DOMAIN, INIT_LOG_TAG, "%{public}s", tmpFmt); va_end(list); return; }