Skip to content
This repository has been archived by the owner on Mar 13, 2021. It is now read-only.

Commit

Permalink
change line default to 500
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrauskopf committed Oct 29, 2020
1 parent 406ee88 commit 19dbdde
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/commands/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class Logs extends BaseCommand {
}),
lines: flags.string({
char: "l",
default: "1500",
default: "500",
description: "The number of lines of logs to show from the server, max of 1500"
}),
all: flags.boolean({
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class Logs extends BaseCommand {
const logs = await apiClient.deployments.getLogsById({ deployId: latestDeployment.deployId, appId: platformApp.id })

if (flags.format !== "raw") {
const parsedLogs = parseDIPLogs(logs, flags.lines, flags.all);
const parsedLogs = parseDIPLogs(logs, Number(flags.lines), flags.all);
parsedLogs.map(log => this.log(log));
}
else {
Expand Down
11 changes: 8 additions & 3 deletions src/core/utils/dip-log-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import chalk from "chalk";
/**
* Parse logs from DIP into a more human readable format.
*/
export function parseDIPLogs(logs: string, lines = "1500", showAll = false): string[] {
export function parseDIPLogs(logs: string, lines = 500, showAll = false): string[] {

// Strip tailing logs that are greater than the line parameter
const splitLogs = logs.split("\n");

// Remove empty space tail to prevent unnecessary newline at the end of the logs
if(splitLogs[splitLogs.length-1] === "") {
if (splitLogs[splitLogs.length - 1] === "") {
splitLogs.pop();
}

Expand All @@ -31,7 +31,12 @@ export function parseDIPLogs(logs: string, lines = "1500", showAll = false): str
}
});

const trimmedLogs = filteredLogs.slice(filteredLogs.length - Number(lines));
// Currently the DIP only supports a maximum of 1500 lines.
if (lines > 1500) {
lines = 1500;
}

const trimmedLogs = filteredLogs.slice(filteredLogs.length - lines);

const parsedLogs: string[] = [];

Expand Down

0 comments on commit 19dbdde

Please sign in to comment.