# js-debugger

> Debug your JS

Latest version **0.4.3** (published 2018-05-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-debugger
pnpm add js-debugger
yarn add js-debugger
bun add js-debugger
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.3 |
| Published | 2018-05-23 |
| First published | 2017-07-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 32.9 KB |
| Known vulnerabilities | 0 (+5 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Bruno Santos |
| Maintainers | pertapacode |
| Keywords | console, debbug, node, browser, js |

## Links

- npm: https://www.npmjs.com/package/js-debugger
- Repository: https://github.com/PertapaCode/js-debugger
- Homepage: https://github.com/PertapaCode/js-debugger#readme
- Issues: https://github.com/PertapaCode/js-debugger/issues
- npm.io page: https://npm.io/package/js-debugger

## Dependencies (3)

- [log4js](https://npm.io/package/log4js.md) 2.3.3
- [morgan](https://npm.io/package/morgan.md) 1.8.2
- [log4js-extend](https://npm.io/package/log4js-extend.md) 0.2.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.4.3 (latest) — 2018-05-23
- 0.4.2 — 2018-05-22
- 0.4.1 — 2018-05-22
- 0.3.0 — 2017-10-27
- 0.2.2 — 2017-10-02
- 0.2.1 — 2017-09-20
- 0.2.0 — 2017-09-20
- 0.1.0 — 2017-07-24

## README

# JSdebugger

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

[![NPM](https://nodei.co/npm/js-debugger.png)](https://nodei.co/npm/js-debugger/)
[![Build Status](https://travis-ci.org/PertapaCode/js-debugger.svg?branch=develop)](https://travis-ci.org/PertapaCode/js-debugger)
![](http://img.badgesize.io/PertapaCode/js-debugger/develop/src/client.js.svg?label=client_size)

## Overview

**JSdebugger** uses [morgan](https://github.com/expressjs/morgan) to log HTTP requests, [log4js-node](https://github.com/nomiddlename/log4js-node) for node and [js-logger](https://github.com/jonnyreeves/js-logger) for the browser.

Wraps **js-logger** and **log4js-node** with a unique API and some default values.

## Install

```bash
npm install js-debugger
```

## How it works

### browser

###### Options

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.

#### Exemple

```js
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](images/browser_log.png)

### Node

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

###### Options

Name | Type | Default | Description
---- | ---- | ----    | ----
line | `Boolean` `Object` | **false** | Display line numbe, see [line](#line).
morgan | `Object` | **undefined** | Options for morgan, see [morgan](#morgan).
notify | `Object` | **undefined** | Options for notify, see [notify](#notify).

##### line

Enable line number, thanks to [log4js-node-extend](https://github.com/ww24/log4js-node-extend).

```js
line: true;

// or

line: {
  path: __dirname,
  format: 'at @name (@file:@line:@column)'
};
```

##### morgan

Enable **morgan** with express, please check the [API](https://github.com/expressjs/morgan#api).

```js
morgan: {
  app: app, // The express app object.
  format: 'dev', // morgan format.
  opts: {}, // morgan options.
};
```
![alt text](images/morgan_log.png)

##### notify

Enable notifications by email, please check the [API](https://github.com/nomiddlename/log4js-node/wiki/SMTP).

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

#### Exemple

```js
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](images/node_log.png)

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.

---
_Source: https://npm.io/package/js-debugger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
