<commit_before>var _ = require('lodash')
var assert = require('assert')

module.exports = function () {
  var log = []

  return {
    write: function () {
      log.push(_(arguments).toArray().join(' '))
    },
    read: function () { return log },
    toString: function () { return log.join('\n') },
    assert: function () {
      var lines = _.toArray(arguments)

      _.each(lines, function (line, i) {
        if (line instanceof RegExp) {
          assert(line.test(log[i]), line.toString() + ' did not match: "' + log[i] + '"')
        } else {
          assert.equal(log[i], line)
        }
      })
    }
  }
}<commit_msg>Make debugging easier by always printing the log<commit_after>var _ = require('lodash')
var assert = require('assert')

module.exports = function () {
  var log = []

  return {
    write: function () {
      log.push(_(arguments).toArray().join(' '))
    },
    read: function () { return log },
    toString: function () { return log.join('\n') },
    assert: function () {
      var lines = _.toArray(arguments)

      try {
        _.each(lines, function (line, i) {
          if (line instanceof RegExp) {
            assert(line.test(log[i]), line.toString() + ' did not match: "' + log[i] + '"')
          } else {
            assert.equal(log[i], line)
          }
        })
      } catch (e) {
        console.error('Error asserting the log. Full log follows:')
        console.log(log)
        throw e
      }
    }
  }
}
{'fraction_non_alphanumeric': 0.1664392905866303, 'fraction_numerical': 0.0, 'mean_word_length': 2.148068669527897, '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': '100980', 'n_tokens_mistral': 455, 'n_tokens_neox': 447, 'n_words': 106}