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_EVENT_H 17 #define HOS_LITE_HIVIEW_OUTPUT_EVENT_H 18 19 #include "ohos_types.h" 20 #include "event.h" 21 22 23 #ifdef __cplusplus 24 #if __cplusplus 25 extern "C" { 26 #endif 27 #endif /* End of #ifdef __cplusplus */ 28 29 void InitCoreEventOutput(void); 30 void InitEventOutput(void); 31 void ClearEventOutput(void); 32 33 /** 34 * Output the event to file. 35 * @param data HiEvent data. 36 **/ 37 void OutputEvent(const uint8 *data); 38 39 /** 40 * Get the event file size. 41 * @param eventType Event type: HIEVENT_FAULT/HIEVENT_UE/HIEVENT_STAT 42 * @retval File size. 43 **/ 44 uint32 GetEventFileSize(uint8 eventType); 45 46 /** 47 * Read the event data form the event file. 48 * @param eventType Event type: HIEVENT_FAULT/HIEVENT_UE/HIEVENT_STAT 49 * @param buf Read buffer. 50 * @param len Read buffer size. 51 * @retval The length of read data. 52 **/ 53 uint32 ReadEventFile(uint8 eventType, uint8 *buf, uint32 len); 54 55 /** 56 * Formatting event content. 57 * @param outStr Output string buffer. 58 * @param outStrLen Maximum length of the string buffer. 59 * @param pEvent Pointer to the HiEvent object. 60 * @retval The actual length of the formatted string. 61 **/ 62 int32 EventContentFmt(char *outStr, int32 outStrLen, const uint8 *pEvent); 63 64 /* 65 * Interface for flush event before the system restarts. 66 * @param syncFlag indicates synchronised flush or asynchronous flush. 67 * @attention Use this interface to flush event to the UART or the files. 68 */ 69 void FlushEvent(boolean syncFlag); 70 71 /** 72 * Interface for register the Hievent handle. 73 * @param func Function Pointer. 74 **/ 75 void HiviewRegisterHieventProc(HieventProc func); 76 77 /** 78 * Interface for deregister the Hievent handle. 79 **/ 80 void HiviewUnRegisterHieventProc(HieventProc func); 81 82 /** 83 * Process files according to mode. 84 * @param type hievent type. 85 * @param dest hievent output target file path. 86 * @param mode file processing mode. 0 for copy specified type hievent file to dest and keep the 87 * content in the source file, 1 for rename specified type hievent file to dest. 88 * @return 0 if success, otherwise -1. 89 **/ 90 int HiEventFileProcImp(uint8 type, const char *dest, uint8 mode); 91 92 /** 93 * Add a monitoring function when the specified type of file is full . 94 * @param type hievent type. 95 * @param func callback function. 96 * @param dest hievent output target file path. 97 **/ 98 void HiviewRegisterHieventFileWatcher(uint8 type, FileProc func, const char *dest); 99 100 /** 101 * Remove monitoring of specified types of files. 102 * @param type hievent type. 103 * @param func callback function. 104 **/ 105 void HiviewUnRegisterHieventFileWatcher(uint8 type, FileProc func); 106 107 /** 108 * Lock the hievent output target file. 109 * 110 **/ 111 void HiEventOutputFileLockImp(void); 112 113 /** 114 * Unlock the hievent output target file. 115 * 116 **/ 117 void HiEventOutputFileUnLockImp(void); 118 119 #ifdef __cplusplus 120 #if __cplusplus 121 } 122 #endif 123 #endif /* End of #ifdef __cplusplus */ 124 125 #endif /* End of #ifndef HOS_LITE_HIVIEW_OUTPUT_EVENT_H */ 126