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