1 | # Legacy
|
2 |
|
3 | ## Legacy Node Support
|
4 |
|
5 | ### Node v4
|
6 |
|
7 | Node v4 is supported on the [Pino v4](#pino-v4-documentation) line.
|
8 |
|
9 | ### Node v0.10-v0.12
|
10 |
|
11 | Node 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 |
|
33 | In Pino v4 the destination could be set by passing a stream as the
|
34 | second parameter to the exported `pino` function. This is still the
|
35 | case in v5. However it's strongly recommended to use `pino.destination`
|
36 | which will write logs ~30% faster.
|
37 |
|
38 | ##### v4
|
39 |
|
40 | ```js
|
41 | const stdoutLogger = require('pino')()
|
42 | const stderrLogger = require('pino')(process.stderr)
|
43 | const fileLogger = require('pino')(fs.createWriteStream('/log/path'))
|
44 | ```
|
45 |
|
46 | ##### v5
|
47 |
|
48 | ```js
|
49 | const stdoutLogger = require('pino')() // pino.destination by default
|
50 | const stderrLogger = require('pino')(pino.destination(2))
|
51 | const fileLogger = require('pino')(pino.destination('/log/path'))
|
52 | ```
|
53 |
|
54 | Note: This is not a breaking change, `WritableStream` instances are still
|
55 | supported, but are slower than `pino.destination` which
|
56 | uses 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 |
|
62 | The `extreme` setting does not exist as an option in Pino v5, instead use
|
63 | a `pino.extreme` destination.
|
64 |
|
65 | ##### v4
|
66 |
|
67 | ```js
|
68 | const stdoutLogger = require('pino')({extreme: true})
|
69 | const stderrLogger = require('pino')({extreme: true}, process.stderr)
|
70 | const fileLogger = require('pino')({extreme: true}, fs.createWriteStream('/log/path'))
|
71 | ```
|
72 |
|
73 | ##### v5
|
74 |
|
75 | ```js
|
76 | const stdoutLogger = require('pino')(pino.extreme())
|
77 | const stderrLogger = require('pino')(pino.extreme(2))
|
78 | const 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 |
|
87 | The Pino CLI is provided with Pino v4 for basic log prettification.
|
88 |
|
89 | From 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 |
|
107 | The [`pino.pretty()`](https://github.com/pinojs/pino/blob/v4.x.x/docs/API.md#prettyoptions)
|
108 | method has also been removed from Pino v5.
|
109 |
|
110 | ##### v4
|
111 |
|
112 | ```js
|
113 | var pino = require('pino')
|
114 | var pretty = pino.pretty()
|
115 | pretty.pipe(process.stdout)
|
116 | ```
|
117 |
|
118 | ##### v5
|
119 |
|
120 | Instead use the `prettyPrint` option (also available in v4):
|
121 |
|
122 | ```js
|
123 | const logger = require('pino')({
|
124 | prettyPrint: process.env.NODE_ENV !== 'production'
|
125 | })
|
126 | ```
|
127 |
|
128 | In v5 the `pretty-print` module must be installed to use the `prettyPrint` option:
|
129 |
|
130 | ```sh
|
131 | npm 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 |
|
139 | In Pino v4 a `slowtime` option was supplied, which allowed for full ISO dates
|
140 | in the timestamps instead of milliseconds since the Epoch. In Pino v5 this
|
141 | has been completely removed, along with the `pino.stdTimeFunctions.slowTime`
|
142 | function. In order to achieve the equivalent in v5, a custom
|
143 | time function should be supplied:
|
144 |
|
145 | ##### v4
|
146 |
|
147 | ```js
|
148 | const pino = require('pino')
|
149 | const logger = pino({slowtime: true})
|
150 | // following avoids deprecation warning in v4:
|
151 | const loggerAlt = pino({timestamp: pino.stdTimeFunctions.slowTime})
|
152 | ```
|
153 |
|
154 | ##### v5
|
155 |
|
156 | ```js
|
157 | const logger = require('pino')({
|
158 | timestamp: () => ',"time":"' + (new Date()).toISOString() + '"'
|
159 | })
|
160 | ```
|
161 |
|
162 | The practice of creating ISO dates in-process for logging purposes is strongly
|
163 | recommended against. Instead consider post-processing the logs or using a transport
|
164 | to convert the timestamps.
|
165 |
|
166 |
|
167 | * See [timestamp option](/docs/api.md#timestamp)
|