Skip to content

Instantly share code, notes, and snippets.

@tj
Created July 14, 2009 15:27
Show Gist options
  • Select an option

  • Save tj/147015 to your computer and use it in GitHub Desktop.

Select an option

Save tj/147015 to your computer and use it in GitHub Desktop.
var console = console || {
log : function(args){
this.print('black', arguments)
},
error : function(args) {
this.print('red', arguments)
},
// ... etc
print : function(color, args) {
for (i = 0, len = args.length; i < len; ++i)
print(this.color(args[i], color))
},
color : function(string, color) {
return "\u001B[" + {
black : 30,
red : 31,
green : 32,
}[color] + 'm' + string + "\u001B[0m"
}
}
console.log('test', 'foo');
console.error('test', 'foo', 'bar');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment