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

Commit

Permalink
Hide pkgVersion in pretty stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Vlasák committed Jun 10, 2019
1 parent 386993e commit cd862b9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ const getDefaultTransformStream = (options: AckeeLoggerOptions & { messageKey: s
// tslint:disable-next-line:function-name
public _transform(chunk: any, _encoding: string, callback: TransformCallback) {
const obj = JSON.parse(chunk);
obj.pkgVersion = pkgJson.version;
const loggerName = options.loggerName;
if (options.pretty) {
obj['name\0'] = obj.name; // add null character so that it is not interpreted by pino-pretty but still visible to user unchanged
delete obj.name;
if (loggerName) {
obj.name = loggerName;
}
} else if (obj[options.messageKey] && isString(obj[options.messageKey]) && loggerName) {
obj[options.messageKey] = `[${loggerName}] ${obj[options.messageKey]}`;
} else {
obj.pkgVersion = pkgJson.version;
if (obj[options.messageKey] && isString(obj[options.messageKey]) && loggerName) {
obj[options.messageKey] = `[${loggerName}] ${obj[options.messageKey]}`;
}
}

this.push(`${JSON.stringify(obj)}\n`);
Expand Down

0 comments on commit cd862b9

Please sign in to comment.