From adba71e1a670bfaf0688b5ad185e25943cc81832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BD=98=E5=8C=96=E4=BA=91?= Date: Mon, 19 Apr 2021 19:48:16 +0800 Subject: [PATCH] The interface for flush event data is added to the hilog. --- frameworks/mini/hiview_log.c | 5 +++++ frameworks/mini/hiview_output_log.c | 19 +++++++++++++++++++ frameworks/mini/hiview_output_log.h | 6 ++++++ .../native/kits/hilog_lite/hiview_log.h | 6 ++++++ 4 files changed, 36 insertions(+) diff --git a/frameworks/mini/hiview_log.c b/frameworks/mini/hiview_log.c index 5bae2c9..9b59a5d 100755 --- a/frameworks/mini/hiview_log.c +++ b/frameworks/mini/hiview_log.c @@ -135,3 +135,8 @@ void HiLogPrintf(uint8 module, uint8 level, const char *nums, const char *fmt, . OutputLog((uint8 *)&logContent, sizeof(HiLogCommon) + sizeof(uint32) * argsNum); } + +void HiLogFlush(void) +{ + FlushLog(); +} \ No newline at end of file diff --git a/frameworks/mini/hiview_output_log.c b/frameworks/mini/hiview_output_log.c index cafb1d9..ec7dfe5 100755 --- a/frameworks/mini/hiview_output_log.c +++ b/frameworks/mini/hiview_output_log.c @@ -397,3 +397,22 @@ static int32 LogDebugValuesFmt(char *desStrPtr, int32 desLen, const HiLogContent } return ret; } + +void FlushLog(void) +{ + if (g_logCache.usedSize > 0) { + switch (g_hiviewConfig.outputOption) { + case OUTPUT_OPTION_TEXT_FILE: + HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_LOG_TEXT_FILE, 0); + break; + case OUTPUT_OPTION_BIN_FILE: + HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_LOG_BIN_FILE, 0); + break; + case OUTPUT_OPTION_FLOW: + HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_LOG_FLOW, 0); + break; + default: + break; + } + } +} \ No newline at end of file diff --git a/frameworks/mini/hiview_output_log.h b/frameworks/mini/hiview_output_log.h index 6812f78..b5d4cf4 100755 --- a/frameworks/mini/hiview_output_log.h +++ b/frameworks/mini/hiview_output_log.h @@ -58,6 +58,12 @@ uint32 ReadLogFile(uint8 *buf, uint32 len); **/ int32 LogContentFmt(char *outStr, int32 outStrLen, const uint8 *pLogContent); +/* + * Interface for flush logs before the system restarts. + * @attention Use this interface to flush logs to the UART or the files. + */ +void FlushLog(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/interfaces/native/kits/hilog_lite/hiview_log.h b/interfaces/native/kits/hilog_lite/hiview_log.h index 3700cfb..e5148b5 100755 --- a/interfaces/native/kits/hilog_lite/hiview_log.h +++ b/interfaces/native/kits/hilog_lite/hiview_log.h @@ -155,6 +155,12 @@ const char *HiLogGetModuleName(uint8 id); void HiLogPrintf(uint8 module, uint8 level, const char *nums, const char *fmt, ...) __attribute__((format(printf, 4, 5))); +/* + * Interface for flush logs before the system restarts. + * @attention Use this interface to flush logs to the UART or the files. + */ +void HiLogFlush(void); + /** * @brief Defines the pre-compiled macro for log levels. * -- Gitee