# good-winston

> hapi good-reporter to winston logging adapter

Latest version **4.0.0** (published 2017-04-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install good-winston
pnpm add good-winston
yarn add good-winston
bun add good-winston
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2017-04-21 |
| First published | 2015-03-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Lance Speelmon |
| Maintainers | lancespeelmon |
| Keywords | hapi, good, reporter, winston, logger, adapter |

## Links

- npm: https://www.npmjs.com/package/good-winston
- Repository: https://github.com/lancespeelmon/good-winston
- Issues: https://github.com/lancespeelmon/good-winston/issues
- npm.io page: https://npm.io/package/good-winston

## Dependencies (3)

- [hoek](https://npm.io/package/hoek.md) ^4.1.0
- [moment](https://npm.io/package/moment.md) ^2.18.1
- [json-stringify-safe](https://npm.io/package/json-stringify-safe.md) ^5.0.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

- 4.0.0 (latest) — 2017-04-21
- 3.1.0 — 2017-03-29
- 3.0.0 — 2016-10-14
- 2.1.0 — 2016-08-19
- 1.0.0 — 2015-04-08
- 0.1.5 — 2015-03-15
- 0.1.4 — 2015-03-15
- 0.1.3 — 2015-03-14
- 0.1.2 — 2015-03-14
- 0.1.1 — 2015-03-14
- 0.1.0 — 2015-03-13

## README

# good-winston

A [hapi](http://hapijs.com) [good](https://github.com/hapijs/good) stream to [winston](https://github.com/winstonjs/winston) logging adapter.

This stream clones [good-console](https://github.com/hapijs/good-console) but terminates logs to winston.

## Installation

```bash
  $ npm install -S winston
  $ npm install -S good-winston
```

## Usage

To use the `GoodWinston` you simply need to require it and pass it a winston logger instance -
```javascript
const GoodWinston = require('good-winston');
const winston = require('winston');
const goodWinstonStream = new GoodWinston({ winston });
```

The following `config` options are availble to configure `GoodWinston`:
- `config` - required configuration object with the following keys
  - `winston` - winston logger (required).
  - `level` - Log level for internal events -
    - `error` - Map all good `error` events to this winston level (Default `error`).
    - `other` - Map all other good events to this winston level (Default `info`).
    - `ops` - Map all good `ops` events to this winston level (Default `info`).
    - `response` - Map all good `response` events to this winston level (Default `info`).
    - `request` - Map all good `request` events to this winston level (Default `undefined` so level will be deduced from tags).
  - `format` - [MomentJS](http://momentjs.com/docs/#/displaying/format/) format string. Defaults to 'YYMMDD/HHmmss.SSS'.
  - `utc` - boolean controlling Moment using [utc mode](http://momentjs.com/docs/#/parsing/utc/) or not. Defaults to `true`.
  - `color` - a boolean specifying whether to output in color. Defaults to `true`.

## Integrating with good
As with any good stream new `good-winston` you can either pass the created stream to good -
```javascript
const GoodWinston = require('good-winston');
const goodWinstonStream = new GoodWinston({ winston: require('winston') });
const good = require('good');


server.register({
  register: good,  
  options: {
    reporters:{
      winston: [ goodWinstonStream ]
    }
}, err => {
  if (err) {
    throw err;
  }
});
```

Or you can have good initiate the stream from the module for you -
```javascript
const winston = require('winston');
const good = require('good');

server.register({
  register: good,  
  options: {
    reporters:{
      winston: [{
        module: 'good-winston',
        args: [{ winston }]
      }]
    }
}, err => {
  if (err) {
    throw err;
  }
});
```

### Using Tags and Levels
Using the `level` parameter in the `config` variable you can set the log level for internal events that are not controlled from your code (like `ops` and `response`) but for logs where are called from your code you should set a tag with the appropriate log level .`good-winston` will iterate the tag and will set the level by the first tag that matches the `winston` logger available levels. If no appropriate level was found `other` level will be used

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