You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and use only properties from the {"topLevelPropsFieldName": {...}} to populate the top level.
Why this is needed:
Without this manual and explicit control 'random' properties go to the top level and this may affect other tools (like DataDog filters)
The text was updated successfully, but these errors were encountered:
Here is an example how it can be implemented (not tested)
/** * It takes the arguments passed to the console.log function and logs them using Winston * @param {any[]} args - any[] - the arguments passed to the console.log function * @param {LOG_LEVEL} level - LOG_LEVEL * @param topLevelFieldName - when defined only object properties under this field are moved to the top level. */exportfunctionlogUsingWinston(args: any[],level: LOG_LEVEL,topLevelFieldName: string|undefined){if(packageName.length===0){args.push({'@packageName': '<not-yet-set> Please await the call LoggerAdaptToConsole() on startup'});}else{args.push({'@packageName': packageName});}if(topLevelFieldName){for(leti=0;i<args.length;i++){if(typeofargs[i]==='object'){letwrappedArg: Record<string,any>={};wrappedArg[`[${i}]`]={...args[i]};if(typeofwrappedArg[topLevelFieldName]==='object'){consttopLevelFieldSet=wrappedArg[topLevelFieldName];deletewrappedArg[topLevelFieldName];wrappedArg={...wrappedArg, ...topLevelFieldSet};}args[i]=wrappedArg;}}}
...
Today console-log-json pulls object properties passed as args to the top level.
Example:
results to
The behavior I suggest:
and use only properties from the
{"topLevelPropsFieldName": {...}}
to populate the top level.Why this is needed:
Without this manual and explicit control 'random' properties go to the top level and this may affect other tools (like DataDog filters)
The text was updated successfully, but these errors were encountered: