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