in packages/app/src/cloudwatch.ts [14:32]
async function getAllLogGroups(
cloudwatchLogs: CloudWatchLogs,
logGroupNamePrefix?: string,
): Promise<LogGroup[]> {
async function rec(acc: LogGroup[], nextToken?: string): Promise<LogGroup[]> {
const command = new DescribeLogGroupsCommand({
nextToken,
logGroupNamePrefix,
});
const result = await cloudwatchLogs.send(command);
const newAcc = acc.concat(result.logGroups ?? []);
if (result.nextToken) {
return rec(newAcc, result.nextToken);
} else {
return newAcc;
}
}
return rec([]);
}