Skip to content

Commit 5aa18c9

Browse files
committed
Add last lines log option.
1 parent 1acee5b commit 5aa18c9

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/commands/app/logs.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ export default class AppLogs extends Command {
9797
char: 'r',
9898
description: 'show logs for a specific release (e.g. v1, v2)',
9999
}),
100+
'last-lines': Flags.boolean({
101+
char: 'l',
102+
default: false,
103+
}),
100104
};
101105

102106
static aliases = ['logs'];
@@ -182,6 +186,7 @@ export default class AppLogs extends Command {
182186
Math.max(start, lastLogUnix),
183187
project,
184188
releaseId,
189+
flags['last-lines'],
185190
);
186191

187192
if (!logs?.length && !follow) {
@@ -192,6 +197,10 @@ export default class AppLogs extends Command {
192197
this.#printLogLine(log.values, log.releaseTag);
193198
}
194199

200+
if (flags['last-lines']) {
201+
break;
202+
}
203+
195204
const lastLog = logs[logs.length - 1];
196205

197206
if (lastLog) {
@@ -206,14 +215,20 @@ export default class AppLogs extends Command {
206215
}
207216
}
208217

209-
fetchLogs = async (since: number, appName: string, releaseId?: string) => {
218+
fetchLogs = async (
219+
since: number,
220+
appName: string,
221+
releaseId?: string,
222+
last_lines: boolean = false,
223+
) => {
210224
this.debug('Polling...');
211225

212226
try {
213227
const url = `v2/projects/${appName}/logs`;
214228
const searchParams: any = {
215229
start: since,
216230
direction: 'forward',
231+
last_lines: last_lines,
217232
};
218233

219234
if (releaseId) {

0 commit comments

Comments
 (0)