Skip to content

Commit

Permalink
Merge pull request #10 from mcollina/transports-readme
Browse files Browse the repository at this point in the history
Explain why there are no transports.
mcollina committed Mar 16, 2016
2 parents 1791707 + df1ebab commit f5b8f52
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ It also includes a shell utility to pretty-print its log files.
* [Benchmarks](#benchmarks)
* [API](#api)
* [How do I rotate log files?](#rotate)
* [How to use Transports with Pino](#transports)
* [Acknowledgements](#acknowledgements)
* [License](#license)

@@ -299,6 +300,38 @@ In order to rotate your log files, add in `/etc/logrotate.d/myapp`:
}
```
<a name="transports"></a>
## How to use Transports with Pino
Transports are not part of Pino. There will never be an API for transports,
or support for ObjectMode Writable streams.
This library is fast because it does way less than the others. We went
to great lengths to make sure this library is _really fast_, and transports
will slow things down.
So, how do you do a transport? With Pino, we create a separate process for our transport and pipe to it.
It's the Unix philosophy.
Something like:
```js
var split = require('split2')
var pump = require('pump')
var through = require('through2')

var myTransport = through.obj(function (chunk, enc, cb) {
// do whatever you want here!
console.log(chunk)
cb()
}

pump(process.stdin, split2(JSON.parse), myTransport)
```
Using transports in the same process causes unnecessary load and slows down Node's single threaded event loop.
If you write a transport, let us know and we will add a link here!
<a name="acknowledgements"></a>
## Acknowledgements

0 comments on commit f5b8f52

Please sign in to comment.