File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,40 @@ logger.info('hi')
130
130
131
131
See the [ Options] ( #options ) section for all possible options.
132
132
133
+ ### Handling non-serializable options
134
+
135
+ Using the new [ pino v7+
136
+ transports] ( https://getpino.io/#/docs/transports?id=v7-transports ) not all
137
+ options are serializable, for example if you want to use ` messageFormat ` as a
138
+ function you will need to wrap ` pino-pretty ` in a custom module.
139
+
140
+ Executing ` main.js ` below will log a colorized ` hello world ` message using a
141
+ custom function ` messageFormat ` :
142
+
143
+ ``` js
144
+ // main.js
145
+ const pino = require (' pino' )
146
+
147
+ const logger = pino ({
148
+ transport: {
149
+ target: ' ./pino-pretty-transport' ,
150
+ options: {
151
+ colorize: true
152
+ }
153
+ },
154
+ })
155
+
156
+ logger .info (' world' )
157
+ ```
158
+
159
+ ``` js
160
+ // pino-pretty-transport.js
161
+ module .exports = opts => require (' pino-pretty' )({
162
+ ... opts,
163
+ messageFormat : (log , messageKey ) => ` hello ${ log[messageKey]} `
164
+ })
165
+ ```
166
+
133
167
<a id =" options " ></a >
134
168
### Options
135
169
You can’t perform that action at this time.
0 commit comments