A human-friendly logger. Comes with pretty console output for both development and production environments, and may be extended by implementing custom writers.
Additional writers:
$ npm install h-logger2
const Logger = require('h-logger2');
// ConsoleWriter is available directly in this module,
// other output/transfer methods may be implemented as separate modules
const logger = new Logger('my-app-name', [ new Logger.ConsoleWriter(Logger.TRACE) ]);
// simple text message
logger.trace('message');
// message with additional context object
logger.debug('message', { foo: 123 });
// message with associated error
logger.error('message', new Error('error'));
// message with associated error and additional context
logger.trace('message', new Error('error'), { foo: 123 });
// creates a new logger with name my-app-name:redis
const redisLogger = logger.scope('redis');
A writer is simply a class that implements the Writer interface. See the ConsoleWriter implementation for an example.
Copyright (c) 2018 Martin Kolárik. Released under the MIT license.