Created
February 6, 2017 17:53
-
-
Save bradstemke/182bb3625534ca8efa4bbf261446aa90 to your computer and use it in GitHub Desktop.
Formatting console.log()
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 that takes the message and returns the BG color, Error Type, and message. | |
const label = ([raw]) => { | |
const [color, label, ...message] = raw.split(' ') | |
return [ | |
`%c${label}%c ${message.join(' ')}`, | |
`color: white; background-color: ${color}; padding: 0 0.5rem 0 0.5rem;`, | |
'' | |
] | |
} | |
// example of log. red = bg color, error = title of error, and then the messaging. | |
console.log(...label`red error this is my message`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment