<commit_before>// Local Dependencies
const { generateString } = require('./helpers')

// Package Dependencies
const fs = require('fs-extra')
const strip = require('strip-ansi')

/**
 * Object to log to a file as well as the console
 */
class FancylogFile {
  /**
   * @param {string} path Output logfile path
   */
  constructor (path) {
    if (path === undefined || path === null || path === '') throw new Error('Path cannot be undefined or a blank string')

    /**
     * @type {string}
     */
    this.path = path
  }

  /**
   * Internal Helper Logging File
   * @private
   * @param {*} value Log Input
   * @param {string} level Level String ID
   */
  _log (value, level) {
    let string = `${generateString(value, level)}\n`
    console.log(string)

    fs.ensureFile(this.path)
      .then(() => fs.appendFile(this.path, strip(string)))
      .catch(err => { throw err })
  }

  /**
   * Logs an object at INFO Level
   * @param {*} value Value to output
   */
  info (value) { this._log(value, 'info') }

  /**
   * Logs an object at DEBUG Level
   * @param {*} value Value to output
   */
  debug (value) { this._log(value, 'debug') }

  /**
   * Logs an object at ERROR Level
   * @param {*} value Value to output
   */
  error (value) { this._log(value, 'error') }

  /**
   * Logs an object at VERBOSE Level
   * @param {*} value Value to output
   */
  verbose (value) { this._log(value, 'verbose') }

  /**
   * Logs an object at WARN Level
   * @param {*} value Value to output
   */
  warn (value) { this._log(value, 'warn') }

  /**
   * Logs an object at INFO Level
   * @param {*} value Value to output
   */
  i (value) { this._log(value, 'info') }
  
  /**
   * Logs an object at DEBUG Level
   * @param {*} value Value to output
   */<commit_msg>linting<commit_after>// Local Dependencies
const { generateString } = require('./helpers')

// Package Dependencies
const fs = require('fs-extra')
const strip = require('strip-ansi')

/**
 * Object to log to a file as well as the console
 */
class FancylogFile {
  /**
   * @param {string} path Output logfile path
   */
  constructor (path) {
    if (path === undefined || path === null || path === '') throw new Error('Path cannot be undefined or a blank string')

    /**
     * @type {string}
     */
    this.path = path
  }

  /**
   * Internal Helper Logging File
   * @private
   * @param {*} value Log Input
   * @param {string} level Level String ID
   */
  _log (value, level) {
    let string = `${generateString(value, level)}\n`
    console.log(string)

    fs.ensureFile(this.path)
      .then(() => fs.appendFile(this.path, strip(string)))
      .catch(err => { throw err })
  }

  /**
   * Logs an object at INFO Level
   * @param {*} value Value to output
   */
  info (value) { this._log(value, 'info') }

  /**
   * Logs an object at DEBUG Level
   * @param {*} value Value to output
   */
  debug (value) { this._log(value, 'debug') }

  /**
   * Logs an object at ERROR Level
   * @param {*} value Value to output
   */
  error (value) { this._log(value, 'error') }

  /**
   * Logs an object at VERBOSE Level
   * @param {*} value Value to output
   */
  verbose (value) { this._log(value, 'verbose') }

  /**
   * Logs an object at WARN Level
   * @param {*} value Value to output
   */
  warn (value) { this._log(value, 'warn') }

  /**
   * Logs an object at INFO Level
   * @param {*} value Value to output
   */
  i (value) { this._log(value, 'info') }

  /**
   * Logs an object at DEBUG Level
   * @param {*} value Value to output
   */
{'fraction_non_alphanumeric': 0.15649717514124295, 'fraction_numerical': 0.0, 'mean_word_length': 2.5445445445445447, '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': '7078380', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1137, 'n_words': 374}