<commit_before>//Define the logger.
var Logger = exports.Logger = function (options) {

};<commit_msg>Add the logger.js<commit_after>// Generated by CoffeeScript 1.6.2
(function() {
  var Config, Levels, Logger, Message;

  Levels = (function() {
    function Levels() {}

    Levels.prototype.fatal = {
      name: "Fatal",
      value: 0
    };

    Levels.prototype.error = {
      name: "Error",
      value: 1
    };

    Levels.prototype.warn = {
      name: "Warn",
      value: 2
    };

    Levels.prototype.info = {
      name: "Info",
      value: 3
    };

    Levels.prototype.debug = {
      name: "Debug",
      value: 4
    };

    Levels.prototype.trace = {
      name: "Trace",
      value: 5
    };

    Levels.prototype.toJSON = function() {
      var json;

      json = {
        fatal: {
          name: "Fatal",
          value: 0
        },
        error: {
          name: "Error",
          value: 1
        },
        warn: {
          name: "Warn",
          value: 2
        },
        info: {
          name: "Info",
          value: 3
        },
        debug: {
          name: "Debug",
          value: 4
        },
        trace: {
          name: "Trace",
          value: 5
        }
      };
      return json;
    };

    return Levels;

  })();

  if (typeof module === 'undefined' && typeof window !== 'undefined') {
    window.Levels = Levels;
  } else {
    module.exports = Levels;
  }

  Config = (function() {
    function Config() {}

    Config.prototype.max = 10;

    Config.prototype.outputs = ['console'];

    return Config;

  })();

  if (typeof module === 'undefined' && typeof window !== 'undefined') {
    window.Config = Config;
  } else {
    module.exports = Config;
  }

  if (typeof module === 'undefined' && typeof window !== 'undefined') {
    Levels = window.Levels;
    Message = window.Message;
  } else {
    Levels = require('./levels');
    Message = require('./message');
  }

  Logger = (function() {
    function Logger(name, level, options) {
      this.name = name != null ? name : "noName";
      this.level = level != null ? level : "info";
      this.options = options != null ? options : {};
      this.outputs = this.options.outputs || ['console'];
      this.is = {};
      this.messages = [];
      this.levels = new Levels();
      this.parseOutputs();
      this.log('info', "The logger has started.");
    }

    Logger.prototype.log = function(level, message) {
      if ((this.levels[level] != null) && this.levels[level].value >= this.levels[this.level].value) {
        if (this.messages.length > (this.options.max || 9)) {
          this.save();
        }
        message = new Message(level, message);
        if (this.is.console) {
          console[level](message.toString());
        }
        return this.messages.push(message);
      }
    };

    Logger.prototype.trace = function(message) {
      return this.log('trace', message);
    };

    Logger.prototype.warn = function(message) {
      return this.log('warn', message);
    };

    Logger.prototype.info = function(message) {
      return this.log('info', message);
    };

    Logger.prototype.debug = function(message) {
      return this.log('debug', message);
    };

    Logger.prototype.error = function(message) {
      return this.log('error', message);
    };

    Logger.prototype.parseOutputs = function() {
      var out, _i, _len, _ref, _results;

      this.is = this.is || {};
      _ref = this.outputs;
      _results = [];
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        out = _ref[_i];
        switch (out) {
          case 'console':
            _results.push(this.is.console = true);
            break;
          case 'localStorage':
            _results.push(this.is.localStorage = (typeof window !== "undefined" && window !== null) && (window.localStorage != null));
            break;
          case 'file':
            _results.push(this.is.file = true);
            break;
          case 'server':
            _results.push(this.is.server = true);
            break;
          default:
            _results.push(void 0);
        }
      }
      return _results;
    };

    Logger.prototype.clear = function() {
      return this.messages.length = 0;
    };

    Logger.prototype.display = function() {
      var message, _i, _len, _ref, _results;

      _ref = this.messages;
      _results = [];
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        message = _ref[_i];
        _results.push(message.toString());
      }
      return _results;
    };

    Logger.prototype.save = function() {
      if (this.is.localStorage) {
        localStorage.setItem(this.name, JSON.stringify(this.messages));
      }
      return this.clear();
    };

    return Logger;

  })();

  if (typeof module === 'undefined' && typeof window !== 'undefined') {
    window.Logger = Logger;
  } else {
    module.exports = Logger;
  }

  if (typeof module === 'undefined' && typeof window !== 'undefined') {
    Levels = window.Levels;
  } else {
    Levels = require('./levels');
  }

  Message = (function() {
    function Message(level, message) {
      this.level = level;
      this.message = message;
      this.date = new Date();
      this.levels = new Levels();
    }

    Message.prototype.toString = function() {
      return "" + this.levels[this.level].name + " : " + this.message + " at: " + this.date;
    };

    Message.prototype.toJSON = function() {
      return {
        "level": this.level,
        "message": this.message,
        "label": this.toString(),
        "date": this.date
      };
    };

    return Message;

  })();

  if (typeof module === 'undefined' && typeof window !== 'undefined') {
    window.Message = Message;
  } else {
    module.exports = Message;
  }

}).call(this);
{'fraction_non_alphanumeric': 0.15579273541056982, 'fraction_numerical': 0.003787226717163023, 'mean_word_length': 1.9254783484390736, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, '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': '3561958', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1720, 'n_words': 392}