<commit_before>import LOGLEVEL from "./loglevel";


/**
 */
export default class AbstractLogger {
  getLogLevel() {
    throw new Error('Must be overridden in subclasses.');
  }

  _noOutput() {

  }

  /**
   * Exposes console.log. Will only print if current level is
   * higher than or equal to {@link LogLevels#DEBUG}.
   * @returns {Function} console.log
   */
  get debug() {
    if (this.getLogLevel() >= LOGLEVEL.DEBUG) {
      return console.log.bind(console);
    }
    return this._noOutput;
  }

  /**
   * Exposes console.log. Will only print if current level is
   * higher than or equal to {@link LogLevels#INFO}.
   * @returns {Function} console.log
   */
  get info() {
    if (this.getLogLevel() >= LOGLEVEL.INFO) {
      return console.log.bind(console);
    }
    return this._noOutput;
  }

  /**
   * Exposes console.warn. Will only print if current level is
   * higher than or equal to {@link LogLevels#WARNING}.
   * @returns {Function} console.warn
   */
  get warning() {
    if(this.getLogLevel() >= LOGLEVEL.WARNING) {
      return console.warn.bind(console);
    }
    return this._noOutput;
  }

  /**
   * Exposes console.error. Will only print if current level is
   * higher than or equal to {@link LogLevels#ERROR}.
   * @returns {Function} console.error
   */
  get error() {
    if (this.getLogLevel() >= LOGLEVEL.ERROR) {
      return console.error.bind(console);
    }
    return this._noOutput;
  }

  /**
   * Calls the provided function if loglevel is higher
   * than or equal to {@link LogLevels#DEBUG}.
   *
   * @param {function} callable
   */
  ifDebug(callable) {
    if (this.getLogLevel() >= LOGLEVEL.DEBUG) {
        callable();
    }
  }

  /**
   * Calls the provided function if loglevel is higher
   * than or equal to {@link LogLevels#INFO}.
   *
   * @param {function} callable
   */
  ifInfo(callable) {
    if (this.getLogLevel() >= LOGLEVEL.INFO) {
        callable();
    }
  }

  /**
   * Calls the provided function if loglevel is higher
   * than or equal to {@link LogLevels#WARNING}.
   *
   * @param {function} callable
   */
  ifWarning(callable) {
    if (this.getLogLevel() >= LOGLEVEL.WARNING) {
        callable();
    }
  }

  /**
   * Calls the provided function if loglevel is higher
   * than or equal to {@link LogLevels#ERROR}.
   *
   * @param {function} callable
   */
  ifError(callable) {
    if (this.getLogLevel() >= LOGLEVEL.ERROR) {
        callable();
    }
  }

}<commit_msg>jsbase...AbstractLogger: Replace deferred logger functions with is<Level> getters.<commit_after>import LOGLEVEL from "./loglevel";


/**
 */
export default class AbstractLogger {
  getLogLevel() {
    throw new Error('Must be overridden in subclasses.');
  }

  /**
   * Returns ``true`` if loglevel is higher
   * than or equal to {@link LogLevels#DEBUG}.
   */
  get isDebug() {
    return this.getLogLevel() >= LOGLEVEL.DEBUG;
  }

  /**
   * Returns ``true`` if loglevel is higher
   * than or equal to {@link LogLevels#INFO}.
   */
  get isInfo() {
    return this.getLogLevel() >= LOGLEVEL.INFO;
  }

  /**
   * Returns ``true`` if loglevel is higher
   * than or equal to {@link LogLevels#WARNING}.
   */
  get isWarning() {
    return this.getLogLevel() >= LOGLEVEL.WARNING;
  }

  /**
   * Returns ``true`` if loglevel is higher
   * than or equal to {@link LogLevels#ERROR}.
   */
  get isError() {
    return this.getLogLevel() >= LOGLEVEL.ERROR;
  }

  _noOutput() {

  }

  /**
   * Exposes console.log. Will only print if current level is
   * higher than or equal to {@link LogLevels#DEBUG}.
   * @returns {Function} console.log
   */
  get debug() {
    if (this.getLogLevel() >= LOGLEVEL.DEBUG) {
      return console.log.bind(console);
    }
    return this._noOutput;
  }

  /**
   * Exposes console.log. Will only print if current level is
   * higher than or equal to {@link LogLevels#INFO}.
   * @returns {Function} console.log
   */
  get info() {
    if (this.getLogLevel() >= LOGLEVEL.INFO) {
      return console.log.bind(console);
    }
    return this._noOutput;
  }

  /**
   * Exposes console.warn. Will only print if current level is
   * higher than or equal to {@link LogLevels#WARNING}.
   * @returns {Function} console.warn
   */
  get warning() {
    if(this.getLogLevel() >= LOGLEVEL.WARNING) {
      return console.warn.bind(console);
    }
    return this._noOutput;
  }

  /**
   * Exposes console.error. Will only print if current level is
   * higher than or equal to {@link LogLevels#ERROR}.
   * @returns {Function} console.error
   */
  get error() {
    if (this.getLogLevel() >= LOGLEVEL.ERROR) {
      return console.error.bind(console);
    }
    return this._noOutput;
  }

}
{'fraction_non_alphanumeric': 0.13414374066965237, 'fraction_numerical': 0.0, 'mean_word_length': 2.630030959752322, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 20, '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': '382479', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1491, 'n_words': 419}