File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,16 @@ const myFormat = combine(
1212 splat ( ) ,
1313 printf ( ( obj ) => {
1414 obj . localTimestamp = new Date ( ) . toISOString ( )
15+ // Prevent errors and other objects to be inserted as Objects into message field
16+ if ( typeof obj . message === 'object' ) {
17+ if ( obj . message instanceof Error ) {
18+ const errorObj = obj . message
19+ obj . message = errorObj . message
20+ obj . details = errorObj
21+ } else {
22+ obj . message = JSON . stringify ( obj . message )
23+ }
24+ }
1525 return JSON . stringify ( obj ) // make single line
1626 } )
1727)
Original file line number Diff line number Diff line change @@ -12,6 +12,16 @@ const myFormat = combine(
1212 splat ( ) ,
1313 printf ( ( obj ) => {
1414 obj . localTimestamp = new Date ( ) . toISOString ( )
15+ // Prevent errors and other objects to be inserted as Objects into message field
16+ if ( typeof obj . message === 'object' ) {
17+ if ( obj . message instanceof Error ) {
18+ const errorObj = obj . message
19+ obj . message = errorObj . message
20+ obj . details = errorObj
21+ } else {
22+ obj . message = JSON . stringify ( obj . message )
23+ }
24+ }
1525 return JSON . stringify ( obj ) // make single line
1626 } )
1727)
You can’t perform that action at this time.
0 commit comments