Loglevel Debug Plugin
Plugin for JS logger loglevel which allows enable/disable debug output dynamically and draws inspiration from TJ Hollowaychuk's debug.
Features
- Ability to change logging levels of specific modules.
- Ability to turn on/off debug output for specific modules in development.
- Production logging would be all modules with warn, info, error levels,
Installation
npm install loglevel-debug
bower install loglevel-debug
Usage
This plugin is deigned to be used standalone.
var log = 'http' http = name = 'My App'; // fake app ; http; // fake worker of some kind ;
Example worker.js:
var log = 'worker'; ;
Use DEBUG environment variable to control debug output.
$ DEBUG=http,worker:* node example/app[DEBUG] http booting %s[DEBUG] worker:a doing lots of uninteresting work[DEBUG] worker:b doing some work[INFO] http listening[DEBUG] worker:a doing lots of uninteresting work[DEBUG] worker:a doing lots of uninteresting work[DEBUG] worker:b doing some work[DEBUG] worker:a doing lots of uninteresting work[DEBUG] worker:a doing lots of uninteresting work
Logging Methods
loglevel methods are all supported.
# creates a logger for Module1var log = 'Module1'; ;log;log;log;log;log;
you can dynamic change specific logger's logging level.
log.setLevel(log.levels.INFO)
Browser support
This plugin works on browser as well. To enable debug output, you can use its enable
public api,
loglevelDebug.enable('worker:*');
As a loglevel plugin
var loglevel = ;var loglevelDebug = ; ; log;