<commit_before>'use strict';

const Express = require('express');
const favicon = require('serve-favicon');
const LoggingMiddleware = require('turing-logging').Middleware;
const config = require('turing-config');
const morgan = require('morgan');
const logger = require('turing-logging').logger;
const pkg = require(`${__dirname}/package.json`);

function getSpecific(error, port) {
  if (error.syscall !== 'listen') {
    return error;
  }
  switch (error.code) {
    case 'EACCES':
      return new Error(`Port ${port} requires elevated privileges`);
    case 'EADDRINUSE':
      return new Error(`Port ${port} is already in use`);
    default:
      return error;
  }
}

module.exports = class TuringServer extends Express {
  constructor() {
    super();
    this.disable('x-powered-by');
    this.enable('strict routing');

    this.use(favicon(`${__dirname}/public/favicon.ico`));

    this.use(LoggingMiddleware.spy);

    if (config.get('turing:logging:accesslog:enabled')) {
      const format = config.get('turing:logging:accesslog:format');
      this.use(morgan(format, {
        stream: logger.stream({
          type: 'sharing-accesslog',
          logformat: 'COMBINEDAPACHELOG'
        })
      }));
    }

    this.start = () => {
      const port = config.get('turing:server:port');
      const server = config.get('turing:server:onlyIPv4') ? this.listen(port, '0.0.0.0') : this.listen(port);
      server.on('listening', () => {
        logger.info(`${pkg.name} microservice listening on port ${port}!`);
      });
      server.on('error', (error) => {
        const specificError = getSpecific(error, port);
        logger.error(specificError);
        throw specificError;
      });
    };
  }
};<commit_msg>fixed accesslog type<commit_after>'use strict';

const Express = require('express');
const favicon = require('serve-favicon');
const LoggingMiddleware = require('turing-logging').Middleware;
const config = require('turing-config');
const morgan = require('morgan');
const logger = require('turing-logging').logger;
const pkg = require(`${__dirname}/package.json`);

function getSpecific(error, port) {
  if (error.syscall !== 'listen') {
    return error;
  }
  switch (error.code) {
    case 'EACCES':
      return new Error(`Port ${port} requires elevated privileges`);
    case 'EADDRINUSE':
      return new Error(`Port ${port} is already in use`);
    default:
      return error;
  }
}

module.exports = class TuringServer extends Express {
  constructor() {
    super();
    this.disable('x-powered-by');
    this.enable('strict routing');

    this.use(favicon(`${__dirname}/public/favicon.ico`));

    this.use(LoggingMiddleware.spy);

    if (config.get('turing:logging:accesslog:enabled')) {
      const format = config.get('turing:logging:accesslog:format');
      this.use(morgan(format, {
        stream: logger.stream({
          type: `${config.get('turing:logging:namespace')}-accesslog`,
          logformat: 'COMBINEDAPACHELOG'
        })
      }));
    }

    this.start = () => {
      const port = config.get('turing:server:port');
      const server = config.get('turing:server:onlyIPv4') ? this.listen(port, '0.0.0.0') : this.listen(port);
      server.on('listening', () => {
        logger.info(`${pkg.name} microservice listening on port ${port}!`);
      });
      server.on('error', (error) => {
        const specificError = getSpecific(error, port);
        logger.error(specificError);
        throw specificError;
      });
    };
  }
};
{'fraction_non_alphanumeric': 0.1657616461846242, 'fraction_numerical': 0.002857959416976279, 'mean_word_length': 3.3969849246231156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2722485', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1067, 'n_words': 212}