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 | // @flow import chalk from 'chalk' export default class ColoredLog { _log: Object constructor (level: string = 'info') { this._log = require('console-log-level')({ level }) } trace (msg: string) { this._log.trace(chalk.gray(msg)) } debug (msg: string) { this._log.debug(chalk.green(msg)) } info (msg: string) { this._log.info(chalk.cyan(msg)) } warn (msg: string) { this._log.warn(chalk.yellow(msg)) } error (msg: string) { this._log.error(chalk.red(msg)) } } |