/* eslint-disable no-console */
import { Logger } from './Logger.js'

export enum LogLevel {
  Silly,
  Debug,
  Verbose,
  Info,
  Warn,
  Error,
  Silent,
}

export interface LoggerConfig {
  level?: LogLevel
}

export class DefaultLogger extends Logger {
  level: LogLevel = LogLevel.Info

  constructor(config: LoggerConfig = {}) {
    super()
    if (typeof config.level !== 'undefined') {
      this.level = config.level
    }
  }

  warn(...args: unknown[]): void {
    if (this.level > LogLevel.Warn) return
    console.warn(...args)
  }

  info(...args: unknown[]): void {
    if (this.level > LogLevel.Info) return
    console.info(...args)
  }

  error(...args: unknown[]): void {
    if (this.level > LogLevel.Error) return
    console.error(...args)
  }

  log(...args: unknown[]): void {
    if (this.level > LogLevel.Debug) return
    console.log(...args)
  }

  debug(...args: unknown[]): void {
    if (this.level > LogLevel.Debug) return
    console.debug(...args)
  }
}
