• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 "dfx_report.h"
17 
18 namespace OHOS {
19 namespace CameraStandard {
20 
ReportCameraCreateNullptr(std::string funcName,std::string useFunc)21 void CameraReportUtils::ReportCameraCreateNullptr(std::string funcName,
22     std::string useFunc)
23 {
24     std::string str = funcName;
25     str += " use ";
26     str += useFunc;
27     str += " get nullptr";
28     HiSysEventWrite(
29         HiviewDFX::HiSysEvent::Domain::CAMERA,
30         "CAMERA_ERR",
31         HiviewDFX::HiSysEvent::EventType::FAULT,
32         "MSG", str);
33 }
34 
ReportCameraFalse(std::string funcName,std::string useFunc)35 void CameraReportUtils::ReportCameraFalse(std::string funcName, std::string useFunc)
36 {
37     std::string str = funcName;
38     str += " use ";
39     str += useFunc;
40     str += "get false";
41     HiSysEventWrite(
42         HiviewDFX::HiSysEvent::Domain::CAMERA,
43         "CAMERA_ERR",
44         HiviewDFX::HiSysEvent::EventType::FAULT,
45         "MSG", str);
46 }
47 
48 template<typename T>
ReportCameraError(std::string funcName,std::string useFunc,T ret)49 void CameraReportUtils::ReportCameraError(std::string funcName, std::string useFunc, T ret)
50 {
51     std::string str = funcName;
52     str += " use ";
53     str += useFunc;
54     str += "get retCode is " + std::to_string(ret);
55     HiSysEventWrite(
56         HiviewDFX::HiSysEvent::Domain::CAMERA,
57         "CAMERA_ERR",
58         HiviewDFX::HiSysEvent::EventType::FAULT,
59         "MSG", str);
60 }
61 
62 template void CameraReportUtils::ReportCameraError<int32_t>(
63     std::string, std::string, int32_t);
64 template void CameraReportUtils::ReportCameraError<uint32_t>(
65     std::string, std::string, uint32_t);
66 
ReportCameraGetNullStr(std::string funcName,std::string useFunc)67 void CameraReportUtils::ReportCameraGetNullStr(std::string funcName, std::string useFunc)
68 {
69     std::string str = funcName;
70     str += " use ";
71     str += useFunc;
72     str += "get null string ";
73     HiSysEventWrite(
74         HiviewDFX::HiSysEvent::Domain::CAMERA,
75         "CAMERA_ERR",
76         HiviewDFX::HiSysEvent::EventType::FAULT,
77         "MSG", str);
78 }
79 
ReportCameraFail(std::string funcName,std::string useFunc)80 void CameraReportUtils::ReportCameraFail(std::string funcName, std::string useFunc)
81 {
82     std::string str = funcName;
83     str += " use ";
84     str += useFunc;
85     str += " is false";
86     HiSysEventWrite(
87         HiviewDFX::HiSysEvent::Domain::CAMERA,
88         "CAMERA_ERR",
89         HiviewDFX::HiSysEvent::EventType::FAULT,
90         "MSG", str);
91 }
92 
93 }  // namespace CameraStandard
94 }  // namespace OHOS