fix(loggable): removed private properties from logs

This commit is contained in:
Joan Sanchez 2022-02-01 11:24:04 +01:00
parent 9fac23038f
commit 67985077e7
1 changed files with 9 additions and 3 deletions

View File

@ -291,7 +291,8 @@ module.exports = function(Self) {
* @param {*} properties Modified object properties
*/
function removeUnloggable(definition, properties) {
const propList = Object.keys(properties);
const objectCopy = Object.assign({}, properties);
const propList = Object.keys(objectCopy);
const propDefs = new Map();
for (let property in definition.properties) {
@ -302,10 +303,15 @@ module.exports = function(Self) {
for (let property of propList) {
const propertyDef = propDefs.get(property);
const firstChar = property.substring(0, 1);
const isPrivate = firstChar == '$';
if (!propertyDef) return;
if (isPrivate || !propertyDef)
delete properties[property];
if (propertyDef.log === false)
if (!propertyDef) continue;
if (propertyDef.log === false || isPrivate)
delete properties[property];
else if (propertyDef.logValue === false)
properties[property] = null;