From 45317f5861a4243dbac8166c4c7c0aa98262158b Mon Sep 17 00:00:00 2001 From: danielm-codefresh Date: Thu, 23 Dec 2021 10:33:23 +0200 Subject: [PATCH] Updated the task-logger version (#78) (#83) --- lib/ContainerLogger.js | 21 +++++++++++++++++---- service.yaml | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/ContainerLogger.js b/lib/ContainerLogger.js index 2fb2770..0158171 100644 --- a/lib/ContainerLogger.js +++ b/lib/ContainerLogger.js @@ -102,14 +102,21 @@ class ContainerLogger extends EventEmitter { logger.info(`Piping stdout and stderr step streams`); const stepLoggerWritableStream = this.stepLogger.writeStream(); + const { useLogsTimestamps } = this.stepLogger.opts; stepLoggerWritableStream.on('error', (err) => logger.error(`stepLoggerWritableStream: ${err}`)); // Attention(!) all streams piped to step logger writable stream must be a new streams(!) in order to avoid message piping twice to writable stream. // { end = false } on the stepLoggerWritableStream because there is only one instance of it for all the steps. this.handledStreams++; - stdout + let stdoutStream = stdout .pipe(this._logSizeLimitStream()) - .pipe(this.stepLogger.createMaskingStream()) + .pipe(this.stepLogger.createMaskingStream()); + + if (useLogsTimestamps) { + stdoutStream = stdoutStream.pipe(this.stepLogger.createPrependTimestampsStream()); + } + + stdoutStream .pipe(this.stepLogger.stepNameTransformStream().once('end', this._handleFinished.bind(this))) .pipe(stepLoggerWritableStream, { end: false }); @@ -118,10 +125,16 @@ class ContainerLogger extends EventEmitter { } this.handledStreams++; - stderr + let stderrStream = stderr .pipe(this._logSizeLimitStream()) .pipe(this._errorTransformerStream()) - .pipe(this.stepLogger.createMaskingStream()) + .pipe(this.stepLogger.createMaskingStream()); + + if (useLogsTimestamps) { + stderrStream = stderrStream.pipe(this.stepLogger.createPrependTimestampsStream()); + } + + stderrStream .pipe(this.stepLogger.stepNameTransformStream().once('end', this._handleFinished.bind(this))) .pipe(stepLoggerWritableStream, { end: false }); diff --git a/service.yaml b/service.yaml index 9712804..a8ed905 100644 --- a/service.yaml +++ b/service.yaml @@ -1 +1 @@ -version: 1.5.9 +version: 1.6.0