SYS_Log.sort() method
Filter and get log entries
Signature
typescript
function sort(types?: ESYS_LogType | Array<ESYS_LogType>): Promise<Array<ISYS_LogLine>>;1
Parameters
Parameter | Type | Description |
|---|---|---|
types | ESYS_LogType | Array<ESYS_LogType> | (Optional) Array of log types. Multiple log types can be specified at the same time. If not specified, all types are used |
Returns
Promise<Array<ISYS_LogLine>>
Array of log entries matching the filter criteria
Remarks
If the log panel is open, the filter operation will also be displayed on the front end
Example
javascript
// 1. 写入三种不同类型的示例日志,便于观察筛选效果
eda.sys_Log.add('嘉立创示例_筛选演示:常规信息');
eda.sys_Log.add('嘉立创示例_筛选演示:电压偏高', 'warn');
eda.sys_Log.add('嘉立创示例_筛选演示:铺铜失败', 'error');
// 2. 不传参数,获取全部类型的日志(返回 Promise,需要 await)
const all = await eda.sys_Log.sort();
console.log('全部日志条目数:', all.length);
// 3. 传入类型数组,只筛选警告和错误两类
const problems = await eda.sys_Log.sort(['warn', 'error']);
console.log('警告和错误条目数:', problems.length);
console.log('问题明细:', problems.map(line => `[${line.type}] ${line.message}`).join(';'));1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13