import {ERROR, WARN, INFO, DEBUG} from './logger/level.js';

/**
 * A logging class that can be used with most functions to provide status output
 * @param {Object} args the arguments for the class
 * @param {Object} [args.logger=console] the underlying logger that will be used to output the logging messages
 * @param {number} [args.level=logger.level.WARN] the logging level
 */
export default class {
  constructor({console=console, level=WARN} = {}) {
    Object.defineProperties(this, {
      level: {value: level, writable: true},
      console: {value: console}
    });
  }

  /**
   * Logs a debug message, this is usually useful to developers
   * @param {...*} args the objects to log
   */
  debug(...args) {
    if (DEBUG <= this.level) {
      this.console.debug(...args);
    }
  }

  /**
   * Logs a message that would be useful to a user
   * @param {...*} args the objects to log
   */
  info(...args) {
    if (INFO <= this.level) {
      this.console.info(...args);
    }
  }

  /**
   * Logs a recoverable error
   * @param {...*} args the objects to log
   */
  warn(...args) {
    if (WARN <= this.level) {
      this.console.warn(...args);
    }
  }

  /**
   * Logs a non-recoverable error
   * @param {...*} args the objects to log
   */
  error(...args) {
    if (ERROR <= this.level) {
      this.console.error(...args);
    }
  }
}

@@ -54,16 +54,36 @@
 l.js';%0A%0A
+const c = console;%0A%0A
 /**%0A * A
@@ -442,22 +442,16 @@
 onsole=c
-onsole
 , level=

Fix circular console references