import * as chalk from 'chalk' ; import * as ProgressBar from 'progress' ; class Logger { private prefixLength = 8 ; public info ( ... params ) { const prefix = chalk . blue ( this . padPrefix ( 'info' ) ) ; console . log ( prefix , ... params ) ; } public warn ( ... params ) { const prefix = chalk . yellow ( this . padPrefix ( 'warn' ) ) ; console . log ( prefix , ... params ) ; } public error ( ... params ) { const prefix = chalk . red ( this . padPrefix ( 'error' ) ) ; console . error ( prefix , ... params ) ; } public success ( ... params ) { const prefix = chalk . green ( this . padPrefix ( 'success' ) ) ; console . error ( prefix , ... params ) ; } public progress ( total = 100 ) { const prefix = chalk . cyan ( this . padPrefix ( 'progress' ) ) ; return new ProgressBar ( `${ prefix } [:bar] :percent` , { complete : '=' , incomplete : ' ' , width : 50 , total , } ) ; } private padPrefix ( prefix ) { return ' ' . repeat ( this . prefixLength - prefix . length ) + prefix ; } } export const logger = new Logger ( ) ;