A suite of tools to debug your JavaScript in the browser and in Node.
JSdebugger uses morgan to log HTTP requests, log4js-node for node and js-logger for the browser.
Wraps js-logger and log4js-node with a unique API and some default values.
npm install js-debugger
Name | Type | Default | Description |
---|---|---|---|
disabled | Boolean |
false | If set to true disable all logs. |
globalDebug | string |
false | A name for the global debug variable. |
globalConsole | string |
false | A name for the global console variable. |
level | string |
'error' | Default maximun level. |
import jsdebugger from 'js-debugger';
// passing options
const debug = jsdebugger(options);
const _log = debug('module').level('debug');
// or using the default options
const _log = jsdebugger('module').level('debug');
_log.info('info');
_log.debug('debug');
_log.verbose('verbose');
_log.warn('warn');
_log.error('error');
_log.fatal('fatal');
_log.trace('trace');
You can use all the options from the browser plus this ones:
Name | Type | Default | Description |
---|---|---|---|
line | Boolean Object |
false | Display line numbe, see line. |
morgan | Object |
undefined | Options for morgan, see morgan. |
notify | Object |
undefined | Options for notify, see notify. |
Enable line number, thanks to log4js-node-extend.
line: true;
// or
line: {
path: __dirname,
format: 'at @name (@file:@line:@column)'
};
Enable morgan with express, please check the API.
morgan: {
app: app, // The express app object.
format: 'dev', // morgan format.
opts: {}, // morgan options.
};
Enable notifications by email, please check the API.
morgan: {
smtp: Object, // The SMTP object.
email: {
from: string,
to: string,
subject: string
}
};
const jsdebugger = require('js-debugger');
// passing options
const debug = jsdebugger(options);
const _log = debug('module').level('debug');
// or using the default options
const _log = jsdebugger('module').level('debug');
_log.info('info');
_log.debug('debug');
_log.verbose('verbose');
_log.warn('warn');
_log.error('error');
_log.fatal('fatal');
_log.trace('trace');
Test
The unit test are written in Mocha.
Please add a unit test for every new feature or bug fix. npm test
will run the tests.
Documentation
Please read and add documentation for every API change.
Feel free to contribute!
Copyright (c) 2017 Bruno Santos Licensed under the MIT license.