• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (C) 2021-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/**
17 * @file
18 * @kit PerformanceAnalysisKit
19 */
20
21import type { AsyncCallback } from './@ohos.base';
22
23/**
24 * This module provides the capability to query faultlog data.
25 * @namespace FaultLogger
26 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
27 * @since 8
28 */
29
30
31declare namespace FaultLogger {
32  /**
33   * The type of fault type.
34   * @enum { number }
35   * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
36   * @since 8
37   */
38  enum FaultType {
39    /**
40     * NO_SPECIFIC log type not distinguished.
41     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
42     * @since 8
43     */
44    NO_SPECIFIC = 0,
45    /**
46     * CPP_CRASH CPP crash log type.
47     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
48     * @since 8
49     */
50    CPP_CRASH = 2,
51    /**
52     * JS_CRASH JS crash log type.
53     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
54     * @since 8
55     */
56    JS_CRASH = 3,
57    /**
58     * APP_FREEZE app freeze log type.
59     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
60     * @since 8
61     */
62    APP_FREEZE = 4,
63  }
64
65  /**
66   * Query the result of the current application FaultLog in callback Mode.
67   * @param { FaultType } faultType - Fault type to query
68   * @param { AsyncCallback<Array<FaultLogInfo>> } callback - Faultlog information data callback function
69   * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
70   * @since 8
71   * @deprecated since 9
72   * @useinstead ohos.faultlogger/FaultLogger#query
73   */
74  function querySelfFaultLog(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>): void;
75
76  /**
77   * Query the result of the current application FaultLog in return promise mode.
78   * @param { FaultType } faultType - Fault type to query
79   * @returns { Promise<Array<FaultLogInfo>> } return faultlog information data by promise
80   * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
81   * @since 8
82   * @deprecated since 9
83   * @useinstead ohos.faultlogger/FaultLogger#query
84   */
85  function querySelfFaultLog(faultType: FaultType): Promise<Array<FaultLogInfo>>;
86
87  /**
88   * Query the result of the current application FaultLog in callback Mode.
89   * @param { FaultType } faultType - Fault type to query
90   * @param { AsyncCallback<Array<FaultLogInfo>> } callback - Faultlog information data callback function
91   * @throws { BusinessError } 401 - The parameter check failed, Parameter type error
92   * @throws { BusinessError } 801 - The specified SystemCapability name was not found
93   * @throws { BusinessError } 10600001 - The service is not started or is faulty
94   * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
95   * @since 9
96   */
97  function query(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>): void;
98
99  /**
100   * Query the result of the current application FaultLog in return promise mode.
101   * @param { FaultType } faultType - Fault type to query
102   * @returns { Promise<Array<FaultLogInfo>> } return faultlog information data by promise
103   * @throws { BusinessError } 401 - The parameter check failed, Parameter type error
104   * @throws { BusinessError } 801 - The specified SystemCapability name was not found
105   * @throws { BusinessError } 10600001 - The service is not started or is faulty
106   * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
107   * @since 9
108   */
109  function query(faultType: FaultType): Promise<Array<FaultLogInfo>>;
110
111  /**
112   * FaultLog information data structure.
113   * @interface FaultLogInfo
114   * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
115   * @since 8
116   */
117  interface FaultLogInfo {
118    /**
119     * Process id.
120     * @type { number }
121     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
122     * @since 8
123     */
124    pid: number;
125
126    /**
127     * User id.
128     * @type { number }
129     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
130     * @since 8
131     */
132    uid: number;
133
134    /**
135     * Fault type.
136     * @type { FaultType }
137     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
138     * @since 8
139     */
140    type: FaultType;
141
142    /**
143     * Second level timestamp.
144     * @type { number }
145     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
146     * @since 8
147     */
148    timestamp: number;
149
150    /**
151     * Fault reason.
152     * @type { string }
153     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
154     * @since 8
155     */
156    reason: string;
157
158    /**
159     * Fault module.
160     * @type { string }
161     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
162     * @since 8
163     */
164    module: string;
165
166    /**
167     * Fault summary.
168     * @type { string }
169     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
170     * @since 8
171     */
172    summary: string;
173
174    /**
175     * Fault log.
176     * @type { string }
177     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
178     * @since 8
179     */
180    fullLog: string;
181  }
182}
183
184export default FaultLogger;
185