SYS_Log.find() method
Find entries
Signature
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
Parameters
Parameter | Type | Description |
|---|---|---|
message | string | Array<string | { text: string; attr?: undefined | { id?: undefined | string; path?: undefined | string; sheet?: undefined | string; pcbid?: undefined | string; type?: undefined | string } }> | Find content |
types | ESYS_LogType | Array<ESYS_LogType> | (Optional) Array of log types. The search can be performed within the specified log types |
Returns
Promise<Array<ISYS_LogLine>>
Array of log entries matching the find criteria
Remarks
If the log panel is open, the find operation will also be displayed on the front end
Example
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