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 "dm_hisysevent.h" 17 18#include "dm_log.h" // for LOGE 19#include "hisysevent.h" // for HiSysEvent, HiSysEvent::Domain, HiSysEvent... 20#include "unistd.h" // for getpid, getuid 21 22namespace OHOS { 23namespace DistributedHardware { 24constexpr int32_t DM_OK = 0; 25void SysEventWrite(const std::string &status, int32_t eventType, const std::string &msg) 26{ 27 int32_t res = HiSysEventWrite( 28 OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_DEVICE_MANAGER, 29 status.c_str(), 30 (OHOS::HiviewDFX::HiSysEvent::EventType)eventType, 31 "PID", getpid(), 32 "UID", getuid(), 33 "MSG", msg.c_str()); 34 if (res != DM_OK) { 35 LOGE("%{public}s Write HiSysEvent error, res:%{public}d", status.c_str(), res); 36 } 37} 38} // namespace DistributedHardware 39} // namespace OHOS 40