Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private createPrettyTransport(level: string, prettyOptions?: PrettyOptions): Transform {
const pinoPretty = PinoPretty({
...{
levelFirst: false,
translateTime: "yyyy-mm-dd HH:MM:ss.l",
},
...prettyOptions,
});
const levelValue = this.logger.levels.values[level];
return new Transform({
transform(chunk, enc, cb) {
try {
const json = JSON.parse(chunk);
if (json.level >= levelValue) {
const line = pinoPretty(json);
if (line !== undefined) {
function getPrettyStream (opts, prettifier, dest) {
if (prettifier && typeof prettifier === 'function') {
return prettifierMetaWrapper(prettifier(opts), dest)
}
try {
var prettyFactory = require('pino-pretty')
prettyFactory.asMetaWrapper = prettifierMetaWrapper
return prettifierMetaWrapper(prettyFactory(opts), dest)
} catch (e) {
throw Error('Missing `pino-pretty` module: `pino-pretty` must be installed separately')
}
}