Last active
January 18, 2024 16:26
-
-
Save jaredrethman/d68afb6e8a52a494b73c1ea863baf15f to your computer and use it in GitHub Desktop.
Simple colorful console output
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 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