1 | const { logs } = require('../sdk');
|
2 | const { getAPIKey } = require('./userConf');
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | const logCLI = async function logCLI(funcName, follow, since, logStream) {
|
13 | const apiKey = await getAPIKey();
|
14 | let token;
|
15 | let startAfter = since && since.toISOString();
|
16 | if (!follow && !startAfter) {
|
17 | const baseDate = new Date();
|
18 | baseDate.setTime(0);
|
19 | startAfter = baseDate.toISOString();
|
20 | }
|
21 | do {
|
22 |
|
23 | const { nextToken, body } = await logs(funcName, apiKey, follow, startAfter, token);
|
24 | for (const record of body) {
|
25 | logStream.push(record);
|
26 | }
|
27 | token = nextToken;
|
28 | } while (token);
|
29 | };
|
30 |
|
31 | module.exports = logCLI;
|