cloggy
A minimal debugging utility to replace console statements with debug powered logging. This works well with libraries like redux-logger;
Getting Started
npm install cloggy
In your code, require cloggy and pass in a namespace for your debug statements.
import cloggy from 'cloggy';
const log = cloggy('app');
log.info('Doing something');
log.error('An error happened');
log.debug('Doing something');
log.log('Doing something');
log.warn('Doing something');
Debugging can be enabled with space or comma-delimited names in the following ways:
- Browser: Open the browser console and set the following local storage item
localStorage.debug = '*'
localStorage.debug = '*,-not_this'
localStorage.debug = 'app:*,section:*'
- Node: Set
DEBUG
environment variable
DEBUG=* node app.js
DEBUG=*,-not_this node app.js
DEBUG=app:*,section:* node app.js
For more information about debug
, check out the docs.
Methods
The returned debug object contains the following namespaced log statements.
There's nothing really special about the different methods other than debug assigning unique colors per function.
Screenshot
Example running in redux-logger via custom logger object.