• 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 #include "hiview_output_event.h"
17 #include "securec.h"
18 #include "ohos_types.h"
19 #include "hiview_def.h"
20 #include "hiview_util.h"
21 #include "hiview_event.h"
22 #include "hiview_cache.h"
23 #include "hiview_config.h"
24 #include "hiview_log.h"
25 #include "hiview_file.h"
26 #include "hiview_service.h"
27 
28 #define EVENT_PAYLOAD_MAX_SIZE   (5 * 16)
29 
30 #ifdef SYNC_FILE
31 #undef SYNC_FILE
32 #endif
33 #define SYNC_FILE (1 << 6)
34 
35 static HiviewCache g_faultEventCache = {
36     .size = 0,
37     .buffer = NULL,
38 };
39 static HiviewCache g_ueEventCache = {
40     .size = 0,
41     .buffer = NULL,
42 };
43 static HiviewCache g_statEventCache = {
44     .size = 0,
45     .buffer = NULL,
46 };
47 static HiviewFile g_faultEventFile = {
48     .path = HIVIEW_FILE_PATH_FAULT_EVENT,
49     .outPath = HIVIEW_FILE_OUT_PATH_FAULT_EVENT,
50     .pFunc = NULL,
51     .mutex = NULL,
52     .fhandle = -1,
53     .configSize = 0,
54 };
55 static HiviewFile g_ueEventFile = {
56     .path = HIVIEW_FILE_PATH_UE_EVENT,
57     .outPath = HIVIEW_FILE_OUT_PATH_UE_EVENT,
58     .pFunc = NULL,
59     .mutex = NULL,
60     .fhandle = -1,
61     .configSize = 0,
62 };
63 static HiviewFile g_statEventFile = {
64     .path = HIVIEW_FILE_PATH_STAT_EVENT,
65     .outPath = HIVIEW_FILE_OUT_PATH_STAT_EVENT,
66     .pFunc = NULL,
67     .mutex = NULL,
68     .fhandle = -1,
69     .configSize = 0,
70 };
71 
72 typedef struct EventFlushInfo EventFlushInfo;
73 struct EventFlushInfo {
74     HiviewMutexId_t mutex;
75 };
76 static EventFlushInfo g_eventFlushInfo;
77 static HieventProc g_hieventOutputProc = NULL;
78 
79 typedef struct OutputEventInfo OutputEventInfo;
80 struct OutputEventInfo {
81     HiviewMutexId_t mutex;
82 };
83 static OutputEventInfo g_outputEventInfo;
84 
85 static int32 g_retryFaultInitCount = 0;
86 static int32 g_retryUeInitCount = 0;
87 static int32 g_retryStatInitCount = 0;
88 #define MAX_RETRY_COUNT 100
89 
90 /* Output the event to UART using plaintext. */
91 static void OutputEventRealtime(const Request *req);
92 /* Output the event to FLASH using binary. */
93 static void OutputEvent2Flash(const Request *req);
94 static void InitFaultEventOutput(void);
95 static void InitUeEventOutput(void);
96 static void InitStatEventOutput(void);
97 static void Output2Flash(uint8 eventType);
98 static void CloseEventOutputFile(uint8 type);
99 static void GetEventCache(uint8 type, HiviewCache **c, HiviewFile **f);
100 
InitCoreEventOutput(void)101 void InitCoreEventOutput(void)
102 {
103     g_eventFlushInfo.mutex = HIVIEW_MutexInit();
104     g_outputEventInfo.mutex = HIVIEW_MutexInit();
105     HiviewRegisterMsgHandle(HIVIEW_MSG_OUTPUT_EVENT_BIN_FILE, OutputEvent2Flash);
106     HiviewRegisterMsgHandle(HIVIEW_MSG_OUTPUT_EVENT_FLOW, OutputEventRealtime);
107 }
108 
InitEventOutput(void)109 void InitEventOutput(void)
110 {
111     InitFaultEventOutput();
112     InitUeEventOutput();
113     InitStatEventOutput();
114 }
115 
ClearEventOutput(void)116 void ClearEventOutput(void)
117 {
118     int8 opt = GETOPTION(g_hiviewConfig.outputOption);
119     if (opt == OUTPUT_OPTION_BIN_FILE || opt == OUTPUT_OPTION_TEXT_FILE) {
120         CloseEventOutputFile(FAULT_EVENT_CACHE);
121         CloseEventOutputFile(UE_EVENT_CACHE);
122         CloseEventOutputFile(STAT_EVENT_CACHE);
123     }
124 }
125 
InitFaultEventOutput(void)126 static void InitFaultEventOutput(void)
127 {
128     int8 opt = GETOPTION(g_hiviewConfig.outputOption);
129     if (InitHiviewCache(&g_faultEventCache, FAULT_EVENT_CACHE, EVENT_CACHE_SIZE) == FALSE) {
130         printf("malloc[%d] fail.", FAULT_EVENT_CACHE);
131     }
132     if (opt == OUTPUT_OPTION_DEBUG || opt == OUTPUT_OPTION_FLOW) {
133         return;
134     }
135     if (InitHiviewFile(&g_faultEventFile, HIVIEW_FAULT_EVENT_FILE, FAULT_EVENT_FILE_SIZE) == FALSE) {
136         printf("Open file[%d] failed.", HIVIEW_FAULT_EVENT_FILE);
137     }
138     g_faultEventFile.mutex = g_outputEventInfo.mutex;
139 }
140 
InitUeEventOutput(void)141 static void InitUeEventOutput(void)
142 {
143     if (InitHiviewCache(&g_ueEventCache, UE_EVENT_CACHE, EVENT_CACHE_SIZE) == FALSE) {
144         printf("malloc[%d] fail.", UE_EVENT_CACHE);
145     }
146     int8 opt = GETOPTION(g_hiviewConfig.outputOption);
147     if (opt == OUTPUT_OPTION_DEBUG || opt == OUTPUT_OPTION_FLOW) {
148         return;
149     }
150     if (InitHiviewFile(&g_ueEventFile, HIVIEW_UE_EVENT_FILE, UE_EVENT_FILE_SIZE) == FALSE) {
151         printf("Open file[%d] failed.", HIVIEW_UE_EVENT_FILE);
152     }
153     g_ueEventFile.mutex = g_outputEventInfo.mutex;
154 }
155 
InitStatEventOutput(void)156 static void InitStatEventOutput(void)
157 {
158     if (InitHiviewCache(&g_statEventCache, STAT_EVENT_CACHE, EVENT_CACHE_SIZE) == FALSE) {
159         printf("malloc[%d] fail.", STAT_EVENT_CACHE);
160     }
161     int8 opt = GETOPTION(g_hiviewConfig.outputOption);
162     if (opt == OUTPUT_OPTION_DEBUG || opt == OUTPUT_OPTION_FLOW) {
163         return;
164     }
165     if (InitHiviewFile(&g_statEventFile, HIVIEW_STAT_EVENT_FILE, STAT_EVENT_FILE_SIZE) == FALSE) {
166         printf("Open file[%d] failed.", HIVIEW_STAT_EVENT_FILE);
167     }
168     g_statEventFile.mutex = g_outputEventInfo.mutex;
169 }
170 
CloseEventOutputFile(uint8 type)171 static void CloseEventOutputFile(uint8 type)
172 {
173     HiviewCache *c = NULL;
174     HiviewFile *f = NULL;
175     GetEventCache(type, &c, &f);
176     if (c != NULL && c->usedSize > 0) {
177         Output2Flash(type);
178     }
179     CloseHiviewFile(f);
180 }
181 
ReInitHiEventFile(uint8 eventType)182 static void ReInitHiEventFile(uint8 eventType)
183 {
184     if (eventType & HIEVENT_FAULT) {
185         if (g_retryFaultInitCount > MAX_RETRY_COUNT) {
186             return;
187         }
188         if (InitHiviewFile(&g_faultEventFile, HIVIEW_FAULT_EVENT_FILE, FAULT_EVENT_FILE_SIZE) == FALSE) {
189             HILOG_ERROR(HILOG_MODULE_HIVIEW, "Open file[%d] failed.", HIVIEW_FAULT_EVENT_FILE);
190             g_retryFaultInitCount++;
191         } else {
192             // once success, clean retry count
193             g_retryFaultInitCount = 0;
194         }
195     } else if (eventType & HIEVENT_UE) {
196         if (g_retryUeInitCount > MAX_RETRY_COUNT) {
197             return;
198         }
199         if (InitHiviewFile(&g_ueEventFile, HIVIEW_UE_EVENT_FILE, UE_EVENT_FILE_SIZE) == FALSE) {
200             HILOG_ERROR(HILOG_MODULE_HIVIEW, "Open file[%d] failed.", HIVIEW_UE_EVENT_FILE);
201             g_retryUeInitCount++;
202         } else {
203             // once success, clean retry count
204             g_retryUeInitCount = 0;
205         }
206     } else if (eventType & HIEVENT_STAT) {
207         if (g_retryStatInitCount > MAX_RETRY_COUNT) {
208             return;
209         }
210         if (InitHiviewFile(&g_statEventFile, HIVIEW_STAT_EVENT_FILE, STAT_EVENT_FILE_SIZE) == FALSE) {
211             HILOG_ERROR(HILOG_MODULE_HIVIEW, "Open file[%d] failed.", HIVIEW_STAT_EVENT_FILE);
212             g_retryStatInitCount++;
213         } else {
214             // once success, clean retry count
215             g_retryStatInitCount = 0;
216         }
217     }
218 }
219 
OutputEvent(const uint8 * data)220 void OutputEvent(const uint8 *data)
221 {
222     if (data == NULL) {
223         return;
224     }
225 
226     if (g_hieventOutputProc != NULL && g_hieventOutputProc((HiEvent *)data) == TRUE) {
227         return;
228     }
229 
230     HiEvent *event = (HiEvent *)data;
231     HiviewCache *c = NULL;
232     HiviewFile *f = NULL;
233     GetEventCache(event->type, &c, &f);
234     if (c == NULL) {
235         return;
236     }
237 #if LITTLE_ENDIAN_SYSTEM
238     event->common.eventId = Change16Endian(event->common.eventId);
239     event->common.time = Change32Endian(event->common.time);
240 #endif
241     boolean reachMaxThreshold  = FALSE;
242     /* If the cache reach the max size, output and do not write cache. */
243     if ((c->usedSize + sizeof(HiEventCommon) + event->common.len) > EVENT_CACHE_SIZE) {
244         HIVIEW_UartPrint("HiEvent have no sufficient space to write event info to cache!\n");
245         reachMaxThreshold = TRUE;
246     } else if (WriteToCache(c, (uint8 *)&(event->common), sizeof(HiEventCommon)) == sizeof(HiEventCommon)) {
247         WriteToCache(c, event->payload, event->common.len);
248     }
249 
250     int8 opt = GETOPTION(g_hiviewConfig.outputOption);
251     if (c->usedSize >= HIVIEW_HIEVENT_FILE_BUF_SIZE || opt == OUTPUT_OPTION_DEBUG) {
252         switch (opt) {
253             /* Event do not support the text format */
254             case OUTPUT_OPTION_TEXT_FILE:
255             case OUTPUT_OPTION_BIN_FILE:
256                 HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_EVENT_BIN_FILE, event->type);
257                 break;
258             case OUTPUT_OPTION_FLOW:
259             case OUTPUT_OPTION_DEBUG:
260                 HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_EVENT_FLOW, event->type);
261                 break;
262             default:
263                 break;
264         }
265     }
266 
267     /* The cache reach the max size, output and then write cache. */
268     if (reachMaxThreshold) {
269         if ((c->usedSize + sizeof(HiEventCommon) + event->common.len) > EVENT_CACHE_SIZE) {
270             if (WriteToCache(c, (uint8 *)&(event->common), sizeof(HiEventCommon)) == sizeof(HiEventCommon)) {
271                 WriteToCache(c, event->payload, event->common.len);
272             }
273         } else {
274             printf("HiEvent have no sufficient space to write, drop event id %d\n", event->common.eventId);
275         }
276     }
277 }
278 
OutputEventRealtime(const Request * req)279 static void OutputEventRealtime(const Request *req)
280 {
281     HIVIEW_MutexLock(g_eventFlushInfo.mutex);
282     HiviewCache *c = NULL;
283     HiviewFile *f = NULL;
284     uint16 payloadLen;
285     HiEvent event;
286     uint8 payload[EVENT_PAYLOAD_MAX_SIZE];
287     char tmpBuffer[LOG_FMT_MAX_LEN] = {0};
288 
289     event.type = (uint8)req->msgValue;
290     GetEventCache(event.type, &c, &f);
291     while (ReadFromCache(c, (uint8 *)&(event.common), sizeof(HiEventCommon)) == sizeof(HiEventCommon)) {
292         if (event.common.mark != EVENT_INFO_HEAD) {
293             DiscardCacheData(c);
294             printf("Discard cache[%d] data.", c->type);
295             break;
296         }
297 #if LITTLE_ENDIAN_SYSTEM
298         event.common.eventId = Change16Endian(event.common.eventId);
299         event.common.time = Change32Endian(event.common.time);
300 #endif
301         payloadLen = event.common.len;
302         if (payloadLen > sizeof(payload)) {
303             payloadLen = sizeof(payload);
304         }
305         if (payloadLen > 0 && ReadFromCache(c, payload, payloadLen) != payloadLen) {
306             break;
307         }
308         event.payload = (payloadLen > 0) ? payload : NULL;
309         EventContentFmt(tmpBuffer, LOG_FMT_MAX_LEN, (uint8 *)&event);
310         HIVIEW_UartPrint(tmpBuffer);
311     }
312     HIVIEW_MutexUnlock(g_eventFlushInfo.mutex);
313 }
314 
OutputEvent2Flash(const Request * req)315 static void OutputEvent2Flash(const Request *req)
316 {
317     Output2Flash((uint8)req->msgValue);
318 }
319 
Output2Flash(uint8 eventType)320 static void Output2Flash(uint8 eventType)
321 {
322     HIVIEW_MutexLock(g_eventFlushInfo.mutex);
323     HiviewCache *c = NULL;
324     HiviewFile *f = NULL;
325     uint8 *tmpBuffer = NULL;
326     HiEventCommon *pEventCommon = NULL;
327     uint16 len = 0, payloadLen, outputSize;
328 
329     GetEventCache((uint8)eventType, &c, &f);
330     if (c == NULL) {
331         HIVIEW_MutexUnlock(g_eventFlushInfo.mutex);
332         return;
333     }
334     outputSize = c->usedSize;
335     if (outputSize < sizeof(HiEventCommon)) {
336         HIVIEW_MutexUnlock(g_eventFlushInfo.mutex);
337         return;
338     }
339     tmpBuffer = (uint8 *)HIVIEW_MemAlloc(MEM_POOL_HIVIEW_ID, outputSize);
340     if (tmpBuffer == NULL) {
341         HIVIEW_MutexUnlock(g_eventFlushInfo.mutex);
342         return;
343     }
344     while (c->usedSize >= sizeof(HiEventCommon) && outputSize >= (len + sizeof(HiEventCommon))) {
345         if (ReadFromCache(c, tmpBuffer + len, sizeof(HiEventCommon)) != sizeof(HiEventCommon)) {
346             continue;
347         }
348         pEventCommon = (HiEventCommon *)(tmpBuffer + len);
349         len += sizeof(HiEventCommon);
350         if (pEventCommon->mark != EVENT_INFO_HEAD) {
351             DiscardCacheData(c);
352             printf("Discard cache[%d] data.", c->type);
353             break;
354         }
355         payloadLen = pEventCommon->len;
356         if (payloadLen > 0) {
357             if (ReadFromCache(c, tmpBuffer + len, payloadLen) != payloadLen) {
358                 continue;
359             }
360             len += payloadLen;
361         }
362     }
363     if (f->fhandle < 0) {
364         ReInitHiEventFile(eventType);
365     }
366     if (len > 0 && WriteToFile(f, tmpBuffer, len) != len) {
367         g_hiviewConfig.writeFailureCount++;
368         HIVIEW_UartPrint("Failed to write event data.");
369     }
370     HIVIEW_MemFree(MEM_POOL_HIVIEW_ID, tmpBuffer);
371     HIVIEW_MutexUnlock(g_eventFlushInfo.mutex);
372     if ((eventType & SYNC_FILE) != 0) {
373         HIVIEW_FileSync(f->fhandle);
374     }
375 }
376 
GetEventFileSize(uint8 eventType)377 uint32 GetEventFileSize(uint8 eventType)
378 {
379     HiviewCache *c = NULL;
380     HiviewFile *f = NULL;
381 
382     GetEventCache(eventType, &c, &f);
383     return GetFileUsedSize(f);
384 }
385 
ReadEventFile(uint8 eventType,uint8 * buf,uint32 len)386 uint32 ReadEventFile(uint8 eventType, uint8 *buf, uint32 len)
387 {
388     HiviewCache *c = NULL;
389     HiviewFile *f = NULL;
390     uint32 usedSize;
391 
392     if (buf == NULL) {
393         return 0;
394     }
395     GetEventCache(eventType, &c, &f);
396     usedSize = GetFileUsedSize(f);
397     if (usedSize < len) {
398         len = usedSize;
399     }
400     if (ReadFromFile(f, buf, len) != (int32)len) {
401         return 0;
402     }
403 
404     return len;
405 }
406 
EventContentFmt(char * outStr,int32 outStrLen,const uint8 * pEvent)407 int32 EventContentFmt(char *outStr, int32 outStrLen, const uint8 *pEvent)
408 {
409     if (outStrLen < TAIL_LINE_BREAK) {
410         return -1;
411     }
412     if (pEvent == NULL) {
413         return -1;
414     }
415     int32 len;
416     uint32 time, hour, mte, sec;
417     HiEvent *event = (HiEvent *)pEvent;
418 
419     time = event->common.time;
420     hour = time % SECONDS_PER_DAY / SECONDS_PER_HOUR;
421     mte = time % SECONDS_PER_HOUR / SECONDS_PER_MINUTE;
422     sec = time % SECONDS_PER_MINUTE;
423     if (event->payload == NULL) {
424         len = snprintf_s(outStr, outStrLen, outStrLen - 1,
425             "EVENT: time=%02d:%02d:%02d id=%d type=%d data=null",
426             hour, mte, sec, event->common.eventId, event->type);
427     } else {
428         len = snprintf_s(outStr, outStrLen, outStrLen - 1,
429             "EVENT: time=%02d:%02d:%02d id=%d type=%d data=%p",
430             hour, mte, sec, event->common.eventId, event->type, event->payload);
431     }
432 
433     if (len < 0) {
434         return -1;
435     }
436 
437     if (len >= outStrLen - 1) {
438         outStr[outStrLen - TAIL_LINE_BREAK] = '\n';
439         outStr[outStrLen - 1] = '\0';
440     } else {
441         outStr[len++] = '\n';
442         outStr[len++] = '\0';
443     }
444 
445     return len;
446 }
447 
GetEventCache(uint8 type,HiviewCache ** c,HiviewFile ** f)448 static void GetEventCache(uint8 type, HiviewCache **c, HiviewFile **f)
449 {
450     if (type & HIEVENT_FAULT) {
451         *c = &g_faultEventCache;
452         *f = &g_faultEventFile;
453     } else if (type & HIEVENT_UE) {
454         *c = &g_ueEventCache;
455         *f = &g_ueEventFile;
456     } else if (type & HIEVENT_STAT) {
457         *c = &g_statEventCache;
458         *f = &g_statEventFile;
459     } else {
460         *c = NULL;
461         *f = NULL;
462     }
463 }
464 
FlushEventAsync(const uint8 type)465 static void FlushEventAsync(const uint8 type)
466 {
467     switch (GETOPTION(g_hiviewConfig.outputOption)) {
468         /* Event do not support the text format */
469         case OUTPUT_OPTION_TEXT_FILE:
470         case OUTPUT_OPTION_BIN_FILE:
471             HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_EVENT_BIN_FILE, type | SYNC_FILE);
472             break;
473         case OUTPUT_OPTION_FLOW:
474             HiviewSendMessage(HIVIEW_SERVICE, HIVIEW_MSG_OUTPUT_EVENT_FLOW, type);
475             break;
476         default:
477             break;
478     }
479 }
480 
FlushEventInfo(const uint8 type,const HiviewCache * c,boolean syncFlag)481 static void FlushEventInfo(const uint8 type, const HiviewCache *c, boolean syncFlag)
482 {
483     if (c == NULL) {
484         return;
485     }
486     Request request = {0};
487     request.msgValue = type;
488     if (c->usedSize > 0) {
489         if (syncFlag == FALSE) {
490             /* If syncFlag is FALSE, refresh event information asynchronously */
491             FlushEventAsync(type);
492         } else {
493             switch (GETOPTION(g_hiviewConfig.outputOption)) {
494                 /* Event do not support the text format */
495                 case OUTPUT_OPTION_TEXT_FILE:
496                 case OUTPUT_OPTION_BIN_FILE:
497                     request.msgValue |= SYNC_FILE;
498                     OutputEvent2Flash(&request);
499                     break;
500                 case OUTPUT_OPTION_FLOW:
501                     OutputEventRealtime(&request);
502                     break;
503                 default:
504                     break;
505             }
506         }
507     }
508 }
509 
FlushFaultEvent(boolean syncFlag)510 static void FlushFaultEvent(boolean syncFlag)
511 {
512     HiviewCache *c = NULL;
513     HiviewFile *f = NULL;
514 
515     GetEventCache(HIEVENT_FAULT, &c, &f);
516     if (c == NULL || f == NULL) {
517         return;
518     }
519     FlushEventInfo(HIEVENT_FAULT, c, syncFlag);
520 }
521 
FlushUeEvent(boolean syncFlag)522 static void FlushUeEvent(boolean syncFlag)
523 {
524     HiviewCache *c = NULL;
525     HiviewFile *f = NULL;
526 
527     GetEventCache(HIEVENT_UE, &c, &f);
528     if (c == NULL || f == NULL) {
529         return;
530     }
531     FlushEventInfo(HIEVENT_UE, c, syncFlag);
532 }
533 
FlushStatEvent(boolean syncFlag)534 static void FlushStatEvent(boolean syncFlag)
535 {
536     HiviewCache *c = NULL;
537     HiviewFile *f = NULL;
538 
539     GetEventCache(HIEVENT_STAT, &c, &f);
540     if (c == NULL || f == NULL) {
541         return;
542     }
543     FlushEventInfo(HIEVENT_STAT, c, syncFlag);
544 }
545 
FlushEvent(boolean syncFlag)546 void FlushEvent(boolean syncFlag)
547 {
548     FlushFaultEvent(syncFlag);
549     FlushUeEvent(syncFlag);
550     FlushStatEvent(syncFlag);
551 }
552 
HiviewRegisterHieventProc(HieventProc func)553 void HiviewRegisterHieventProc(HieventProc func)
554 {
555     g_hieventOutputProc = func;
556 }
557 
HiviewUnRegisterHieventProc(HieventProc func)558 void HiviewUnRegisterHieventProc(HieventProc func)
559 {
560     (void)func;
561     if (g_hieventOutputProc != NULL) {
562         g_hieventOutputProc = NULL;
563     }
564 }
565 
HiEventFileProcImp(uint8 type,const char * dest,uint8 mode)566 int HiEventFileProcImp(uint8 type, const char *dest, uint8 mode)
567 {
568     Output2Flash(type);
569     HIVIEW_MutexLock(g_eventFlushInfo.mutex);
570     HiviewCache* c = NULL;
571     HiviewFile* f = NULL;
572 
573     GetEventCache(type, &c, &f);
574     if (f == NULL || strcmp(f->path, dest) == 0) {
575         HIVIEW_MutexUnlock(g_eventFlushInfo.mutex);
576         return -1;
577     }
578     int ret = ProcFile(f, dest, (FileProcMode)mode);
579     HIVIEW_MutexUnlock(g_eventFlushInfo.mutex);
580     return ret;
581 }
582 
HiviewRegisterHieventFileWatcher(uint8 type,FileProc func,const char * path)583 void HiviewRegisterHieventFileWatcher(uint8 type, FileProc func, const char *path)
584 {
585     if (func == NULL) {
586         return;
587     }
588     HiviewCache* c = NULL;
589     HiviewFile* f = NULL;
590     GetEventCache(type, &c, &f);
591     RegisterFileWatcher(f, func, path);
592 }
593 
HiviewUnRegisterHieventFileWatcher(uint8 type,FileProc func)594 void HiviewUnRegisterHieventFileWatcher(uint8 type, FileProc func)
595 {
596     if (func == NULL) {
597         return;
598     }
599     HiviewCache* c = NULL;
600     HiviewFile* f = NULL;
601     GetEventCache(type, &c, &f);
602     UnRegisterFileWatcher(f, func);
603 }
604 
HiEventOutputFileLockImp(void)605 void HiEventOutputFileLockImp(void)
606 {
607     HIVIEW_MutexLock(g_outputEventInfo.mutex);
608 }
609 
HiEventOutputFileUnLockImp(void)610 void HiEventOutputFileUnLockImp(void)
611 {
612     HIVIEW_MutexUnlock(g_outputEventInfo.mutex);
613 }
614