import chalk from 'chalk' ; import { LogRecord , LogLevel } from '@osd/logging' ; import { Conversion } from './type' ; const LEVEL_COLORS = new Map ( [ [ LogLevel . Fatal , chalk . red ] , [ LogLevel . Error , chalk . red ] , [ LogLevel . Warn , chalk . yellow ] , [ LogLevel . Debug , chalk . green ] , [ LogLevel . Trace , chalk . blue ] , ] ) ; export const LevelConversion = { pattern : /%level/g , convert ( record , highlight ) { let message = record . level . id . toUpperCase ( ) . padEnd ( 5 ) ; if ( highlight && LEVEL_COLORS . has ( record . level ) ) { const color = LEVEL_COLORS . get ( record . level ) ! ; message = color ( message ) ; } return message ; } , } ;