Skip to content

Instantly share code, notes, and snippets.

@jaredrethman
Last active January 18, 2024 16:26
Show Gist options
  • Save jaredrethman/d68afb6e8a52a494b73c1ea863baf15f to your computer and use it in GitHub Desktop.
Save jaredrethman/d68afb6e8a52a494b73c1ea863baf15f to your computer and use it in GitHub Desktop.
Simple colorful console output
const COLOR_SCHEMES = {
success: [ '#FFFFFF', '#009b4b' ],
error: [ '#FFFFFF', '#ff3f71' ],
info: [ '#333333', '#11c7d7' ],
warning: [ '#FFFFFF', '#e87834' ],
};
const __sDebugger = ( {
type = 'info',
msg = null,
label = 'No Label',
collapsed = true,
table = false,
index,
} ) => {
console[ collapsed ? 'groupCollapsed' : 'group' ](
`%c(${ index }) ${ label }`,
`padding:0.2em 0.5em;color:${ COLOR_SCHEMES[ type ][ 0 ] }; background-color:${ COLOR_SCHEMES[ type ][ 1 ] }`
);
console[ table ? 'table' : 'info' ]( msg );
console.groupEnd();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment