中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
应用发生故障时如何获取系统日志?
微信扫码分享
import { FaultLogger } from '@kit.LancetKit'; import { BusinessError } from '@kit.BasicServicesKit'; function queryFaultLogCallback(error: BusinessError, value: Array<FaultLogger.FaultLogInfo>) { if (error) { console.info('error is ' + error); } else { console.info("value length is " + value.length); let len: number = value.length; for (let i = 0; i < len; i++) { console.info("log: " + i); console.info("Log pid: " + value[i].pid); console.info("Log uid: " + value[i].uid); console.info("Log type: " + value[i].type); console.info("Log timestamp: " + value[i].timestamp); console.info("Log reason: " + value[i].reason); console.info("Log module: " + value[i].module); console.info("Log summary: " + value[i].summary); console.info("Log text: " + value[i].fullLog); } } } try { FaultLogger.query(FaultLogger.FaultType.JS_CRASH, queryFaultLogCallback); } catch (err) { console.error(`code: ${(err as BusinessError).code}, message: ${(err as BusinessError).message}`); }