Simple logging utility.
npm install mini-console-logger --save
import logger, { LOG_LEVELS } from 'mini-console-logger';
logger.trace('trace');
logger.debug('debug');
logger.info('info');
logger.warn('warn');
logger.error('error');
// objects and Errors are stringified automatically
logger.debug({
prop1: 'foo',
prop2: 'bar'
});
logger.error(new Error('foo'));
logger.level = null; // silence logger
logger.level = LOG_LEVELS.WARN; // log only warn and above
logger.on(LOG_LEVELS.ERROR, err => {
// do something with the error
});
logger.off(LOG_LEVELS.ERROR); // unbind error listener