UNPKG

4.06 kBMarkdownView Raw
1# Legacy
2
3## Legacy Node Support
4
5### Node v4
6
7Node v4 is supported on the [Pino v4](#pino-v4-documentation) line.
8
9### Node v0.10-v0.12
10
11Node v0.10 or Node v0.12 is supported on the [Pino v2](#pino-v2-documentation) line.
12
13## Documentation
14
15### Pino v4 Documentation
16
17<https://github.com/pinojs/pino/tree/v4.x.x/docs>
18
19### Pino v3 Documentation
20
21<https://github.com/pinojs/pino/tree/v3.x.x/docs>
22
23### Pino v2 Documentation
24
25<https://github.com/pinojs/pino/tree/v2.x.x/docs>
26
27## Migration
28
29### Pino v4 to to Pino v5
30
31#### Logging Destination
32
33In Pino v4 the destination could be set by passing a stream as the
34second parameter to the exported `pino` function. This is still the
35case in v5. However it's strongly recommended to use `pino.destination`
36which will write logs ~30% faster.
37
38##### v4
39
40```js
41const stdoutLogger = require('pino')()
42const stderrLogger = require('pino')(process.stderr)
43const fileLogger = require('pino')(fs.createWriteStream('/log/path'))
44```
45
46##### v5
47
48```js
49const stdoutLogger = require('pino')() // pino.destination by default
50const stderrLogger = require('pino')(pino.destination(2))
51const fileLogger = require('pino')(pino.destination('/log/path'))
52```
53
54Note: This is not a breaking change, `WritableStream` instances are still
55supported, but are slower than `pino.destination` which
56uses the high speed [`sonic-boom` ⇗](https://github.com/mcollina/sonic-boom) library.
57
58* See [`destination` parameter](/docs/api.md#destination)
59
60#### Extreme Mode
61
62The `extreme` setting does not exist as an option in Pino v5, instead use
63a `pino.extreme` destination.
64
65##### v4
66
67```js
68const stdoutLogger = require('pino')({extreme: true})
69const stderrLogger = require('pino')({extreme: true}, process.stderr)
70const fileLogger = require('pino')({extreme: true}, fs.createWriteStream('/log/path'))
71```
72
73##### v5
74
75```js
76const stdoutLogger = require('pino')(pino.extreme())
77const stderrLogger = require('pino')(pino.extreme(2))
78const fileLogger = require('pino')(pino.extreme('/log/path'))
79```
80
81* See [pino.extreme](/docs/api.md#pino-extreme)
82* See [Extreme mode ⇗](/docs/extreme.md)
83
84
85#### Pino CLI is now pino-pretty CLI
86
87The Pino CLI is provided with Pino v4 for basic log prettification.
88
89From Pino v5 the CLI is installed separately with `pino-pretty`.
90
91##### v4
92```sh
93$ npm install -g pino
94$ node app.js | pino
95```
96
97##### v5
98```sh
99$ npm install -g pino-pretty
100$ node app.js | pino-pretty
101```
102
103* See [Pretty Printing documentation](/docs/pretty.md)
104
105#### Programmatic Pretty Printing
106
107The [`pino.pretty()`](https://github.com/pinojs/pino/blob/v4.x.x/docs/API.md#prettyoptions)
108method has also been removed from Pino v5.
109
110##### v4
111
112```js
113var pino = require('pino')
114var pretty = pino.pretty()
115pretty.pipe(process.stdout)
116```
117
118##### v5
119
120Instead use the `prettyPrint` option (also available in v4):
121
122```js
123const logger = require('pino')({
124 prettyPrint: process.env.NODE_ENV !== 'production'
125})
126```
127
128In v5 the `pretty-print` module must be installed to use the `prettyPrint` option:
129
130```sh
131npm install --save-dev pino-pretty
132```
133
134* See [prettyPrint option](/docs/api.md#prettyPrint)
135* See [Pretty Printing documentation](/docs/pretty.md)
136
137#### Slowtime
138
139In Pino v4 a `slowtime` option was supplied, which allowed for full ISO dates
140in the timestamps instead of milliseconds since the Epoch. In Pino v5 this
141has been completely removed, along with the `pino.stdTimeFunctions.slowTime`
142function. In order to achieve the equivalent in v5, a custom
143time function should be supplied:
144
145##### v4
146
147```js
148const pino = require('pino')
149const logger = pino({slowtime: true})
150// following avoids deprecation warning in v4:
151const loggerAlt = pino({timestamp: pino.stdTimeFunctions.slowTime})
152```
153
154##### v5
155
156```js
157const logger = require('pino')({
158 timestamp: () => ',"time":"' + (new Date()).toISOString() + '"'
159})
160```
161
162The practice of creating ISO dates in-process for logging purposes is strongly
163recommended against. Instead consider post-processing the logs or using a transport
164to convert the timestamps.
165
166
167* See [timestamp option](/docs/api.md#timestamp)