diff --git a/app/lib/server/lib/debug.js b/app/lib/server/lib/debug.js index 5ea5ad0b5bf25..fddda9806a2c0 100644 --- a/app/lib/server/lib/debug.js +++ b/app/lib/server/lib/debug.js @@ -49,6 +49,11 @@ const traceConnection = (enable, filter, prefix, name, connection, userId) => { } }; +const omitKeyArgs = (args) => args.map((arg) => + (typeof arg !== 'object' + ? arg + : _.omit(arg, 'password', 'msg', 'pass', 'username', 'message'))); + const wrapMethods = function(name, originalHandler, methodsMap) { methodsMap[name] = function(...originalArgs) { traceConnection(Log_Trace_Methods, Log_Trace_Methods_Filter, 'method', name, this.connection, this.userId); @@ -58,7 +63,7 @@ const wrapMethods = function(name, originalHandler, methodsMap) { has_user: this.userId != null, }); const args = name === 'ufsWrite' ? Array.prototype.slice.call(originalArgs, 1) : originalArgs; - logger.method(name, '-> userId:', Meteor.userId(), ', arguments: ', args); + logger.method(() => `${ name } -> userId: ${ Meteor.userId() }, arguments: ${ JSON.stringify(omitKeyArgs(args)) }`); const result = originalHandler.apply(this, originalArgs); end(); return result; @@ -79,7 +84,7 @@ const originalMeteorPublish = Meteor.publish; Meteor.publish = function(name, func) { return originalMeteorPublish(name, function(...args) { traceConnection(Log_Trace_Subscriptions, Log_Trace_Subscriptions_Filter, 'subscription', name, this.connection, this.userId); - logger.publish(name, '-> userId:', this.userId, ', arguments: ', args); + logger.publish(() => `${ name } -> userId: ${ this.userId }, arguments: ${ JSON.stringify(omitKeyArgs(args)) }`); const end = metrics.meteorSubscriptions.startTimer({ subscription: name }); const originalReady = this.ready;