diff --git a/frameworks/libhilog/utils/log_print.cpp b/frameworks/libhilog/utils/log_print.cpp index 3c7be480deeba6a28a2723c15fbb6939a9a5e62a..37b3cb6266f97da92d1f2456b1dfe11d09a3fdfa 100644 --- a/frameworks/libhilog/utils/log_print.cpp +++ b/frameworks/libhilog/utils/log_print.cpp @@ -162,7 +162,8 @@ void LogPrintWithFormat(const LogContent& content, const LogFormat& format, std: const char *pHead = content.log; const char *pScan = content.log; - if (*pScan != '\0') { + // not print prefix if log is empty string or start with \n + if (*pScan != '\0' && *pScan != '\n') { PrintLogPrefix(content, format, out); } // split the log content by '\n', and add log prefix(datetime, pid, tid....) to each new line