SYS_Log.find() method
查找条目
签名
typescript
function find(
message:
| string
| Array<
| string
| {
text: string;
attr?:
| undefined
| {
id?: undefined | string;
path?: undefined | string;
sheet?: undefined | string;
pcbid?: undefined | string;
type?: undefined | string;
};
}
>,
types?: ESYS_LogType | Array<ESYS_LogType>,
): Promise<Array<ISYS_LogLine>>;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
参数名
参数 | 类型 | 描述 |
|---|---|---|
message | string | Array<string | { text: string; attr?: undefined | { id?: undefined | string; path?: undefined | string; sheet?: undefined | string; pcbid?: undefined | string; type?: undefined | string } }> | 查找内容 |
types | ESYS_LogType | Array<ESYS_LogType> | (可选) 日志类型数组,可以在指定的日志类型内查找 |
返回值
Promise<Array<ISYS_LogLine>>
符合查找条件的日志条目数组
备注
如果日志面板处于打开状态,查找操作会同时在前端展现
示例
javascript
// 1. 写入待查找的示例日志(一条 info、一条 error)
eda.sys_Log.add('嘉立创示例_查找演示:任务开始');
eda.sys_Log.add('嘉立创示例_查找演示:网络请求失败', 'error');
// 2. 按关键字查找全部匹配条目(返回 Promise,需要 await)
const all = await eda.sys_Log.find('嘉立创示例_查找演示');
console.log('关键字匹配条目数:', all.length);
// 3. 限定只在 error 类型中查找,缩小搜索范围
const errors = await eda.sys_Log.find('嘉立创示例_查找演示', 'error');
console.log('error 类型匹配条目数:', errors.length);
console.log('匹配内容:', errors.map(line => line.message).join(';'));1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12