File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -147,11 +147,13 @@ function pretty (inputData) {
147
147
this . messageKey ,
148
148
this . levelKey ,
149
149
this . timestampKey
150
- ] . filter ( key => {
151
- return typeof log [ key ] === 'string' ||
152
- typeof log [ key ] === 'number' ||
153
- typeof log [ key ] === 'boolean'
154
- } )
150
+ ]
151
+ . map ( ( key ) => key . replaceAll ( / \\ / g, '' ) )
152
+ . filter ( key => {
153
+ return typeof log [ key ] === 'string' ||
154
+ typeof log [ key ] === 'number' ||
155
+ typeof log [ key ] === 'boolean'
156
+ } )
155
157
const prettifiedObject = prettifyObject ( {
156
158
log,
157
159
skipKeys,
Original file line number Diff line number Diff line change @@ -218,6 +218,22 @@ test('basic prettifier tests', (t) => {
218
218
log . info ( { msg : 'foo' , bar : 'warn' } )
219
219
} )
220
220
221
+ t . test ( 'can use nested level keys' , ( t ) => {
222
+ t . plan ( 1 )
223
+ const pretty = prettyFactory ( { levelKey : 'log\\.level' } )
224
+ const log = pino ( { } , new Writable ( {
225
+ write ( chunk , enc , cb ) {
226
+ const formatted = pretty ( chunk . toString ( ) )
227
+ t . equal (
228
+ formatted ,
229
+ `[${ formattedEpoch } ] WARN (${ pid } ): foo\n`
230
+ )
231
+ cb ( )
232
+ }
233
+ } ) )
234
+ log . info ( { msg : 'foo' , 'log.level' : 'warn' } )
235
+ } )
236
+
221
237
t . test ( 'can use a customPrettifier on default level output' , ( t ) => {
222
238
t . plan ( 1 )
223
239
const veryCustomLevels = {
You can’t perform that action at this time.
0 commit comments