logdown.js
logdown.js copied to clipboard
Emojis don't render properly on all terminals
Emojis cannot be rendered on every terminal. This causes the issue that log messages will look strange and don't have a common alignment.
You can see the issue by running my demo code in different terminals:
NODE_DEBUG=* node index.js
const logdown = require('logdown')
const logger = logdown('MyLogger')
logger.debug('Type "debug"')
logger.error('Type "error"')
logger.info('Type "info"')
logger.log('Type "log"')
logger.warn('Type "warn"')
Because the output isn't consistent across platforms, we should replace emojis with standard ASCII symbols (which can be rendered on most of the systems).
I also noticed that logger.debug is not printed on the console. How can I get debug messages? I already used NODE_DEBUG=*.
Command-line interface (Windows)

PowerShell (Windows)

Ubuntu Bash (Linux Subsystem on Windows 10)

Another good solution would be to make the emojis configurable, so that the end user can decide if they should be printed to the console or not.
Proposal:
var logger = logdown({ icons: false })
WDYT @SleepWalker & @caiogondim ?
Configurable it's good! But is should be enabled by default to keep backward compatibility.
What would be better? Completely disabling the icons or configuring them individually? Or maybe both?
const logger1 = logdown({ icons: false })
const logger2 = logdown({ icons: {
warning: '!',
error: '!!'
} })
What do you think?
The easiest to implement (and already useful) config would be turning it on or off completely.
I'm cool with that