@wbce/projen-d9 0.0.27 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (422) hide show
  1. package/.jsii +185 -46
  2. package/API.md +153 -37
  3. package/CHANGELOG.md +20 -0
  4. package/README.md +10 -3
  5. package/docs/D9-plumbing.md +189 -0
  6. package/lib/cli/atlas.d.ts +10 -0
  7. package/lib/cli/atlas.js +65 -0
  8. package/lib/cli/commands/cedar/cedar-format.d.ts +7 -0
  9. package/lib/cli/commands/cedar/cedar-format.js +75 -0
  10. package/lib/cli/commands/cedar/cedar-to-d9-translations.d.ts +12 -0
  11. package/lib/cli/commands/cedar/cedar-to-d9-translations.js +130 -0
  12. package/lib/cli/commands/cedar/cedar-to-d9.d.ts +57 -0
  13. package/lib/cli/commands/cedar/cedar-to-d9.js +221 -0
  14. package/lib/cli/commands/cedar/cedar-translations.d.ts +9 -0
  15. package/lib/cli/commands/cedar/cedar-translations.js +213 -0
  16. package/lib/cli/commands/cedar/d9-permission.d.ts +27 -0
  17. package/lib/cli/commands/cedar/d9-permission.js +45 -0
  18. package/lib/cli/commands/cedar/d9-to-cedar.d.ts +33 -0
  19. package/lib/cli/commands/cedar/d9-to-cedar.js +157 -0
  20. package/lib/cli/commands/cedar/roles-table.d.ts +14 -0
  21. package/lib/cli/commands/cedar/roles-table.js +29 -0
  22. package/lib/cli/commands/save/apply-snapshot.js +39 -30
  23. package/lib/cli/commands/save/check-unsaved.d.ts +9 -0
  24. package/lib/cli/commands/save/check-unsaved.js +81 -0
  25. package/lib/cli/commands/save/env.d.ts +33 -0
  26. package/lib/cli/commands/save/env.js +109 -0
  27. package/lib/cli/commands/save/save-snapshot.d.ts +9 -0
  28. package/lib/cli/commands/save/save-snapshot.js +232 -0
  29. package/lib/cli/commands/save/sync-files.d.ts +5 -0
  30. package/lib/cli/commands/save/sync-files.js +46 -0
  31. package/lib/cli/commands/save/transfer.d.ts +18 -0
  32. package/lib/cli/commands/save/transfer.js +96 -0
  33. package/lib/cli/commands/save/utils.d.ts +5 -0
  34. package/lib/cli/commands/save/utils.js +33 -3
  35. package/lib/cli/commands/sync.js +4 -3
  36. package/lib/cli/index.js +65 -25
  37. package/lib/cli/logger.d.ts +2 -0
  38. package/lib/cli/logger.js +10 -0
  39. package/lib/cli/plumbing-config.d.ts +11 -0
  40. package/lib/cli/plumbing-config.js +13 -0
  41. package/lib/index.d.ts +44 -5
  42. package/lib/index.js +54 -41
  43. package/node_modules/@cedar-policy/cedar-wasm/README.md +181 -0
  44. package/node_modules/@cedar-policy/cedar-wasm/esm/README.md +181 -0
  45. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm.d.ts +427 -0
  46. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm.js +9 -0
  47. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.js +434 -0
  48. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.wasm +0 -0
  49. package/node_modules/@cedar-policy/cedar-wasm/esm/cedar_wasm_bg.wasm.d.ts +34 -0
  50. package/node_modules/@cedar-policy/cedar-wasm/esm/package.json +23 -0
  51. package/node_modules/@cedar-policy/cedar-wasm/nodejs/README.md +181 -0
  52. package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm.d.ts +427 -0
  53. package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm.js +463 -0
  54. package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm_bg.wasm +0 -0
  55. package/node_modules/@cedar-policy/cedar-wasm/nodejs/cedar_wasm_bg.wasm.d.ts +34 -0
  56. package/node_modules/@cedar-policy/cedar-wasm/nodejs/package.json +18 -0
  57. package/node_modules/@cedar-policy/cedar-wasm/package.json +53 -0
  58. package/node_modules/@cedar-policy/cedar-wasm/web/README.md +181 -0
  59. package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm.d.ts +486 -0
  60. package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm.js +534 -0
  61. package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm_bg.wasm +0 -0
  62. package/node_modules/@cedar-policy/cedar-wasm/web/cedar_wasm_bg.wasm.d.ts +34 -0
  63. package/node_modules/@cedar-policy/cedar-wasm/web/package.json +21 -0
  64. package/node_modules/@types/node/README.md +5 -6
  65. package/node_modules/@types/node/assert/strict.d.ts +111 -0
  66. package/node_modules/@types/node/assert.d.ts +1040 -79
  67. package/node_modules/@types/node/async_hooks.d.ts +476 -119
  68. package/node_modules/@types/node/buffer.buffer.d.ts +472 -0
  69. package/node_modules/@types/node/buffer.d.ts +1925 -13
  70. package/node_modules/@types/node/child_process.d.ts +1204 -235
  71. package/node_modules/@types/node/cluster.d.ts +455 -137
  72. package/node_modules/@types/node/compatibility/disposable.d.ts +14 -0
  73. package/node_modules/@types/node/compatibility/index.d.ts +9 -0
  74. package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
  75. package/node_modules/@types/node/compatibility/iterators.d.ts +20 -0
  76. package/node_modules/@types/node/console.d.ts +450 -1
  77. package/node_modules/@types/node/constants.d.ts +20 -447
  78. package/node_modules/@types/node/crypto.d.ts +3962 -600
  79. package/node_modules/@types/node/dgram.d.ts +515 -33
  80. package/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
  81. package/node_modules/@types/node/dns/promises.d.ts +503 -0
  82. package/node_modules/@types/node/dns.d.ts +798 -247
  83. package/node_modules/@types/node/domain.d.ts +164 -10
  84. package/node_modules/@types/node/events.d.ts +954 -25
  85. package/node_modules/@types/node/fs/promises.d.ts +1295 -0
  86. package/node_modules/@types/node/fs.d.ts +3463 -1569
  87. package/node_modules/@types/node/globals.d.ts +98 -1277
  88. package/node_modules/@types/node/globals.typedarray.d.ts +38 -0
  89. package/node_modules/@types/node/http.d.ts +1933 -300
  90. package/node_modules/@types/node/http2.d.ts +1946 -254
  91. package/node_modules/@types/node/https.d.ts +557 -134
  92. package/node_modules/@types/node/index.d.ts +54 -48
  93. package/node_modules/@types/node/inspector.d.ts +227 -3014
  94. package/node_modules/@types/node/inspector.generated.d.ts +4052 -0
  95. package/node_modules/@types/node/module.d.ts +890 -2
  96. package/node_modules/@types/node/net.d.ts +872 -105
  97. package/node_modules/@types/node/os.d.ts +452 -209
  98. package/node_modules/@types/node/package.json +78 -128
  99. package/node_modules/@types/node/path.d.ts +196 -155
  100. package/node_modules/@types/node/perf_hooks.d.ts +829 -120
  101. package/node_modules/@types/node/process.d.ts +2072 -3
  102. package/node_modules/@types/node/punycode.d.ts +69 -27
  103. package/node_modules/@types/node/querystring.d.ts +132 -9
  104. package/node_modules/@types/node/readline/promises.d.ts +161 -0
  105. package/node_modules/@types/node/readline.d.ts +485 -49
  106. package/node_modules/@types/node/repl.d.ts +121 -83
  107. package/node_modules/@types/node/sea.d.ts +153 -0
  108. package/node_modules/@types/node/sqlite.d.ts +721 -0
  109. package/node_modules/@types/node/stream/consumers.d.ts +38 -0
  110. package/node_modules/@types/node/stream/promises.d.ts +90 -0
  111. package/node_modules/@types/node/stream/web.d.ts +622 -0
  112. package/node_modules/@types/node/stream.d.ts +1470 -140
  113. package/node_modules/@types/node/string_decoder.d.ts +64 -4
  114. package/node_modules/@types/node/test.d.ts +2163 -0
  115. package/node_modules/@types/node/timers/promises.d.ts +108 -0
  116. package/node_modules/@types/node/timers.d.ts +284 -13
  117. package/node_modules/@types/node/tls.d.ts +850 -244
  118. package/node_modules/@types/node/trace_events.d.ts +147 -11
  119. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
  120. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
  121. package/node_modules/@types/node/ts5.6/index.d.ts +97 -0
  122. package/node_modules/@types/node/tty.d.ts +160 -18
  123. package/node_modules/@types/node/url.d.ts +890 -53
  124. package/node_modules/@types/node/util.d.ts +2566 -160
  125. package/node_modules/@types/node/v8.d.ts +806 -83
  126. package/node_modules/@types/node/vm.d.ts +932 -44
  127. package/node_modules/@types/node/wasi.d.ts +148 -22
  128. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  129. package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  130. package/node_modules/@types/node/web-globals/events.d.ts +97 -0
  131. package/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
  132. package/node_modules/@types/node/web-globals/navigator.d.ts +22 -0
  133. package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  134. package/node_modules/@types/node/worker_threads.d.ts +657 -80
  135. package/node_modules/@types/node/zlib.d.ts +510 -119
  136. package/node_modules/pino/.prettierignore +1 -0
  137. package/node_modules/pino/CNAME +1 -0
  138. package/node_modules/pino/CONTRIBUTING.md +34 -0
  139. package/node_modules/pino/LICENSE +21 -0
  140. package/node_modules/pino/README.md +177 -0
  141. package/node_modules/pino/SECURITY.md +103 -0
  142. package/node_modules/pino/benchmarks/basic.bench.js +95 -0
  143. package/node_modules/pino/benchmarks/child-child.bench.js +52 -0
  144. package/node_modules/pino/benchmarks/child-creation.bench.js +73 -0
  145. package/node_modules/pino/benchmarks/child.bench.js +62 -0
  146. package/node_modules/pino/benchmarks/deep-object.bench.js +88 -0
  147. package/node_modules/pino/benchmarks/formatters.bench.js +50 -0
  148. package/node_modules/pino/benchmarks/internal/custom-levels.js +67 -0
  149. package/node_modules/pino/benchmarks/internal/just-pino-heavy.bench.js +76 -0
  150. package/node_modules/pino/benchmarks/internal/just-pino.bench.js +182 -0
  151. package/node_modules/pino/benchmarks/internal/parent-vs-child.bench.js +75 -0
  152. package/node_modules/pino/benchmarks/internal/redact.bench.js +86 -0
  153. package/node_modules/pino/benchmarks/long-string.bench.js +81 -0
  154. package/node_modules/pino/benchmarks/multi-arg.bench.js +193 -0
  155. package/node_modules/pino/benchmarks/multistream.js +98 -0
  156. package/node_modules/pino/benchmarks/object.bench.js +82 -0
  157. package/node_modules/pino/benchmarks/utils/generate-benchmark-doc.js +36 -0
  158. package/node_modules/pino/benchmarks/utils/runbench.js +138 -0
  159. package/node_modules/pino/benchmarks/utils/wrap-log-level.js +55 -0
  160. package/node_modules/pino/bin.js +6 -0
  161. package/node_modules/pino/browser.js +607 -0
  162. package/node_modules/pino/build/sync-version.js +25 -0
  163. package/node_modules/pino/docs/api.md +1664 -0
  164. package/node_modules/pino/docs/asynchronous.md +55 -0
  165. package/node_modules/pino/docs/benchmarks.md +55 -0
  166. package/node_modules/pino/docs/browser.md +341 -0
  167. package/node_modules/pino/docs/bundling.md +40 -0
  168. package/node_modules/pino/docs/child-loggers.md +116 -0
  169. package/node_modules/pino/docs/diagnostics.md +16 -0
  170. package/node_modules/pino/docs/ecosystem.md +87 -0
  171. package/node_modules/pino/docs/help.md +353 -0
  172. package/node_modules/pino/docs/lts.md +93 -0
  173. package/node_modules/pino/docs/pretty.md +38 -0
  174. package/node_modules/pino/docs/redaction.md +130 -0
  175. package/node_modules/pino/docs/transports.md +1447 -0
  176. package/node_modules/pino/docs/web.md +306 -0
  177. package/node_modules/pino/eslint.config.js +36 -0
  178. package/node_modules/pino/examples/basic.js +43 -0
  179. package/node_modules/pino/examples/transport.js +68 -0
  180. package/node_modules/pino/favicon.ico +0 -0
  181. package/node_modules/pino/file.js +12 -0
  182. package/node_modules/pino/inc-version.sh +42 -0
  183. package/node_modules/pino/index.html +55 -0
  184. package/node_modules/pino/lib/caller.js +40 -0
  185. package/node_modules/pino/lib/constants.js +28 -0
  186. package/node_modules/pino/lib/deprecations.js +8 -0
  187. package/node_modules/pino/lib/levels.js +241 -0
  188. package/node_modules/pino/lib/meta.js +3 -0
  189. package/node_modules/pino/lib/multistream.js +211 -0
  190. package/node_modules/pino/lib/proto.js +256 -0
  191. package/node_modules/pino/lib/redaction.js +119 -0
  192. package/node_modules/pino/lib/symbols.js +76 -0
  193. package/node_modules/pino/lib/time.js +39 -0
  194. package/node_modules/pino/lib/tools.js +427 -0
  195. package/node_modules/pino/lib/transport-stream.js +56 -0
  196. package/node_modules/pino/lib/transport.js +302 -0
  197. package/node_modules/pino/lib/worker.js +197 -0
  198. package/node_modules/pino/package.json +112 -0
  199. package/node_modules/pino/pino.d.ts +881 -0
  200. package/node_modules/pino/pino.js +259 -0
  201. package/node_modules/pino/test/basic.test.js +952 -0
  202. package/node_modules/pino/test/broken-pipe.test.js +59 -0
  203. package/node_modules/pino/test/browser-bindings.test.js +114 -0
  204. package/node_modules/pino/test/browser-child.test.js +132 -0
  205. package/node_modules/pino/test/browser-disabled.test.js +87 -0
  206. package/node_modules/pino/test/browser-early-console-freeze.test.js +12 -0
  207. package/node_modules/pino/test/browser-is-level-enabled.test.js +101 -0
  208. package/node_modules/pino/test/browser-levels.test.js +241 -0
  209. package/node_modules/pino/test/browser-redaction.test.js +264 -0
  210. package/node_modules/pino/test/browser-serializers.test.js +352 -0
  211. package/node_modules/pino/test/browser-set-bindings.test.js +99 -0
  212. package/node_modules/pino/test/browser-timestamp.test.js +88 -0
  213. package/node_modules/pino/test/browser-transmit.test.js +417 -0
  214. package/node_modules/pino/test/browser.test.js +698 -0
  215. package/node_modules/pino/test/caller.test.js +20 -0
  216. package/node_modules/pino/test/complex-objects.test.js +36 -0
  217. package/node_modules/pino/test/crlf.test.js +34 -0
  218. package/node_modules/pino/test/custom-levels.test.js +267 -0
  219. package/node_modules/pino/test/diagnostics.test.js +107 -0
  220. package/node_modules/pino/test/error-key.test.js +37 -0
  221. package/node_modules/pino/test/error.test.js +403 -0
  222. package/node_modules/pino/test/escaping.test.js +110 -0
  223. package/node_modules/pino/test/esm/esm.mjs +14 -0
  224. package/node_modules/pino/test/esm/index.test.js +21 -0
  225. package/node_modules/pino/test/esm/named-exports.mjs +29 -0
  226. package/node_modules/pino/test/exit.test.js +79 -0
  227. package/node_modules/pino/test/fixtures/broken-pipe/basic.js +9 -0
  228. package/node_modules/pino/test/fixtures/broken-pipe/destination.js +10 -0
  229. package/node_modules/pino/test/fixtures/broken-pipe/syncfalse.js +12 -0
  230. package/node_modules/pino/test/fixtures/caller-loop.js +6 -0
  231. package/node_modules/pino/test/fixtures/console-transport.js +13 -0
  232. package/node_modules/pino/test/fixtures/crashing-transport.js +13 -0
  233. package/node_modules/pino/test/fixtures/default-exit.js +8 -0
  234. package/node_modules/pino/test/fixtures/destination-exit.js +8 -0
  235. package/node_modules/pino/test/fixtures/eval/index.js +13 -0
  236. package/node_modules/pino/test/fixtures/eval/node_modules/14-files.js +3 -0
  237. package/node_modules/pino/test/fixtures/eval/node_modules/2-files.js +3 -0
  238. package/node_modules/pino/test/fixtures/eval/node_modules/file1.js +5 -0
  239. package/node_modules/pino/test/fixtures/eval/node_modules/file10.js +5 -0
  240. package/node_modules/pino/test/fixtures/eval/node_modules/file11.js +5 -0
  241. package/node_modules/pino/test/fixtures/eval/node_modules/file12.js +5 -0
  242. package/node_modules/pino/test/fixtures/eval/node_modules/file13.js +5 -0
  243. package/node_modules/pino/test/fixtures/eval/node_modules/file14.js +11 -0
  244. package/node_modules/pino/test/fixtures/eval/node_modules/file2.js +5 -0
  245. package/node_modules/pino/test/fixtures/eval/node_modules/file3.js +5 -0
  246. package/node_modules/pino/test/fixtures/eval/node_modules/file4.js +5 -0
  247. package/node_modules/pino/test/fixtures/eval/node_modules/file5.js +5 -0
  248. package/node_modules/pino/test/fixtures/eval/node_modules/file6.js +5 -0
  249. package/node_modules/pino/test/fixtures/eval/node_modules/file7.js +5 -0
  250. package/node_modules/pino/test/fixtures/eval/node_modules/file8.js +5 -0
  251. package/node_modules/pino/test/fixtures/eval/node_modules/file9.js +5 -0
  252. package/node_modules/pino/test/fixtures/noop-transport.js +10 -0
  253. package/node_modules/pino/test/fixtures/pretty/null-prototype.js +8 -0
  254. package/node_modules/pino/test/fixtures/stdout-hack-protection.js +11 -0
  255. package/node_modules/pino/test/fixtures/syncfalse-child.js +6 -0
  256. package/node_modules/pino/test/fixtures/syncfalse-exit.js +9 -0
  257. package/node_modules/pino/test/fixtures/syncfalse-flush-exit.js +10 -0
  258. package/node_modules/pino/test/fixtures/syncfalse.js +6 -0
  259. package/node_modules/pino/test/fixtures/syntax-error-esm.mjs +2 -0
  260. package/node_modules/pino/test/fixtures/to-file-transport-with-transform.js +20 -0
  261. package/node_modules/pino/test/fixtures/to-file-transport.js +13 -0
  262. package/node_modules/pino/test/fixtures/to-file-transport.mjs +8 -0
  263. package/node_modules/pino/test/fixtures/transport/index.js +12 -0
  264. package/node_modules/pino/test/fixtures/transport/package.json +5 -0
  265. package/node_modules/pino/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
  266. package/node_modules/pino/test/fixtures/transport-exit-immediately.js +11 -0
  267. package/node_modules/pino/test/fixtures/transport-exit-on-ready.js +12 -0
  268. package/node_modules/pino/test/fixtures/transport-invalid-node-options.js +26 -0
  269. package/node_modules/pino/test/fixtures/transport-main.js +9 -0
  270. package/node_modules/pino/test/fixtures/transport-many-lines.js +29 -0
  271. package/node_modules/pino/test/fixtures/transport-preload-main.mjs +13 -0
  272. package/node_modules/pino/test/fixtures/transport-preload.mjs +13 -0
  273. package/node_modules/pino/test/fixtures/transport-string-stdout.js +9 -0
  274. package/node_modules/pino/test/fixtures/transport-transform.js +21 -0
  275. package/node_modules/pino/test/fixtures/transport-uses-pino-config.js +33 -0
  276. package/node_modules/pino/test/fixtures/transport-with-on-exit.js +12 -0
  277. package/node_modules/pino/test/fixtures/transport-worker-data.js +19 -0
  278. package/node_modules/pino/test/fixtures/transport-worker-name.js +24 -0
  279. package/node_modules/pino/test/fixtures/transport-worker.js +15 -0
  280. package/node_modules/pino/test/fixtures/transport-wrong-export-type.js +3 -0
  281. package/node_modules/pino/test/fixtures/ts/to-file-transport-native.mts +15 -0
  282. package/node_modules/pino/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
  283. package/node_modules/pino/test/fixtures/ts/to-file-transport.ts +11 -0
  284. package/node_modules/pino/test/fixtures/ts/transpile.cjs +36 -0
  285. package/node_modules/pino/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
  286. package/node_modules/pino/test/fixtures/ts/transport-exit-immediately.ts +10 -0
  287. package/node_modules/pino/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
  288. package/node_modules/pino/test/fixtures/ts/transport-main.ts +8 -0
  289. package/node_modules/pino/test/fixtures/ts/transport-string-stdout.ts +8 -0
  290. package/node_modules/pino/test/fixtures/ts/transport-worker.ts +14 -0
  291. package/node_modules/pino/test/formatters.test.js +364 -0
  292. package/node_modules/pino/test/helper.d.ts +4 -0
  293. package/node_modules/pino/test/helper.js +159 -0
  294. package/node_modules/pino/test/hooks.test.js +114 -0
  295. package/node_modules/pino/test/http.test.js +214 -0
  296. package/node_modules/pino/test/internals/version.test.js +17 -0
  297. package/node_modules/pino/test/is-level-enabled.test.js +179 -0
  298. package/node_modules/pino/test/jest/basic.spec.js +10 -0
  299. package/node_modules/pino/test/levels.test.js +810 -0
  300. package/node_modules/pino/test/metadata.test.js +120 -0
  301. package/node_modules/pino/test/mixin-merge-strategy.test.js +57 -0
  302. package/node_modules/pino/test/mixin.test.js +241 -0
  303. package/node_modules/pino/test/multistream.test.js +793 -0
  304. package/node_modules/pino/test/redact.test.js +923 -0
  305. package/node_modules/pino/test/serializers.test.js +257 -0
  306. package/node_modules/pino/test/smoke.js +59 -0
  307. package/node_modules/pino/test/stdout-protection.test.js +41 -0
  308. package/node_modules/pino/test/syncfalse.test.js +186 -0
  309. package/node_modules/pino/test/timestamp-nano.test.js +37 -0
  310. package/node_modules/pino/test/timestamp.test.js +124 -0
  311. package/node_modules/pino/test/transport/big.test.js +42 -0
  312. package/node_modules/pino/test/transport/bundlers-support.test.js +99 -0
  313. package/node_modules/pino/test/transport/caller.test.js +24 -0
  314. package/node_modules/pino/test/transport/core.test.js +818 -0
  315. package/node_modules/pino/test/transport/core.transpiled.test.ts +114 -0
  316. package/node_modules/pino/test/transport/crash.test.js +36 -0
  317. package/node_modules/pino/test/transport/module-link.test.js +241 -0
  318. package/node_modules/pino/test/transport/native-type-stripping.test.mjs +151 -0
  319. package/node_modules/pino/test/transport/node-options.test.js +116 -0
  320. package/node_modules/pino/test/transport/pipeline.test.js +137 -0
  321. package/node_modules/pino/test/transport/preload.test.js +54 -0
  322. package/node_modules/pino/test/transport/repl.test.js +15 -0
  323. package/node_modules/pino/test/transport/sync-false.test.js +79 -0
  324. package/node_modules/pino/test/transport/sync-true.test.js +57 -0
  325. package/node_modules/pino/test/transport/targets.test.js +48 -0
  326. package/node_modules/pino/test/transport/uses-pino-config.test.js +166 -0
  327. package/node_modules/pino/test/transport-stream.test.js +40 -0
  328. package/node_modules/pino/test/types/pino-import.tst.cts +30 -0
  329. package/node_modules/pino/test/types/pino-import.tst.js +73 -0
  330. package/node_modules/pino/test/types/pino-multistream.tst.ts +49 -0
  331. package/node_modules/pino/test/types/pino-top-export.tst.ts +32 -0
  332. package/node_modules/pino/test/types/pino-transport.tst.ts +171 -0
  333. package/node_modules/pino/test/types/pino-type-only.tst.ts +77 -0
  334. package/node_modules/pino/test/types/pino.ts +98 -0
  335. package/node_modules/pino/test/types/pino.tst.ts +681 -0
  336. package/node_modules/pino/test/types/tsconfig.json +10 -0
  337. package/node_modules/pino/tsconfig.json +14 -0
  338. package/node_modules/pino-pretty/.borp.yaml +6 -0
  339. package/node_modules/pino-pretty/.editorconfig +13 -0
  340. package/node_modules/pino-pretty/.github/dependabot.yml +13 -0
  341. package/node_modules/pino-pretty/.github/workflows/ci.yml +83 -0
  342. package/node_modules/pino-pretty/LICENSE +21 -0
  343. package/node_modules/pino-pretty/Readme.md +425 -0
  344. package/node_modules/pino-pretty/SECURITY.md +146 -0
  345. package/node_modules/pino-pretty/benchmark.js +105 -0
  346. package/node_modules/pino-pretty/bin.js +113 -0
  347. package/node_modules/pino-pretty/demo.png +0 -0
  348. package/node_modules/pino-pretty/docs/help.md +24 -0
  349. package/node_modules/pino-pretty/eslint.config.js +5 -0
  350. package/node_modules/pino-pretty/help/help.txt +68 -0
  351. package/node_modules/pino-pretty/index.d.ts +227 -0
  352. package/node_modules/pino-pretty/index.js +234 -0
  353. package/node_modules/pino-pretty/lib/colors.js +134 -0
  354. package/node_modules/pino-pretty/lib/colors.test.js +132 -0
  355. package/node_modules/pino-pretty/lib/constants.js +55 -0
  356. package/node_modules/pino-pretty/lib/pretty.js +171 -0
  357. package/node_modules/pino-pretty/lib/utils/build-safe-sonic-boom.js +69 -0
  358. package/node_modules/pino-pretty/lib/utils/build-safe-sonic-boom.test.js +84 -0
  359. package/node_modules/pino-pretty/lib/utils/create-date.js +26 -0
  360. package/node_modules/pino-pretty/lib/utils/create-date.test.js +20 -0
  361. package/node_modules/pino-pretty/lib/utils/delete-log-property.js +28 -0
  362. package/node_modules/pino-pretty/lib/utils/delete-log-property.test.js +31 -0
  363. package/node_modules/pino-pretty/lib/utils/filter-log.js +99 -0
  364. package/node_modules/pino-pretty/lib/utils/filter-log.test.js +265 -0
  365. package/node_modules/pino-pretty/lib/utils/format-time.js +66 -0
  366. package/node_modules/pino-pretty/lib/utils/format-time.test.js +71 -0
  367. package/node_modules/pino-pretty/lib/utils/get-level-label-data.js +29 -0
  368. package/node_modules/pino-pretty/lib/utils/get-property-value.js +30 -0
  369. package/node_modules/pino-pretty/lib/utils/get-property-value.test.js +31 -0
  370. package/node_modules/pino-pretty/lib/utils/handle-custom-levels-names-opts.js +38 -0
  371. package/node_modules/pino-pretty/lib/utils/handle-custom-levels-names-opts.test.js +45 -0
  372. package/node_modules/pino-pretty/lib/utils/handle-custom-levels-opts.js +39 -0
  373. package/node_modules/pino-pretty/lib/utils/handle-custom-levels-opts.test.js +47 -0
  374. package/node_modules/pino-pretty/lib/utils/index.js +108 -0
  375. package/node_modules/pino-pretty/lib/utils/index.test.js +37 -0
  376. package/node_modules/pino-pretty/lib/utils/interpret-conditionals.js +41 -0
  377. package/node_modules/pino-pretty/lib/utils/interpret-conditionals.test.js +84 -0
  378. package/node_modules/pino-pretty/lib/utils/is-object.js +7 -0
  379. package/node_modules/pino-pretty/lib/utils/is-object.test.js +10 -0
  380. package/node_modules/pino-pretty/lib/utils/is-valid-date.js +14 -0
  381. package/node_modules/pino-pretty/lib/utils/is-valid-date.test.js +16 -0
  382. package/node_modules/pino-pretty/lib/utils/join-lines-with-indentation.js +29 -0
  383. package/node_modules/pino-pretty/lib/utils/join-lines-with-indentation.test.js +16 -0
  384. package/node_modules/pino-pretty/lib/utils/noop.js +3 -0
  385. package/node_modules/pino-pretty/lib/utils/noop.test.js +12 -0
  386. package/node_modules/pino-pretty/lib/utils/parse-factory-options.js +171 -0
  387. package/node_modules/pino-pretty/lib/utils/prettify-error-log.js +76 -0
  388. package/node_modules/pino-pretty/lib/utils/prettify-error-log.test.js +143 -0
  389. package/node_modules/pino-pretty/lib/utils/prettify-error.js +54 -0
  390. package/node_modules/pino-pretty/lib/utils/prettify-error.test.js +25 -0
  391. package/node_modules/pino-pretty/lib/utils/prettify-level.js +41 -0
  392. package/node_modules/pino-pretty/lib/utils/prettify-level.test.js +70 -0
  393. package/node_modules/pino-pretty/lib/utils/prettify-message.js +65 -0
  394. package/node_modules/pino-pretty/lib/utils/prettify-message.test.js +287 -0
  395. package/node_modules/pino-pretty/lib/utils/prettify-metadata.js +75 -0
  396. package/node_modules/pino-pretty/lib/utils/prettify-metadata.test.js +170 -0
  397. package/node_modules/pino-pretty/lib/utils/prettify-object.js +115 -0
  398. package/node_modules/pino-pretty/lib/utils/prettify-object.test.js +217 -0
  399. package/node_modules/pino-pretty/lib/utils/prettify-time.js +43 -0
  400. package/node_modules/pino-pretty/lib/utils/prettify-time.test.js +264 -0
  401. package/node_modules/pino-pretty/lib/utils/split-property-key.js +49 -0
  402. package/node_modules/pino-pretty/lib/utils/split-property-key.test.js +29 -0
  403. package/node_modules/pino-pretty/lib/utils/strip-unsafe-control-chars.js +18 -0
  404. package/node_modules/pino-pretty/lib/utils/strip-unsafe-control-chars.test.js +9 -0
  405. package/node_modules/pino-pretty/package.json +64 -0
  406. package/node_modules/pino-pretty/test/basic.test.js +1305 -0
  407. package/node_modules/pino-pretty/test/boolean-options.test.js +228 -0
  408. package/node_modules/pino-pretty/test/cli-rc.test.js +275 -0
  409. package/node_modules/pino-pretty/test/cli.test.js +360 -0
  410. package/node_modules/pino-pretty/test/crlf.test.js +33 -0
  411. package/node_modules/pino-pretty/test/error-objects.test.js +494 -0
  412. package/node_modules/pino-pretty/test/example/example.js +33 -0
  413. package/node_modules/pino-pretty/test/helper.js +19 -0
  414. package/node_modules/pino-pretty/test/types/exports.tst.ts +15 -0
  415. package/node_modules/pino-pretty/test/types/pino-pretty.tst.ts +140 -0
  416. package/node_modules/pino-pretty/test/types/tsconfig.json +9 -0
  417. package/package.json +14 -7
  418. package/lib/cli/commands/init.d.ts +0 -1
  419. package/lib/cli/commands/init.js +0 -8
  420. package/lib/cli/commands/save/draft.js +0 -2
  421. package/node_modules/@types/node/globals.global.d.ts +0 -1
  422. /package/{lib/cli/commands/save/draft.d.ts → node_modules/pino/.nojekyll} +0 -0
@@ -0,0 +1,1664 @@
1
+ # API
2
+
3
+ * [pino() => logger](#export)
4
+ * [options](#options)
5
+ * [destination](#destination)
6
+ * [destination\[Symbol.for('pino.metadata')\]](#metadata)
7
+ * [Logger Instance](#logger)
8
+ * [logger.trace()](#trace)
9
+ * [logger.debug()](#debug)
10
+ * [logger.info()](#info)
11
+ * [logger.warn()](#warn)
12
+ * [logger.error()](#error)
13
+ * [logger.fatal()](#fatal)
14
+ * [logger.silent()](#silent)
15
+ * [logger.child()](#child)
16
+ * [logger.bindings()](#logger-bindings)
17
+ * [logger.setBindings()](#logger-set-bindings)
18
+ * [logger.flush()](#flush)
19
+ * [logger.level](#logger-level)
20
+ * [logger.isLevelEnabled()](#islevelenabled)
21
+ * [logger.levels](#levels)
22
+ * [logger\[Symbol.for('pino.serializers')\]](#serializers)
23
+ * [Event: 'level-change'](#level-change)
24
+ * [logger.version](#version)
25
+ * [logger.msgPrefix](#msgPrefix)
26
+ * [Statics](#statics)
27
+ * [pino.destination()](#pino-destination)
28
+ * [pino.transport()](#pino-transport)
29
+ * [pino.multistream()](#pino-multistream)
30
+ * [pino.stdSerializers](#pino-stdserializers)
31
+ * [pino.stdTimeFunctions](#pino-stdtimefunctions)
32
+ * [pino.symbols](#pino-symbols)
33
+ * [pino.version](#pino-version)
34
+ * [Interfaces](#interfaces)
35
+ * [MultiStreamRes](#multistreamres)
36
+ * [StreamEntry](#streamentry)
37
+ * [DestinationStream](#destinationstream)
38
+ * [Types](#types)
39
+ * [Level](#level-1)
40
+ * [TypeScript](#typescript)
41
+ * [Module Augmentation](#module-augmentation)
42
+ * [LogFnFields Interface](#logfnfields-interface)
43
+
44
+ <a id="export"></a>
45
+ ## `pino([options], [destination]) => logger`
46
+
47
+ The exported `pino` function takes two optional arguments,
48
+ [`options`](#options) and [`destination`](#destination), and
49
+ returns a [logger instance](#logger).
50
+
51
+ <a id=options></a>
52
+ ### `options` (Object)
53
+
54
+ #### `name` (String)
55
+
56
+ Default: `undefined`
57
+
58
+ The name of the logger. When set adds a `name` field to every JSON line logged.
59
+
60
+ #### `level` (String)
61
+
62
+ Default: `'info'`
63
+
64
+ The minimum level to log: Pino will not log messages with a lower level. Setting this option reduces the load, as typically, debug and trace logs are only valid for development, and not needed in production.
65
+
66
+ One of `'fatal'`, `'error'`, `'warn'`, `'info'`, `'debug'`, `'trace'` or `'silent'`.
67
+
68
+ Additional levels can be added to the instance via the `customLevels` option.
69
+
70
+ * See [`customLevels` option](#opt-customlevels)
71
+
72
+ <a id=opt-customlevels></a>
73
+
74
+ #### `levelComparison` ("ASC", "DESC", Function)
75
+
76
+ Default: `ASC`
77
+
78
+ Use this option to customize levels order.
79
+ In order to be able to define custom levels ordering pass a function which will accept `current` and `expected` values and return `boolean` which shows should `current` level to be shown or not.
80
+
81
+ ```js
82
+ const logger = pino({
83
+ levelComparison: 'DESC',
84
+ customLevels: {
85
+ foo: 20, // `foo` is more valuable than `bar`
86
+ bar: 10
87
+ },
88
+ })
89
+
90
+ // OR
91
+
92
+ const logger = pino({
93
+ levelComparison: function(current, expected) {
94
+ return current >= expected;
95
+ }
96
+ })
97
+ ```
98
+
99
+ #### `customLevels` (Object)
100
+
101
+ Default: `undefined`
102
+
103
+ Use this option to define additional logging levels.
104
+ The keys of the object correspond to the namespace of the log level,
105
+ and the values should be the numerical value of the level.
106
+
107
+ ```js
108
+ const logger = pino({
109
+ customLevels: {
110
+ foo: 35
111
+ }
112
+ })
113
+ logger.foo('hi')
114
+ ```
115
+
116
+ <a id=opt-useOnlyCustomLevels></a>
117
+ #### `useOnlyCustomLevels` (Boolean)
118
+
119
+ Default: `false`
120
+
121
+ Use this option to only use defined `customLevels` and omit Pino's levels.
122
+ Logger's default `level` must be changed to a value in `customLevels` to use `useOnlyCustomLevels`
123
+ Warning: this option may not be supported by downstream transports.
124
+
125
+ ```js
126
+ const logger = pino({
127
+ customLevels: {
128
+ foo: 35
129
+ },
130
+ useOnlyCustomLevels: true,
131
+ level: 'foo'
132
+ })
133
+ logger.foo('hi')
134
+ logger.info('hello') // Will throw an error saying info is not found in logger object
135
+ ```
136
+ #### `depthLimit` (Number)
137
+
138
+ Default: `5`
139
+
140
+ Maximum nesting depth used by Pino's fallback serializer.
141
+
142
+ #### `edgeLimit` (Number)
143
+
144
+ Default: `100`
145
+
146
+ Maximum number of properties/elements per object or array used by Pino's fallback serializer.
147
+
148
+ Pino uses the fallback serializer, and therefore applies `depthLimit` and `edgeLimit`, only after
149
+ `JSON.stringify` throws. These options are not general limits on serialization work or output size.
150
+ For example, `JSON.stringify` successfully serializes a non-circular object graph that contains
151
+ repeated references to the same object. In that case, every reference is traversed and serialized
152
+ in full, without applying either limit.
153
+
154
+ <a id="opt-mixin"></a>
155
+ #### `mixin` (Function):
156
+
157
+ Default: `undefined`
158
+
159
+ If provided, the `mixin` function is called each time one of the active
160
+ logging methods is called. The first parameter is the value `mergeObject` or an empty object. The second parameter is the log level number.
161
+ The third parameter is the logger or child logger itself, which can be used to
162
+ retrieve logger-specific context from within the `mixin` function.
163
+ The function must synchronously return an object. The properties of the returned object will be added to the
164
+ logged JSON.
165
+
166
+ ```js
167
+ let n = 0
168
+ const logger = pino({
169
+ mixin () {
170
+ return { line: ++n }
171
+ }
172
+ })
173
+ logger.info('hello')
174
+ // {"level":30,"time":1573664685466,"pid":78742,"hostname":"x","line":1,"msg":"hello"}
175
+ logger.info('world')
176
+ // {"level":30,"time":1573664685469,"pid":78742,"hostname":"x","line":2,"msg":"world"}
177
+ ```
178
+
179
+ The result of `mixin()` is supposed to be a _new_ object. For performance reason, the object returned by `mixin()` will be mutated by pino.
180
+ In the following example, passing `mergingObject` argument to the first `info` call will mutate the global `mixin` object by default:
181
+ (* See [`mixinMergeStrategy` option](#opt-mixin-merge-strategy)):
182
+ ```js
183
+ const mixin = {
184
+ appName: 'My app'
185
+ }
186
+
187
+ const logger = pino({
188
+ mixin() {
189
+ return mixin;
190
+ }
191
+ })
192
+
193
+ logger.info({
194
+ description: 'Ok'
195
+ }, 'Message 1')
196
+ // {"level":30,"time":1591195061437,"pid":16012,"hostname":"x","appName":"My app","description":"Ok","msg":"Message 1"}
197
+ logger.info('Message 2')
198
+ // {"level":30,"time":1591195061437,"pid":16012,"hostname":"x","appName":"My app","description":"Ok","msg":"Message 2"}
199
+ // Note: the second log contains "description":"Ok" text, even if it was not provided.
200
+ ```
201
+
202
+ The `mixin` method can be used to add the level label to each log message such as in the following example:
203
+ ```js
204
+ const logger = pino({
205
+ mixin(_context, level) {
206
+ return { 'level-label': logger.levels.labels[level] }
207
+ }
208
+ })
209
+
210
+ logger.info({
211
+ description: 'Ok'
212
+ }, 'Message 1')
213
+ // {"level":30,"time":1591195061437,"pid":16012,"hostname":"x","description":"Ok","level-label":"info","msg":"Message 1"}
214
+ logger.error('Message 2')
215
+ // {"level":30,"time":1591195061437,"pid":16012,"hostname":"x","level-label":"error","msg":"Message 2"}
216
+ ```
217
+
218
+ If the `mixin` feature is being used merely to add static metadata to each log message,
219
+ then a [child logger ⇗](/docs/child-loggers.md) should be used instead. Unless your application
220
+ needs to concatenate values for a specific key multiple times, in which case `mixin` can be
221
+ used to avoid the [duplicate keys caveat](/docs/child-loggers.md#duplicate-keys-caveat):
222
+
223
+ ```js
224
+ const logger = pino({
225
+ mixin (obj, num, logger) {
226
+ return {
227
+ tags: logger.tags
228
+ }
229
+ }
230
+ })
231
+ logger.tags = {}
232
+
233
+ logger.addTag = function (key, value) {
234
+ logger.tags[key] = value
235
+ }
236
+
237
+ function createChild (parent, ...context) {
238
+ const newChild = logger.child(...context)
239
+ newChild.tags = { ...logger.tags }
240
+ newChild.addTag = function (key, value) {
241
+ newChild.tags[key] = value
242
+ }
243
+ return newChild
244
+ }
245
+
246
+ logger.addTag('foo', 1)
247
+ const child = createChild(logger, {})
248
+ child.addTag('bar', 2)
249
+ logger.info('this will only have `foo: 1`')
250
+ child.info('this will have both `foo: 1` and `bar: 2`')
251
+ logger.info('this will still only have `foo: 1`')
252
+ ```
253
+
254
+ As of pino 7.x, when the `mixin` is used with the [`nestedKey` option](#opt-nestedkey),
255
+ the object returned from the `mixin` method will also be nested. Prior versions would mix
256
+ this object into the root.
257
+
258
+ ```js
259
+ const logger = pino({
260
+ nestedKey: 'payload',
261
+ mixin() {
262
+ return { requestId: requestId.currentId() }
263
+ }
264
+ })
265
+
266
+ logger.info({
267
+ description: 'Ok'
268
+ }, 'Message 1')
269
+ // {"level":30,"time":1591195061437,"pid":16012,"hostname":"x","payload":{"requestId":"dfe9a9014b","description":"Ok"},"msg":"Message 1"}
270
+ ```
271
+
272
+ <a id="opt-mixin-merge-strategy"></a>
273
+ #### `mixinMergeStrategy` (Function):
274
+
275
+ Default: `undefined`
276
+
277
+ If provided, the `mixinMergeStrategy` function is called each time one of the active
278
+ logging methods is called. The first parameter is the value `mergeObject` or an empty object,
279
+ the second parameter is the value resulting from `mixin()` (* See [`mixin` option](#opt-mixin) or an empty object.
280
+ The function must synchronously return an object.
281
+
282
+ ```js
283
+ // Default strategy, `mergeObject` has priority
284
+ const logger = pino({
285
+ mixin() {
286
+ return { tag: 'docker' }
287
+ },
288
+ // mixinMergeStrategy(mergeObject, mixinObject) {
289
+ // return Object.assign(mixinMeta, mergeObject)
290
+ // }
291
+ })
292
+
293
+ logger.info({
294
+ tag: 'local'
295
+ }, 'Message')
296
+ // {"level":30,"time":1591195061437,"pid":16012,"hostname":"x","tag":"local","msg":"Message"}
297
+ ```
298
+
299
+ ```js
300
+ // Custom mutable strategy, `mixin` has priority
301
+ const logger = pino({
302
+ mixin() {
303
+ return { tag: 'k8s' }
304
+ },
305
+ mixinMergeStrategy(mergeObject, mixinObject) {
306
+ return Object.assign(mergeObject, mixinObject)
307
+ }
308
+ })
309
+
310
+ logger.info({
311
+ tag: 'local'
312
+ }, 'Message')
313
+ // {"level":30,"time":1591195061437,"pid":16012,"hostname":"x","tag":"k8s","msg":"Message"}
314
+ ```
315
+
316
+ ```js
317
+ // Custom immutable strategy, `mixin` has priority
318
+ const logger = pino({
319
+ mixin() {
320
+ return { tag: 'k8s' }
321
+ },
322
+ mixinMergeStrategy(mergeObject, mixinObject) {
323
+ return Object.assign({}, mergeObject, mixinObject)
324
+ }
325
+ })
326
+
327
+ logger.info({
328
+ tag: 'local'
329
+ }, 'Message')
330
+ // {"level":30,"time":1591195061437,"pid":16012,"hostname":"x","tag":"k8s","msg":"Message"}
331
+ ```
332
+
333
+ <a id="opt-redact"></a>
334
+ #### `redact` (Array | Object):
335
+
336
+ Default: `undefined`
337
+
338
+ As an array, the `redact` option specifies paths that should
339
+ have their values redacted from any log output.
340
+
341
+ Each path must be a string using a syntax that corresponds to JavaScript dot and bracket notation.
342
+
343
+ If an object is supplied, three options can be specified:
344
+ * `paths` (array): Required. An array of paths. See [redaction - Path Syntax ⇗](/docs/redaction.md#paths) for specifics.
345
+ * `censor` (String|Function|Undefined): Optional. When supplied as a String the `censor` option will overwrite keys that are to be redacted. When set to `undefined` the key will be removed entirely from the object.
346
+ The `censor` option may also be a mapping function. The (synchronous) mapping function has the signature `(value, path) => redactedValue` and is called with the unredacted `value` and `path` to the key being redacted, as an array. For example given a redaction path of `a.b.c` the `path` argument would be `['a', 'b', 'c']`. The value returned from the mapping function becomes the applied censor value. Default: `'[Redacted]'`
347
+ value synchronously.
348
+ Default: `'[Redacted]'`
349
+ * `remove` (Boolean): Optional. Instead of censoring the value, remove both the key and the value. Default: `false`
350
+
351
+ **WARNING**: Never allow user input to define redacted paths.
352
+
353
+ * See the [redaction ⇗](/docs/redaction.md) documentation.
354
+ * See [fast-redact#caveat ⇗](https://github.com/davidmarkclements/fast-redact#caveat)
355
+
356
+ <a id=opt-hooks></a>
357
+ #### `hooks` (Object)
358
+
359
+ An object mapping to hook functions. Hook functions allow for customizing
360
+ internal logger operations. Hook functions ***must*** be synchronous functions.
361
+
362
+ <a id="logmethod"></a>
363
+ ##### `logMethod`
364
+
365
+ Allows for manipulating the parameters passed to logger methods. The signature
366
+ for this hook is `logMethod (args, method, level) {}`, where `args` is an array
367
+ of the arguments that were passed to the log method and `method` is the log
368
+ method itself, `level` is the log level itself. This hook ***must*** invoke the
369
+ `method` function by using apply, like so: `method.apply(this, newArgumentsArray)`.
370
+
371
+ For example, Pino expects a binding object to be the first parameter with an
372
+ optional string message as the second parameter. Using this hook the parameters
373
+ can be flipped:
374
+
375
+ ```js
376
+ const hooks = {
377
+ logMethod (inputArgs, method, level) {
378
+ if (inputArgs.length >= 2) {
379
+ const arg1 = inputArgs.shift()
380
+ const arg2 = inputArgs.shift()
381
+ return method.apply(this, [arg2, arg1, ...inputArgs])
382
+ }
383
+ return method.apply(this, inputArgs)
384
+ }
385
+ }
386
+ ```
387
+
388
+
389
+ <a id="streamWrite"></a>
390
+ ##### `streamWrite`
391
+
392
+ Allows for manipulating the _stringified_ JSON log data just before writing to various transports.
393
+
394
+ The method receives the stringified JSON and must return valid stringified JSON.
395
+
396
+ For example:
397
+ ```js
398
+ const hooks = {
399
+ streamWrite (s) {
400
+ return s.replaceAll('sensitive-api-key', 'XXX')
401
+ }
402
+ }
403
+ ```
404
+
405
+ <a id=opt-formatters></a>
406
+ #### `formatters` (Object)
407
+
408
+ An object containing functions for formatting the shape of the log lines.
409
+ These functions should return a JSONifiable object and
410
+ should never throw. These functions allow for full customization of
411
+ the resulting log lines. For example, they can be used to change
412
+ the level key name or to enrich the default metadata.
413
+
414
+ ##### `level`
415
+
416
+ Changes the shape of the log level. The default shape is `{ level: number }`.
417
+ The function takes two arguments, the label of the level (e.g. `'info'`)
418
+ and the numeric value (e.g. `30`).
419
+
420
+ When using multiple transport targets, the log record must keep a numeric `level` field for per-target routing. Because of that, `formatters.level` cannot be used to replace `level` with a string or rename it in multi-target mode. `timestamp` customization is still supported.
421
+
422
+ ```js
423
+ const formatters = {
424
+ level (label, number) {
425
+ return { level: number }
426
+ }
427
+ }
428
+ ```
429
+
430
+ ##### `bindings`
431
+
432
+ Changes the shape of the bindings. The default shape is `{ pid, hostname }`.
433
+ The function takes a single argument, the bindings object, which can be configured
434
+ using the [`base` option](#opt-base). Called once when creating logger.
435
+
436
+ ```js
437
+ const formatters = {
438
+ bindings (bindings) {
439
+ return { pid: bindings.pid, hostname: bindings.hostname }
440
+ }
441
+ }
442
+ ```
443
+
444
+ ##### `log`
445
+
446
+ Changes the shape of the log object. This function will be called every time
447
+ one of the log methods (such as `.info`) is called. All arguments passed to the
448
+ log method, except the message, will be passed to this function. By default, it does
449
+ not change the shape of the log object.
450
+
451
+ ```js
452
+ const formatters = {
453
+ log (object) {
454
+ return object
455
+ }
456
+ }
457
+ ```
458
+
459
+ <a id=opt-serializers></a>
460
+ #### `serializers` (Object)
461
+
462
+ Default: `{err: pino.stdSerializers.err}`
463
+
464
+ An object containing functions for custom serialization of objects.
465
+ These functions should return an JSONifiable object and they
466
+ should never throw. When logging an object, each top-level property
467
+ matching the exact key of a serializer will be serialized using the defined serializer.
468
+
469
+ The serializers are applied when a property in the logged object matches a property
470
+ in the serializers. The only exception is the `err` serializer as it is also applied in case
471
+ the object is an instance of `Error`, e.g. `logger.info(new Error('kaboom'))`.
472
+ See `errorKey` option to change `err` namespace.
473
+
474
+ Serializers are also applied to the [bindings passed to `logger.child()`](#logger-child-bindings).
475
+ Child bindings are serialized once, when the child logger is created, so a matching
476
+ serializer runs at that point rather than on every subsequent log call. This is
477
+ deliberate: it allows a child logger to precompute its bindings and stay fast at log
478
+ time. If a serializer needs to run per log call, pass the value to the log method
479
+ instead of to `child()`.
480
+
481
+ * See [pino.stdSerializers](#pino-stdserializers)
482
+
483
+ #### `msgPrefix` (String)
484
+
485
+ Default: `undefined`
486
+
487
+ The `msgPrefix` property allows you to specify a prefix for every message of the logger and its children.
488
+
489
+ ```js
490
+ const logger = pino({
491
+ msgPrefix: '[HTTP] '
492
+ })
493
+ logger.info('got new request!')
494
+ // > [HTTP] got new request!
495
+
496
+ const child = logger.child({})
497
+ child.info('User authenticated!')
498
+ // > [HTTP] User authenticated!
499
+ ```
500
+
501
+ <a id=opt-base></a>
502
+ #### `base` (Object)
503
+
504
+ Default: `{pid: process.pid, hostname: os.hostname()}`
505
+
506
+ Key-value object added as child logger to each log line.
507
+
508
+ Set to `undefined` to avoid adding `pid`, `hostname` properties to each log.
509
+
510
+ #### `enabled` (Boolean)
511
+
512
+ Default: `true`
513
+
514
+ Set to `false` to disable logging.
515
+
516
+ #### `crlf` (Boolean)
517
+
518
+ Default: `false`
519
+
520
+ Set to `true` to logs newline delimited JSON with `\r\n` instead of `\n`.
521
+
522
+ <a id=opt-timestamp></a>
523
+ #### `timestamp` (Boolean | Function)
524
+
525
+ Default: `true`
526
+
527
+ Enables or disables the inclusion of a timestamp in the
528
+ log message. If a function is supplied, it must synchronously return a partial JSON string
529
+ representation of the time, e.g. `,"time":1493426328206` (which is the default).
530
+
531
+ If set to `false`, no timestamp will be included in the output.
532
+
533
+ See [stdTimeFunctions](#pino-stdtimefunctions) for a set of available functions
534
+ for passing in as a value for this option.
535
+
536
+ Example:
537
+ ```js
538
+ timestamp: () => `,"time":"${new Date(Date.now()).toISOString()}"`
539
+ // which is equivalent to:
540
+ // timestamp: stdTimeFunctions.isoTime
541
+ ```
542
+
543
+ **Caution**: attempting to format time in-process will significantly impact logging performance.
544
+
545
+ <a id=opt-messagekey></a>
546
+ #### `messageKey` (String)
547
+
548
+ Default: `'msg'`
549
+
550
+ The string key for the 'message' in the JSON object.
551
+
552
+ <a id=opt-messagekey></a>
553
+ #### `errorKey` (String)
554
+
555
+ Default: `'err'`
556
+
557
+ The string key for the 'error' in the JSON object.
558
+
559
+ <a id=opt-nestedkey></a>
560
+ #### `nestedKey` (String)
561
+
562
+ Default: `null`
563
+
564
+ If there's a chance that objects being logged have properties that conflict with those from pino itself (`level`, `timestamp`, `pid`, etc)
565
+ and duplicate keys in your log records are undesirable, pino can be configured with a `nestedKey` option that causes any `object`s that are logged
566
+ to be placed under a key whose name is the value of `nestedKey`.
567
+
568
+ This way, when searching something like Kibana for values, one can consistently search under the configured `nestedKey` value instead of the root log record keys.
569
+
570
+ For example,
571
+ ```js
572
+ const logger = require('pino')({
573
+ nestedKey: 'payload'
574
+ })
575
+
576
+ const thing = { level: 'hi', time: 'never', foo: 'bar'} // has pino-conflicting properties!
577
+ logger.info(thing)
578
+
579
+ // logs the following:
580
+ // {"level":30,"time":1578357790020,"pid":91736,"hostname":"x","payload":{"level":"hi","time":"never","foo":"bar"}}
581
+ ```
582
+ In this way, logged objects' properties don't conflict with pino's standard logging properties,
583
+ and searching for logged objects can start from a consistent path.
584
+
585
+ #### `browser` (Object)
586
+
587
+ Browser only, may have `asObject` and `write` keys. This option is separately
588
+ documented in the [Browser API ⇗](/docs/browser.md) documentation.
589
+
590
+ * See [Browser API ⇗](/docs/browser.md)
591
+
592
+ #### `transport` (Object)
593
+
594
+ The `transport` option is a shorthand for the [pino.transport()](#pino-transport) function.
595
+ It supports the same input options:
596
+ ```js
597
+ require('pino')({
598
+ transport: {
599
+ target: '/absolute/path/to/my-transport.mjs'
600
+ }
601
+ })
602
+
603
+ // or multiple transports
604
+ require('pino')({
605
+ transport: {
606
+ targets: [
607
+ { target: '/absolute/path/to/my-transport.mjs', level: 'error' },
608
+ { target: 'some-file-transport', options: { destination: '/dev/null' }
609
+ ]
610
+ }
611
+ })
612
+ ```
613
+
614
+ If the transport option is supplied to `pino`, a [`destination`](#destination) parameter may not also be passed as a separate argument to `pino`:
615
+
616
+ ```js
617
+ pino({ transport: {}}, '/path/to/somewhere') // THIS WILL NOT WORK, DO NOT DO THIS
618
+ pino({ transport: {}}, process.stderr) // THIS WILL NOT WORK, DO NOT DO THIS
619
+ ```
620
+
621
+ when using the `transport` option. In this case, an `Error` will be thrown.
622
+
623
+ * See [pino.transport()](#pino-transport)
624
+
625
+ #### `onChild` (Function)
626
+
627
+ The `onChild` function is a synchronous callback that will be called on each creation of a new child, passing the child instance as its first argument.
628
+ Any error thrown inside the callback will be uncaught and should be handled inside the callback.
629
+ ```js
630
+ const parent = require('pino')({ onChild: (instance) => {
631
+ // Execute call back code for each newly created child.
632
+ }})
633
+ // `onChild` will now be executed with the new child.
634
+ parent.child(bindings)
635
+ ```
636
+
637
+
638
+ <a id="destination"></a>
639
+ ### `destination` (Number | String | Object | DestinationStream | SonicBoomOpts | WritableStream)
640
+
641
+ Default: `pino.destination(1)` (STDOUT)
642
+
643
+ The `destination` parameter can be a file descriptor, a file path, or an
644
+ object with `dest` property pointing to a fd or path.
645
+ An ordinary Node.js `stream` file descriptor can be passed as the
646
+ destination (such as the result
647
+ of `fs.createWriteStream`) but for peak log writing performance, it is strongly
648
+ recommended to use `pino.destination` to create the destination stream.
649
+ Note that the `destination` parameter can be the result of `pino.transport()`.
650
+
651
+ ```js
652
+ // pino.destination(1) by default
653
+ const stdoutLogger = require('pino')()
654
+
655
+ // destination param may be in first position when no options:
656
+ const fileLogger = require('pino')( pino.destination('/log/path'))
657
+
658
+ // use the stderr file handle to log to stderr:
659
+ const opts = {name: 'my-logger'}
660
+ const stderrLogger = require('pino')(opts, pino.destination(2))
661
+
662
+ // automatic wrapping in pino.destination
663
+ const fileLogger = require('pino')('/log/path')
664
+
665
+ // Asynchronous logging
666
+ const fileLogger = pino(pino.destination({ dest: '/log/path', sync: false }))
667
+ ```
668
+
669
+ However, there are some special instances where `pino.destination` is not used as the default:
670
+
671
+ + When something, e.g a process manager, has monkey-patched `process.stdout.write`.
672
+
673
+ In these cases `process.stdout` is used instead.
674
+
675
+ Note: If the parameter is a string integer, e.g. `'1'`, it will be coerced to
676
+ a number and used as a file descriptor. If this is not desired, provide a full
677
+ path, e.g. `/tmp/1`.
678
+
679
+ * See [`pino.destination`](#pino-destination)
680
+
681
+ <a id="metadata"></a>
682
+ #### `destination[Symbol.for('pino.metadata')]`
683
+
684
+ Default: `false`
685
+
686
+ Using the global symbol `Symbol.for('pino.metadata')` as a key on the `destination` parameter and
687
+ setting the key to `true`, indicates that the following properties should be
688
+ set on the `destination` object after each log line is written:
689
+
690
+ * the last logging level as `destination.lastLevel`
691
+ * the last logging message as `destination.lastMsg`
692
+ * the last logging object as `destination.lastObj`
693
+ * the last time as `destination.lastTime`, which will be the partial string returned
694
+ by the time function.
695
+ * the last logger instance as `destination.lastLogger` (to support child
696
+ loggers)
697
+
698
+ The following is a succinct usage example:
699
+
700
+ ```js
701
+ const dest = pino.destination('/dev/null')
702
+ dest[Symbol.for('pino.metadata')] = true
703
+ const logger = pino(dest)
704
+ logger.info({a: 1}, 'hi')
705
+ const { lastMsg, lastLevel, lastObj, lastTime} = dest
706
+ console.log(
707
+ 'Logged message "%s" at level %d with object %o at time %s',
708
+ lastMsg, lastLevel, lastObj, lastTime
709
+ ) // Logged message "hi" at level 30 with object { a: 1 } at time 1531590545089
710
+ ```
711
+
712
+ <a id="logger"></a>
713
+ ## Logger Instance
714
+
715
+ The logger instance is the object returned by the main exported
716
+ [`pino`](#export) function.
717
+
718
+ The primary purpose of the logger instance is to provide logging methods.
719
+
720
+ The default logging methods are `trace`, `debug`, `info`, `warn`, `error`, and `fatal`.
721
+
722
+ Each logging method has the following signature:
723
+ `([mergingObject], [message], [...interpolationValues])`.
724
+
725
+ The parameters are explained below using the `logger.info` method but the same applies to all logging methods.
726
+
727
+ ### Logging Method Parameters
728
+
729
+ <a id=mergingobject></a>
730
+ #### `mergingObject` (Object)
731
+
732
+ An object can optionally be supplied as the first parameter. Each enumerable key and value
733
+ of the `mergingObject` is copied into the JSON log line.
734
+
735
+ ```js
736
+ logger.info({MIX: {IN: true}})
737
+ // {"level":30,"time":1531254555820,"pid":55956,"hostname":"x","MIX":{"IN":true}}
738
+ ```
739
+
740
+ Do not pass an externally supplied object directly as the `mergingObject`.
741
+ Top-level keys are written at the root of the log line and can conflict with
742
+ Pino fields such as `level`, `time`, or `msg`, as well as application or
743
+ security fields. If untrusted data must be logged, place it under an
744
+ application-controlled key:
745
+
746
+ ```js
747
+ // Avoid: user-controlled keys become top-level log fields
748
+ logger.info(untrustedObject)
749
+
750
+ // Prefer: user-controlled keys are contained under a trusted namespace
751
+ logger.info({ untrusted: untrustedObject })
752
+ ```
753
+
754
+ As a matter of good security hygiene, prefer not to log untrusted data at all
755
+ unless it is necessary. When it is necessary, sanitize and redact it first.
756
+ The same top-level key guidance applies to [`logger.child()` bindings](#logger-child-bindings)
757
+ and [`logger.setBindings()`](#logger-set-bindings).
758
+
759
+ If the object is of type Error, it is wrapped in an object containing a property err (`{ err: mergingObject }`).
760
+ This allows for a unified error handling flow.
761
+
762
+ Options `serializers` and `errorKey` could be used at instantiation time to change the namespace
763
+ from `err` to another string as preferred.
764
+
765
+ <a id="message"></a>
766
+ #### `message` (String)
767
+
768
+ A `message` string can optionally be supplied as the first parameter, or
769
+ as the second parameter after supplying a `mergingObject`.
770
+
771
+ By default, the contents of the `message` parameter will be merged into the
772
+ JSON log line under the `msg` key:
773
+
774
+ ```js
775
+ logger.info('hello world')
776
+ // {"level":30,"time":1531257112193,"msg":"hello world","pid":55956,"hostname":"x"}
777
+ ```
778
+
779
+ The `message` parameter takes precedence over the `mergingObject`.
780
+ That is, if a `mergingObject` contains a `msg` property, and a `message` parameter
781
+ is supplied in addition, the `msg` property in the output log will be the value of
782
+ the `message` parameter not the value of the `msg` property on the `mergingObject`.
783
+ See [Avoid Message Conflict](/docs/help.md#avoid-message-conflict) for information
784
+ on how to overcome this limitation.
785
+
786
+ If no `message` parameter is provided, and the `mergingObject` is of type `Error` or it has a property named `err`, the
787
+ `message` parameter is set to the `message` value of the error. See option `errorKey` if you want to change the namespace.
788
+
789
+ The `messageKey` option can be used at instantiation time to change the namespace
790
+ from `msg` to another string as preferred.
791
+
792
+ The `message` string may contain a printf style string with support for
793
+ the following placeholders:
794
+
795
+ * `%s` – string placeholder, every non-string value passed in will have `.toString()` called.
796
+ * `%d` – digit placeholder
797
+ * `%O`, `%o`, and `%j` – object placeholder
798
+
799
+ Values supplied as additional arguments to the logger method will
800
+ then be interpolated accordingly.
801
+
802
+ * See [`messageKey` pino option](#opt-messagekey)
803
+ * See [`...interpolationValues` log method parameter](#interpolationvalues)
804
+
805
+ <a id="interpolationvalues"></a>
806
+ #### `...interpolationValues` (Any)
807
+
808
+ All arguments supplied after `message` are serialized and interpolated according
809
+ to any supplied printf-style placeholders (`%s`, `%d`, `%o`|`%O`|`%j`) to form
810
+ the final output `msg` value for the JSON log line.
811
+
812
+ ```js
813
+ logger.info('%o hello %s', {worldly: 1}, 'world')
814
+ // {"level":30,"time":1531257826880,"msg":"{\"worldly\":1} hello world","pid":55956,"hostname":"x"}
815
+ ```
816
+
817
+ Since pino v6, we do not automatically concatenate and cast to string
818
+ consecutive parameters:
819
+
820
+ ```js
821
+ logger.info('hello', 'world')
822
+ // {"level":30,"time":1531257618044,"msg":"hello","pid":55956,"hostname":"x"}
823
+ // world is missing
824
+ ```
825
+
826
+ However, it's possible to inject a hook to modify this behavior:
827
+
828
+ ```js
829
+ const pinoOptions = {
830
+ hooks: { logMethod }
831
+ }
832
+
833
+ function logMethod (args, method) {
834
+ if (args.length === 2) {
835
+ args[0] = `${args[0]} %j`
836
+ }
837
+ method.apply(this, args)
838
+ }
839
+
840
+ const logger = pino(pinoOptions)
841
+ ```
842
+
843
+ * See [`message` log method parameter](#message)
844
+ * See [`logMethod` hook](#logmethod)
845
+
846
+ <a id="error-serialization"></a>
847
+ #### Errors
848
+
849
+ Errors can be supplied as either the first parameter or if already using `mergingObject` then as the `err` property on the `mergingObject`.
850
+
851
+ Options `serializers` and `errorKey` could be used at instantiation time to change the namespace
852
+ from `err` to another string as preferred.
853
+
854
+ > ## Note
855
+ > This section describes the default configuration. The error serializer can be
856
+ > mapped to a different key using the [`serializers`](#opt-serializers) option.
857
+ ```js
858
+ logger.info(new Error("test"))
859
+ // {"level":30,"time":1531257618044,"msg":"test","stack":"...","type":"Error","pid":55956,"hostname":"x"}
860
+
861
+ logger.info({ err: new Error("test"), otherkey: 123 }, "some text")
862
+ // {"level":30,"time":1531257618044,"err":{"msg": "test", "stack":"...","type":"Error"},"msg":"some text","pid":55956,"hostname":"x","otherkey":123}
863
+ ```
864
+
865
+ <a id="trace"></a>
866
+ ### `logger.trace([mergingObject], [message], [...interpolationValues])`
867
+
868
+ Write a `'trace'` level log, if the configured [`level`](#level) allows for it.
869
+
870
+ * See [`mergingObject` log method parameter](#mergingobject)
871
+ * See [`message` log method parameter](#message)
872
+ * See [`...interpolationValues` log method parameter](#interpolationvalues)
873
+
874
+ <a id="debug"></a>
875
+ ### `logger.debug([mergingObject], [message], [...interpolationValues])`
876
+
877
+ Write a `'debug'` level log, if the configured `level` allows for it.
878
+
879
+ * See [`mergingObject` log method parameter](#mergingobject)
880
+ * See [`message` log method parameter](#message)
881
+ * See [`...interpolationValues` log method parameter](#interpolationvalues)
882
+
883
+ <a id="info"></a>
884
+ ### `logger.info([mergingObject], [message], [...interpolationValues])`
885
+
886
+ Write an `'info'` level log, if the configured `level` allows for it.
887
+
888
+ * See [`mergingObject` log method parameter](#mergingobject)
889
+ * See [`message` log method parameter](#message)
890
+ * See [`...interpolationValues` log method parameter](#interpolationvalues)
891
+
892
+ <a id="warn"></a>
893
+ ### `logger.warn([mergingObject], [message], [...interpolationValues])`
894
+
895
+ Write a `'warn'` level log, if the configured `level` allows for it.
896
+
897
+ * See [`mergingObject` log method parameter](#mergingobject)
898
+ * See [`message` log method parameter](#message)
899
+ * See [`...interpolationValues` log method parameter](#interpolationvalues)
900
+
901
+ <a id="error"></a>
902
+ ### `logger.error([mergingObject], [message], [...interpolationValues])`
903
+
904
+ Write a `'error'` level log, if the configured `level` allows for it.
905
+
906
+ * See [`mergingObject` log method parameter](#mergingobject)
907
+ * See [`message` log method parameter](#message)
908
+ * See [`...interpolationValues` log method parameter](#interpolationvalues)
909
+
910
+ <a id="fatal"></a>
911
+ ### `logger.fatal([mergingObject], [message], [...interpolationValues])`
912
+
913
+ Write a `'fatal'` level log, if the configured `level` allows for it.
914
+
915
+ Since `'fatal'` level messages are intended to be logged just before the process exiting the `fatal`
916
+ method will always sync flush the destination.
917
+ Therefore it's important not to misuse `fatal` since
918
+ it will cause performance overhead if used for any
919
+ other purpose than writing final log messages before
920
+ the process crashes or exits.
921
+
922
+ * See [`mergingObject` log method parameter](#mergingobject)
923
+ * See [`message` log method parameter](#message)
924
+ * See [`...interpolationValues` log method parameter](#interpolationvalues)
925
+
926
+ <a id="silent"><a>
927
+ ### `logger.silent()`
928
+
929
+ Noop function.
930
+
931
+ <a id="child"></a>
932
+ ### `logger.child(bindings, [options]) => logger`
933
+
934
+ The `logger.child` method allows for the creation of stateful loggers,
935
+ where key-value pairs can be pinned to a logger causing them to be output
936
+ on every log line.
937
+
938
+ Child loggers use the same output stream as the parent and inherit
939
+ the current log level of the parent at the time they are spawned.
940
+
941
+ The log level of a child is mutable. It can be set independently
942
+ of the parent either by setting the [`level`](#level) accessor after creating
943
+ the child logger or using the [`options.level`](#optionslevel-string) key.
944
+
945
+ <a id="logger-child-bindings"></a>
946
+ #### `bindings` (Object)
947
+
948
+ An object of key-value pairs to include in every log line output
949
+ via the returned child logger.
950
+
951
+ ```js
952
+ const child = logger.child({ MIX: {IN: 'always'} })
953
+ child.info('hello')
954
+ // {"level":30,"time":1531258616689,"msg":"hello","pid":64849,"hostname":"x","MIX":{"IN":"always"}}
955
+ child.info('child!')
956
+ // {"level":30,"time":1531258617401,"msg":"child!","pid":64849,"hostname":"x","MIX":{"IN":"always"}}
957
+ ```
958
+
959
+ The `bindings` object may contain any key except for reserved configuration keys `level` and `serializers`.
960
+
961
+ Do not pass externally supplied objects directly as child bindings. Binding keys
962
+ are top-level log fields emitted on every log line from the child logger, so
963
+ user-controlled keys can conflict with Pino fields such as `level`, `time`, or
964
+ `msg`, as well as application or security fields. If untrusted data must be
965
+ included in child bindings, place it under an application-controlled key:
966
+
967
+ ```js
968
+ // Avoid: user-controlled keys become top-level fields on every child log line
969
+ const child = logger.child(untrustedObject)
970
+
971
+ // Prefer: user-controlled keys are contained under a trusted namespace
972
+ const child = logger.child({ untrusted: untrustedObject })
973
+ ```
974
+
975
+ As a matter of good security hygiene, prefer not to log untrusted data at all
976
+ unless it is necessary. When it is necessary, sanitize and redact it first.
977
+ See also [`mergingObject`](#mergingobject) and [`logger.setBindings()`](#logger-set-bindings).
978
+
979
+ ##### `bindings.serializers` (Object) - DEPRECATED
980
+
981
+ Use `options.serializers` instead.
982
+
983
+ #### `options` (Object)
984
+
985
+ Options for child logger. These options will override the parent logger options.
986
+
987
+ ##### `options.level` (String)
988
+
989
+ The `level` property overrides the log level of the child logger.
990
+ By default, the parent log level is inherited.
991
+ After the creation of the child logger, it is also accessible using the [`logger.level`](#logger-level) key.
992
+
993
+ ```js
994
+ const logger = pino()
995
+ logger.debug('nope') // will not log, since default level is info
996
+ const child = logger.child({foo: 'bar'}, {level: 'debug'})
997
+ child.debug('debug!') // will log as the `level` property set the level to debug
998
+ ```
999
+
1000
+ <a id="options-msgPrefix"></a>
1001
+ ##### `options.msgPrefix` (String)
1002
+
1003
+ Default: `undefined`
1004
+
1005
+ The `msgPrefix` property allows you to specify a prefix for every message of the child logger.
1006
+ By default, the parent prefix is inherited.
1007
+ If the parent already has a prefix, the prefix of the parent and then the child will be displayed.
1008
+
1009
+ ```js
1010
+ const logger = pino({
1011
+ msgPrefix: '[HTTP] '
1012
+ })
1013
+ logger.info('got new request!')
1014
+ // > [HTTP] got new request!
1015
+
1016
+ const child = logger.child({avengers: 'assemble'}, {msgPrefix: '[Proxy] '})
1017
+ child.info('message proxied!')
1018
+ // > [HTTP] [Proxy] message proxied!
1019
+ ```
1020
+
1021
+ ##### `options.redact` (Array | Object)
1022
+
1023
+ Setting `options.redact` to an array or object will override the parent `redact` options. To remove `redact` options inherited from the parent logger set this value as an empty array (`[]`).
1024
+
1025
+ ```js
1026
+ const logger = require('pino')({ redact: ['hello'] })
1027
+ logger.info({ hello: 'world' })
1028
+ // {"level":30,"time":1625794363403,"pid":67930,"hostname":"x","hello":"[Redacted]"}
1029
+ const child = logger.child({ foo: 'bar' }, { redact: ['foo'] })
1030
+ logger.info({ hello: 'world' })
1031
+ // {"level":30,"time":1625794553558,"pid":67930,"hostname":"x","hello":"world", "foo": "[Redacted]" }
1032
+ ```
1033
+
1034
+ * See [`redact` option](#opt-redact)
1035
+
1036
+ ##### `options.serializers` (Object)
1037
+
1038
+ Child loggers inherit the [serializers](#opt-serializers) from the parent logger.
1039
+
1040
+ Setting the `serializers` key of the `options` object will override
1041
+ any configured parent serializers.
1042
+
1043
+ ```js
1044
+ const logger = require('pino')()
1045
+ logger.info({test: 'will appear'})
1046
+ // {"level":30,"time":1531259759482,"pid":67930,"hostname":"x","test":"will appear"}
1047
+ const child = logger.child({}, {serializers: {test: () => `child-only serializer`}})
1048
+ child.info({test: 'will be overwritten'})
1049
+ // {"level":30,"time":1531259784008,"pid":67930,"hostname":"x","test":"child-only serializer"}
1050
+ ```
1051
+
1052
+ * See [`serializers` option](#opt-serializers)
1053
+ * See [pino.stdSerializers](#pino-stdSerializers)
1054
+
1055
+ <a id="logger-bindings"></a>
1056
+ ### `logger.bindings()`
1057
+
1058
+ Returns an object containing all the current bindings, cloned from the ones passed in via `logger.child()`.
1059
+ ```js
1060
+ const child = logger.child({ foo: 'bar' })
1061
+ console.log(child.bindings())
1062
+ // { foo: 'bar' }
1063
+ const anotherChild = child.child({ MIX: { IN: 'always' } })
1064
+ console.log(anotherChild.bindings())
1065
+ // { foo: 'bar', MIX: { IN: 'always' } }
1066
+ ```
1067
+
1068
+ <a id="logger-set-bindings"></a>
1069
+ ### `logger.setBindings(bindings)`
1070
+
1071
+ Adds to the bindings of this logger instance.
1072
+
1073
+ **Note:** Does not overwrite bindings. Can potentially result in duplicate keys in
1074
+ log lines.
1075
+
1076
+ Do not pass externally supplied objects directly as bindings. Binding keys are
1077
+ top-level log fields and can conflict with Pino fields or application fields.
1078
+ If untrusted data must be added, place it under an application-controlled key,
1079
+ for example `logger.setBindings({ untrusted })`, and sanitize or redact it first.
1080
+
1081
+ * See [`bindings` parameter in `logger.child`](#logger-child-bindings)
1082
+
1083
+ <a id="flush"></a>
1084
+ ### `logger.flush([cb])`
1085
+
1086
+ Flushes the content of the buffer when using `pino.destination({
1087
+ sync: false })`.
1088
+
1089
+ This is an asynchronous, best used as fire and forget, operation.
1090
+
1091
+ The use case is primarily for asynchronous logging, which may buffer
1092
+ log lines while others are being written. The `logger.flush` method can be
1093
+ used to flush the logs
1094
+ on a long interval, say ten seconds. Such a strategy can provide an
1095
+ optimum balance between extremely efficient logging at high demand periods
1096
+ and safer logging at low demand periods.
1097
+
1098
+ If there is a need to wait for the logs to be flushed, a callback should be used.
1099
+
1100
+ **Note:** `logger.flush()` does not flush the output of `pino-pretty`. See
1101
+ [Flush Limitations with `pino-pretty`](/docs/asynchronous.md) for more details.
1102
+
1103
+ **Note:** in the browser this method is a no-op and `cb` is never invoked. See
1104
+ [Node.js-only APIs](/docs/browser.md#nodejs-only-apis).
1105
+
1106
+ * See [`destination` parameter](#destination)
1107
+ * See [Asynchronous Logging ⇗](./asynchronous.md)
1108
+
1109
+ <a id="logger-level"></a>
1110
+ ### `logger.level` (String) [Getter/Setter]
1111
+
1112
+ Set this property to the desired logging level.
1113
+
1114
+ The core levels and their values are as follows:
1115
+
1116
+ | | | | | | | | |
1117
+ |:-----------|-------|-------|------|------|-------|-------|---------:|
1118
+ | **Level:** | trace | debug | info | warn | error | fatal | silent |
1119
+ | **Value:** | 10 | 20 | 30 | 40 | 50 | 60 | Infinity |
1120
+
1121
+ The logging level is a *minimum* level based on the associated value of that level.
1122
+
1123
+ For instance if `logger.level` is `info` *(30)* then `info` *(30)*, `warn` *(40)*, `error` *(50)*, and `fatal` *(60)* log methods will be enabled but the `trace` *(10)* and `debug` *(20)* methods, being less than 30, will not.
1124
+
1125
+ The `silent` logging level is a specialized level that will disable all logging,
1126
+ the `silent` log method is a noop function.
1127
+
1128
+ <a id="islevelenabled"></a>
1129
+ ### `logger.isLevelEnabled(level)`
1130
+
1131
+ A utility method for determining if a given log level will write to the destination.
1132
+
1133
+ #### `level` (String)
1134
+
1135
+ The given level to check against:
1136
+
1137
+ ```js
1138
+ if (logger.isLevelEnabled('debug')) logger.debug('conditional log')
1139
+ ```
1140
+
1141
+ #### `levelLabel` (String)
1142
+
1143
+ Defines the method name of the new level.
1144
+
1145
+ * See [`logger.level`](#level)
1146
+
1147
+ #### `levelValue` (Number)
1148
+
1149
+ Defines the associated minimum threshold value for the level, and
1150
+ therefore where it sits in order of priority among other levels.
1151
+
1152
+ * See [`logger.level`](#level)
1153
+
1154
+ <a id="levelVal"></a>
1155
+ ### `logger.levelVal` (Number)
1156
+
1157
+ Supplies the integer value for the current logging level.
1158
+
1159
+ ```js
1160
+ if (logger.levelVal === 30) {
1161
+ console.log('logger level is `info`')
1162
+ }
1163
+ ```
1164
+
1165
+ <a id="levels"></a>
1166
+ ### `logger.levels` (Object)
1167
+
1168
+ Levels are mapped to values to determine the minimum threshold that a
1169
+ logging method should be enabled at (see [`logger.level`](#level)).
1170
+
1171
+ The `logger.levels` property holds the mappings between levels and values,
1172
+ and vice versa.
1173
+
1174
+ ```sh
1175
+ $ node -p "require('pino')().levels"
1176
+ ```
1177
+
1178
+ ```js
1179
+ { labels:
1180
+ { '10': 'trace',
1181
+ '20': 'debug',
1182
+ '30': 'info',
1183
+ '40': 'warn',
1184
+ '50': 'error',
1185
+ '60': 'fatal' },
1186
+ values:
1187
+ { fatal: 60, error: 50, warn: 40, info: 30, debug: 20, trace: 10 } }
1188
+ ```
1189
+
1190
+ * See [`logger.level`](#level)
1191
+
1192
+ <a id="serializers"></a>
1193
+ ### logger\[Symbol.for('pino.serializers')\]
1194
+
1195
+ Returns the serializers as applied to the current logger instance. If a child logger did not
1196
+ register its own serializer upon instantiation the serializers of the parent will be returned.
1197
+
1198
+ <a id="level-change"></a>
1199
+ ### Event: 'level-change'
1200
+
1201
+ The logger instance is also an [`EventEmitter ⇗`](https://nodejs.org/dist/latest/docs/api/events.html#events_class_eventemitter)
1202
+
1203
+ **Note:** the `EventEmitter` methods are no-ops in the browser, so this event
1204
+ never fires there. See
1205
+ [Node.js-only APIs](/docs/browser.md#nodejs-only-apis).
1206
+
1207
+ A listener function can be attached to a logger via the `level-change` event
1208
+
1209
+ The listener is passed five arguments:
1210
+
1211
+ * `levelLabel` – the new level string, e.g `trace`
1212
+ * `levelValue` – the new level number, e.g `10`
1213
+ * `previousLevelLabel` – the prior level string, e.g `info`
1214
+ * `previousLevelValue` – the prior level number, e.g `30`
1215
+ * `logger` – the logger instance from which the event originated
1216
+
1217
+ ```js
1218
+ const logger = require('pino')()
1219
+ logger.on('level-change', (lvl, val, prevLvl, prevVal) => {
1220
+ console.log('%s (%d) was changed to %s (%d)', prevLvl, prevVal, lvl, val)
1221
+ })
1222
+ logger.level = 'trace' // trigger event
1223
+ ```
1224
+
1225
+ Please note that due to a [known bug](https://github.com/pinojs/pino/issues/1006), every `logger.child()` call will
1226
+ fire a `level-change` event. These events can be ignored by writing an event handler like:
1227
+
1228
+ ```js
1229
+ const logger = require('pino')()
1230
+ logger.on('level-change', function (lvl, val, prevLvl, prevVal, instance) {
1231
+ if (logger !== instance) {
1232
+ return
1233
+ }
1234
+ console.log('%s (%d) was changed to %s (%d)', prevLvl, prevVal, lvl, val)
1235
+ })
1236
+ logger.child({}); // trigger an event by creating a child instance, notice no console.log
1237
+ logger.level = 'trace' // trigger event using actual value change, notice console.log
1238
+ ```
1239
+
1240
+ <a id="version"></a>
1241
+ ### `logger.version` (String)
1242
+
1243
+ Exposes the Pino package version. Also available on the exported `pino` function.
1244
+
1245
+ * See [`pino.version`](#pino-version)
1246
+
1247
+ <a id="msgPrefix"></a>
1248
+ ### `logger.msgPrefix` (String|Undefined)
1249
+
1250
+ Exposes the cumulative `msgPrefix` of the logger.
1251
+
1252
+ * See [`options.msgPrefix`](#options-msgPrefix)
1253
+
1254
+ ## Statics
1255
+
1256
+ <a id="pino-destination"></a>
1257
+ ### `pino.destination([opts]) => SonicBoom`
1258
+
1259
+ Create a Pino Destination instance: a stream-like object with
1260
+ significantly more throughput than a standard Node.js stream.
1261
+
1262
+ **Note:** this is not available in the browser build. See [Node.js-only APIs](/docs/browser.md#nodejs-only-apis).
1263
+
1264
+ ```js
1265
+ const pino = require('pino')
1266
+ const logger = pino(pino.destination('./my-file'))
1267
+ const logger2 = pino(pino.destination())
1268
+ const logger3 = pino(pino.destination({
1269
+ dest: './my-file',
1270
+ minLength: 4096, // Buffer before writing
1271
+ sync: false // Asynchronous logging, the default
1272
+ }))
1273
+ const logger4 = pino(pino.destination({
1274
+ dest: './my-file2',
1275
+ sync: true // Synchronous logging
1276
+ }))
1277
+ ```
1278
+
1279
+ The `pino.destination` method may be passed a file path or a numerical file descriptor.
1280
+ By default, `pino.destination` will use `process.stdout.fd` (1) as the file descriptor.
1281
+
1282
+ `pino.destination` is implemented on [`sonic-boom` ⇗](https://github.com/mcollina/sonic-boom).
1283
+
1284
+ A `pino.destination` instance can also be used to reopen closed files
1285
+ (for example, for some log rotation scenarios), see [Reopening log files](/docs/help.md#reopening).
1286
+
1287
+ * See [`destination` parameter](#destination)
1288
+ * See [`sonic-boom` ⇗](https://github.com/mcollina/sonic-boom)
1289
+ * See [Reopening log files](/docs/help.md#reopening)
1290
+ * See [Asynchronous Logging ⇗](/docs/asynchronous.md)
1291
+
1292
+ <a id="pino-transport"></a>
1293
+ ### `pino.transport(options) => ThreadStream`
1294
+
1295
+ Create a stream that routes logs to a worker thread that
1296
+ wraps around a [Pino Transport](/docs/transports.md).
1297
+
1298
+ **Note:** this is not available in the browser build. See [Node.js-only APIs](/docs/browser.md#nodejs-only-apis).
1299
+
1300
+ ```js
1301
+ const pino = require('pino')
1302
+ const transport = pino.transport({
1303
+ target: 'some-transport',
1304
+ options: { some: 'options for', the: 'transport' }
1305
+ })
1306
+ pino(transport)
1307
+ ```
1308
+
1309
+ Multiple transports may also be defined, and specific levels can be logged to each transport:
1310
+
1311
+ ```js
1312
+ const pino = require('pino')
1313
+ const transport = pino.transport({
1314
+ targets: [{
1315
+ level: 'info',
1316
+ target: 'pino-pretty' // must be installed separately
1317
+ }, {
1318
+ level: 'trace',
1319
+ target: 'pino/file',
1320
+ options: { destination: '/path/to/store/logs' }
1321
+ }]
1322
+ })
1323
+ pino(transport)
1324
+ ```
1325
+
1326
+ A pipeline could also be created to transform log lines _before_ sending them:
1327
+
1328
+ ```js
1329
+ const pino = require('pino')
1330
+ const transport = pino.transport({
1331
+ pipeline: [{
1332
+ target: 'pino-syslog' // must be installed separately
1333
+ }, {
1334
+ target: 'pino-socket' // must be installed separately
1335
+ }]
1336
+ })
1337
+ pino(transport)
1338
+ ```
1339
+
1340
+ Multiple transports can now be defined to include pipelines:
1341
+
1342
+ ```js
1343
+ const pino = require('pino')
1344
+ const transport = pino.transport({
1345
+ targets: [{
1346
+ level: 'info',
1347
+ target: 'pino-pretty' // must be installed separately
1348
+ }, {
1349
+ level: 'trace',
1350
+ target: 'pino/file',
1351
+ options: { destination: '/path/to/store/logs' }
1352
+ }, {
1353
+ pipeline: [{
1354
+ target: 'pino-syslog' // must be installed separately
1355
+ }, {
1356
+ target: 'pino-socket' // must be installed separately
1357
+ }]
1358
+ }
1359
+ ]
1360
+ })
1361
+ pino(transport)
1362
+ ```
1363
+
1364
+ If `WeakRef`, `WeakMap`, and `FinalizationRegistry` are available in the current runtime (v14.5.0+), then the thread
1365
+ will be automatically terminated in case the stream or logger goes out of scope.
1366
+ The `transport()` function adds a listener to `process.on('beforeExit')` and `process.on('exit')` to ensure the worker
1367
+ is flushed and all data synced before the process exits.
1368
+
1369
+ Note that calling `process.exit()` on the main thread will stop the event loop on the main thread from turning. As a result,
1370
+ using `console.log` and `process.stdout` after the main thread called `process.exit()` will not produce any output.
1371
+
1372
+ If you are embedding/integrating pino within your framework, you will need to make pino aware of the script that is calling it,
1373
+ like so:
1374
+
1375
+ ```js
1376
+ const pino = require('pino')
1377
+ const getCaller = require('get-caller-file')
1378
+
1379
+ module.exports = function build () {
1380
+ const logger = pino({
1381
+ transport: {
1382
+ caller: getCaller(),
1383
+ target: 'transport',
1384
+ options: { destination: './destination' }
1385
+ }
1386
+ })
1387
+ return logger
1388
+ }
1389
+ ```
1390
+
1391
+ Note that _any `'error'`_ event emitted by the transport must be considered a fatal error and the process must be terminated.
1392
+ Error events are not recoverable.
1393
+
1394
+ For more on transports, how they work, and how to create them see the [`Transports documentation`](/docs/transports.md).
1395
+
1396
+ * See [`Transports`](/docs/transports.md)
1397
+ * See [`thread-stream` ⇗](https://github.com/mcollina/thread-stream)
1398
+
1399
+ #### Options
1400
+
1401
+ * `target`: The transport to pass logs through. This may be an installed module name or an absolute path.
1402
+ * `options`: An options object which is serialized (see [Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)), passed to the worker thread, parsed and then passed to the exported transport function.
1403
+ * `worker`: [Worker thread](https://nodejs.org/api/worker_threads.html#worker_threads_new_worker_filename_options) configuration options. Additionally, the `worker` option supports `worker.autoEnd`. If this is set to `false` logs will not be flushed on process exit. It is then up to the developer to call `transport.end()` to flush logs.
1404
+ * `targets`: May be specified instead of `target`. Must be an array of transport configurations and/or pipelines. Transport configurations include the aforementioned `options` and `target` options plus a `level` option which will send only logs above a specified level to that transport. If `level` is omitted, it defaults to `info`.
1405
+ * `pipeline`: May be specified instead of `target`. Must be an array of transport configurations. Transport configurations include the aforementioned `options` and `target` options. All intermediate steps in the pipeline _must_ be `Transform` streams and not `Writable`.
1406
+ * `dedupe`: See [pino.multistream options](#pino-multistream)
1407
+
1408
+ Notes:
1409
+ - The top-level `level` in `pino.transport({ ... })` is not used for filtering.
1410
+ - With a single `target` (or a single `pipeline`), filtering is controlled by `logger.level`.
1411
+ - Per-transport level filtering is applied when using `targets` (multi-destination mode).
1412
+
1413
+ <a id="pino-multistream"></a>
1414
+
1415
+ ### `pino.multistream(streamsArray, opts) => MultiStreamRes`
1416
+
1417
+ Create a stream composed by multiple destination streams and returns an
1418
+ object implementing the [MultiStreamRes](#multistreamres) interface.
1419
+
1420
+ **Note:** this is not available in the browser build. See [Node.js-only APIs](/docs/browser.md#nodejs-only-apis).
1421
+
1422
+ ```js
1423
+ var fs = require('node:fs')
1424
+ var pino = require('pino')
1425
+ var pretty = require('pino-pretty')
1426
+ var streams = [
1427
+ {stream: fs.createWriteStream('/tmp/info.stream.out')},
1428
+ {stream: pretty() },
1429
+ {level: 'debug', stream: fs.createWriteStream('/tmp/debug.stream.out')},
1430
+ {level: 'fatal', stream: fs.createWriteStream('/tmp/fatal.stream.out')}
1431
+ ]
1432
+
1433
+ var log = pino({
1434
+ level: 'debug' // this MUST be set at the lowest level of the
1435
+ // destinations
1436
+ }, pino.multistream(streams))
1437
+
1438
+ log.debug('this will be written to /tmp/debug.stream.out')
1439
+ log.info('this will be written to /tmp/debug.stream.out and /tmp/info.stream.out')
1440
+ log.fatal('this will be written to /tmp/debug.stream.out, /tmp/info.stream.out and /tmp/fatal.stream.out')
1441
+ ```
1442
+
1443
+ In order for `multistream` to work, the log level __must__ be set to the lowest level used in the streams array. Default is `info`.
1444
+
1445
+ #### Options
1446
+
1447
+ * `levels`: Pass custom log level definitions to the instance as an object.
1448
+
1449
+ + `dedupe`: Set this to `true` to send logs only to the stream with the higher level. Default: `false`
1450
+
1451
+ `dedupe` flag can be useful for example when using `pino.multistream` to redirect `error` logs to `process.stderr` and others to `process.stdout`:
1452
+
1453
+ ```js
1454
+ var pino = require('pino')
1455
+ var multistream = pino.multistream
1456
+ var streams = [
1457
+ {level: 'debug', stream: process.stdout},
1458
+ {level: 'error', stream: process.stderr},
1459
+ ]
1460
+
1461
+ var opts = {
1462
+ levels: {
1463
+ silent: Infinity,
1464
+ fatal: 60,
1465
+ error: 50,
1466
+ warn: 50,
1467
+ info: 30,
1468
+ debug: 20,
1469
+ trace: 10
1470
+ },
1471
+ dedupe: true,
1472
+ }
1473
+
1474
+ var log = pino({
1475
+ level: 'debug' // this MUST be set at the lowest level of the
1476
+ // destinations
1477
+ }, multistream(streams, opts))
1478
+
1479
+ log.debug('this will be written ONLY to process.stdout')
1480
+ log.info('this will be written ONLY to process.stdout')
1481
+ log.error('this will be written ONLY to process.stderr')
1482
+ log.fatal('this will be written ONLY to process.stderr')
1483
+ ```
1484
+
1485
+ <a id="pino-stdserializers"></a>
1486
+ ### `pino.stdSerializers` (Object)
1487
+
1488
+ The `pino.stdSerializers` object provides functions for serializing objects common to many projects. The standard serializers are directly imported from [pino-std-serializers](https://github.com/pinojs/pino-std-serializers).
1489
+
1490
+ * See [pino-std-serializers ⇗](https://github.com/pinojs/pino-std-serializers)
1491
+
1492
+ <a id="pino-stdtimefunctions"></a>
1493
+ ### `pino.stdTimeFunctions` (Object)
1494
+
1495
+ The [`timestamp`](#opt-timestamp) option can accept a function that determines the
1496
+ `timestamp` value in a log line.
1497
+
1498
+ The `pino.stdTimeFunctions` object provides a very small set of common functions for generating the
1499
+ `timestamp` property. These consist of the following
1500
+
1501
+ * `pino.stdTimeFunctions.epochTime`: Milliseconds since Unix epoch (Default)
1502
+ * `pino.stdTimeFunctions.unixTime`: Seconds since Unix epoch
1503
+ * `pino.stdTimeFunctions.nullTime`: Clears timestamp property (Used when `timestamp: false`)
1504
+ * `pino.stdTimeFunctions.isoTime`: ISO 8601-formatted time in UTC
1505
+ * `pino.stdTimeFunctions.isoTimeNano`: RFC 3339-formatted time in UTC with nanosecond precision
1506
+
1507
+ * See [`timestamp` option](#opt-timestamp)
1508
+
1509
+ <a id="pino-symbols"></a>
1510
+ ### `pino.symbols` (Object)
1511
+
1512
+ For integration purposes with ecosystem and third-party libraries `pino.symbols`
1513
+ exposes the symbols used to hold non-public state and methods on the logger instance.
1514
+
1515
+ Access to the symbols allows logger state to be adjusted, and methods to be overridden or
1516
+ proxied for performant integration where necessary.
1517
+
1518
+ The `pino.symbols` object is intended for library implementers and shouldn't be utilized
1519
+ for general use.
1520
+
1521
+ <a id="pino-version"></a>
1522
+ ### `pino.version` (String)
1523
+
1524
+ Exposes the Pino package version. Also available on the logger instance.
1525
+
1526
+ * See [`logger.version`](#version)
1527
+
1528
+ ## Interfaces
1529
+ <a id="pino-multistreamres"></a>
1530
+
1531
+ ### `MultiStreamRes`
1532
+ Properties:
1533
+
1534
+ * `write(data)`
1535
+ - `data` Object | string
1536
+ - Returns: void
1537
+
1538
+ Write `data` onto the streams held by the current instance.
1539
+ * `add(dest)`
1540
+ - `dest` [StreamEntry](#streamentry) | [DestinationStream](#destinationstream)
1541
+ - Returns: [MultiStreamRes](#multistreamres)
1542
+
1543
+ Add `dest` stream to the array of streams of the current instance.
1544
+ * `flushSync()`
1545
+ - Returns: `undefined`
1546
+
1547
+ Call `flushSync` on each stream held by the current instance.
1548
+
1549
+ * `lastId`
1550
+ - number
1551
+
1552
+ The ID assigned to the last stream assigned to the current instance.
1553
+ * `minLevel`
1554
+ - number
1555
+
1556
+ The minimum level amongst all the streams held by the current instance.
1557
+
1558
+ * `remove(id)`
1559
+ - `id` [number]
1560
+
1561
+ Removes a stream from the array of streams of the current instance using its assigned ID.
1562
+ * `streams`
1563
+ - Returns: [StreamEntry[]](#streamentry)
1564
+
1565
+ The array of streams currently held by the current instance.
1566
+ * `clone(level)`
1567
+ - `level` [Level](#level-1)
1568
+ - Returns: [MultiStreamRes](#multistreamres)
1569
+
1570
+ Returns a cloned object of the current instance but with the provided `level`.
1571
+
1572
+ ### `StreamEntry`
1573
+ Properties:
1574
+
1575
+ * `stream`
1576
+ - DestinationStream
1577
+ * `level`
1578
+ - Optional: [Level](#level-1)
1579
+
1580
+ ### `DestinationStream`
1581
+ Properties:
1582
+
1583
+ * `write(msg)`
1584
+ - `msg` string
1585
+
1586
+ ## Types
1587
+ ### `Level`
1588
+
1589
+ * Values: `"fatal"` | `"error"` | `"warn"` | `"info"` | `"debug"` | `"trace"`
1590
+
1591
+ ## TypeScript
1592
+
1593
+ ### Module Augmentation
1594
+
1595
+ Pino supports TypeScript module augmentation to extend its type definitions. This allows you to customize the logging behavior to fit your application's specific requirements.
1596
+
1597
+ #### `LogFnFields` Interface
1598
+
1599
+ The `LogFnFields` interface can be augmented to control what fields are allowed in logging method objects. This is particularly useful for:
1600
+
1601
+ - Preventing certain fields from being logged (for security or compliance reasons)
1602
+ - Enforcing specific field types across your application
1603
+ - Enforcing consistent structured logging
1604
+
1605
+ ##### Banning Fields
1606
+
1607
+ You can ban specific fields from being passed to logging methods by setting them to `never`. This helps prevent users from unintentionally overriding fields that are already set in the logger's `base` option, or clarifies that these fields are predefined.
1608
+
1609
+ ```typescript
1610
+ declare module "pino" {
1611
+ interface LogFnFields {
1612
+ service?: never;
1613
+ version?: never;
1614
+ }
1615
+ }
1616
+
1617
+
1618
+ // These will now cause TypeScript errors
1619
+ logger.info({ service: 'other-api', message: 'success' }) // ❌
1620
+ logger.info({ message: 'success' }) // ✅
1621
+ ```
1622
+
1623
+ ##### Enforcing Field Types
1624
+
1625
+ You can also enforce specific types for certain fields:
1626
+
1627
+ ```typescript
1628
+ declare module "pino" {
1629
+ interface LogFnFields {
1630
+ userId?: string;
1631
+ requestId?: string;
1632
+ }
1633
+ }
1634
+
1635
+ // These will cause TypeScript errors
1636
+ logger.info({ userId: 123 }) // ❌ Error: userId must be string
1637
+ logger.info({ requestId: null }) // ❌ Error: requestId must be string
1638
+
1639
+ // This works fine
1640
+ logger.info({ userId: '123' }) // ✅ Works fine
1641
+ ```
1642
+
1643
+ ##### Enforcing Structured Logging
1644
+
1645
+ Required fields (non-optional) enforce consistent structured logging by requiring specific fields in all log objects:
1646
+
1647
+ ```typescript
1648
+ declare module "pino" {
1649
+ interface LogFnFields {
1650
+ userId: string
1651
+ }
1652
+ }
1653
+
1654
+ logger.info({ userId: '123' }) // ✅ Works fine
1655
+ logger.info({}) // ❌ Property 'userId' is missing in type '{}'
1656
+ ```
1657
+
1658
+ **Note**: Required fields will cause TypeScript errors when logging certain types like `Error` objects that don't contain the required properties:
1659
+
1660
+ ```typescript
1661
+ logger.error(new Error('test')) // ❌ Property 'userId' is missing in type 'Error'
1662
+ ```
1663
+
1664
+ This ensures that all log entries include required context fields, promoting consistent logging practices.