File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -278,17 +278,20 @@ export class LoggerHelper {
278278
279279 public static cloneObjectRecursively < T > (
280280 obj : T ,
281- maskValuesFn : ( key : number | string , value : unknown ) => unknown ,
281+ maskValuesFn ? : ( key : number | string , value : unknown ) => unknown ,
282282 done : unknown [ ] = [ ] ,
283283 clonedObject : T = Object . create ( Object . getPrototypeOf ( obj ) ) as T
284284 ) : T {
285285 done . push ( obj ) ;
286- Object . keys ( obj ) . forEach ( ( currentKey : string | number ) => {
286+ Object . getOwnPropertyNames ( obj ) . forEach ( ( currentKey : string | number ) => {
287287 if ( ! done . includes ( obj [ currentKey ] ) ) {
288288 if ( obj [ currentKey ] == null ) {
289289 clonedObject [ currentKey ] = obj [ currentKey ] ;
290290 } else if ( typeof obj [ currentKey ] !== "object" ) {
291- clonedObject [ currentKey ] = maskValuesFn ( currentKey , obj [ currentKey ] ) ;
291+ clonedObject [ currentKey ] =
292+ maskValuesFn != null
293+ ? maskValuesFn ( currentKey , obj [ currentKey ] )
294+ : obj [ currentKey ] ;
292295 } else {
293296 clonedObject [ currentKey ] = LoggerHelper . cloneObjectRecursively (
294297 obj [ currentKey ] ,
Original file line number Diff line number Diff line change @@ -444,7 +444,9 @@ export class LoggerWithoutCallSite {
444444 relevantCallSites . length = stackLimit ;
445445 }
446446
447- const errorObject : IErrorObject = JSON . parse ( JSON . stringify ( error ) ) ;
447+ const errorObject : IErrorObject = ( LoggerHelper . cloneObjectRecursively (
448+ error
449+ ) as unknown ) as IErrorObject ;
448450 errorObject . nativeError = error ;
449451 errorObject . details = { ...error } ;
450452 errorObject . name = errorObject . name ?? "Error" ;
You can’t perform that action at this time.
0 commit comments