-
-
Save ghoullier/3fc51c552c723cf00e27c321ea6368d3 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
const createLogger = (backgroundColor, color, enabled = true) => ( | |
message, | |
...args | |
) => { | |
if (!enabled) { | |
return; | |
} | |
console.groupCollapsed( | |
`%c${message}`, | |
`background-color: ${backgroundColor}; color: ${color}; padding: 2px 4px;`, | |
...args | |
); | |
console.log( | |
new Error("stack").stack | |
.split("\n") | |
.slice(2) | |
.join("\n") | |
); | |
console.groupEnd(); | |
}; | |
const log = { | |
blue: createLogger("#1E88E5", "#90CAF9"), | |
brown: createLogger("#6D4C41", "#D7CCC8"), | |
gray: createLogger("#212121", "#BDBDBD"), | |
green: createLogger("#388E3C", "#A5D6A7"), | |
red: createLogger("#E53935", "#EF9A9A"), | |
orange: createLogger("#F4511E", "#FFAB91"), | |
purple: createLogger("#8E24AA", "#E1BEE7"), | |
yellow: createLogger("#FFD600", "#FFF59D") | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment