Skip to content

Instantly share code, notes, and snippets.

@ghoullier
Forked from bvaughn/console-colors.js
Created September 25, 2018 15:34
Show Gist options
  • Save ghoullier/3fc51c552c723cf00e27c321ea6368d3 to your computer and use it in GitHub Desktop.
Save ghoullier/3fc51c552c723cf00e27c321ea6368d3 to your computer and use it in GitHub Desktop.
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