Skip to content

Commit

Permalink
Updated the task-logger version (#78) (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielm-codefresh authored Dec 23, 2021
1 parent f55c676 commit 45317f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions lib/ContainerLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand All @@ -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 });

Expand Down
2 changes: 1 addition & 1 deletion service.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version: 1.5.9
version: 1.6.0

0 comments on commit 45317f5

Please sign in to comment.