# All files / src/utils logger.ts

68.57% Statements 24/35
50% Branches 3/6
60% Functions 3/5
68.57% Lines 24/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
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    7121x

    21x

    21x

    21x

    21x

    21x

    21x
    8x

    8x

    21x
    6x

    6x

    21x
    9x

    9x

    21x
    21x

    21x
    21x
    21x
    21x
    21x
    21x
    21x

     import winston from 'winston';
    import type { ProgressBar } from '../lib/progress';

    let progressBar: ProgressBar | null = null;

    const setProgressBar = (bar: ProgressBar) => {
      progressBar = bar;
    };
    const removeProgressBar = () => {
      progressBar = null;
    };

    const consoleTransport = new winston.transports.Console({
      colorize: true,
      handleExceptions: true,
      humanReadableUnhandledException: true,
      level: 'debug',
      showLevel: true,
    });

    winston.configure({
      exitOnError: false,
      transports: [consoleTransport],
    });

    // create a wrapper for error messages
    const errorWrap = (input: any) => {
      Iif (progressBar) {
        progressBar.interruptBegin();
        winston.error(input);
        progressBar.interruptEnd();
      } else {
        winston.error(input);
      }
    };

    // create a wrapper for warning messages
    const warnWrap = (input: any) => {
      Iif (progressBar) {
        progressBar.interruptBegin();
        winston.warn(input);
        progressBar.interruptEnd();
      } else {
        winston.warn(input);
      }
    };

    // create a wrapper for info messages
    const infoWrap = (input: any) => {
      Iif (progressBar) {
        progressBar.interruptBegin();
        winston.info(input);
        progressBar.interruptEnd();
      } else {
        winston.info(input);
      }
    };

    const { debug } = winston;
    const { verbose } = winston;

    export {
      errorWrap as error,
      warnWrap as warn,
      infoWrap as info,
      verbose,
      debug,
      setProgressBar,
      removeProgressBar,
    };