Loggerhythm
A winston-wrapper to log in a debug-like manner including namespaces
Usage
Loggerhythm exports a Logger-class, whose instances have different log-functions for different log-levels. the avaliable loglevels are:
- error
- warn
- info
- verbose
error logs to stderr
, everything else logs to stdout
!
Example
const Logger = Logger;// import {Logger} from 'loggerhythm'; // for TypeScript const logger = 'readme-namespace';// alias: logger = logger.createLogger('readme-namespace'); logger;
The output would look like this (the different log-leves use different colors):
2016-08-30T14:06:33.751Z - info: [readme-namespace] foo
2016-08-30T14:06:33.752Z - warn: [readme-namespace] bar
Methods
Static
The Logger-Class has static methods, that can be used to globally set loggerhythm-config and register global log-hooks:
const Logger = Logger;// import {Logger, LogLevel} from 'loggerhythm'; // for TypeScript // get informed about all Logs everywhereconst subscription = Logger; // do stuff // unsubscribesubscription;
Instance-methods
The Instances of the Logger-class have a log-method for every loglevel and a subscribe-method to get informed about logs of that instance
const Logger = Logger;// import {Logger} from 'loggerhythm'; // for TypeScript const logger = Logger; // get informed about all the logs of that instanceconst subscription = Logger; logger;logger;logger;logger; // this loggers namespace will be 'readme-namespace:child-logger-lamespace'const logger2 = logger; // do stuff // unsubscribesubscription;