diff --git a/lib/plugins/output-filter/dropEventsFilter.js b/lib/plugins/output-filter/dropEventsFilter.js index 8a1778e4..85fb026f 100644 --- a/lib/plugins/output-filter/dropEventsFilter.js +++ b/lib/plugins/output-filter/dropEventsFilter.js @@ -6,8 +6,8 @@ function testCondition (data, fieldName, condition) { } function logStatus (debug, a, b, c, d) { - if (debug === 'true') { - consoleLogger.log(JSON.stringify(['drop-filter-events plugin:', a, b, c])) + if (debug != false) { + consoleLogger.debug(`drop-events plugin: ${a} ${b} ${c} ${d}`.replace(/undefined/g, '-')) } } @@ -26,23 +26,27 @@ function dropEventsFilter (context, config, eventEmitter, data, callback) { var exclude = config.filters[config.keys[i]].exclude if (config.filters[config.keys[i]].include) { drop = (!testCondition(data, config.keys[i], include)) || drop - logStatus(debug, config.keys[i], 'include', drop) + logStatus(debug, config.keys[i], 'include', drop, config.filters[config.keys[i]].include) } if (config.filters[config.keys[i]].exclude) { drop = testCondition(data, config.keys[i], exclude) || drop - logStatus(debug, config.keys[i], 'exclude', drop) + logStatus(debug, config.keys[i], 'exclude', drop, config.filters[config.keys[i]].exclude) } } - logStatus('filter result', drop) + logStatus(debug, 'filter result', drop) if (drop) { - logStatus(debug, 'drop', data) + if (debug) { + logStatus(debug, 'drop', JSON.stringify(data)) + } return callback(new Error('drop filter')) } else { - logStatus(debug, 'pass', data) + if (debug) { + logStatus(debug, 'pass', JSON.stringify(data)) + } return callback(null, data) } } catch (ex) { - logStatus(debug, ex) + logStatus(debug, 'exceptoion', ex) // pass events in case of error return callback(null, data) }