<commit_before>var util = require('util')

var output
var LEVELS = {
  VERBOSE: 1,
  INFO: 2,
  WARN: 3,
  ERROR: 4,
  SILENT: 5
}

module.exports = {
  levels: LEVELS,

  read: function () {
    return output
  },

  reset: function () {
    output = ''
    module.exports.level(LEVELS.INFO)
  },

  level: function (level) {
    for (var l in LEVELS) {
      var methodName = l.toLowerCase()
      if (normalize(level) <= LEVELS[l]) {
        module.exports[methodName] = console.error
      } else {
        module.exports[methodName] = silentLogger
      }
    }
  }
}

module.exports.reset()

// private

function normalize (level) {
  for (var l in LEVELS) {
    if (level === LEVELS[l] ||
      l === String(level).toUpperCase()) {
      return LEVELS[l]
    }
  }

  return LEVELS.INFO
}

function silentLogger () {
  output += util.format.apply(util, arguments) + '\n'
}<commit_msg>Strip the stacktrace from printed errors<commit_after>var util = require('util')

var output
var LEVELS = {
  VERBOSE: 1,
  INFO: 2,
  WARN: 3,
  ERROR: 4,
  SILENT: 5
}

module.exports = {
  levels: LEVELS,

  read: function () {
    return output
  },

  reset: function () {
    output = ''
    module.exports.level(LEVELS.INFO)
  },

  level: function (level) {
    for (var l in LEVELS) {
      var methodName = l.toLowerCase()
      if (normalize(level) <= LEVELS[l]) {
        module.exports[methodName] = formatError(console.error)
      } else {
        module.exports[methodName] = silentLogger
      }
    }
  }
}

module.exports.reset()

// private

function normalize (level) {
  for (var l in LEVELS) {
    if (level === LEVELS[l] ||
      l === String(level).toUpperCase()) {
      return LEVELS[l]
    }
  }

  return LEVELS.INFO
}

function formatError (f) {
  return function () {
    f.apply(null, Array.from(arguments, function (arg) {
      return arg instanceof Error ? arg.message : arg
    }))
  }
}

function silentLogger () {
  output += util.format.apply(util, arguments) + '\n'
}
{'fraction_non_alphanumeric': 0.14364364364364365, 'fraction_numerical': 0.005005005005005005, 'mean_word_length': 2.5953237410071943, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2161854', 'n_tokens_mistral': 738, 'n_tokens_neox': 718, 'n_words': 164}