<commit_before>'use strict';

let _            = require('lodash');
let JsonDsl      = require('./dsl/JsonDsl');
let EventEmitter = require('events');
let Logger       = require('./Logger');

class Processor extends EventEmitter {

  constructor(config) {
    super();
    config = config || {};

    this.sources      = {};
    this.logger       = Logger.getGlobalLogger();
    this.dsl          = new JsonDsl();

    if (config) {
      this.configure(config);
    }
  }

  configure(sourcesConfig) {
    this.sources = this.dsl.parse(sourcesConfig);
  }

  listen() {
    let promises = _.map(this.sources, (source) => {

      source.on('eventProcessed', (evt) => {
        this.emit('eventProcessed', evt);
        this.logger('debug', 'eventProcessed', evt);
      });

      source.on('eventProcessingError', (err) => {
        this.emit('eventProcessingError', err);
        this.logger('error', 'eventProcessingError', err);
      });

      return source.listen();
    });

    return Promise.all(promises);
  }

}

module.exports = Processor;<commit_msg>fixed logger error on pipeline fail<commit_after>'use strict';

let _            = require('lodash');
let JsonDsl      = require('./dsl/JsonDsl');
let EventEmitter = require('events');
let Logger       = require('./Logger');

class Processor extends EventEmitter {

  constructor(config) {
    super();
    config = config || {};

    this.sources      = {};
    this.logger       = Logger.getGlobalLogger();
    this.dsl          = new JsonDsl();

    if (config) {
      this.configure(config);
    }
  }

  configure(sourcesConfig) {
    this.sources = this.dsl.parse(sourcesConfig);
  }

  listen() {
    let promises = _.map(this.sources, (source) => {

      source.on('eventProcessed', (evt) => {
        this.emit('eventProcessed', evt);
        this.logger.log('debug', 'eventProcessed', evt);
      });

      source.on('eventProcessingError', (err) => {
        this.emit('eventProcessingError', err);
        this.logger.log('error', 'eventProcessingError', err);
      });

      return source.listen();
    });

    return Promise.all(promises);
  }

}

module.exports = Processor;
{'fraction_non_alphanumeric': 0.16111111111111112, 'fraction_numerical': 0.0, 'mean_word_length': 2.6258389261744965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2047533', 'n_tokens_mistral': 654, 'n_tokens_neox': 642, 'n_words': 120}