Skip to content

Instantly share code, notes, and snippets.

@roziscoding
Last active March 27, 2020 16:49
Show Gist options
  • Save roziscoding/81b956f5b65533abb5c892d5ffc13da3 to your computer and use it in GitHub Desktop.
Save roziscoding/81b956f5b65533abb5c892d5ffc13da3 to your computer and use it in GitHub Desktop.
front-end fancy console log messages

Fancy console log functinos

Usage:

Just call the common log type functions:

info('Informando algo');
debug('Informação muito relevante pra debugar');
error('Errinho aqui em');
warn('Cê fez algo ruim, mas eu resolvi')

Result:

demo image

const makeMessage = (message, badge, badgeColor) => console.log(`%c ${badge} %c ${message} `, `background: ${badgeColor}; color: white; padding: 4px; border-radius: 3px 0 0 3px`, 'background:#35495e; color: white; padding: 4px; border-radius: 0 3px 3px 0')
const info = message => makeMessage(message, 'Info', '#03A9F4')
const debug = message => makeMessage(message, 'Debug', '#FF9800')
const error = message => makeMessage(message, 'Error', '#F44336')
const warn = message => makeMessage(message, 'Warn', '#FFC107')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment