• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (C) 2021 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
16import { AsyncCallback } from "./basic";
17
18
19/**
20 * This module provides the capability to query faultlog data.
21 *
22 * @since 8
23 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
24 * @import import sensor from '@ohos.faultlogger'
25 */
26
27declare namespace FaultLogger {
28  /**
29   * The type of fault type.
30   * @since 8
31   * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
32   */
33  enum FaultType {
34    /**
35     * NO_SPECIFIC log type not distinguished.
36     * @since 8
37     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
38     */
39    NO_SPECIFIC = 0,
40    /**
41     * CPP_CRASH CPP crash log type
42     * @since 8
43     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
44     */
45    CPP_CRASH = 2,
46    /**
47     * JS_CRASH JS crash log type
48     * @since 8
49     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
50     */
51    JS_CRASH = 3,
52    /**
53     * APP_FREEZE app feeeze log type
54     * @since 8
55     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
56     */
57    APP_FREEZE = 4,
58  }
59
60  /**
61   * Query the result of the current application FaultLog in callback Mode
62   * @since 8
63   * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
64   * @param faultType fault type to query
65   * @param callback faultlog information data callback function
66   */
67  function querySelfFaultLog(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>) : void;
68
69  /**
70   * Query the result of the current application FaultLog in return promise mode.
71   * @since 8
72   * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
73   * @param faultType fault type to query
74   * @return return faultlog information data by promise
75   */
76  function querySelfFaultLog(faultType: FaultType) : Promise<Array<FaultLogInfo>>;
77
78  /**
79   * FaultLog information data structure
80   * @since 8
81   * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
82   */
83  interface FaultLogInfo {
84    /**
85     * pid Process id
86     * @since 8
87     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
88     */
89    pid: number;
90
91    /**
92     * uid user id
93     * @since 8
94     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
95     */
96    uid: number;
97
98    /**
99     * type fault type
100     * @since 8
101     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
102     */
103    type: FaultType;
104
105    /**
106     * second level timestamp
107     * @since 8
108     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
109     */
110    timestamp: number;
111
112    /**
113     * reason fault reason
114     * @since 8
115     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
116     */
117    reason: string;
118
119    /**
120     * module fault module
121     * @since 8
122     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
123     */
124    module: string;
125
126    /**
127     * summary fault summary
128     * @since 8
129     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
130     */
131    summary: string;
132
133    /**
134     * fullLog fault log
135     * @since 8
136     * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger
137     */
138    fullLog: string;
139  }
140}
141
142export default FaultLogger;
143