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 | 1x 1x 1x 1x 1x 5x 5x 5x 1x 1x 1x 14x 14x 60x 60x 75x 75x 75x | import { config } from './config'
export const levels = [
'debug',
'info',
'warn',
'error',
'none'
]
const levelToInt: {[level: string]: number} = {}
const intToLevel: {[int: number]: string} = {}
for (let index = 0; index < levels.length; index++) {
const level = levels[index]
levelToInt[level] = index
intToLevel[index] = level
}
export class Logger {
static error(message: string) {
if (!this.shouldLog('error')) return
console.error(this.logMessage('error', message))
}
static warn(message: string) {
Iif (!this.shouldLog('warn')) return
console.warn(this.logMessage('warn', message))
}
static info(message: string) {
Iif (!this.shouldLog('info')) return
console.log(this.logMessage('info', message))
}
static debug(message: string) {
Iif (!this.shouldLog('debug')) return
console.log(this.logMessage('debug', message))
}
static logMessage(level: string, message: string) {
return `[${level.toUpperCase()}] ${message}`
}
static shouldLog(level: string) {
const currentLevel = levelToInt[config.logLevel]
return currentLevel <= levelToInt[level]
}
}
|