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