node-simple-logger-es6

Really simplistic log system for node v6 using ES6 Proxies


Keywords
log, logger, es6, proxy
License
MIT
Install
npm install node-simple-logger-es6@0.0.1

Documentation

node-simple-logger

Really simplistic log system for node v6 using ES6 Proxies

Yet another log system?

Yes. I made this because other log systems like Winston or Bunyan felt so overwhelmingly complicated for really small projects. I wanted just something to print colored messages in the stdout. Besides, I wanted to play with ES6 and proxies, so this was the perfect opportunity.

Pre-requisites

  • Node v6 (ES6 proxies are not implemented in node version 5 or lower (Source)). There is a .nvmrc file if you use nvm

How to use

Basic usage

const logger = require('node-simple-logger-es6');

logger.log('Log Message'); // Output (in gray): [12-Jul-2016 16:57:46] Log Message

Log Levels

logger.debug('Debug message');
logger.info('Info message');
logger.log('Log message');
logger.warn('Warning message');
logger.error('Error message');

Output:

Screenshot of log levels

Since it uses ES6 Proxy, any other member function call will default to log():

Screenshot of default behaviour of undefined log levels

Using with pm2

pm2 by default ignores the colors set by this library, so all one would see when calling pm2 logs would be white (and ugly) text. To ensure that the logs show with colors, use pm2 start app.js -- --color.