fix logging

pull/265/head
Frostebite 2021-05-28 19:44:47 +01:00
parent e8a987ea7e
commit caeeeb4573
3 changed files with 17 additions and 9 deletions

12
dist/index.js vendored
View File

@ -1053,7 +1053,8 @@ class Kubernetes {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
let running = true; let running = true;
let logQueryTime; let logQueryTime = 0;
let mostRecentLine = '';
while (running) { while (running) {
yield new Promise((resolve) => setTimeout(resolve, pollInterval)); yield new Promise((resolve) => setTimeout(resolve, pollInterval));
core.info('Polling logs...'); core.info('Polling logs...');
@ -1062,14 +1063,17 @@ class Kubernetes {
if (arrayOfLines) { if (arrayOfLines) {
for (const element of arrayOfLines) { for (const element of arrayOfLines) {
const [time, ...line] = element.split(' '); const [time, ...line] = element.split(' ');
if (time !== logQueryTime) { const lineString = line.join(' ');
core.info(line.join(' ')); const lineDate = Date.parse(time);
if (mostRecentLine !== lineString || lineDate !== logQueryTime) {
core.info(lineString);
logQueryTime = lineDate;
mostRecentLine = lineString;
} }
else { else {
break; break;
} }
} }
logQueryTime = arrayOfLines[0].split(' ')[0];
} }
const pod = yield this.kubeClient.readNamespacedPod(name, namespace); const pod = yield this.kubeClient.readNamespacedPod(name, namespace);
running = ((_b = pod.body.status) === null || _b === void 0 ? void 0 : _b.phase) === 'Running'; running = ((_b = pod.body.status) === null || _b === void 0 ? void 0 : _b.phase) === 'Running';

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -339,7 +339,8 @@ class Kubernetes {
static async streamLogs(name: string, namespace: string) { static async streamLogs(name: string, namespace: string) {
try { try {
let running = true; let running = true;
let logQueryTime; let logQueryTime: number = 0;
let mostRecentLine: string = '';
while (running) { while (running) {
await new Promise((resolve) => setTimeout(resolve, pollInterval)); await new Promise((resolve) => setTimeout(resolve, pollInterval));
core.info('Polling logs...'); core.info('Polling logs...');
@ -360,13 +361,16 @@ class Kubernetes {
if (arrayOfLines) { if (arrayOfLines) {
for (const element of arrayOfLines) { for (const element of arrayOfLines) {
const [time, ...line] = element.split(' '); const [time, ...line] = element.split(' ');
if (time !== logQueryTime) { const lineString: string = line.join(' ');
core.info(line.join(' ')); const lineDate: number = Date.parse(time);
if (mostRecentLine !== lineString || lineDate !== logQueryTime) {
core.info(lineString);
logQueryTime = lineDate;
mostRecentLine = lineString;
} else { } else {
break; break;
} }
} }
logQueryTime = arrayOfLines[0].split(' ')[0];
} }
const pod = await this.kubeClient.readNamespacedPod(name, namespace); const pod = await this.kubeClient.readNamespacedPod(name, namespace);
running = pod.body.status?.phase === 'Running'; running = pod.body.status?.phase === 'Running';