<commit_before>var path = require('path');

function addZero(i) {
  if (i < 10) {
    i = '0' + i;
  }
  return i;
}

var pingu = {
  logLevel: 1,
  logDir: path.resolve(path.dirname(require.main.filename), 'log'),
  logFile: 'pingu.log',

  /**
    * set the log level without redefining the class
    */

  setLogLevel: function(level) {
    this.logLevel = level;
    console.log('PINGU: Set log level to ' + level);
  },

  /**
    * check the log level
    */

  checkLogLevel: function() {
    console.log('PINGU: Log level is ' + this.logLevel);
  },

  /**
    * set the log directory without redefining the class
    */

  setLogDir: function(dir) {
    this.logDir = path.resolve(path.dirname(require.main.filename), dir);
    console.log('PINGU: Set log directory to ' + dir);
  },

  /**
    * check the log directory
    */

  checkLogDir: function() {
    console.log('PINGU: Log directory is ' + this.logDir);
  },

  log: function(message) {
     var out = 'PINGU [LOG]: ' + message;
    console.log(out);

    if(this.logLevel <= 1) {
      /* write log */
      this.writeLog(out, 'log');
    }
  },

  warn: function(message) {
     var out = 'PINGU [WARN]: ' + message;
    console.warn(out);
    console.trace();

    if(this.logLevel <= 2) {
      /* write log */
      this.writeLog(out, 'warn');
    }
  },

  error: function(message) {
     var out = 'PINGU [ERROR]: ' + message;
    console.error(out);
    console.trace();

    if(this.logLevel <= 3) {
      /* write log */
      this.writeLog(out, 'error');
    }
  },

  /**
    * write our messages to the
    */

  writeLog: function(message, type) {
    if(typeof window === 'undefined') {
      var fs = require('fs');
      var logFile = path.join(this.logDir, this.logFile);

      var now = new Date();
      var date = now.getFullYear() + '-' + addZero(( now.getMonth() + 1 )) + '-' + addZero(now.getDate());
      var time = addZero(now.getHours()) + ':' + addZero(now.getMinutes()) + ':' + addZero(now.getSeconds());
      var dateTime = date + ' ' + time;

      try {

        if (!fs.existsSync(this.logDir)) {
          fs.mkdirSync(this.logDir);
        }

         var append = '[' + dateTime + '] ' + message + '\r\n';<commit_msg>Adding dir function back in as it was accidentally removed in 0.3.0. Additionally tidying up some spacing.<commit_after>var path = require('path');

function addZero(i) {
  if (i < 10) {
    i = '0' + i;
  }
  return i;
}

var pingu = {
  logLevel: 1,
  logDir: path.resolve(path.dirname(require.main.filename), 'log'),
  logFile: 'pingu.log',

  /**
    * set the log level without redefining the class
    */

  setLogLevel: function(level) {
    this.logLevel = level;
    console.log('PINGU: Set log level to ' + level);
  },

  /**
    * check the log level
    */

  checkLogLevel: function() {
    console.log('PINGU: Log level is ' + this.logLevel);
  },

  /**
    * set the log directory without redefining the class
    */

  setLogDir: function(dir) {
    this.logDir = path.resolve(path.dirname(require.main.filename), dir);
    console.log('PINGU: Set log directory to ' + dir);
  },

  /**
    * check the log directory
    */

  checkLogDir: function() {
    console.log('PINGU: Log directory is ' + this.logDir);
  },

  log: function(message) {
    var out = 'PINGU [LOG]: ' + message;
    console.log(out);

    if(this.logLevel <= 1) {
      /* write log */
      this.writeLog(out, 'log');
    }
  },
  
  dir: function(message) {
    var out = 'PINGU [DIR]: ';
    console.log(out);
    console.dir(message);

    if(this.logLevel <= 1) {
      /* write log */
      this.writeLog(JSON.stringify(message), 'log');
    }
  },

  warn: function(message) {
    var out = 'PINGU [WARN]: ' + message;
    console.warn(out);
    console.trace();

    if(this.logLevel <= 2) {
      /* write log */
      this.writeLog(out, 'warn');
    }
  },

  error: function(message) {
    var out = 'PINGU [ERROR]: ' + message;
    console.error(out);
    console.trace();

    if(this.logLevel <= 3) {
      /* write log */
      this.writeLog(out, 'error');
    }
  },

  /**
    * write our messages to the
    */

  writeLog: function(message, type) {
    if(typeof window === 'undefined') {
      var fs = require('fs');
      var logFile = path.join(this.logDir, this.logFile);

      var now = new Date();
      var date = now.getFullYear() + '-' + addZero(( now.getMonth() + 1 )) + '-' + addZero(now.getDate());
      var time = addZero(now.getHours()) + ':' + addZero(now.getMinutes()) + ':' + addZero(now.getSeconds());
      var dateTime = date + ' ' + time;

      try {

        if (!fs.existsSync(this.logDir)) {
          fs.mkdirSync(this.logDir);
        }

         var append = '[' + dateTime + '] ' + message + '\r\n';
{'fraction_non_alphanumeric': 0.1723631788634934, 'fraction_numerical': 0.004193751310547285, 'mean_word_length': 2.382978723404255, 'pattern_counts': {'":': 0, '<': 12, '<?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': '1383100', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1614, 'n_words': 373}