# All files / src/utils logger.ts

61.76% Statements 21/34
33.33% Branches 2/6
40% Functions 2/5
61.76% Lines 21/34

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
    7025x

    25x

    25x

    25x

    25x

    25x
    4x

    4x

    25x
    18x

    18x

    25x

    25x
    25x

    25x
    25x
    25x
    25x
    25x
    25x
    25x

     import winston from 'winston';

    let progressBar: any;

    const setProgressBar = (bar: any) => {
      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 warnWarp = (input: any) => {
      Iif (progressBar) {
        progressBar.interruptBegin();
        winston.warn(input);
        progressBar.interruptEnd();
      } else {
        winston.warn(input);
      }
    };

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

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

    export {
      errorWrap as error,
      warnWarp as warn,
      infoWarp as info,
      verbose,
      debug,
      setProgressBar,
      removeProgressBar,
    };