<commit_before>'use strict';

var _ = require('lodash');
var bunyan = require('bunyan');
var log = bunyan.createLogger({
  name: 'http-status-check',
  streams: [{
      path: './httpstatuscheck.log'
    }
  ]
});

var successHits = 0;
var failHits = 0;
var disableHits = 0;

var organizeErrors = function(errors) {
  if(!Array.isArray(errors)){
    if(_.isObject(errors)){
      var accumulator = [];
      for(var property in errors) {
        if(errors.hasOwnProperty(property)){
          accumulator.push(property + ': ' + errors[property]);
        }
      }
      errors = accumulator;
    } else {
      errors = [errors];
    }
  }
  return _.flatten(errors);
};

var writeResult = function(result, uri) {
  switch(result) {
    case 'success':
      log.info('_ ' + uri.name + ' (' + uri.requestUrl + ') working as expected.');
      successHits++;
      break;
    case 'fail':
      log.error('X ' + uri.name + ' (' + uri.requestUrl + ') failed. Here are the problems:');
      if(uri.errors) {
        uri.errors = organizeErrors(uri.errors);
        _.forEach(uri.errors, function(error) { log.error('  - ' + error); } );
      }
      failHits++;
      break;
    case 'disabled':
      log.info('_ ' + uri.name + ' (' + uri.requestUrl + ') testing disabled.');
      disableHits++;
      break;
    default:
      throw new Error('unknown case statement: ' + result);
  }
};

var done = function() {
  log.info('A total of ' + (successHits + failHits + disableHits) + ' URIs were tested.');
  log.info('Failure count: ', failHits);
  log.info('Success count: ', successHits);
  log.info('Disable count: ', disableHits);
};

module.exports = {
  writeResult: writeResult,
  done: done
};
<commit_msg>updated to only log the results<commit_after>'use strict';

var _ = require('lodash');
var bunyan = require('bunyan');
var log = bunyan.createLogger({
  name: 'http-status-check',
  streams: [{
      path: './httpstatuscheck.log'
    }
  ]
});

var successHits = 0;
var failHits = 0;
var disableHits = 0;

var organizeErrors = function(errors) {
  if(!Array.isArray(errors)){
    if(_.isObject(errors)){
      var accumulator = [];
      for(var property in errors) {
        if(errors.hasOwnProperty(property)){
          accumulator.push(property + ': ' + errors[property]);
        }
      }
      errors = accumulator;
    } else {
      errors = [errors];
    }
  }
  return _.flatten(errors);
};

var writeResult = function(result, uri) {
  switch(result) {
    case 'success':
      console.log('_ ' + uri.name + ' (' + uri.requestUrl + ') working as expected.');
      successHits++;
      break;
    case 'fail':
      console.log('X ' + uri.name + ' (' + uri.requestUrl + ') failed. Here are the problems:');
      if(uri.errors) {
        uri.errors = organizeErrors(uri.errors);
        _.forEach(uri.errors, function(error) { console.log('  - ' + error); } );
      }
      failHits++;
      break;
    case 'disabled':
      console.log('_ ' + uri.name + ' (' + uri.requestUrl + ') testing disabled.');
      disableHits++;
      break;
    default:
      throw new Error('unknown case statement: ' + result);
  }
};

var done = function() {
  log.info('A total of ' + (successHits + failHits + disableHits) + ' URIs were tested.');
  log.info('Failure count: ', failHits);
  log.info('Success count: ', successHits);
  log.info('Disable count: ', disableHits);
};

module.exports = {
  writeResult: writeResult,
  done: done
};

{'fraction_non_alphanumeric': 0.1659919028340081, 'fraction_numerical': 0.001735106998264893, 'mean_word_length': 2.7516268980477223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4102442', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1113, 'n_words': 247}