diff --git a/loopback/common/models/loggable.js b/loopback/common/models/loggable.js index 956762be2..28a6075d0 100644 --- a/loopback/common/models/loggable.js +++ b/loopback/common/models/loggable.js @@ -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;