import { MESSAGE_COLOR_BY_LEVEL } from '../constants' ; const DEFAULT_COLOR = MESSAGE_COLOR_BY_LEVEL . info ; const TIMESTAMP_COLOR = '50' ; const LABEL_COLOR = '33' ; export function colorizeTimestamp ( timestamp ) { return colorize ( TIMESTAMP_COLOR , timestamp ) ; } export function colorizeLevel ( level ) { return colorize ( MESSAGE_COLOR_BY_LEVEL [ level ] || DEFAULT_COLOR , level ) ; } export function colorizeLabel ( label ) { return colorize ( LABEL_COLOR , label ) ; } export function colorizeMessage ( level , message ) { return colorize ( MESSAGE_COLOR_BY_LEVEL [ level ] || DEFAULT_COLOR , message ) ; } function colorize ( color , message ) { return [ '\x1b[' , color , 'm' , message , '\x1b[0m' ] . join ( '' ) ; }