File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,9 @@ function pino (opts, stream) {
9999 data += ',"type":"Error","stack":' + stringify ( obj . stack ) + '}'
100100 } else {
101101 for ( var key in obj ) {
102- data += ',"' + key + '":' + stringify ( obj [ key ] )
102+ if ( obj [ key ] ) {
103+ data += ',"' + key + '":' + stringify ( obj [ key ] )
104+ }
103105 }
104106 data += '}'
105107 }
Original file line number Diff line number Diff line change @@ -206,3 +206,22 @@ test('set the level via constructor', function (t) {
206206 instance . error ( 'this is an error' )
207207 instance . fatal ( 'this is fatal' )
208208} )
209+
210+ test ( 'set undefined properties' , function ( t ) {
211+ t . plan ( 2 )
212+
213+ var instance = pino ( sink ( function ( chunk , enc , cb ) {
214+ t . ok ( Date . parse ( chunk . time ) <= new Date ( ) , 'time is greater than Date.now()' )
215+ delete chunk . time
216+ t . deepEqual ( chunk , {
217+ pid : pid ,
218+ hostname : hostname ,
219+ level : 30 ,
220+ hello : 'world' ,
221+ v : 0
222+ } )
223+ cb ( )
224+ } ) )
225+
226+ instance . info ( { hello : 'world' , property : undefined } )
227+ } )
You can’t perform that action at this time.
0 commit comments