Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Coping0606
Docs
提交
e058d3af
D
Docs
项目概览
Coping0606
/
Docs
与 Fork 源项目一致
Fork自
OpenHarmony / Docs
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e058d3af
编写于
10月 17, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
!10708 faultlogger新增异常处理机制
Merge pull request !10708 from hw_mzyan/master
上级
6d59bd73
2e306e30
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
144 addition
and
14 deletion
+144
-14
zh-cn/application-dev/reference/apis/js-apis-faultLogger.md
zh-cn/application-dev/reference/apis/js-apis-faultLogger.md
+125
-14
zh-cn/application-dev/reference/errorcodes/errorcode-faultlogger.md
...ication-dev/reference/errorcodes/errorcode-faultlogger.md
+19
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-faultLogger.md
浏览文件 @
e058d3af
...
...
@@ -39,10 +39,12 @@ import faultLogger from '@ohos.faultLogger'
| summary | string | 故障的概要 |
| fullLog | string | 故障日志全文 |
## faultLogger.querySelfFaultLog
## faultLogger.querySelfFaultLog
<sup>(deprecated)</sup>
querySelfFaultLog(faultType: FaultType, callback: AsyncCallback
<
Array
<
FaultLogInfo
>>
) : void
> **说明:** 从 API Version 9 开始废弃,建议使用[faultLogger.query](#faultloggerquery9)替代。
获取当前进程故障信息,该方法通过回调方式获取故障信息数组,故障信息数组内最多上报10份故障信息。
**系统能力:**
SystemCapability.HiviewDFX.Hiview.FaultLogger
...
...
@@ -79,10 +81,12 @@ function queryFaultLogCallback(error, value) {
faultLogger
.
querySelfFaultLog
(
faultLogger
.
FaultType
.
JS_CRASH
,
queryFaultLogCallback
);
```
## faultLogger.querySelfFaultLog
## faultLogger.querySelfFaultLog
<sup>(deprecated)</sup>
querySelfFaultLog(faultType: FaultType) : Promise
<
Array
<
FaultLogInfo
>>
> **说明:** 从 API Version 9 开始废弃,建议使用[faultLogger.query](#faultloggerquery9-1)替代。
获取当前进程故障信息,该方法通过Promise方式返回故障信息数组,故障信息数组内最多上报10份故障信息。
**系统能力:**
SystemCapability.HiviewDFX.Hiview.FaultLogger
...
...
@@ -106,18 +110,125 @@ async function getLog() {
let
value
=
await
faultLogger
.
querySelfFaultLog
(
faultLogger
.
FaultType
.
JS_CRASH
);
if
(
value
)
{
console
.
info
(
"
value length is
"
+
value
.
length
);
let
len
=
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
);
}
let
len
=
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
);
}
}
}
```
## faultLogger.query<sup>9+</sup>
query(faultType: FaultType, callback: AsyncCallback
<
Array
<
FaultLogInfo
>>
) : void
获取当前进程故障信息,该方法通过回调方式获取故障信息数组,故障信息数组内最多上报10份故障信息。
**系统能力:**
SystemCapability.HiviewDFX.Hiview.FaultLogger
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| faultType |
[
FaultType
](
#faulttype
)
| 是 | 输入要查询的故障类型。 |
| callback | AsyncCallbackArray
<
Array
<
[FaultLogInfo](#faultloginfo)
>>
| 是 | 回调函数,在回调函数中获取故障信息数组。
<br/>
-
value拿到故障信息数组;value为undefined表示获取过程中出现异常,error返回错误提示字符串
**错误码:**
以下错误码的详细介绍参见
[
ohos.faultLogger错误码
](
../errorcodes/errorcode-faultlogger.md
)
。
| 错误码ID | 错误信息(此处仅提供错误抛出的关键信息) |
| --- | --- |
| 10600001 | The service is not running or broken |
**示例:**
```
js
function
queryFaultLogCallback
(
error
,
value
)
{
if
(
error
)
{
console
.
info
(
'
error is
'
+
error
);
}
else
{
console
.
info
(
"
value length is
"
+
value
.
length
);
let
len
=
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
.
code
}
, message:
${
err
.
message
}
`
);
}
```
## faultLogger.query<sup>9+</sup>
query(faultType: FaultType) : Promise
<
Array
<
FaultLogInfo
>>
获取当前进程故障信息,该方法通过Promise方式返回故障信息数组,故障信息数组内最多上报10份故障信息。
**系统能力:**
SystemCapability.HiviewDFX.Hiview.FaultLogger
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| faultType |
[
FaultType
](
#faulttype
)
| 是 | 输入要查询的故障类型。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
Array
<
[FaultLogInfo](#faultloginfo)
>>
| Promise实例,可以在其then()方法中获取故障信息实例,也可以使用await。
<br/>
-
value拿到故障信息数组;value为undefined表示获取过程中出现异常 |
**错误码:**
以下错误码的详细介绍参见
[
ohos.faultLogger错误码
](
../errorcodes/errorcode-faultlogger.md
)
。
| 错误码ID | 错误信息(此处仅提供错误抛出的关键信息) |
| --- | --- |
| 10600001 | The service is not running or broken |
**示例:**
```
js
async
function
getLog
()
{
try
{
let
value
=
await
faultLogger
.
query
(
faultLogger
.
FaultType
.
JS_CRASH
);
if
(
value
)
{
console
.
info
(
"
value length is
"
+
value
.
length
);
let
len
=
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
);
}
}
}
catch
(
err
)
{
console
.
error
(
`code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
}
```
zh-cn/application-dev/reference/errorcodes/errorcode-faultlogger.md
0 → 100644
浏览文件 @
e058d3af
# faultlogger 错误码
## 10600001 服务未启动或故障
**错误信息**
The service is not running or broken.
**错误描述**
服务未启动/故障。
**可能原因**
hiview服务未启动。
**处理步骤**
不应该发生的场景,考虑重试。
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录