const chalk = require('chalk')

const INFO_COLOR = 'green'
const ERROR_COLOR = 'red'

/**
 * Logging
 * @param args
 */
const log = {
  plain: (...args) => {
    console.log.bind(console, ...args)()
  },
  info: (...args) => {
    args[0] = '\r' + args[0]
    args.unshift(chalk[INFO_COLOR]._styler.open)
    args.push(chalk[INFO_COLOR]._styler.close)
    console.log.bind(console, ...args)()
  },
  error: (...args) => {
    args[0] = '\r' + args[0]
    args.unshift(chalk[ERROR_COLOR]._styler.open)
    args.push(chalk[ERROR_COLOR]._styler.close)
    console.error.bind(console, ...args)()
  }
}

module.exports = log
