# bunyan-pmx

> a lightweight module to pretty print a bunyan stream.

Latest version **0.1.3** (published 2016-05-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install bunyan-pmx
pnpm add bunyan-pmx
yarn add bunyan-pmx
bun add bunyan-pmx
```

## 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.1.3 |
| Published | 2016-05-26 |
| First published | 2016-05-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Cole Chamberlain |
| Maintainers | cchamberlain |
| Keywords | bunyan, pmx, pm2, keymetrics, scoped-action, stream, serialize, serialization, deserialize, deserialization, pretty, WritableStream, EventEmitter |

## Links

- npm: https://www.npmjs.com/package/bunyan-pmx
- Repository: https://github.com/cchamberlain/bunyan-pmx
- Homepage: http://bunyan-pmx.js.org
- Issues: https://github.com/cchamberlain/bunyan-pmx/issues
- npm.io page: https://npm.io/package/bunyan-pmx

## Dependencies (2)

- [chai](https://npm.io/package/chai.md) ^3.5.0
- [bunyan-serializer](https://npm.io/package/bunyan-serializer.md) latest

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 0.1.3 (latest) — 2016-05-26
- 0.1.2 — 2016-05-26
- 0.1.1 — 2016-05-26

## README

# bunyan-pmx

**bunyan-pmx is a lightweight bunyan stream to log to [keymetrics.io](http://keymetrics.io).**

[![NPM](https://nodei.co/npm/bunyan-pmx.png?stars=true&downloads=true)](https://nodei.co/npm/bunyan-pmx/)

## Install

`npm i -S bunyan-pmx`


## Documentation

This module creates a bunyan stream that writes to pmx. It uses the linked pm2 account to interact with the pmx api.  At this time, only scoped actions are supported (`bunyan-pmx` requires the scoped action data and res parameters in its constructor).

If there are additional bunyan loggers that must be intercepted and relayed to pmx, they can be specified in the hijackLoggers array parameter of the `bunyan-pmx` constructor.

Plan to add support for non scoped actions and other integration points in future releases.

## How to use

```js
import { createLogger } from 'bunyan'
import BunyanPmx from 'bunyan-pmx'
import pmx from 'pmx'

/** bunyan logger used throughout application (optional) */
import log as hijackLog from './log'

/** Useful in bin scripts - when there is already a logger being used throughout the app it can be passed to the BunyanPmx stream writer within hijackLoggers array. */
const createPmxLogger = ({ name = 'pmx', level = 'info', streams = [], data, res } = {}) => {
  const stream = new BunyanPmx({ data, res, hijackLoggers: [hijackLog] })
  const pmxStream = { level, stream }
  return createLogger({ name, streams: [pmxStream, ...streams] })
}


pmx.scopedAction('start', (data, res) => {
  const log = createPmxLogger({ data, res, level: 'trace'})
  log.info('woohoo, this is getting transmitted as a log to keymetrics.io!')

  /** DO STUFF */
})
```


## Options

**The BunyanPmx class constructor takes a single options argument with the following properties:**

Name            | Type                  | Description
-------------   | -----------------     | -----------
`data`          | `Object (required)`   | The data callback argument from a pmx scoped action
`res`           | `Object (required)`   | The res callback argument from a pmx scoped action
`reply`         | `(unimplemented)`     | The reply callback argument from a pmx action (coming in future release)
`serializer`    | `function (optional)` | A custom serializer that will be proxied arguments as stream is written to. Should return the preferred string log format to be displayed on keymetrics.io. Defaults to a human readable format.
`hijackLoggers` | `Array (optional)`    | An array of bunyan loggers that should be hijacked and rewritten to pmx stream.

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