• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "hisysevent_adapter.h"
16 #include "hisysevent.h"
17 #include "hilog_wrapper.h"
18 
19 namespace OHOS {
20 namespace Global {
21 namespace Resource {
22 using HiSysEventNameSpace = OHOS::HiviewDFX::HiSysEvent;
23 
ReportInitResourceManagerFail(const std::string & bundleName,const std::string & errMsg)24 void ReportInitResourceManagerFail(const std::string& bundleName, const std::string& errMsg)
25 {
26     int ret = HiSysEventWrite(HiSysEventNameSpace::Domain::GLOBAL_RESMGR, "INIT_RESMGR_FAILED",
27         HiSysEventNameSpace::EventType::FAULT,
28         "BUNDLENAME", bundleName,
29         "ERROR_MSG", errMsg);
30     if (ret != 0) {
31         HILOG_ERROR("hisysevent write failed! ret %{public}d, bundleName %{public}s, errMsg %{public}s",
32             ret, bundleName.c_str(), errMsg.c_str());
33     }
34 }
35 
ReportGetResourceByIdFail(int32_t resId,const std::string & result,const std::string & errMsg)36 void ReportGetResourceByIdFail(int32_t resId, const std::string& result, const std::string& errMsg)
37 {
38     int ret = HiSysEventWrite(HiSysEventNameSpace::Domain::GLOBAL_RESMGR, "GET_RES_BY_ID_FAILED",
39         HiSysEventNameSpace::EventType::BEHAVIOR,
40         "ID", resId,
41         "RESULT", result,
42         "ERROR_MSG", errMsg);
43     if (ret != 0) {
44         HILOG_ERROR("hisysevent write failed! ret %{public}d, resId %{public}d, result %{public}s, errMsg %{public}s.",
45             ret, resId, result.c_str(), errMsg.c_str());
46     }
47 }
48 
ReportGetResourceByNameFail(const std::string & resName,const std::string & result,const std::string & errMsg)49 void ReportGetResourceByNameFail(const std::string& resName, const std::string& result, const std::string& errMsg)
50 {
51     int ret = HiSysEventWrite(HiSysEventNameSpace::Domain::GLOBAL_RESMGR, "GET_RES_BY_NAME_FAILED",
52         HiSysEventNameSpace::EventType::BEHAVIOR,
53         "NAME", resName,
54         "RESULT", result,
55         "ERROR_MSG", errMsg);
56     if (ret != 0) {
57         HILOG_ERROR("hisysevent write failed! ret %{public}d, resName %{public}s, result %{public}s, errMsg %{public}s",
58             ret, resName.c_str(), result.c_str(), errMsg.c_str());
59     }
60 }
61 
ReportAddResourcePathFail(const char * resourcePath,const std::string & errMsg)62 void ReportAddResourcePathFail(const char* resourcePath, const std::string& errMsg)
63 {
64     int ret = HiSysEventWrite(HiSysEventNameSpace::Domain::GLOBAL_RESMGR, "ADD_RES_PATH_FAILED",
65         HiSysEventNameSpace::EventType::BEHAVIOR,
66         "PATH", resourcePath,
67         "ERROR_MSG", errMsg);
68     if (ret != 0) {
69         HILOG_ERROR("hisysevent write failed! ret %{public}d, resourcePath %{public}s, errMsg %{public}s.",
70             ret, resourcePath, errMsg.c_str());
71     }
72 }
73 } // Resource
74 } // Global
75 } // OHOS