Skip to content

Commit

Permalink
Clean up for d7e3e52
Browse files Browse the repository at this point in the history
  • Loading branch information
arb committed Mar 30, 2016
1 parent a89a608 commit 4db033c
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 108 deletions.
12 changes: 4 additions & 8 deletions README.md
@@ -1,31 +1,27 @@
# good-console

Console broadcasting for Good process monitor
`good-console` is a transform stream useful for turning [good](https://github.com/hapijs/good) server events into formatted strings.

[![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)

Lead Maintainer: [Adam Bretz](https://github.com/arb)

## Usage

`good-console` is a [good](https://github.com/hapijs/good) reporter implementation to transform streams of [hapi](http://hapijs.com/) server events into formatted strings.

## `GoodConsole([config])`
## `new GoodConsole([config])`
Creates a new GoodConsole object with the following arguments:

- `[config]` - optional configuration object with the following available keys
- `[config]` - optional configuration object with the following keys
- `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`.

The example above we use the module `good-squeeze` for filtering our events and pipe that to `GoodConsole` and finally to `stdout` as the `Good` API suggest.

## Output Formats

Below are example outputs for the designated event type:

- "ops" - 160318/013330.957, [ops] memory: 29Mb, uptime (seconds): 6, load: [1.650390625,1.6162109375,1.65234375]
- "error" - 160318/013330.957, [error,`event.tags`] message: Just a simple error stack: `event.error.stack`
- "error" - 160318/013330.957, [error,`event.tags`] message: Just a simple error stack: `event.error.stack`
- "request" - 160318/013330.957, [request,`event.tags`] data: you made a request
- "log" - 160318/013330.957, [log,`event.tags`] data: you made a default
- "response" - 160318/013330.957, [response, `event.tags`] http://localhost:61253: post /data {"name":"adam"} 200 (150ms)
1 change: 0 additions & 1 deletion lib/index.js
Expand Up @@ -179,4 +179,3 @@ class GoodConsole extends Stream.Transform {
}

module.exports = GoodConsole;

9 changes: 3 additions & 6 deletions test/fixture/streams.js
Expand Up @@ -8,22 +8,19 @@ class Writer extends Stream.Writable {
super({ objectMode: true });
this.data = [];
}
_write(chunk, end, callback) {
_write(chunk, enc, callback) {

this.data.push(chunk);
callback(null);
}
}

class Reader extends Stream.Transform {
class Reader extends Stream.Readable {
constructor() {

super({ objectMode: true });
}
_transform(value, encoding, callback) {

callback(null, value);
}
_read() {}
}

module.exports = { Writer, Reader };

0 comments on commit 4db033c

Please sign in to comment.