Skip to content

Repository files navigation

JSdebugger

A suite of tools to debug your JavaScript in the browser and in Node.

NPMBuild Status

Overview

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.

Install

npm install js-debugger

How it works

browser

Options
NameTypeDefaultDescription
disabledBooleanfalseIf set to true disable all logs.
globalDebugstring falseA name for the global debug variable.
globalConsolestringfalseA name for the global console variable.
levelstring'error'Default maximun level.

Exemple

importjsdebuggerfrom'js-debugger';// passing optionsconstdebug=jsdebugger(options);const_log=debug('module').level('debug');// or using the default optionsconst_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');

alt text

Node

You can use all the options from the browser plus this ones:

Options
NameTypeDefaultDescription
lineBooleanObjectfalseDisplay line numbe, see line.
morganObjectundefinedOptions for morgan, see morgan.
notifyObjectundefinedOptions for notify, see notify.
line

Enable line number, thanks to log4js-node-extend.

line: true;// or
line: {path: __dirname,format: 'at @name (@file:@line:@column)'};
morgan

Enable morgan with express, please check the API.

morgan: {app: app,// The express app object.format: 'dev',// morgan format.opts: {},// morgan options.};

alt text

notify

Enable notifications by email, please check the API.

morgan: {smtp: Object,// The SMTP object.email: {from: string,to: string,subject: string}};

Exemple

constjsdebugger=require('js-debugger');// passing optionsconstdebug=jsdebugger(options);const_log=debug('module').level('debug');// or using the default optionsconst_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');

alt text

Contributing

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!

License

Copyright (c) 2017 Bruno Santos Licensed under the MIT license.

About

Debug your JS

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages