-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbin.js
executable file
·32 lines (27 loc) · 903 Bytes
/
bin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/env node
const fs = require('fs')
const pump = require('pump')
const args = require('args')
const split = require('split2')
const through = require('through2')
const prettyFactory = require('./lib')
args
.option(['t', 'timeSince'], 'Use time since first log, rather than timestamp')
.option(['s', 'stackTrace'], 'Highlight stack traces')
.option(['q', 'quiet'], 'Truncate messages, try to keep them one line')
args
.example('node example.js | pino-pretty-min', 'To prettify logs, simply pipe a log through')
const opts = args.parse(process.argv)
const pretty = prettyFactory(opts)
const prettyTransport = through.obj(function (chunk, enc, cb) {
process.stdout.write(pretty(chunk.toString()))
cb()
})
pump(
process.stdin,
split(),
prettyTransport
)
if (!process.stdin.isTTY && !fs.fstatSync(process.stdin.fd).isFile()) {
process.once('SIGINT', function noOp () {})
}