• 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 
16 #ifndef DB_DFX_ADAPTER_H
17 #define DB_DFX_ADAPTER_H
18 
19 #include <string>
20 #include <vector>
21 
22 namespace DistributedDB {
23 enum DBEventType {
24     FAULT = 1,
25     STATISTIC = 2,
26     SECURITY = 3,
27     BEHAVIOR = 4
28 };
29 struct ReportTask {
30     std::string eventName;
31     std::string appId;
32     std::string userId;
33     std::string storeId;
34     int errCode = 0;
35 };
36 class DBDfxAdapter {
37 public:
38     static void Dump(int fd, const std::vector<std::u16string> &args);
39 
40     static void ReportFault(const ReportTask &reportTask);
41 
42     static void StartTrace(const std::string &action);
43     static void FinishTrace();
44 
45     static void StartTraceSQL();
46     static void FinishTraceSQL();
47 
48     static void StartAsyncTrace(const std::string &action, int32_t taskId);
49     static void FinishAsyncTrace(const std::string &action, int32_t taskId);
50 
51     static const std::string SYNC_ACTION;
52     static const std::string EVENT_OPEN_DATABASE_FAILED;
53 private:
54     static const std::string EVENT_CODE;
55     static const std::string APP_ID;
56     static const std::string USER_ID;
57     static const std::string STORE_ID;
58     static const std::string SQLITE_EXECUTE;
59 };
60 } // namespace DistributedDB
61 
62 #endif // DB_DFX_ADAPTER_H
63