# All files / src/utils logger.ts

82.5% Statements 33/40
55.56% Branches 10/18
90% Functions 9/10
85.71% Lines 30/35

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    5414x
    14x

    14x
    14x
    14x
    14x
    14x
    14x
    14x
    14x
    84x
    84x

    14x
    1x

    14x
    2x

    14x
    1x

    14x
    3x

    75x
    25x
    25x

    14x

    14x
    2x
    2x

    14x
    14x
    14x
     import { _global, _support } from './global'
    const PREFIX = 'MITO Logger'

    export class Logger {
      private enabled = false
      private _console: Console = {} as Console
      constructor() {
        _global.console = console || _global.console
        Eif (console || _global.console) {
          const logType = ['log', 'debug', 'info', 'warn', 'error', 'assert']
          logType.forEach((level) => {
            Iif (!(level in _global.console)) return
            this._console[level] = _global.console[level]
          })
        }
      }
      disable(): void {
        this.enabled = false
      }

      bindOptions(debug: boolean): void {
        this.enabled = debug ? true : false
      }

      enable(): void {
        this.enabled = true
      }

      getEnableStatus() {
        return this.enabled
      }

      log(...args: any[]): void {
        Eif (!this.enabled) {
          return
        }
        this._console.log(`${PREFIX}[Log]:`, ...args)
      }
      warn(...args: any[]): void {
        if (!this.enabled) {
          return
        }
        this._console.warn(`${PREFIX}[Warn]:`, ...args)
      }
      error(...args: any[]): void {
        Eif (!this.enabled) {
          return
        }
        this._console.error(`${PREFIX}[Error]:`, ...args)
      }
    }
    const logger = _support.logger || (_support.logger = new Logger())
    export { logger }