Skip to content

Commit

Permalink
feat: add logger (#113)
Browse files Browse the repository at this point in the history
Add simple logger.
  • Loading branch information
Esemesek authored and thymikee committed Jan 23, 2019
1 parent 61bc288 commit 802e4ec
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/cli/src/util/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// @flow
const chalk = require('chalk');

const SEPARATOR = ', ';

const joinMessages = (messages: Array<string>) => messages.join(SEPARATOR);

const info = (...messages: Array<string>) => {
console.log(
`${chalk.black.bgCyan(' INFO ')} ${chalk.cyan(joinMessages(messages))}`
);
};

const warn = (...messages: Array<string>) => {
console.warn(
`${chalk.black.bgYellow(' WARN ')} ${chalk.yellow(joinMessages(messages))}`
);
};

const error = (...messages: Array<string>) => {
console.error(
`${chalk.black.bgRed(' ERROR ')} ${chalk.red(joinMessages(messages))}`
);
};

const debug = (...messages: Array<string>) => {
console.log(`${chalk.black.bgWhite(' DEBUG ')} ${joinMessages(messages)}`);
};

module.exports = {
info,
warn,
error,
debug,
};

0 comments on commit 802e4ec

Please sign in to comment.