UNPKG

2.29 kBMarkdownView Raw
1# good-console
2
3Console broadcasting for Good process monitor
4
5[![Build Status](https://travis-ci.org/hapijs/good-console.svg?branch=master)](http://travis-ci.org/hapijs/good-console)![Current Version](https://img.shields.io/npm/v/good-console.svg)
6
7Lead Maintainer: [Adam Bretz](https://github.com/arb)
8
9## Usage
10
11`good-console` is a [good](https://github.com/hapijs/good) reporter implementation to write [hapi](http://hapijs.com/) server events to the console.
12
13## `GoodConsole(events, [config])`
14Creates a new GoodConsole object with the following arguments:
15
16- `events` - an object of key value pairs.
17 - `key` - one of the supported [good events](https://github.com/hapijs/good) indicating the hapi event to subscribe to
18 - `value` - a single string or an array of strings to filter incoming events. "\*" indicates no filtering. `null` and `undefined` are assumed to be "\*"
19- `[config]` - optional configuration object with the following available keys
20 - `format` - [MomentJS](http://momentjs.com/docs/#/displaying/format/) format string. Defaults to 'YYMMDD/HHmmss.SSS'.
21 - `utc` - boolean controlling Moment using [utc mode](http://momentjs.com/docs/#/parsing/utc/) or not. Defaults to `true`.
22
23## Good Console Methods
24### `goodconsole.init(stream, emitter, callback)`
25Initializes the reporter with the following arguments:
26
27- `stream` - a Node readable stream that will be the source of data for this reporter. It is assumed that `stream` is in `objectMode`.
28- `emitter` - an event emitter object.
29- `callback` - a callback to execute when the start function has complete all the necessary set up steps and is ready to receive data.
30
31## Output Formats
32
33Below are example outputs for the designated event type:
34
35- "ops" - 141225/093015.900, [ops, `event.tags`], memory: 10Mb, uptime (seconds): 1000, load: [ 1.650390625, 1.6162109375, 1.65234375 ]
36- "error" - 141225/093015.900, [error, `event.tags`], message: there was an error, stack: `eventData.stack`
37- "request" - 141225/093015.900, [request, `event.tags`], data: {"message":"you made a request to a resource"}
38- "log" - 141225/093015.900, [log, `event.tags`], data: you logged a message
39- "response" - 141223/164207.694, [response], localhost: post /data {"name":"adam"} 200 (150ms) response payload: {"foo":"bar","value":1}