Skip to content

Commit

Permalink
fix: fix pretty print
Browse files Browse the repository at this point in the history
  • Loading branch information
KillWolfVlad committed May 25, 2021
1 parent cca890a commit e8da669
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/providers/pino-logger-options-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export class PinoLoggerOptionsBuilder {
? {
translateTime: "SYS:STANDARD",
colorize: true,
ignore: Object.keys(this._base).concat("hash").join(","),
ignore: Object.keys(this._base)
.concat("errHash", "msgTemplateHash")
.join(","),
suppressFlushSyncWarning: true,
}
: false,
Expand Down
43 changes: 36 additions & 7 deletions test/unit/__snapshots__/pino-logger-options-builder.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,13 @@ Object {
exports[`pino-logger-options-builder must log object 1`] = `
Object {
"a": 1,
"env": "test",
"hostname": "host",
"level": "info",
"name": "name",
"pid": 123456,
"time": "2016-04-05T17:02:19.796Z",
"version": "version",
}
`;

Expand Down Expand Up @@ -162,7 +167,13 @@ Object {

exports[`pino-logger-options-builder must override level 1`] = `
Object {
"base": Object {},
"base": Object {
"env": "test",
"hostname": "host",
"name": "name",
"pid": 123456,
"version": "version",
},
"formatters": Object {
"level": [Function],
},
Expand All @@ -171,15 +182,27 @@ Object {
},
"level": "warn",
"prettyPrint": false,
"redact": Array [],
"serializers": Object {},
"redact": Array [
"req.headers.authorization",
],
"serializers": Object {
"err": [Function],
"req": [Function],
"res": [Function],
},
"timestamp": [Function],
}
`;

exports[`pino-logger-options-builder must override pretty print 1`] = `
Object {
"base": Object {},
"base": Object {
"env": "test",
"hostname": "host",
"name": "name",
"pid": 123456,
"version": "version",
},
"formatters": Object {
"level": [Function],
},
Expand All @@ -189,12 +212,18 @@ Object {
"level": "info",
"prettyPrint": Object {
"colorize": true,
"ignore": "hash",
"ignore": "pid,hostname,name,version,env,errHash,msgTemplateHash",
"suppressFlushSyncWarning": true,
"translateTime": "SYS:STANDARD",
},
"redact": Array [],
"serializers": Object {},
"redact": Array [
"req.headers.authorization",
],
"serializers": Object {
"err": [Function],
"req": [Function],
"res": [Function],
},
"timestamp": [Function],
}
`;
Expand Down
6 changes: 3 additions & 3 deletions test/unit/pino-logger-options-builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe("pino-logger-options-builder", () => {
});

it("must log object", () => {
const builder = new PinoLoggerOptionsBuilder(false);
const builder = new PinoLoggerOptionsBuilder();

stdout.start();
pino(builder.build()).info({a: 1});
Expand Down Expand Up @@ -108,13 +108,13 @@ describe("pino-logger-options-builder", () => {
});

it("must override level", () => {
const builder = new PinoLoggerOptionsBuilder(false);
const builder = new PinoLoggerOptionsBuilder();

expect(builder.withLevel(LogLevel.warn).build()).toMatchSnapshot();
});

it("must override pretty print", () => {
const builder = new PinoLoggerOptionsBuilder(false);
const builder = new PinoLoggerOptionsBuilder();

expect(builder.withPrettyPrint(true).build()).toMatchSnapshot();
});
Expand Down

0 comments on commit e8da669

Please sign in to comment.