0.0.9 • Published 10 years ago

json-stream-formatter v0.0.9

Weekly downloads
41
License
GPL2+
Repository
github
Last release
10 years ago

JSON Event Stream Formatter

Build Status Coverage Status

Usage

CLI usage

By default json-stream-format pretty prints a json stream. If you want to use a more specific format you can use the --format (-f) parameter and specify the format. Place object keys to include inside double curly {{something}} brackets.

Example

cat test/fixtures/example.log | json-stream-format --format '{{time|date("h:m:s")|blue}}: {{msg|green}}'

You can also leave off the format, non-parameter arguments will be used as formats by default.

cat test/fixtures/example.log | json-stream-format '{{time|date("h:m:s")|blue}}: {{msg|green}}'

Node.js usage

Formatting

var jsf = require('json-stream-formatter');
var es = require('event-stream');
process.stdin
  .pipe(es.split())
  .pipe(es.parse())
  .pipe(jsf.format('{{time|date("d/m/y h:m:s")|blue}}: {{msg}}'))
  .pipe(process.stdout);

Pretty printing

var jsf = require('json-stream-formatter');
var es = require('event-stream');
process.stdin
  .pipe(es.split())
  .pipe(es.parse())
  .pipe(jsf.prettyPrint())
  .pipe(process.stdout);

Format sytnax

The formatter utilizes twig.js for foratting the json event messages. Available filters can be found in the twig.js implementation notes. In addition chalk-twig-filters are added to provide all of the chalk colors as twig filters. These are the color filters used in the examples above.

Installation

sudo npm install -g json-stream-formatter
1.0.1

8 years ago

1.0.0

8 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.2

10 years ago

0.0.0

10 years ago