0.4.3 • Published 6 years ago

js-debugger v0.4.3

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

JSdebugger

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

NPM Build Status npm.io

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.
globalDebugstringfalseA name for the global debug variable.
globalConsolestringfalseA name for the global console variable.
levelstring'error'Default maximun level.

Exemple

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');

alt text

Node

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

Options
NameTypeDefaultDescription
lineBoolean ObjectfalseDisplay 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

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');

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.

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.3.0

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago