1d96309c9Sopenharmony_ci/*
2d96309c9Sopenharmony_ci * Copyright (c) 2020 Huawei Device Co., Ltd.
3d96309c9Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4d96309c9Sopenharmony_ci * you may not use this file except in compliance with the License.
5d96309c9Sopenharmony_ci * You may obtain a copy of the License at
6d96309c9Sopenharmony_ci *
7d96309c9Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8d96309c9Sopenharmony_ci *
9d96309c9Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10d96309c9Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11d96309c9Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12d96309c9Sopenharmony_ci * See the License for the specific language governing permissions and
13d96309c9Sopenharmony_ci * limitations under the License.
14d96309c9Sopenharmony_ci */
15d96309c9Sopenharmony_ci
16d96309c9Sopenharmony_ci#ifndef HOS_LITE_HIVIEW_OUTPUT_LOG_H
17d96309c9Sopenharmony_ci#define HOS_LITE_HIVIEW_OUTPUT_LOG_H
18d96309c9Sopenharmony_ci
19d96309c9Sopenharmony_ci#include "ohos_types.h"
20d96309c9Sopenharmony_ci#include "log.h"
21d96309c9Sopenharmony_ci
22d96309c9Sopenharmony_ci#ifdef __cplusplus
23d96309c9Sopenharmony_ci#if __cplusplus
24d96309c9Sopenharmony_ciextern "C" {
25d96309c9Sopenharmony_ci#endif
26d96309c9Sopenharmony_ci#endif /* End of #ifdef __cplusplus */
27d96309c9Sopenharmony_ci
28d96309c9Sopenharmony_civoid InitCoreLogOutput(void);
29d96309c9Sopenharmony_civoid InitLogOutput(void);
30d96309c9Sopenharmony_civoid ClearLogOutput(void);
31d96309c9Sopenharmony_ci
32d96309c9Sopenharmony_ci/**
33d96309c9Sopenharmony_ci * Output the log to file.
34d96309c9Sopenharmony_ci * @param data HiLogContent pointer.
35d96309c9Sopenharmony_ci * @param len log data length.
36d96309c9Sopenharmony_ci **/
37d96309c9Sopenharmony_civoid OutputLog(const uint8 *data, uint32 len);
38d96309c9Sopenharmony_ci
39d96309c9Sopenharmony_ci/**
40d96309c9Sopenharmony_ci * Get the log file size.
41d96309c9Sopenharmony_ci * @retval File size.
42d96309c9Sopenharmony_ci **/
43d96309c9Sopenharmony_ciuint32 GetLogFileSize(void);
44d96309c9Sopenharmony_ci
45d96309c9Sopenharmony_ci/**
46d96309c9Sopenharmony_ci * Read the log data form the log file.
47d96309c9Sopenharmony_ci * @param buf Read buffer.
48d96309c9Sopenharmony_ci * @param len Read buffer size.
49d96309c9Sopenharmony_ci * @retval The length of read data.
50d96309c9Sopenharmony_ci **/
51d96309c9Sopenharmony_ciuint32 ReadLogFile(uint8 *buf, uint32 len);
52d96309c9Sopenharmony_ci
53d96309c9Sopenharmony_ci/**
54d96309c9Sopenharmony_ci * Formatting log content.
55d96309c9Sopenharmony_ci * @param outStr Output string buffer.
56d96309c9Sopenharmony_ci * @param outStrLen Maximum length of the string buffer.
57d96309c9Sopenharmony_ci * @param pLogContent Pointer to the HiLogContent object.
58d96309c9Sopenharmony_ci * @retval The actual length of the formatted string.
59d96309c9Sopenharmony_ci **/
60d96309c9Sopenharmony_ciint32 LogContentFmt(char *outStr, int32 outStrLen, const uint8 *pLogContent);
61d96309c9Sopenharmony_ci
62d96309c9Sopenharmony_ci/*
63d96309c9Sopenharmony_ci * Interface for flush logs before the system restarts.
64d96309c9Sopenharmony_ci * @param syncFlag indicates synchronised flush or asynchronous flush.
65d96309c9Sopenharmony_ci * @attention Use this interface to flush logs to the UART or the files.
66d96309c9Sopenharmony_ci */
67d96309c9Sopenharmony_civoid FlushLog(boolean syncFlag);
68d96309c9Sopenharmony_ci
69d96309c9Sopenharmony_ci/**
70d96309c9Sopenharmony_ci * Interface for register the Hilog handle.
71d96309c9Sopenharmony_ci * @param func Function Pointer.
72d96309c9Sopenharmony_ci **/
73d96309c9Sopenharmony_civoid HiviewRegisterHilogProc(HilogProc func);
74d96309c9Sopenharmony_ci
75d96309c9Sopenharmony_ci/**
76d96309c9Sopenharmony_ci * Interface for deregister the Hilog handle.
77d96309c9Sopenharmony_ci **/
78d96309c9Sopenharmony_civoid HiviewUnRegisterHilogProc(HilogProc func);
79d96309c9Sopenharmony_ci
80d96309c9Sopenharmony_ci/**
81d96309c9Sopenharmony_ci * Interface for get the Hilog Output to UART or file.
82d96309c9Sopenharmony_ci * @retval The the hilog output option.
83d96309c9Sopenharmony_ci **/
84d96309c9Sopenharmony_ciuint32 HiviewGetConfigOption(void);
85d96309c9Sopenharmony_ci
86d96309c9Sopenharmony_ci/**
87d96309c9Sopenharmony_ci * Add a monitoring function when hilog file is full .
88d96309c9Sopenharmony_ci *
89d96309c9Sopenharmony_ci * @param func callback function.
90d96309c9Sopenharmony_ci * @param dest hilog output target file path.
91d96309c9Sopenharmony_ci **/
92d96309c9Sopenharmony_civoid HiviewRegisterHiLogFileWatcher(FileProc func, const char *dest);
93d96309c9Sopenharmony_ci
94d96309c9Sopenharmony_ci/**
95d96309c9Sopenharmony_ci * Remove monitoring of hilog file.
96d96309c9Sopenharmony_ci *
97d96309c9Sopenharmony_ci * @param func callback function.
98d96309c9Sopenharmony_ci **/
99d96309c9Sopenharmony_civoid HiviewUnRegisterHiLogFileWatcher(FileProc func);
100d96309c9Sopenharmony_ci
101d96309c9Sopenharmony_ci/**
102d96309c9Sopenharmony_ci * Process files according to mode.
103d96309c9Sopenharmony_ci *
104d96309c9Sopenharmony_ci * @param dest hilog output target file path.
105d96309c9Sopenharmony_ci * @param mode file processing mode. 0 for copy hilog file to dest and keep the
106d96309c9Sopenharmony_ci *             content in the source file, 1 for rename hilog file to dest.
107d96309c9Sopenharmony_ci * @return 0 if success, otherwise -1.
108d96309c9Sopenharmony_ci **/
109d96309c9Sopenharmony_ciint HiLogFileProcImp(const char *dest, uint8 mode);
110d96309c9Sopenharmony_ci
111d96309c9Sopenharmony_ci/**
112d96309c9Sopenharmony_ci * Lock the hilog output target file.
113d96309c9Sopenharmony_ci *
114d96309c9Sopenharmony_ci **/
115d96309c9Sopenharmony_civoid HiLogOutputFileLockImp(void);
116d96309c9Sopenharmony_ci
117d96309c9Sopenharmony_ci/**
118d96309c9Sopenharmony_ci * Unlock the hilog output target file.
119d96309c9Sopenharmony_ci *
120d96309c9Sopenharmony_ci **/
121d96309c9Sopenharmony_civoid HiLogOutputFileUnLockImp(void);
122d96309c9Sopenharmony_ci
123d96309c9Sopenharmony_ci#ifdef __cplusplus
124d96309c9Sopenharmony_ci#if __cplusplus
125d96309c9Sopenharmony_ci}
126d96309c9Sopenharmony_ci#endif
127d96309c9Sopenharmony_ci#endif /* End of #ifdef __cplusplus */
128d96309c9Sopenharmony_ci
129d96309c9Sopenharmony_ci#endif /* End of #ifndef HOS_LITE_HIVIEW_OUTPUT_LOG_H */
130