File tree Expand file tree Collapse file tree
packages/server/shared/src/lib/logger Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ export const cleanLogEvent = (logEvent: any) => {
4242 eventData [ key ] = Math . round ( value * 100 ) / 100 ;
4343 } else if ( typeof value === 'object' ) {
4444 try {
45- eventData [ key ] = truncate ( JSON . stringify ( value ) ) ;
45+ eventData [ key ] = stringify ( value ) ;
4646 } catch ( error ) {
4747 eventData [ key ] = `Logger error - could not stringify object. ${ error } ` ;
4848 }
@@ -90,10 +90,16 @@ function extractErrorFields(
9090 eventData [ errorKey + 'Name' ] = truncate ( name ) ;
9191 if ( value instanceof ApplicationError ) {
9292 eventData [ errorKey + 'Code' ] = truncate ( value . error . code ) ;
93- eventData [ errorKey + 'Params' ] = truncate (
94- JSON . stringify ( value . error . params ) ,
95- ) ;
93+ eventData [ errorKey + 'Params' ] = stringify ( value . error . params ) ;
9694 } else if ( context && Object . keys ( context ) . length ) {
97- eventData [ errorKey + 'Context' ] = truncate ( JSON . stringify ( context ) ) ;
95+ eventData [ errorKey + 'Context' ] = stringify ( context ) ;
96+ }
97+ }
98+
99+ function stringify ( value : any ) {
100+ try {
101+ return truncate ( JSON . stringify ( value ) ) ;
102+ } catch ( error ) {
103+ return `Logger error - could not stringify object. ${ error } ` ;
98104 }
99105}
You can’t perform that action at this time.
0 commit comments