<commit_before>module.exports = function (reporter) {
  reporter.afterRenderListeners.add('requestsLog', this, function (request) {
    return reporter.settings.findValue('requestsLog').then(function (v) {
      v = v || []
      v.unshift({
        template: { shortid: request.template.shortid },
        timestamp: new Date(),
        logs: request.logs || []
      })

      if (v.length > 5) {
        v.pop()
      }

      return reporter.settings.addOrSet('requestsLog', v)
    })
  })

  if (!reporter.renderErrorListeners) {
    return
  }

  reporter.renderErrorListeners.add('failedRequestsLog', this, function (request, response, err) {
    return reporter.settings.findValue('failedRequestsLog').then(function (v) {
      v = v || []
      v.unshift({
        template: { shortid: request.template.shortid },
        timestamp: new Date(),
        logs: request.logs || [],
        error: {
          message: err.message,
          stack: err.stack
        }
      })

      if (v.length > 5) {
        v.pop()
      }

      return reporter.settings.addOrSet('failedRequestsLog', v)
    })
  })
}<commit_msg>pass req to settings<commit_after>module.exports = function (reporter) {
  reporter.afterRenderListeners.add('requestsLog', this, function (request) {
    return reporter.settings.findValue('requestsLog', request).then(function (v) {
      v = v || []
      v.unshift({
        template: { shortid: request.template.shortid },
        timestamp: new Date(),
        logs: request.logs || []
      })

      if (v.length > 5) {
        v.pop()
      }

      return reporter.settings.addOrSet('requestsLog', v, request)
    })
  })

  if (!reporter.renderErrorListeners) {
    return
  }

  reporter.renderErrorListeners.add('failedRequestsLog', this, function (request, response, err) {
    return reporter.settings.findValue('failedRequestsLog', request).then(function (v) {
      v = v || []
      v.unshift({
        template: { shortid: request.template.shortid },
        timestamp: new Date(),
        logs: request.logs || [],
        error: {
          message: err.message,
          stack: err.stack
        }
      })

      if (v.length > 5) {
        v.pop()
      }

      return reporter.settings.addOrSet('failedRequestsLog', v, request)
    })
  })
}
{'fraction_non_alphanumeric': 0.14316892186817984, 'fraction_numerical': 0.001745962461807071, 'mean_word_length': 2.3411078717201166, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1827838', 'n_tokens_mistral': 684, 'n_tokens_neox': 682, 'n_words': 133}