Skip to content

Instantly share code, notes, and snippets.

Last active December 27, 2022 03:13
  • Star 66 You must be signed in to star a gist
  • Fork 17 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
const createLogger = (backgroundColor, color) => {
const logger = (message, ...args) => {
if (logger.enabled === false) {
`background-color: ${backgroundColor}; color: ${color}; padding: 2px 4px;`,
new Error("stack").stack
return logger;
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")
module.exports = log;
Copy link

Brain, we love you! But we only have 14 hours to save your console! SAVIOUR OF THE UNIVERSE!

Copy link

lqs469 commented Aug 3, 2018

Sometime longerMessage could be Object, will print [Object object]. Maybe use JSON.stringify(longerMessage, null, 2)?

Copy link

bvaughn commented Sep 25, 2018

Updated the gist to add stack traces as well (within a collapsed console group):

screen shot 2018-09-25 at 8 17 07 am

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