logmap

Filter streams of json and format the output using [`JSONSelect`][0]

npm install logmap
8 downloads in the last month

SYNOPSIS

Filter streams of json and format the output using JSONSelect

MOTIVATION

bunyan has too much ceremony, jsontool isn't specific enough for the task.

INSTALL

npm install logmap -g

USAGE

cat test/fixtures/sample.json | logmap ".date, .loglevel, .value" -f "[%d]: (%s) %s"

Input

{ "date": "1369605255506", "loglevel": "info", "value": "Lorem ipsum dolor sit amet.", "title": "C++", "id": "001" }
{ "date": "1369605255507", "loglevel": "info", "value": "Mollit anim id est laborum.", "title": "Javascript", "id": "002" }

Output

[1369605255506]: (info) Lorem ipsum dolor sit amet.
[1369605255507]: (info) Mollit anim id est laborum.

Because JSONSelect gets the data in the order that it is found, you may need to specify a special grammar not yet supported by JSONSelect. Below is an example of the grammar and data.

cat test/fixtures/sample.json | logmap ".date; .loglevel; .value" -f "[%d]: (%s) %s"

Input

{ "title": "C++", "id": "001", "loglevel": "info", "value": "Lorem ipsum dolor sit amet.", "date": "1369605255506" }
{ "title": "Javascript", "id": "002", "loglevel": "info", "value": "Mollit anim id est laborum.", "date": "1369605255507" }

Output

[1369605255506]: (info) Lorem ipsum dolor sit amet.
[1369605255507]: (info) Mollit anim id est laborum.

OPTIONS

If you write a long query, you can save it so you don't have to write it again.

Save

cat test/fixtures/sample.json | logmap ".date, .loglevel, .value" -f "[%d]: (%s) %s" -s myQuery

Load

cat test/fixtures/sample.json | logmap -l myQuery

Load

logmap -d myQuery
npm loves you