File tree Expand file tree Collapse file tree
libs/lib-services/src/logger Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,7 +29,17 @@ export const DO_NOT_LOG = Symbol('DO_NOT_LOG');
2929 */
3030const logFilter = ( key : string , value : unknown ) => {
3131 if ( value != null && typeof value == 'object' && ( value as any ) [ DO_NOT_LOG ] ) {
32- throw new ServiceAssertionError ( `${ Object . getPrototypeOf ( value ) ?. constructor ?. name } must not be logged` ) ;
32+ const name = Object . getPrototypeOf ( value ) ?. constructor ?. name ;
33+ const message = `${ key } : ${ name } must not be logged` ;
34+ if ( process . env . NODE_ENV == 'production' ) {
35+ // In production, log a warning and filter out the value.
36+ // We do this in case a DO_NOT_LOG value is only logged in rare edge cases not covered by tests,
37+ // and we don't want to cause cascading failures in that case.
38+ logger . error ( message ) ;
39+ return undefined ;
40+ }
41+ // In local development and testing, this is a hard error to surface the issue clearly.
42+ throw new ServiceAssertionError ( message ) ;
3343 }
3444 return value ;
3545} ;
You can’t perform that action at this time.
0 commit comments