Skip to content

Instantly share code, notes, and snippets.

@OutThisLife
Forked from davidgilbertson/color-log.js
Last active May 21, 2019 14:11
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save OutThisLife/a02f2fe8470d224359ff753484740a9b to your computer and use it in GitHub Desktop.
Save OutThisLife/a02f2fe8470d224359ff753484740a9b to your computer and use it in GitHub Desktop.
const log = new Proxy({}, {
get: (_, colour) => function() {
console.log(`%c ${[].slice.call(arguments).join(' ')}`, `color: ${colour}`)
}
})
// example
log.tomato('I am tomato')
log.chocolate('I am chocolate')
log.cornflowerblue('I am cornflowerblue')
log.darkcyan('I am darkcyan')
log.goldenrod('I am goldenrod')
@deepu105
Copy link

deepu105 commented Jan 8, 2018

log['#000000']('I am 000000'); you can do this as well

@robalb
Copy link

robalb commented May 21, 2019

Beautiful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment