179a732c7Sopenharmony_ci/* 279a732c7Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 379a732c7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 479a732c7Sopenharmony_ci * you may not use this file except in compliance with the License. 579a732c7Sopenharmony_ci * You may obtain a copy of the License at 679a732c7Sopenharmony_ci * 779a732c7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 879a732c7Sopenharmony_ci * 979a732c7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1079a732c7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1179a732c7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1279a732c7Sopenharmony_ci * See the License for the specific language governing permissions and 1379a732c7Sopenharmony_ci * limitations under the License. 1479a732c7Sopenharmony_ci */ 1579a732c7Sopenharmony_ci 1679a732c7Sopenharmony_ci#include "dm_hisysevent.h" 1779a732c7Sopenharmony_ci 1879a732c7Sopenharmony_ci#include "dm_log.h" // for LOGE 1979a732c7Sopenharmony_ci#include "hisysevent.h" // for HiSysEvent, HiSysEvent::Domain, HiSysEvent... 2079a732c7Sopenharmony_ci#include "unistd.h" // for getpid, getuid 2179a732c7Sopenharmony_ci 2279a732c7Sopenharmony_cinamespace OHOS { 2379a732c7Sopenharmony_cinamespace DistributedHardware { 2479a732c7Sopenharmony_ciconstexpr int32_t DM_OK = 0; 2579a732c7Sopenharmony_civoid SysEventWrite(const std::string &status, int32_t eventType, const std::string &msg) 2679a732c7Sopenharmony_ci{ 2779a732c7Sopenharmony_ci int32_t res = HiSysEventWrite( 2879a732c7Sopenharmony_ci OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, 2979a732c7Sopenharmony_ci status.c_str(), 3079a732c7Sopenharmony_ci (OHOS::HiviewDFX::HiSysEvent::EventType)eventType, 3179a732c7Sopenharmony_ci "PID", getpid(), 3279a732c7Sopenharmony_ci "UID", getuid(), 3379a732c7Sopenharmony_ci "MSG", msg.c_str()); 3479a732c7Sopenharmony_ci if (res != DM_OK) { 3579a732c7Sopenharmony_ci LOGE("%{public}s Write HiSysEvent error, res:%{public}d", status.c_str(), res); 3679a732c7Sopenharmony_ci } 3779a732c7Sopenharmony_ci} 3879a732c7Sopenharmony_ci} // namespace DistributedHardware 3979a732c7Sopenharmony_ci} // namespace OHOS 40