Code coverage report for core/src/log/LogLevel.ts

Statements: 85% (17 / 20)      Branches: 50% (1 / 2)      Functions: 50% (3 / 6)      Lines: 84.21% (16 / 19)      Ignored: none     

All files » core/src/log/ » LogLevel.ts
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 481     10                           1       10 10         2                 1 1 1 1 1 1 1 1 1 1    
export class LogLevel {
 
 
  protected constructor(readonly name: string, readonly severity: number) {
  }
 
 
  gte(other: LogLevel): boolean {
    return this.severity >= other.severity;
  }
 
 
  lte(other: LogLevel): boolean {
    return this.severity <= other.severity;
  }
 
 
  private static readonly levels: Record<string, LogLevel> = {};
 
 
  static register(level: LogLevel): LogLevel {
    LogLevel.levels[level.name] = level;
    return level;
  }
 
 
  static forName(name: string | undefined): LogLevel | undefined {
    return name ? LogLevel.levels[name] : undefined;
  }
 
 
  static names(): string[] {
    return Object.keys(LogLevel.levels);
  }
 
 
  static TRACE = LogLevel.register(new LogLevel('trace', 0));
  static DEBUG = LogLevel.register(new LogLevel('debug', 100));
  static INFO = LogLevel.register(new LogLevel('info', 200));
  static LOG = LogLevel.register(new LogLevel('log', 300));
  static NOTICE = LogLevel.register(new LogLevel('notice', 300));
  static WARN = LogLevel.register(new LogLevel('warn', 400));
  static ERROR = LogLevel.register(new LogLevel('error', 500));
  static CRITICAL = LogLevel.register(new LogLevel('critical', 600));
  static ALERT = LogLevel.register(new LogLevel('alert', 700));
  static EMERGENCY = LogLevel.register(new LogLevel('emergency', 800));
}