# All files / utils Severity.ts

100% Statements 18/18
93.75% Branches 15/16
100% Functions 3/3
100% Lines 18/18

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

    3x
    3x
    3x
    3x

    3x

    3x
    12x

    1x

    3x

    2x

    5x

    1x

     /** 等级程度枚举 */
    export enum Severity {
      Else = 'else',
      Error = 'error',
      Warning = 'warning',
      Info = 'info',
      Debug = 'debug',
      /** 上报的错误等级 */
      Low = 'low',
      Normal = 'normal',
      High = 'high',
      Critical = 'critical'
    }

    // eslint-disable-next-line @typescript-eslint/no-namespace
    export namespace Severity {
      /**
       * Converts a string-based level into a {@link Severity}.
       *
       * @param level string representation of Severity
       * @returns Severity
       */
      export function fromString(level: string): Severity {
        switch (level) {
          case 'debug':
            return Severity.Debug
          case 'info':
          case 'log':
          case 'assert':
            return Severity.Info
          case 'warn':
          case 'warning':
            return Severity.Warning
          case Severity.Low:
          case Severity.Normal:
          case Severity.High:
          case Severity.Critical:
          case 'error':
            return Severity.Error
          default:
            return Severity.Else
        }
      }
    }