# debugnyan

> A logging library that combines the simplicity and convenience of debug with the power of bunyan

Latest version **4.1.1** (published 2023-11-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install debugnyan
pnpm add debugnyan
yarn add debugnyan
bun add debugnyan
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.1.1 |
| Published | 2023-11-23 |
| First published | 2015-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 2 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Rui Marinho |
| Maintainers | fixe, ruimarinho, botatuphold |
| Keywords | bridge, bunyan, debug, debugging, json, log, logging |

## Links

- npm: https://www.npmjs.com/package/debugnyan
- Repository: https://github.com/uphold/debugnyan
- Homepage: https://github.com/uphold/debugnyan/
- Issues: https://github.com/uphold/debugnyan/issues
- npm.io page: https://npm.io/package/debugnyan

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^4.3.4
- [bunyan](https://npm.io/package/bunyan.md) ^1.8.15

## 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

- 4.1.1 (latest) — 2023-11-23
- 4.1.0 — 2023-11-22
- 4.0.0 — 2023-11-20
- 3.1.0 — 2023-11-20
- 3.0.0 — 2021-09-17
- 2.0.2 — 2018-06-08
- 2.0.1 — 2017-03-23
- 2.0.0 — 2017-03-23
- 1.0.0 — 2016-09-28
- 0.0.2 — 2015-12-31
- 0.0.1 — 2015-07-13

## README

# debugnyan

A logging library that combines the simplicity and convenience of [debug](https://github.com/visionmedia/debug) with the power of [bunyan](https://github.com/trentm/node-bunyan).

## Status

[![npm version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]

## Installation

Install the package via `yarn`:

```sh
❯ yarn add debugnyan
```

or via `npm`:

```sh
❯ npm install debugnyan --save
```

## Usage

Create a logger by giving it a namespace and then call [bunyan's log methods](https://github.com/trentm/node-bunyan#log-method-api) on the returned instance.

By default, similarly to `debug`'s behaviour, loggers do not output any content. Each logger output can be selectively activated by using the `DEBUG` environment variable.
Pattern matching is based on the logger's name and it can optionally contain colons (`:`) to create (sub)-components properties on the logger instance.

Consider a logger named `foo:bar:biz`:

- this creates a `bunyan` logger with name `foo`
- and a `bunyan` (simple) child logger with property `component` equal to `bar`.

```js
const logger1 = require('debugnyan')('foo');
const logger2 = require('debugnyan')('foo:bar');

logger1.debug('net');
logger2.debug('qux');
```

*Example output with `DEBUG=foo`*:

```bash
DEBUG=foo node example.js

{"name":"foo","hostname":"ruimarinho","pid":1,"level":20,"msg":"net","time":"2016-10-04T18:54:14.530Z","v":0}
{"name":"foo","hostname":"ruimarinho","pid":1,"component":"bar","level":20,"msg":"qux","time":"2016-10-04T18:54:14.531Z","v":0}
```

*Example output with `DEBUG=foo:bar`*:

```bash
DEBUG=foo:bar node example.js

{"name":"foo","hostname":"ruimarinho","pid":2,"component":"bar","level":20,"msg":"qux","time":"2016-10-04T18:55:08.217Z","v":0}
```

The `prefix` and `suffix` for each component is also customizable:

```js
const logger = require('debugnyan')('foo', {}, { suffix: 'module' });
```

When creating a _child_ logger you may also override the default `simple` behavior:

```js
const logger = require('debugnyan')('foo', {}, { suffix: 'module', simple: false });
```

### Log level

The `level` bunyan option is respected if the logger output is active.

```js
const logger = require('debugnyan')('foo', { level: 'info' });
```

You may also set the log level via the `LOG_LEVEL` environment variable. However, the `level` option will always take precedence over it.

## Tests

```
❯ yarn test
```

## Release

Click `Run Workflow` on the [release github action](https://github.com/uphold/debugnyan/actions/workflows/release.yaml).

## License

MIT

[npm-image]: https://img.shields.io/npm/v/debugnyan.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/debugnyan
[travis-image]: https://img.shields.io/travis/uphold/debugnyan.svg?style=flat-square
[travis-url]: https://travis-ci.org/uphold/debugnyan

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