1 /*
2  * Copyright (c) 2023 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 "comm_log.h"
17 #include "trans_event.h"
18 
19 #include "softbus_event.h"
20 
TransEventInner(int32_t scene,int32_t stage,const char * func,int32_t line,TransEventExtra * extra)21 void TransEventInner(int32_t scene, int32_t stage, const char *func, int32_t line, TransEventExtra *extra)
22 {
23     if (func == NULL ||extra == NULL) {
24         COMM_LOGE(COMM_DFX, "func or extra is NUll");
25         return;
26     }
27     SoftbusEventForm form = {
28         .eventName = TRANS_EVENT_NAME,
29         .scene = scene,
30         .stage = stage,
31         .func = func,
32         .line = line,
33         .transExtra = extra,
34     };
35     SoftbusEventInner(EVENT_MODULE_TRANS, &form);
36 }
37 
TransAlarmInner(int32_t scene,int32_t type,const char * func,int32_t line,TransAlarmExtra * extra)38 void TransAlarmInner(int32_t scene, int32_t type, const char *func, int32_t line, TransAlarmExtra *extra)
39 {
40     SoftbusEventForm form = {
41         .eventName = (type == MANAGE_ALARM_TYPE) ? MANAGE_ALARM_EVENT_NAME : CONTROL_ALARM_EVENT_NAME,
42         .scene = scene,
43         .stage = SOFTBUS_DEFAULT_STAGE,
44         .func = func,
45         .line = line,
46         .transAlarmExtra = extra,
47     };
48     SoftbusEventInner(EVENT_MODULE_TRANS_ALARM, &form);
49 }
50 
TransAuditInner(int32_t scene,const char * func,int32_t line,TransAuditExtra * extra)51 void TransAuditInner(int32_t scene, const char *func, int32_t line, TransAuditExtra *extra)
52 {
53     if (func == NULL || extra == NULL) {
54         COMM_LOGE(COMM_DFX, "func or extra is NUll");
55         return;
56     }
57     SoftbusEventForm form = {
58         .eventName = TRANS_AUDIT_NAME,
59         .scene = scene,
60         .stage = SOFTBUS_DEFAULT_STAGE,
61         .func = func,
62         .line = line,
63         .transAuditExtra = extra,
64     };
65     SoftbusAuditInner(EVENT_MODULE_TRANS, &form);
66 }