Browse Source

Don't use through2 in prettyPrint

update-deps
Alex Mikhalev 6 years ago
parent
commit
f1a9d11dcf
  1. 10
      server/logging/prettyPrint.ts

10
server/logging/prettyPrint.ts

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
import chalk from "chalk";
import * as pump from "pump";
import * as split from "split2";
import * as through from "through2";
import { Transform, TransformCallback } from "stream";
type Level = "default" | 60 | 50 | 40 | 30 | 20 | 10;
@ -121,7 +121,8 @@ function asColoredLevel(value: any) { @@ -121,7 +121,8 @@ function asColoredLevel(value: any) {
}
}
const prettyTransport = through.obj((chunk, enc, cb) => {
class PrettyPrintTranform extends Transform {
_transform(chunk: any, encoding: string, cb: TransformCallback) {
let value: any;
try {
value = JSON.parse(chunk.toString());
@ -135,6 +136,7 @@ const prettyTransport = through.obj((chunk, enc, cb) => { @@ -135,6 +136,7 @@ const prettyTransport = through.obj((chunk, enc, cb) => {
}
process.stdout.write(line);
cb();
});
}
}
pump(process.stdin, split(), prettyTransport);
pump(process.stdin, split(), new PrettyPrintTranform());

Loading…
Cancel
Save