1 /*
2 * Copyright (c) 2022 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 "hisysevent_c.h"
17
18 #include <string>
19
20 #include "hilog/log.h"
21 #include "hisysevent.h"
22
23 #undef LOG_DOMAIN
24 #define LOG_DOMAIN 0xD002D08
25
26 #undef LOG_TAG
27 #define LOG_TAG "HISYSEVENT_C"
28
29 namespace OHOS {
30 namespace HiviewDFX {
HiSysEventInnerWrite(const char * func,int64_t line,const std::string & domain,const std::string & name,HiSysEventEventType type,const HiSysEventParam params[],size_t size)31 int HiSysEventInnerWrite(const char* func, int64_t line, const std::string& domain, const std::string& name,
32 HiSysEventEventType type, const HiSysEventParam params[], size_t size)
33 {
34 HILOG_DEBUG(LOG_CORE, "domain=%{public}s, name=%{public}s, type=%{public}d, param szie=%{public}zu",
35 domain.c_str(), name.c_str(), type, size);
36 return HiSysEvent::Write(func, line, domain, name, HiSysEvent::EventType(type), params, size);
37 }
38 } // namespace HiviewDFX
39 } // namespace OHOS
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
HiSysEvent_Write(const char * func,int64_t line,const char * domain,const char * name,HiSysEventEventType type,const HiSysEventParam params[],size_t size)45 int HiSysEvent_Write(const char* func, int64_t line, const char* domain, const char* name,
46 HiSysEventEventType type, const HiSysEventParam params[], size_t size)
47 {
48 if (domain == nullptr) {
49 return OHOS::HiviewDFX::ERR_DOMAIN_NAME_INVALID;
50 }
51 if (name == nullptr) {
52 return OHOS::HiviewDFX::ERR_EVENT_NAME_INVALID;
53 }
54 return OHOS::HiviewDFX::HiSysEventInnerWrite(func, line, domain, name, type, params, size);
55 }
56
57 #ifdef __cplusplus
58 }
59 #endif