UNPKG

user-console

Version:

User Console for console with colors, emojis, and pretty logs.

24 lines (20 loc) 954 B
function userConsole(message, level = 'info') { const styles = { info: 'color: white; background-color: #1E90FF; font-weight: bold; padding: 2px 6px; border-radius: 3px;', success: 'color: white; background-color: #28a745; font-weight: bold; padding: 2px 6px; border-radius: 3px;', warn: 'color: black; background-color: #ffcc00; font-weight: bold; padding: 2px 6px; border-radius: 3px;', error: 'color: white; background-color: #dc3545; font-weight: bold; padding: 2px 6px; border-radius: 3px;', debug: 'color: white; background-color: #8a2be2; font-weight: bold; padding: 2px 6px; border-radius: 3px;', }; const emojis = { info: 'ℹ️', success: '✅', warn: '⚠️', error: '❌', debug: '🐞', }; const style = styles[level] || styles.info; const emoji = emojis[level] || emojis.info; console.log(`%c${emoji}${message}${emoji}`, style); } module.exports = userConsole;