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 type { AsyncCallback } from './@ohos.base'; 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 * @deprecated since 9 64 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 65 * @param faultType fault type to query 66 * @param callback faultlog information data callback function 67 */ 68 function querySelfFaultLog(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>) : void; 69 70 /** 71 * Query the result of the current application FaultLog in return promise mode. 72 * @since 8 73 * @deprecated since 9 74 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 75 * @param faultType fault type to query 76 * @return return faultlog information data by promise 77 */ 78 function querySelfFaultLog(faultType: FaultType) : Promise<Array<FaultLogInfo>>; 79 80 /** 81 * Query the result of the current application FaultLog in callback Mode 82 * @since 9 83 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 84 * @param faultType fault type to query 85 * @param callback faultlog information data callback function 86 * @throws {error} if the param is invalid or service is broken 87 */ 88 function query(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>) : void; 89 90 /** 91 * Query the result of the current application FaultLog in return promise mode. 92 * @since 9 93 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 94 * @param faultType fault type to query 95 * @throws {error} if the param is invalid or service is broken 96 * @return return faultlog information data by promise 97 */ 98 function query(faultType: FaultType) : Promise<Array<FaultLogInfo>>; 99 100 /** 101 * FaultLog information data structure 102 * @since 8 103 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 104 */ 105 interface FaultLogInfo { 106 /** 107 * pid Process id 108 * @since 8 109 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 110 */ 111 pid: number; 112 113 /** 114 * uid user id 115 * @since 8 116 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 117 */ 118 uid: number; 119 120 /** 121 * type fault type 122 * @since 8 123 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 124 */ 125 type: FaultType; 126 127 /** 128 * second level timestamp 129 * @since 8 130 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 131 */ 132 timestamp: number; 133 134 /** 135 * reason fault reason 136 * @since 8 137 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 138 */ 139 reason: string; 140 141 /** 142 * module fault module 143 * @since 8 144 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 145 */ 146 module: string; 147 148 /** 149 * summary fault summary 150 * @since 8 151 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 152 */ 153 summary: string; 154 155 /** 156 * fullLog fault log 157 * @since 8 158 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger 159 */ 160 fullLog: string; 161 } 162} 163 164export default FaultLogger; 165