Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 3c1830b

Browse files
authored
Merge pull request #58 from AckeeCZ/fix/oom-large-log
⚡️ Update transform stream to parse only on pretty
2 parents 413af6e + 3c6e48f commit 3c1830b

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

src/streams.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ const getDefaultTransformStream = (options: CosmasOptions & { messageKey: string
88
class DefaultTransformStream extends Transform {
99
// tslint:disable-next-line:function-name
1010
public _transform(chunk: any, _encoding: string, callback: TransformCallback) {
11-
const obj = JSON.parse(chunk);
12-
let res;
13-
1411
if (options.pretty) {
15-
res = util.inspect(obj, { colors: true, showHidden: true, depth: Infinity });
12+
const res = util.inspect(JSON.parse(chunk), { colors: true, showHidden: true, depth: Infinity });
13+
this.push(`${res}\n`);
1614
} else {
17-
res = JSON.stringify(obj);
15+
this.push(chunk);
1816
}
19-
20-
this.push(`${res}\n`);
2117
callback();
2218
}
2319
}

0 commit comments

Comments
 (0)