-
Notifications
You must be signed in to change notification settings - Fork 1
/
Logman.ts
55 lines (48 loc) · 1.52 KB
/
Logman.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { LogEntry, Logman as GenericLogman } from '../../driver/generic/Logman';
import { RPCProvider } from '../jsonrpcv2';
export class RPCLogman extends GenericLogman {
private rpc: RPCProvider;
private targetId: string;
constructor(rpc: RPCProvider, targetId: string) {
super();
this.rpc = rpc;
this.targetId = targetId;
}
/**
* Return available log sources in platform
*
* @returns available log sources
*/
public async getAvailableSources(): Promise<string[]> {
const result = await this.rpc.remoteCall({
jsonrpc: '2.0',
target: this.targetId,
class: 'Logman',
method: 'getAvailableSources',
params: [],
}) as string[];
return result;
}
/**
* Retrieve log from target
*
* @param source - Log source. Depend on target
* @param from - Log start date
* @param to - Log end date
* @returns Log entries
*/
public async queryLog(source: string, from: Date | undefined, to: Date | undefined): Promise<LogEntry[]> {
const result = await this.rpc.remoteCall({
jsonrpc: '2.0',
target: this.targetId,
class: 'Logman',
method: 'queryLog',
params: [source, from, to],
}, 600000) as {[key: string]: string}[];
return result.map((ent): LogEntry => {
const ln = new LogEntry(new Date(), '');
ln.restore(ent);
return ln;
});
}
}