Last active
October 11, 2016 22:45
-
-
Save TigerC10/13ed6ec06beb550ad219c6cc69e14d09 to your computer and use it in GitHub Desktop.
My new favorite logging snippet for NodeJS
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
(function () { | |
var resetColor = '\x1b[0m'; | |
if (typeof module !== 'undefined' && module.exports) { | |
[ | |
['log', '\x1b[0m'], | |
['info', '\x1b[36m'], | |
['warn', '\x1b[33m'], | |
['error', '\x1b[31m'], | |
].forEach(function(level) { | |
var method = level[0]; | |
var color = level[1]; | |
console[method] = console[method].bind(console, color, method.toUpperCase(), resetColor); | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment