Skip to content

Commit

Permalink
feat: support specifying a starting time for PaaS logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuruyia committed Dec 2, 2022
1 parent 3647eb5 commit 657aa8f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@types/tmp": "^0.2.0",
"bluebird": "^3.7.2",
"chalk": "^4.1.0",
"chrono-node": "^2.4.2",
"cli-ux": "^5.5.1",
"inquirer": "^8.0.0",
"kepler-companion": "^1.1.3",
Expand Down
10 changes: 9 additions & 1 deletion src/commands/paas/logs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import fs from "fs";
import * as readline from "readline";

import { cli } from "cli-ux";
import { flags } from "@oclif/command";
import chalk from "chalk";
import * as chrono from "chrono-node";
import { cli } from "cli-ux";

import PaasLogin from "./login";
import { PaasKommand } from "../../support/PaasKommand";
Expand Down Expand Up @@ -56,6 +57,9 @@ class PaasLogs extends PaasKommand {
podName: flags.string({
description: "Name of the pod to show logs from",
}),
since: flags.string({
description: "Display logs from a specific absolute (e.g. 2022/12/02 09:41) or relative (e.g. a minute ago) time",
}),
};

static args = [
Expand Down Expand Up @@ -100,6 +104,9 @@ class PaasLogs extends PaasKommand {

const separator = "\t";

// Parse the time arguments
const since = this.flags.since ? chrono.parseDate(this.flags.since).toISOString() : undefined;

// Perform the streamed request
const incomingMessage = await this.paas.queryHttpStream({
controller: "application",
Expand All @@ -110,6 +117,7 @@ class PaasLogs extends PaasKommand {
follow: this.flags.follow,
tailLines: this.flags.tail,
podName: this.flags.podName,
since,
});

// Read the response line by line
Expand Down

0 comments on commit 657aa8f

Please sign in to comment.