Created
December 10, 2015 12:22
-
-
Save msikma/358542b3fd034f888b6d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Returns a function that will print a line to the console in a given color. | |
* The line will be prefixed and colored. All substituted values are bolded. | |
* | |
* @param {String} color Color to print in (must be supported by cli-color) | |
* @param {String} level Severity of the message {log, info, warn, error} | |
* @param {String} pre Prefix character in front of the message | |
* @returns {Function} Logging printer | |
*/ | |
function logMessage(color, level='log', pre=bullet) { | |
return function(msg, ...subs) { | |
subs = subs.map(sub => clc.bold(sub)); | |
console[level].apply(console, [clc[color](`${pre} ${msg}`)].concat(subs)); | |
} | |
} | |
/** | |
* Prints a line of text to the console indicating success. | |
* | |
* @param {String} msg Message to log to the console | |
* @param {Array} subs Any desired substitution values | |
*/ | |
const logSuccess = logMessage('green', 'log'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment