-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple logger.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |