# bunyan-format

> Writable stream that formats bunyan records that are piped into it.

Latest version **0.2.1** (published 2015-01-19) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2015-01-19 |
| First published | 2013-10-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/bunyan-format) |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52 |
| Author | Thorsten Lorenz |
| Maintainers | thlorenz |
| Keywords | bunyan, stream, log, logger, format, pretty, color, style |

## Links

- npm: https://www.npmjs.com/package/bunyan-format
- Repository: https://github.com/thlorenz/bunyan-format
- Issues: https://github.com/thlorenz/bunyan-format/issues
- npm.io page: https://npm.io/package/bunyan-format

## Dependencies (3)

- [xtend](https://npm.io/package/xtend.md) ~2.1.1
- [ansicolors](https://npm.io/package/ansicolors.md) ~0.2.1
- [ansistyles](https://npm.io/package/ansistyles.md) ~0.1.1

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.2.1 (latest) — 2015-01-19
- 0.2.0 — 2015-01-19
- 0.1.1 — 2013-10-23
- 0.1.0 — 2013-10-23

## README

# bunyan-format [![build status](https://secure.travis-ci.org/thlorenz/bunyan-format.png)](http://travis-ci.org/thlorenz/bunyan-format)

Writable stream that formats bunyan records that are piped into it

```js
var bunyan = require('bunyan')
  , bformat = require('bunyan-format')  
  , formatOut = bformat({ outputMode: 'short' })
  ;

var log = bunyan.createLogger({ name: 'app', stream: formatOut, level: 'debug' } );

log.info('starting up');
log.debug('things are heating up', { temperature: 80, status: { started: 'yes', overheated: 'no' } });
log.warn('getting a bit hot', { temperature: 120 });
log.error('OOOOHHH it burns!', new Error('temperature: 200'));
log.fatal('I died! Do you know what that means???');
```

* Printing the level in String representation for Json objects

```js
var bunyan = require('bunyan')
  , bformat = require('../')
  , formatOut = bformat({ outputMode: 'bunyan', levelInString: true })
  ;
```

The output would use the string levels:

```
$ node example/json-string-level.js 
{"name":"app","hostname":"ubuntu","pid":28081,"level":"INFO","msg":"starting up","time":"2014-12-01T19:41:29.136Z","v":0}
{"name":"app","hostname":"ubuntu","pid":28081,"level":"DEBUG","msg":"things are heating up { temperature: 80,\n  status: { started: 'yes', overheated: 'no' } }","time":"2014-12-01T19:41:29.142Z","v":0}
{"name":"app","hostname":"ubuntu","pid":28081,"level":"WARN","msg":"getting a bit hot { temperature: 120 }","time":"2014-12-01T19:41:29.143Z","v":0}
{"name":"app","hostname":"ubuntu","pid":28081,"level":"ERROR","msg":"OOOOHHH it burns! [Error: temperature: 200]","time":"2014-12-01T19:41:29.144Z","v":0}
{"name":"app","hostname":"ubuntu","pid":28081,"level":"FATAL","msg":"I died! Do you know what that means???","time":"2014-12-01T19:41:29.144Z","v":0}
```

![demo](https://github.com/thlorenz/bunyan-format/raw/master/assets/bunyan-format-demo.gif)

## Installation

    npm install bunyan-format

## API

```
/**
 * Creates a writable stream that formats bunyan records written to it.
 * 
 * @name BunyanFormatWritable
 * @function
 * @param opts {Options} passed to bunyan format function
 *  - outputMode: short|long|simple|json|bunyan
 *  - color (true): toggles colors in output
 *  - colorFromLevel: allows overriding log level colors
 * @param out {Stream} (process.stdout) writable stream to write 
 * @return {WritableStream} that you can pipe bunyan output into
 */
```

## License

MIT

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