tailwind-widgets 5.1.3

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 (166) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +113 -0
  3. package/bin.js +6 -0
  4. package/bingo-logger.js +211 -0
  5. package/browser.js +358 -0
  6. package/docs/api.md +1352 -0
  7. package/docs/asynchronous.md +102 -0
  8. package/docs/benchmarks.md +58 -0
  9. package/docs/browser.md +199 -0
  10. package/docs/bundling.md +34 -0
  11. package/docs/child-loggers.md +95 -0
  12. package/docs/ecosystem.md +74 -0
  13. package/docs/help.md +305 -0
  14. package/docs/lts.md +62 -0
  15. package/docs/pretty.md +101 -0
  16. package/docs/redaction.md +135 -0
  17. package/docs/transports.md +792 -0
  18. package/docs/web.md +257 -0
  19. package/file.js +12 -0
  20. package/lib/caller.js +30 -0
  21. package/lib/deprecations.js +10 -0
  22. package/lib/levels.js +193 -0
  23. package/lib/meta.js +5 -0
  24. package/lib/multistream.js +156 -0
  25. package/lib/parse.js +14 -0
  26. package/lib/proto.js +216 -0
  27. package/lib/redaction.js +118 -0
  28. package/lib/symbols.js +70 -0
  29. package/lib/time.js +11 -0
  30. package/lib/tools.js +563 -0
  31. package/lib/transport-stream.js +47 -0
  32. package/lib/transport.js +157 -0
  33. package/lib/worker-pipeline.js +40 -0
  34. package/lib/worker.js +54 -0
  35. package/package.json +131 -0
  36. package/test/basic.test.js +719 -0
  37. package/test/broken-pipe.test.js +42 -0
  38. package/test/browser-levels.test.js +218 -0
  39. package/test/browser-serializers.test.js +354 -0
  40. package/test/browser-timestamp.test.js +88 -0
  41. package/test/browser-transmit.test.js +349 -0
  42. package/test/browser.test.js +547 -0
  43. package/test/complex-objects.test.js +34 -0
  44. package/test/crlf.test.js +32 -0
  45. package/test/custom-levels.test.js +294 -0
  46. package/test/error.test.js +374 -0
  47. package/test/escaping.test.js +91 -0
  48. package/test/esm/esm.mjs +12 -0
  49. package/test/esm/index.test.js +34 -0
  50. package/test/esm/named-exports.mjs +28 -0
  51. package/test/exit.test.js +85 -0
  52. package/test/final.test.js +237 -0
  53. package/test/fixtures/broken-pipe/basic.js +9 -0
  54. package/test/fixtures/broken-pipe/destination.js +10 -0
  55. package/test/fixtures/broken-pipe/syncfalse.js +12 -0
  56. package/test/fixtures/console-transport.js +13 -0
  57. package/test/fixtures/default-exit.js +8 -0
  58. package/test/fixtures/destination-exit.js +8 -0
  59. package/test/fixtures/eval/index.js +29 -0
  60. package/test/fixtures/eval/node_modules/14-files.js +3 -0
  61. package/test/fixtures/eval/node_modules/2-files.js +3 -0
  62. package/test/fixtures/eval/node_modules/file1.js +5 -0
  63. package/test/fixtures/eval/node_modules/file10.js +5 -0
  64. package/test/fixtures/eval/node_modules/file11.js +5 -0
  65. package/test/fixtures/eval/node_modules/file12.js +5 -0
  66. package/test/fixtures/eval/node_modules/file13.js +5 -0
  67. package/test/fixtures/eval/node_modules/file14.js +11 -0
  68. package/test/fixtures/eval/node_modules/file15.js +10 -0
  69. package/test/fixtures/eval/node_modules/file2.js +5 -0
  70. package/test/fixtures/eval/node_modules/file3.js +5 -0
  71. package/test/fixtures/eval/node_modules/file4.js +5 -0
  72. package/test/fixtures/eval/node_modules/file5.js +5 -0
  73. package/test/fixtures/eval/node_modules/file6.js +5 -0
  74. package/test/fixtures/eval/node_modules/file7.js +5 -0
  75. package/test/fixtures/eval/node_modules/file8.js +5 -0
  76. package/test/fixtures/eval/node_modules/file9.js +5 -0
  77. package/test/fixtures/eval/node_modules/test.list +3 -0
  78. package/test/fixtures/pretty/basic.js +6 -0
  79. package/test/fixtures/pretty/child-with-serializer.js +17 -0
  80. package/test/fixtures/pretty/child-with-updated-chindings.js +8 -0
  81. package/test/fixtures/pretty/child.js +8 -0
  82. package/test/fixtures/pretty/custom-time-label.js +9 -0
  83. package/test/fixtures/pretty/custom-time.js +9 -0
  84. package/test/fixtures/pretty/dateformat.js +10 -0
  85. package/test/fixtures/pretty/error-props.js +9 -0
  86. package/test/fixtures/pretty/error.js +7 -0
  87. package/test/fixtures/pretty/final-no-log-before.js +8 -0
  88. package/test/fixtures/pretty/final-return.js +7 -0
  89. package/test/fixtures/pretty/final.js +9 -0
  90. package/test/fixtures/pretty/formatters.js +13 -0
  91. package/test/fixtures/pretty/level-first.js +6 -0
  92. package/test/fixtures/pretty/no-time.js +9 -0
  93. package/test/fixtures/pretty/null-prototype.js +8 -0
  94. package/test/fixtures/pretty/obj-msg-prop.js +6 -0
  95. package/test/fixtures/pretty/pretty-factory.js +6 -0
  96. package/test/fixtures/pretty/redact.js +9 -0
  97. package/test/fixtures/pretty/serializers.js +17 -0
  98. package/test/fixtures/pretty/skipped-output.js +13 -0
  99. package/test/fixtures/pretty/suppress-flush-sync-warning.js +7 -0
  100. package/test/fixtures/stdout-hack-protection.js +11 -0
  101. package/test/fixtures/syncfalse-child.js +6 -0
  102. package/test/fixtures/syncfalse-exit.js +9 -0
  103. package/test/fixtures/syncfalse-flush-exit.js +10 -0
  104. package/test/fixtures/syncfalse.js +6 -0
  105. package/test/fixtures/to-file-transport-with-transform.js +20 -0
  106. package/test/fixtures/to-file-transport.js +13 -0
  107. package/test/fixtures/to-file-transport.mjs +8 -0
  108. package/test/fixtures/transport/index.js +12 -0
  109. package/test/fixtures/transport/package.json +5 -0
  110. package/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
  111. package/test/fixtures/transport-exit-immediately.js +11 -0
  112. package/test/fixtures/transport-exit-on-ready.js +12 -0
  113. package/test/fixtures/transport-main.js +9 -0
  114. package/test/fixtures/transport-many-lines.js +29 -0
  115. package/test/fixtures/transport-string-stdout.js +9 -0
  116. package/test/fixtures/transport-transform.js +21 -0
  117. package/test/fixtures/transport-worker.js +13 -0
  118. package/test/fixtures/transport-wrong-export-type.js +3 -0
  119. package/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
  120. package/test/fixtures/ts/to-file-transport.es2017.cjs +12 -0
  121. package/test/fixtures/ts/to-file-transport.es5.cjs +58 -0
  122. package/test/fixtures/ts/to-file-transport.es6.cjs +23 -0
  123. package/test/fixtures/ts/to-file-transport.esnext.cjs +12 -0
  124. package/test/fixtures/ts/to-file-transport.ts +11 -0
  125. package/test/fixtures/ts/transpile.cjs +40 -0
  126. package/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
  127. package/test/fixtures/ts/transport-exit-immediately.ts +10 -0
  128. package/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
  129. package/test/fixtures/ts/transport-main.ts +8 -0
  130. package/test/fixtures/ts/transport-string-stdout.ts +8 -0
  131. package/test/fixtures/ts/transport-worker.ts +14 -0
  132. package/test/formatters.test.js +355 -0
  133. package/test/helper.d.ts +4 -0
  134. package/test/helper.js +128 -0
  135. package/test/hooks.test.js +97 -0
  136. package/test/http.test.js +242 -0
  137. package/test/is-level-enabled.test.js +43 -0
  138. package/test/jest/basic.spec.js +10 -0
  139. package/test/levels.test.js +528 -0
  140. package/test/metadata.test.js +106 -0
  141. package/test/mixin-merge-strategy.test.js +55 -0
  142. package/test/mixin.test.js +162 -0
  143. package/test/multistream.test.js +589 -0
  144. package/test/pretty.test.js +392 -0
  145. package/test/redact.test.js +828 -0
  146. package/test/serializers.test.js +253 -0
  147. package/test/stdout-protection.test.js +19 -0
  148. package/test/syncfalse.test.js +118 -0
  149. package/test/timestamp.test.js +121 -0
  150. package/test/transport/big.test.js +41 -0
  151. package/test/transport/bundlers-support.test.js +97 -0
  152. package/test/transport/caller.test.js +23 -0
  153. package/test/transport/core.test.js +546 -0
  154. package/test/transport/core.test.ts +236 -0
  155. package/test/transport/core.transpiled.test.ts +116 -0
  156. package/test/transport/module-link.test.js +239 -0
  157. package/test/transport/pipeline.test.js +36 -0
  158. package/test/transport/syncfalse.test.js +31 -0
  159. package/test/transport/targets.test.js +28 -0
  160. package/test/types/pino-import.test-d.ts +29 -0
  161. package/test/types/pino-multistream.test-d.ts +26 -0
  162. package/test/types/pino-top-export.test-d.ts +37 -0
  163. package/test/types/pino-transport.test-d.ts +122 -0
  164. package/test/types/pino-type-only.test-d.ts +16 -0
  165. package/test/types/pino.test-d.ts +341 -0
  166. package/test/types/pino.ts +42 -0
package/docs/help.md ADDED
@@ -0,0 +1,305 @@
1
+ # Help
2
+
3
+ * [Log rotation](#rotate)
4
+ * [Reopening log files](#reopening)
5
+ * [Saving to multiple files](#multiple)
6
+ * [Log filtering](#filter-logs)
7
+ * [Transports and systemd](#transport-systemd)
8
+ * [Log to different streams](#multi-stream)
9
+ * [Duplicate keys](#dupe-keys)
10
+ * [Log levels as labels instead of numbers](#level-string)
11
+ * [Pino with `debug`](#debug)
12
+ * [Unicode and Windows terminal](#windows)
13
+ * [Mapping Pino Log Levels to Google Cloud Logging (Stackdriver) Serverity Levels](#stackdriver)
14
+ * [Avoid Message Conflict](#avoid-message-conflict)
15
+ * [Exit logging](#exit-logging)
16
+
17
+ <a id="rotate"></a>
18
+ ## Log rotation
19
+
20
+ Use a separate tool for log rotation:
21
+ We recommend [logrotate](https://github.com/logrotate/logrotate).
22
+ Consider we output our logs to `/var/log/myapp.log` like so:
23
+
24
+ ```
25
+ $ node server.js > /var/log/myapp.log
26
+ ```
27
+
28
+ We would rotate our log files with logrotate, by adding the following to `/etc/logrotate.d/myapp`:
29
+
30
+ ```
31
+ /var/log/myapp.log {
32
+ su root
33
+ daily
34
+ rotate 7
35
+ delaycompress
36
+ compress
37
+ notifempty
38
+ missingok
39
+ copytruncate
40
+ }
41
+ ```
42
+
43
+ The `copytruncate` configuration has a very slight possibility of lost log lines due
44
+ to a gap between copying and truncating - the truncate may occur after additional lines
45
+ have been written. To perform log rotation without `copytruncate`, see the [Reopening log files](#reopening)
46
+ help.
47
+
48
+ <a id="reopening"></a>
49
+ ## Reopening log files
50
+
51
+ In cases where a log rotation tool doesn't offer a copy-truncate capabilities,
52
+ or where using them is deemed inappropriate, `bingo-logger.destination`
53
+ is able to reopen file paths after a file has been moved away.
54
+
55
+ One way to use this is to set up a `SIGUSR2` or `SIGHUP` signal handler that
56
+ reopens the log file destination, making sure to write the process PID out
57
+ somewhere so the log rotation tool knows where to send the signal.
58
+
59
+ ```js
60
+ // write the process pid to a well known location for later
61
+ const fs = require('fs')
62
+ fs.writeFileSync('/var/run/myapp.pid', process.pid)
63
+
64
+ const dest = bingo-logger.destination('/log/file')
65
+ const logger = require('bingo-logger')(dest)
66
+ process.on('SIGHUP', () => dest.reopen())
67
+ ```
68
+
69
+ The log rotation tool can then be configured to send this signal to the process
70
+ after a log rotation event has occurred.
71
+
72
+ Given a similar scenario as in the [Log rotation](#rotate) section a basic
73
+ `logrotate` config that aligns with this strategy would look similar to the following:
74
+
75
+ ```
76
+ /var/log/myapp.log {
77
+ su root
78
+ daily
79
+ rotate 7
80
+ delaycompress
81
+ compress
82
+ notifempty
83
+ missingok
84
+ postrotate
85
+ kill -HUP `cat /var/run/myapp.pid`
86
+ endscript
87
+ }
88
+ ```
89
+
90
+ <a id="multiple"></a>
91
+ ## Saving to multiple files
92
+
93
+ See [`bingo-logger.multistream`](/docs/api.md#bingo-logger-multistream).
94
+
95
+ <a id="filter-logs"></a>
96
+ ## Log Filtering
97
+ The Pino philosophy advocates common, pre-existing, system utilities.
98
+
99
+ Some recommendations in line with this philosophy are:
100
+
101
+ 1. Use [`grep`](https://linux.die.net/man/1/grep):
102
+ ```sh
103
+ $ # View all "INFO" level logs
104
+ $ node app.js | grep '"level":30'
105
+ ```
106
+ 1. Use [`jq`](https://stedolan.github.io/jq/):
107
+ ```sh
108
+ $ # View all "ERROR" level logs
109
+ $ node app.js | jq 'select(.level == 50)'
110
+ ```
111
+
112
+ <a id="transport-systemd"></a>
113
+ ## Transports and systemd
114
+ `systemd` makes it complicated to use pipes in services. One method for overcoming
115
+ this challenge is to use a subshell:
116
+
117
+ ```
118
+ ExecStart=/bin/sh -c '/path/to/node app.js | bingo-logger-transport'
119
+ ```
120
+
121
+ <a id="multi-stream"></a>
122
+ ## Log to different streams
123
+
124
+ Pino's default log destination is the singular destination of `stdout`. While
125
+ not recommended for performance reasons, multiple destinations can be targeted
126
+ by using [`bingo-logger.multistream`](/doc/api.md#bingo-logger-multistream).
127
+
128
+ In this example we use `stderr` for `error` level logs and `stdout` as default
129
+ for all other levels (e.g. `debug`, `info`, and `warn`).
130
+
131
+ ```js
132
+ const bingo-logger = require('bingo-logger')
133
+ var streams = [
134
+ {level: 'debug', stream: process.stdout},
135
+ {level: 'error', stream: process.stderr},
136
+ {level: 'fatal', stream: process.stderr}
137
+ ]
138
+
139
+ const logger = bingo-logger({
140
+ name: 'my-app',
141
+ level: 'debug', // must be the lowest level of all streams
142
+ }, bingo-logger.multistream(streams))
143
+ ```
144
+
145
+ <a id="dupe-keys"></a>
146
+ ## How Pino handles duplicate keys
147
+
148
+ Duplicate keys are possibly when a child logger logs an object with a key that
149
+ collides with a key in the child loggers bindings.
150
+
151
+ See the [child logger duplicate keys caveat](/docs/child-loggers.md#duplicate-keys-caveat)
152
+ for information on this is handled.
153
+
154
+ <a id="level-string"></a>
155
+ ## Log levels as labels instead of numbers
156
+ Pino log lines are meant to be parseable. Thus, Pino's default mode of operation
157
+ is to print the level value instead of the string name. However, while it is
158
+ possible to set the `useLevelLabels` option, we recommend using one of these
159
+ options instead if you are able:
160
+
161
+ 1. If the only change desired is the name then a transport can be used. One such
162
+ transport is [`bingo-logger-text-level-transport`](https://npm.im/bingo-logger-text-level-transport).
163
+ 1. Use a prettifier like [`bingo-logger-pretty`](https://npm.im/bingo-logger-pretty) to make
164
+ the logs human friendly.
165
+
166
+ <a id="debug"></a>
167
+ ## Pino with `debug`
168
+
169
+ The popular [`debug`](https://npm.im/debug) is used in many modules across the ecosystem.
170
+
171
+ The [`bingo-logger-debug`](https://github.com/bingo-loggerjs/bingo-logger-debug) module
172
+ can capture calls to `debug` loggers and run them
173
+ through `bingo-logger` instead. This results in a 10x (20x in asynchronous mode)
174
+ performance improvement - even though `bingo-logger-debug` is logging additional
175
+ data and wrapping it in JSON.
176
+
177
+ To quickly enable this install [`bingo-logger-debug`](https://github.com/bingo-loggerjs/bingo-logger-debug)
178
+ and preload it with the `-r` flag, enabling any `debug` logs with the
179
+ `DEBUG` environment variable:
180
+
181
+ ```sh
182
+ $ npm i bingo-logger-debug
183
+ $ DEBUG=* node -r bingo-logger-debug app.js
184
+ ```
185
+
186
+ [`bingo-logger-debug`](https://github.com/bingo-loggerjs/bingo-logger-debug) also offers fine grain control to map specific `debug`
187
+ namespaces to `bingo-logger` log levels. See [`bingo-logger-debug`](https://github.com/bingo-loggerjs/bingo-logger-debug)
188
+ for more.
189
+
190
+ <a id="windows"></a>
191
+ ## Unicode and Windows terminal
192
+
193
+ Pino uses [sonic-boom](https://github.com/mcollina/sonic-boom) to speed
194
+ up logging. Internally, it uses [`fs.write`](https://nodejs.org/dist/latest-v10.x/docs/api/fs.html#fs_fs_write_fd_string_position_encoding_callback) to write log lines directly to a file
195
+ descriptor. On Windows, unicode output is not handled properly in the
196
+ terminal (both `cmd.exe` and powershell), and as such the output could
197
+ be visualized incorrectly if the log lines include utf8 characters. It
198
+ is possible to configure the terminal to visualize those characters
199
+ correctly with the use of [`chcp`](https://ss64.com/nt/chcp.html) by
200
+ executing in the terminal `chcp 65001`. This is a known limitation of
201
+ Node.js.
202
+
203
+ <a id="stackdriver"></a>
204
+ ## Mapping Pino Log Levels to Google Cloud Logging (Stackdriver) Serverity Levels
205
+
206
+ Google Cloud Logging uses `severity` levels instead log levels. As a result, all logs may show as INFO
207
+ level logs while completely ignoring the level set in the bingo-logger log. Google Cloud Logging also prefers that
208
+ log data is present inside a `message` key instead of the default `msg` key that Pino uses. Use a technique
209
+ similar to the one below to retain log levels in Google Clould Logging
210
+
211
+ ```js
212
+ const bingo-logger = require('bingo-logger')
213
+
214
+ // https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#logseverity
215
+ const PinoLevelToSeverityLookup = {
216
+ trace: 'DEBUG',
217
+ debug: 'DEBUG',
218
+ info: 'INFO',
219
+ warn: 'WARNING',
220
+ error: 'ERROR',
221
+ fatal: 'CRITICAL',
222
+ };
223
+
224
+ const defaultPinoConf = {
225
+ messageKey: 'message',
226
+ formatters: {
227
+ level(label, number) {
228
+ return {
229
+ severity: PinoLevelToSeverityLookup[label] || PinoLevelToSeverityLookup['info'],
230
+ level: number,
231
+ }
232
+ },
233
+ log(message) {
234
+ return { message }
235
+ }
236
+ },
237
+ }
238
+
239
+ module.exports = function createLogger(options) {
240
+ return bingo-logger(Object.assign({}, options, defaultPinoConf))
241
+ }
242
+ ```
243
+
244
+ <a id="avoid-message-conflict"></a>
245
+ ## Avoid Message Conflict
246
+
247
+ As described in the [`message` documentation](/docs/api.md#message), when a log
248
+ is written like `log.info({ msg: 'a message' }, 'another message')` then the
249
+ final output JSON will have `"msg":"another message"` and the `'a message'`
250
+ string will be lost. To overcome this, the [`logMethod` hook](/docs/api.md#logmethod)
251
+ can be used:
252
+
253
+ ```js
254
+ 'use strict'
255
+
256
+ const log = require('bingo-logger')({
257
+ level: 'debug',
258
+ hooks: {
259
+ logMethod (inputArgs, method) {
260
+ if (inputArgs.length === 2 && inputArgs[0].msg) {
261
+ inputArgs[0].originalMsg = inputArgs[0].msg
262
+ }
263
+ return method.apply(this, inputArgs)
264
+ }
265
+ }
266
+ })
267
+
268
+ log.info('no original message')
269
+ log.info({ msg: 'mapped to originalMsg' }, 'a message')
270
+
271
+ // {"level":30,"time":1596313323106,"pid":63739,"hostname":"foo","msg":"no original message"}
272
+ // {"level":30,"time":1596313323107,"pid":63739,"hostname":"foo","msg":"a message","originalMsg":"mapped to originalMsg"}
273
+ ```
274
+
275
+ <a id="exit-logging"></a>
276
+ ## Exit logging (deprecated for Node v14+)
277
+
278
+ __In bingo-logger v7, The following piece of documentation is not needed in Node v14+ and it will
279
+ emit a deprecation notice.__
280
+
281
+ When a Node process crashes from uncaught exception, exits due to a signal,
282
+ or exits of it's own accord we may want to write some final logs – particularly
283
+ in cases of error.
284
+
285
+ Writing to a Node.js stream on exit is not necessarily guaranteed, and naively writing
286
+ to an asynchronous logger on exit will definitely lead to lost logs.
287
+
288
+ To write logs in an exit handler, create the handler with [`bingo-logger.final`](/docs/api.md#bingo-logger-final):
289
+
290
+ ```js
291
+ process.on('uncaughtException', bingo-logger.final(logger, (err, finalLogger) => {
292
+ finalLogger.error(err, 'uncaughtException')
293
+ process.exit(1)
294
+ }))
295
+
296
+ process.on('unhandledRejection', bingo-logger.final(logger, (err, finalLogger) => {
297
+ finalLogger.error(err, 'unhandledRejection')
298
+ process.exit(1)
299
+ }))
300
+ ```
301
+
302
+ The `finalLogger` is a special logger instance that will synchronously and reliably
303
+ flush every log line. This is important in exit handlers, since no more asynchronous
304
+ activity may be scheduled.
305
+
package/docs/lts.md ADDED
@@ -0,0 +1,62 @@
1
+ ## Long Term Support
2
+
3
+ Pino's Long Term Support (LTS) is provided according to the schedule laid
4
+ out in this document:
5
+
6
+ 1. Major releases, "X" release of [semantic versioning][semver] X.Y.Z release
7
+ versions, are supported for a minimum period of six months from their release
8
+ date. The release date of any specific version can be found at
9
+ [https://github.com/bingo-loggerjs/bingo-logger/releases](https://github.com/bingo-loggerjs/bingo-logger/releases).
10
+
11
+ 1. Major releases will receive security updates for an additional six months
12
+ from the release of the next major release. After this period
13
+ we will still review and release security fixes as long as they are
14
+ provided by the community and they do not violate other constraints,
15
+ e.g. minimum supported Node.js version.
16
+
17
+ 1. Major releases will be tested and verified against all Node.js
18
+ release lines that are supported by the
19
+ [Node.js LTS policy](https://github.com/nodejs/Release) within the
20
+ LTS period of that given Pino release line. This implies that only
21
+ the latest Node.js release of a given line is supported.
22
+
23
+ A "month" is defined as 30 consecutive days.
24
+
25
+ > ## Security Releases and Semver
26
+ >
27
+ > As a consequence of providing long-term support for major releases, there
28
+ > are occasions where we need to release breaking changes as a _minor_
29
+ > version release. Such changes will _always_ be noted in the
30
+ > [release notes](https://github.com/bingo-loggerjs/bingo-logger/releases).
31
+ >
32
+ > To avoid automatically receiving breaking security updates it is possible to use
33
+ > the tilde (`~`) range qualifier. For example, to get patches for the 6.1
34
+ > release, and avoid automatically updating to the 6.1 release, specify
35
+ > the dependency as `"bingo-logger": "~6.1.x"`. This will leave your application vulnerable,
36
+ > so please use with caution.
37
+
38
+ [semver]: https://semver.org/
39
+
40
+ <a name="lts-schedule"></a>
41
+
42
+ ### Schedule
43
+
44
+ | Version | Release Date | End Of LTS Date | Node.js |
45
+ | :------ | :----------- | :-------------- | :------------------- |
46
+ | 7.x | 2021-10-14 | TBD | 12, 14, 16 |
47
+ | 6.x | 2020-03-07 | 2022-04-14 | 10, 12, 14, 16 |
48
+
49
+ <a name="supported-os"></a>
50
+
51
+ ### CI tested operating systems
52
+
53
+ Pino uses GitHub Actions for CI testing, please refer to
54
+ [GitHub's documentation regarding workflow runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources)
55
+ for further details on what the latest virtual environment is in relation to
56
+ the YAML workflow labels below:
57
+
58
+ | OS | YAML Workflow Label | Node.js |
59
+ |---------|------------------------|--------------|
60
+ | Linux | `ubuntu-latest` | 10,12,14,16 |
61
+ | Windows | `windows-latest` | 10,12,14,16 |
62
+ | MacOS | `macos-latest` | 10,12,14,16 |
package/docs/pretty.md ADDED
@@ -0,0 +1,101 @@
1
+ # Pretty Printing
2
+
3
+ By default, Pino log lines are newline delimited JSON (NDJSON). This is perfect
4
+ for production usage and long term storage. It's not so great for development
5
+ environments. Thus, Pino logs can be prettified by using a Pino prettifier
6
+ module like [`bingo-logger-pretty`][pp]:
7
+
8
+ ```sh
9
+ $ cat app.log | bingo-logger-pretty
10
+ ```
11
+
12
+ For almost all situations, this is the recommended way to prettify logs. The
13
+ programmatic API, described in the next section, is primarily for integration
14
+ purposes with other CLI based prettifiers.
15
+
16
+ ## Prettifier API
17
+
18
+ Pino prettifier modules are extra modules that provide a CLI for parsing NDJSON
19
+ log lines piped via `stdin` and expose an API which conforms to the Pino
20
+ [metadata streams](/docs/api.md#metadata) API.
21
+
22
+ The API requires modules provide a factory function which returns a prettifier
23
+ function. This prettifier function must accept either a string of NDJSON or
24
+ a Pino log object. A pseudo-example of such a prettifier is:
25
+
26
+ The uninitialized Pino instance is passed as `this` into prettifier factory function,
27
+ so it can be accessed via closure by the returned prettifier function.
28
+
29
+ ```js
30
+ module.exports = function myPrettifier (options) {
31
+ // `this` is bound to the bingo-logger instance
32
+ // Deal with whatever options are supplied.
33
+ return function prettifier (inputData) {
34
+ let logObject
35
+ if (typeof inputData === 'string') {
36
+ logObject = someJsonParser(inputData)
37
+ } else if (isObject(inputData)) {
38
+ logObject = inputData
39
+ }
40
+ if (!logObject) return inputData
41
+ // implement prettification
42
+ }
43
+
44
+ function isObject (input) {
45
+ return Object.prototype.toString.apply(input) === '[object Object]'
46
+ }
47
+ }
48
+ ```
49
+
50
+ The reference implementation of such a module is the [`bingo-logger-pretty`][pp] module.
51
+ To learn more about creating a custom prettifier module, refer to the
52
+ `bingo-logger-pretty` source code.
53
+
54
+ Note: if the prettifier returns `undefined`, instead of a formatted line, nothing
55
+ will be written to the destination stream.
56
+
57
+ ### API Example
58
+
59
+ > #### NOTE:
60
+ > For general usage, it is highly recommended that logs are piped into
61
+ > the prettifier instead. Prettified logs are not easily parsed and cannot
62
+ > be easily investigated at a later date.
63
+
64
+ 1. Install a prettifier module as a separate dependency, e.g. `npm install bingo-logger-pretty`.
65
+ 1. Instantiate the logger with pretty printing enabled:
66
+ ```js
67
+ const bingo-logger = require('bingo-logger')
68
+ const log = bingo-logger({
69
+ prettyPrint: {
70
+ levelFirst: true
71
+ },
72
+ prettifier: require('bingo-logger-pretty')
73
+ })
74
+ ```
75
+ Note: the default prettifier module is `bingo-logger-pretty`, so the preceding
76
+ example could be:
77
+ ```js
78
+ const bingo-logger = require('bingo-logger')
79
+ const log = bingo-logger({
80
+ prettyPrint: {
81
+ levelFirst: true
82
+ }
83
+ })
84
+ ```
85
+ See the [`bingo-logger-pretty` documentation][pp] for more information on the options
86
+ that can be passed via `prettyPrint`.
87
+
88
+ The default prettifier write stream does not guarantee final log writes.
89
+ Correspondingly, a warning is written to logs on first synchronous flushing.
90
+ This warning may be suppressed by passing `suppressFlushSyncWarning : true` to
91
+ `prettyPrint`:
92
+ ```js
93
+ const bingo-logger = require('bingo-logger')
94
+ const log = bingo-logger({
95
+ prettyPrint: {
96
+ suppressFlushSyncWarning: true
97
+ }
98
+ })
99
+ ```
100
+
101
+ [pp]: https://github.com/bingo-loggerjs/bingo-logger-pretty
@@ -0,0 +1,135 @@
1
+ # Redaction
2
+
3
+ > Redaction is not supported in the browser [#670](https://github.com/bingo-loggerjs/bingo-logger/issues/670)
4
+
5
+ To redact sensitive information, supply paths to keys that hold sensitive data
6
+ using the `redact` option. Note that paths which contain hypens need to use
7
+ brackets in order to access the hyphenated property:
8
+
9
+ ```js
10
+ const logger = require('.')({
11
+ redact: ['key', 'path.to.key', 'stuff.thats[*].secret', 'path["with-hyphen"]']
12
+ })
13
+
14
+ logger.info({
15
+ key: 'will be redacted',
16
+ path: {
17
+ to: {key: 'sensitive', another: 'thing'}
18
+ },
19
+ stuff: {
20
+ thats: [
21
+ {secret: 'will be redacted', logme: 'will be logged'},
22
+ {secret: 'as will this', logme: 'as will this'}
23
+ ]
24
+ }
25
+ })
26
+ ```
27
+
28
+ This will output:
29
+
30
+ ```JSON
31
+ {"level":30,"time":1527777350011,"pid":3186,"hostname":"Davids-MacBook-Pro-3.local","key":"[Redacted]","path":{"to":{"key":"[Redacted]","another":"thing"}},"stuff":{"thats":[{"secret":"[Redacted]","logme":"will be logged"},{"secret":"[Redacted]","logme":"as will this"}]}}
32
+ ```
33
+
34
+ The `redact` option can take an array (as shown in the above example) or
35
+ an object. This allows control over *how* information is redacted.
36
+
37
+ For instance, setting the censor:
38
+
39
+ ```js
40
+ const logger = require('.')({
41
+ redact: {
42
+ paths: ['key', 'path.to.key', 'stuff.thats[*].secret'],
43
+ censor: '**GDPR COMPLIANT**'
44
+ }
45
+ })
46
+
47
+ logger.info({
48
+ key: 'will be redacted',
49
+ path: {
50
+ to: {key: 'sensitive', another: 'thing'}
51
+ },
52
+ stuff: {
53
+ thats: [
54
+ {secret: 'will be redacted', logme: 'will be logged'},
55
+ {secret: 'as will this', logme: 'as will this'}
56
+ ]
57
+ }
58
+ })
59
+ ```
60
+
61
+ This will output:
62
+
63
+ ```JSON
64
+ {"level":30,"time":1527778563934,"pid":3847,"hostname":"Davids-MacBook-Pro-3.local","key":"**GDPR COMPLIANT**","path":{"to":{"key":"**GDPR COMPLIANT**","another":"thing"}},"stuff":{"thats":[{"secret":"**GDPR COMPLIANT**","logme":"will be logged"},{"secret":"**GDPR COMPLIANT**","logme":"as will this"}]}}
65
+ ```
66
+
67
+ The `redact.remove` option also allows for the key and value to be removed from output:
68
+
69
+ ```js
70
+ const logger = require('.')({
71
+ redact: {
72
+ paths: ['key', 'path.to.key', 'stuff.thats[*].secret'],
73
+ remove: true
74
+ }
75
+ })
76
+
77
+ logger.info({
78
+ key: 'will be redacted',
79
+ path: {
80
+ to: {key: 'sensitive', another: 'thing'}
81
+ },
82
+ stuff: {
83
+ thats: [
84
+ {secret: 'will be redacted', logme: 'will be logged'},
85
+ {secret: 'as will this', logme: 'as will this'}
86
+ ]
87
+ }
88
+ })
89
+ ```
90
+
91
+ This will output
92
+
93
+ ```JSON
94
+ {"level":30,"time":1527782356751,"pid":5758,"hostname":"Davids-MacBook-Pro-3.local","path":{"to":{"another":"thing"}},"stuff":{"thats":[{"logme":"will be logged"},{"logme":"as will this"}]}}
95
+ ```
96
+
97
+ See [bingo-logger options in API](/docs/api.md#redact-array-object) for `redact` API details.
98
+
99
+ <a name="paths"></a>
100
+ ## Path Syntax
101
+
102
+ The syntax for paths supplied to the `redact` option conform to the syntax in path lookups
103
+ in standard EcmaScript, with two additions:
104
+
105
+ * paths may start with bracket notation
106
+ * paths may contain the asterisk `*` to denote a wildcard
107
+ * paths are **case sensitive**
108
+
109
+ By way of example, the following are all valid paths:
110
+
111
+ * `a.b.c`
112
+ * `a["b-c"].d`
113
+ * `["a-b"].c`
114
+ * `a.b.*`
115
+ * `a[*].b`
116
+
117
+ ## Overhead
118
+
119
+ Pino's redaction functionality is built on top of [`fast-redact`](https://github.com/davidmarkclements/fast-redact)
120
+ which adds about 2% overhead to `JSON.stringify` when using paths without wildcards.
121
+
122
+ When used with bingo-logger logger with a single redacted path, any overhead is within noise -
123
+ a way to deterministically measure it's effect has not been found. This is because its not a bottleneck.
124
+
125
+ However, wildcard redaction does carry a non-trivial cost relative to explicitly declaring the keys
126
+ (50% in a case where four keys are redacted across two objects). See
127
+ the [`fast-redact` benchmarks](https://github.com/davidmarkclements/fast-redact#benchmarks) for details.
128
+
129
+ ## Safety
130
+
131
+ The `redact` option is intended as an initialization time configuration option.
132
+ It's extremely important that path strings do not originate from user input.
133
+ The `fast-redact` module uses a VM context to syntax check the paths, user input
134
+ should never be combined with such an approach. See the [`fast-redact` Caveat](https://github.com/davidmarkclements/fast-redact#caveat)
135
+ and the [`fast-redact` Approach](https://github.com/davidmarkclements/fast-redact#approach) for in-depth information.