<commit_before>'use strict';

const express = require('express');
const events = require('events');
const http = require('http');
const Promise = require('bluebird');
const chalk = require('chalk');

const logger = require('./logger');
const config = require('./config');
const middleware = require('./middleware');

class Ekko {

  constructor(configPath) {
    this._configPath = configPath;
    config.events = new events.EventEmitter();
  }

  start(options) {

    config.path = this._configPath;
    config.set(options);

    config.app = express();
    config.router = new express.Router();

    middleware.headers();
    if (config.middleware) {
      config.middleware();
    } else {
      middleware.config();
    }

    const port = config.options.servers.web.port || 0;
    config.app.set('port', port);
    config.server = http.createServer(config.app);

    return new Promise((resolve, reject) => {

      config.server.listen(config.options.servers.web.port, () => {

        const url = `http://localhost:${config.server.address().port}`;
        logger.info(`Started ${chalk.yellow('Ekko')} server on ${chalk.green(url)}`);

        config.events.emit(config.constants.EVENTS.START, {
          options: config.options
        });

        resolve(true);

      });

      config.server.on('error', (e) => {

        if (e.errno === 'EADDRINUSE') {
          logger.error('Cannot start server on PORT %s. Check if port is already in use.', config.options.servers.web.port);
        } else {
          logger.error('Failed to start server on PORT %s', config.options.servers.web.port);
        }

        reject(new Error(e));

      });

    });

  }

  stop() {

    return new Promise((resolve) => {

      if (config.server && config.server.close) {
        config.server.close(() => {
          config.events.emit(config.constants.EVENTS.STOPPED);
          resolve(true);
        });
      } else {
        config.events.emit(config.constants.EVENTS.STOPPED);
        resolve(true);
      }

    });

  }
<commit_msg>convert log messages to es6<commit_after>'use strict';

const express = require('express');
const events = require('events');
const http = require('http');
const Promise = require('bluebird');
const chalk = require('chalk');

const logger = require('./logger');
const config = require('./config');
const middleware = require('./middleware');

class Ekko {

  constructor(configPath) {
    this._configPath = configPath;
    config.events = new events.EventEmitter();
  }

  start(options) {

    config.path = this._configPath;
    config.set(options);

    config.app = express();
    config.router = new express.Router();

    middleware.headers();
    if (config.middleware) {
      config.middleware();
    } else {
      middleware.config();
    }

    const port = config.options.servers.web.port || 0;
    config.app.set('port', port);
    config.server = http.createServer(config.app);

    return new Promise((resolve, reject) => {

      config.server.listen(config.options.servers.web.port, () => {

        const url = `http://localhost:${config.server.address().port}`;
        logger.info(`Started ${chalk.yellow('Ekko')} server on ${chalk.green(url)}`);

        config.events.emit(config.constants.EVENTS.START, {
          options: config.options
        });

        resolve(true);

      });

      config.server.on('error', (e) => {

        if (e.errno === 'EADDRINUSE') {
          logger.error(`Cannot start server on PORT ${config.options.servers.web.port}. Check if port is already in use.`);
        } else {
          logger.error(`Failed to start server on PORT ${config.options.servers.web.port}`);
        }

        reject(new Error(e));

      });

    });

  }

  stop() {

    return new Promise((resolve) => {

      if (config.server && config.server.close) {
        config.server.close(() => {
          config.events.emit(config.constants.EVENTS.STOPPED);
          resolve(true);
        });
      } else {
        config.events.emit(config.constants.EVENTS.STOPPED);
        resolve(true);
      }

    });

  }

{'fraction_non_alphanumeric': 0.1621885686370298, 'fraction_numerical': 0.0007327796775769418, 'mean_word_length': 2.614298323036187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3549307', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1199, 'n_words': 236}