Created
August 31, 2010 22:11
-
-
Save thejefflarson/559846 to your computer and use it in GitHub Desktop.
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
// hi there npm | |
var doColor | |
try { | |
var stdio = require("stdio") | |
doColor = stdio.isStderrATTY() | |
} catch (ex) { | |
doColor = true | |
} | |
function colorize (msg, color) { | |
if (!msg) return ""; | |
if (!doColor) return msg; | |
return "\033["+color+"m"+msg+"\033[0m"; | |
} | |
function log(level, color, message, prefix){ | |
if(prefix) message = level.toUpperCase() + " [" + Date() + "]: " + message; | |
console[level](colorize(message, color)) | |
} | |
exports.info = function info(message){ | |
log("info", 32, message, true); | |
} | |
exports.warn = function info(message){ | |
log("warn", 33, message); | |
} | |
exports.error = function info(message){ | |
log("error", 31, message, true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment