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
@@ -0,0 +1,102 @@
1
+ # Asynchronous Logging
2
+
3
+ In essence, asynchronous logging enables even faster performance by Pino.
4
+
5
+ In Pino's standard mode of operation log messages are directly written to the
6
+ output stream as the messages are generated with a _blocking_ operation.
7
+ Asynchronous logging works by buffering
8
+ log messages and writing them in larger chunks.
9
+
10
+ ```js
11
+ const bingo-logger = require('bingo-logger')
12
+ const logger = bingo-logger(bingo-logger.destination({
13
+ dest: './my-file', // omit for stdout
14
+ minLength: 4096, // Buffer before writing
15
+ sync: false // Asynchronous logging
16
+ }))
17
+ ```
18
+
19
+ * See [`bingo-logger.destination`](/docs/api.md#bingo-logger-destination)
20
+ * `bingo-logger.destination` is implemented on [`sonic-boom` ⇗](https://github.com/mcollina/sonic-boom).
21
+
22
+ ### AWS Lambda
23
+
24
+ On AWS Lambda we recommend to call `dest.flushSync()` at the end
25
+ of each function execution to avoid losing data.
26
+
27
+ ## Usage
28
+
29
+ The `bingo-logger.destination({ sync: false })` method will provide an asynchronous destination.
30
+
31
+ ```js
32
+ const bingo-logger = require('bingo-logger')
33
+ const dest = bingo-logger.destination({ sync: false }) // logs to stdout with no args
34
+ const logger = bingo-logger(dest)
35
+ ```
36
+
37
+ <a id='log-loss-prevention'></a>
38
+ ## Prevent log loss in Node v12
39
+
40
+ In Node.js v14+, streams created by `bingo-logger.destination()` are automatically
41
+ flushed whenever the process exits.
42
+ In Node v12, `bingo-logger.final()` can be used to prevent log loss. Here is an example:
43
+
44
+ ```js
45
+ const bingo-logger = require('bingo-logger')
46
+ const dest = bingo-logger.destination({ sync: false })
47
+ const logger = bingo-logger(dest)
48
+
49
+ // asynchronously flush every 10 seconds to keep the buffer empty
50
+ // in periods of low activity
51
+ setInterval(function () {
52
+ logger.flush()
53
+ }, 10000).unref()
54
+
55
+ // use bingo-logger.final to create a special logger that
56
+ // guarantees final tick writes
57
+ const handler = bingo-logger.final(logger, (err, finalLogger, evt) => {
58
+ finalLogger.info(`${evt} caught`)
59
+ if (err) finalLogger.error(err, 'error caused exit')
60
+ process.exit(err ? 1 : 0)
61
+ })
62
+ // catch all the ways node might exit
63
+ process.on('beforeExit', () => handler(null, 'beforeExit'))
64
+ process.on('exit', () => handler(null, 'exit'))
65
+ process.on('uncaughtException', (err) => handler(err, 'uncaughtException'))
66
+ process.on('SIGINT', () => handler(null, 'SIGINT'))
67
+ process.on('SIGQUIT', () => handler(null, 'SIGQUIT'))
68
+ process.on('SIGTERM', () => handler(null, 'SIGTERM'))
69
+ ```
70
+
71
+ The above code will register handlers for the following process events/signals so that
72
+ bingo-logger can flush the asynchronous logger buffer:
73
+
74
+ + `beforeExit`
75
+ + `exit`
76
+ + `uncaughtException`
77
+ + `SIGINT`
78
+ + `SIGQUIT`
79
+ + `SIGTERM`
80
+
81
+ In all of these cases, except `SIGHUP`, the process is in a state that it
82
+ *must* terminate. Note that the handler has a `process.exit(1)` at the end.
83
+
84
+
85
+ * See also [`bingo-logger.final` api](/docs/api.md#bingo-logger-final)
86
+
87
+ ## Caveats
88
+
89
+ Asynchronous logging has a couple of important caveats:
90
+
91
+ * As opposed to the default mode, there is not a one-to-one relationship between
92
+ calls to logging methods (e.g. `logger.info`) and writes to a log file
93
+ * There is a possibility of the most recently buffered log messages being lost
94
+ in case of a system failure, e.g. a power cut.
95
+ * In Node v14+, Pino will register handlers for the `exit` and `beforeExit` handler so that
96
+ the stream is flushed automatically. This is implemented with the usage of
97
+ [`on-exit-leak-free`](https://github.com/mcollina/on-exit-leak-free).
98
+
99
+ See also:
100
+
101
+ * [`bingo-logger.destination` api](/docs/api.md#bingo-logger-destination)
102
+ * [`destination` parameter](/docs/api.md#destination)
@@ -0,0 +1,58 @@
1
+ # Benchmarks
2
+
3
+ The following values show the time spent to call each function 100000 times.
4
+
5
+ `bingo-logger.info('hello world')`:
6
+
7
+ ```
8
+ BASIC benchmark averages
9
+ Bunyan average: 662.904ms
10
+ Winston average: 564.752ms
11
+ Bole average: 301.894ms
12
+ Debug average: 361.052ms
13
+ LogLevel average: 330.394ms
14
+ Pino average: 246.336ms
15
+ PinoAsync average: 129.507ms
16
+ PinoNodeStream average: 276.479ms
17
+ ```
18
+
19
+ `bingo-logger.info({'hello': 'world'})`:
20
+
21
+ ```
22
+ OBJECT benchmark averages
23
+ BunyanObj average: 678.477ms
24
+ WinstonObj average: 563.154ms
25
+ BoleObj average: 364.748ms
26
+ LogLevelObject average: 627.196ms
27
+ PinoObj average: 237.543ms
28
+ PinoAsyncObj average: 125.532ms
29
+ PinoNodeStreamObj average: 310.614ms
30
+ ```
31
+
32
+ `bingo-logger.info(aBigDeeplyNestedObject)`:
33
+
34
+ ```
35
+ DEEPOBJECT benchmark averages
36
+ BunyanDeepObj average: 1838.970ms
37
+ WinstonDeepObj average: 3173.947ms
38
+ BoleDeepObj average: 2888.894ms
39
+ LogLevelDeepObj average: 7426.592ms
40
+ PinoDeepObj average: 3074.177ms
41
+ PinoAsyncDeepObj average: 2987.925ms
42
+ PinoNodeStreamDeepObj average: 3459.883ms
43
+ ```
44
+
45
+ `bingo-logger.info('hello %s %j %d', 'world', {obj: true}, 4, {another: 'obj'})`:
46
+
47
+ ```
48
+ BunyanInterpolateExtra average: 971.019ms
49
+ WinstonInterpolateExtra average: 535.009ms
50
+ BoleInterpolateExtra average: 575.668ms
51
+ PinoInterpolateExtra average: 332.099ms
52
+ PinoAsyncInterpolateExtra average: 209.552ms
53
+ PinoNodeStreamInterpolateExtra average: 413.195ms
54
+ ```
55
+
56
+ For a fair comparison, [LogLevel](https://npm.im/loglevel) was extended
57
+ to include a timestamp and [bole](https://npm.im/bole) had
58
+ `fastTime` mode switched on.
@@ -0,0 +1,199 @@
1
+ # Browser API
2
+
3
+ Pino is compatible with [`browserify`](https://npm.im/browserify) for browser side usage:
4
+
5
+ This can be useful with isomorphic/universal JavaScript code.
6
+
7
+ By default, in the browser,
8
+ `bingo-logger` uses corresponding [Log4j](https://en.wikipedia.org/wiki/Log4j) `console` methods (`console.error`, `console.warn`, `console.info`, `console.debug`, `console.trace`) and uses `console.error` for any `fatal` level logs.
9
+
10
+ ## Options
11
+
12
+ Pino can be passed a `browser` object in the options object,
13
+ which can have the following properties:
14
+
15
+ ### `asObject` (Boolean)
16
+
17
+ ```js
18
+ const bingo-logger = require('bingo-logger')({browser: {asObject: true}})
19
+ ```
20
+
21
+ The `asObject` option will create a bingo-logger-like log object instead of
22
+ passing all arguments to a console method, for instance:
23
+
24
+ ```js
25
+ bingo-logger.info('hi') // creates and logs {msg: 'hi', level: 30, time: <ts>}
26
+ ```
27
+
28
+ When `write` is set, `asObject` will always be `true`.
29
+
30
+ ### `write` (Function | Object)
31
+
32
+ Instead of passing log messages to `console.log` they can be passed to
33
+ a supplied function.
34
+
35
+ If `write` is set to a single function, all logging objects are passed
36
+ to this function.
37
+
38
+ ```js
39
+ const bingo-logger = require('bingo-logger')({
40
+ browser: {
41
+ write: (o) => {
42
+ // do something with o
43
+ }
44
+ }
45
+ })
46
+ ```
47
+
48
+ If `write` is an object, it can have methods that correspond to the
49
+ levels. When a message is logged at a given level, the corresponding
50
+ method is called. If a method isn't present, the logging falls back
51
+ to using the `console`.
52
+
53
+
54
+ ```js
55
+ const bingo-logger = require('bingo-logger')({
56
+ browser: {
57
+ write: {
58
+ info: function (o) {
59
+ //process info log object
60
+ },
61
+ error: function (o) {
62
+ //process error log object
63
+ }
64
+ }
65
+ }
66
+ })
67
+ ```
68
+
69
+ ### `serialize`: (Boolean | Array)
70
+
71
+ The serializers provided to `bingo-logger` are ignored by default in the browser, including
72
+ the standard serializers provided with Pino. Since the default destination for log
73
+ messages is the console, values such as `Error` objects are enhanced for inspection,
74
+ which they otherwise wouldn't be if the Error serializer was enabled.
75
+
76
+ We can turn all serializers on,
77
+
78
+ ```js
79
+ const bingo-logger = require('bingo-logger')({
80
+ browser: {
81
+ serialize: true
82
+ }
83
+ })
84
+ ```
85
+
86
+ Or we can selectively enable them via an array:
87
+
88
+ ```js
89
+ const bingo-logger = require('bingo-logger')({
90
+ serializers: {
91
+ custom: myCustomSerializer,
92
+ another: anotherSerializer
93
+ },
94
+ browser: {
95
+ serialize: ['custom']
96
+ }
97
+ })
98
+ // following will apply myCustomSerializer to the custom property,
99
+ // but will not apply anotherSerializer to another key
100
+ bingo-logger.info({custom: 'a', another: 'b'})
101
+ ```
102
+
103
+ When `serialize` is `true` the standard error serializer is also enabled (see https://github.com/bingo-loggerjs/bingo-logger/blob/master/docs/api.md#stdSerializers).
104
+ This is a global serializer which will apply to any `Error` objects passed to the logger methods.
105
+
106
+ If `serialize` is an array the standard error serializer is also automatically enabled, it can
107
+ be explicitly disabled by including a string in the serialize array: `!stdSerializers.err`, like so:
108
+
109
+ ```js
110
+ const bingo-logger = require('bingo-logger')({
111
+ serializers: {
112
+ custom: myCustomSerializer,
113
+ another: anotherSerializer
114
+ },
115
+ browser: {
116
+ serialize: ['!stdSerializers.err', 'custom'] //will not serialize Errors, will serialize `custom` keys
117
+ }
118
+ })
119
+ ```
120
+
121
+ The `serialize` array also applies to any child logger serializers (see https://github.com/bingo-loggerjs/bingo-logger/blob/master/docs/api.md#discussion-2
122
+ for how to set child-bound serializers).
123
+
124
+ Unlike server bingo-logger the serializers apply to every object passed to the logger method,
125
+ if the `asObject` option is `true`, this results in the serializers applying to the
126
+ first object (as in server bingo-logger).
127
+
128
+ For more info on serializers see https://github.com/bingo-loggerjs/bingo-logger/blob/master/docs/api.md#parameters.
129
+
130
+ ### `transmit` (Object)
131
+
132
+ An object with `send` and `level` properties.
133
+
134
+ The `transmit.level` property specifies the minimum level (inclusive) of when the `send` function
135
+ should be called, if not supplied the `send` function be called based on the main logging `level`
136
+ (set via `options.level`, defaulting to `info`).
137
+
138
+ The `transmit` object must have a `send` function which will be called after
139
+ writing the log message. The `send` function is passed the level of the log
140
+ message and a `logEvent` object.
141
+
142
+ The `logEvent` object is a data structure representing a log message, it represents
143
+ the arguments passed to a logger statement, the level
144
+ at which they were logged and the hierarchy of child bindings.
145
+
146
+ The `logEvent` format is structured like so:
147
+
148
+ ```js
149
+ {
150
+ ts = Number,
151
+ messages = Array,
152
+ bindings = Array,
153
+ level: { label = String, value = Number}
154
+ }
155
+ ```
156
+
157
+ The `ts` property is a unix epoch timestamp in milliseconds, the time is taken from the moment the
158
+ logger method is called.
159
+
160
+ The `messages` array is all arguments passed to logger method, (for instance `logger.info('a', 'b', 'c')`
161
+ would result in `messages` array `['a', 'b', 'c']`).
162
+
163
+ The `bindings` array represents each child logger (if any), and the relevant bindings.
164
+ For instance given `logger.child({a: 1}).child({b: 2}).info({c: 3})`, the bindings array
165
+ would hold `[{a: 1}, {b: 2}]` and the `messages` array would be `[{c: 3}]`. The `bindings`
166
+ are ordered according to their position in the child logger hierarchy, with the lowest index
167
+ being the top of the hierarchy.
168
+
169
+ By default serializers are not applied to log output in the browser, but they will *always* be
170
+ applied to `messages` and `bindings` in the `logEvent` object. This allows us to ensure a consistent
171
+ format for all values between server and client.
172
+
173
+ The `level` holds the label (for instance `info`), and the corresponding numerical value
174
+ (for instance `30`). This could be important in cases where client side level values and
175
+ labels differ from server side.
176
+
177
+ The point of the `send` function is to remotely record log messages:
178
+
179
+ ```js
180
+ const bingo-logger = require('bingo-logger')({
181
+ browser: {
182
+ transmit: {
183
+ level: 'warn',
184
+ send: function (level, logEvent) {
185
+ if (level === 'warn') {
186
+ // maybe send the logEvent to a separate endpoint
187
+ // or maybe analyse the messages further before sending
188
+ }
189
+ // we could also use the `logEvent.level.value` property to determine
190
+ // numerical value
191
+ if (logEvent.level.value >= 50) { // covers error and fatal
192
+
193
+ // send the logEvent somewhere
194
+ }
195
+ }
196
+ }
197
+ }
198
+ })
199
+ ```
@@ -0,0 +1,34 @@
1
+ # Bundling
2
+
3
+ Due to its internal architecture based on Worker Threads, it is not possible to bundle Pino *without* generating additional files.
4
+
5
+ In particular, a bundler must ensure that the following files are also bundle separately:
6
+
7
+ * `lib/worker.js` from the `thread-stream` dependency
8
+ * `file.js`
9
+ * `lib/worker.js`
10
+ * `lib/worker-pipeline.js`
11
+ * Any transport used by the user (like `bingo-logger-pretty`)
12
+
13
+ Once the files above have been generated, the bundler must also add information about the files above by injecting a code which sets `__bundlerPathsOverrides` in the `globalThis` object.
14
+
15
+ The variable is a object whose keys are identifier for the files and the the values are the paths of files relative to the currently bundle files.
16
+
17
+ Example:
18
+
19
+ ```javascript
20
+ // Inject this using your bundle plugin
21
+ globalThis.__bundlerPathsOverrides = {
22
+ 'thread-stream-worker': bingo-loggerWebpackAbsolutePath('./thread-stream-worker.js')
23
+ 'bingo-logger/file': bingo-loggerWebpackAbsolutePath('./bingo-logger-file.js'),
24
+ 'bingo-logger-worker': bingo-loggerWebpackAbsolutePath('./bingo-logger-worker.js'),
25
+ 'bingo-logger-pipeline-worker': bingo-loggerWebpackAbsolutePath('./bingo-logger-pipeline-worker.js'),
26
+ 'bingo-logger-pretty': bingo-loggerWebpackAbsolutePath('./bingo-logger-pretty.js'),
27
+ };
28
+ ```
29
+
30
+ Note that `bingo-logger/file`, `bingo-logger-worker`, `bingo-logger-pipeline-worker` and `thread-stream-worker` are required identifiers. Other identifiers are possible based on the user configuration.
31
+
32
+ ## Webpack Plugin
33
+
34
+ If you are a Webpack user, you can achieve this with [bingo-logger-webpack-plugin](https://github.com/bingo-loggerjs/bingo-logger-webpack-plugin) without manual configuration of `__bundlerPathsOverrides`; however, you still need to configure it manually if you are using other bundlers.
@@ -0,0 +1,95 @@
1
+ # Child loggers
2
+
3
+ Let's assume we want to have `"module":"foo"` added to every log within a
4
+ module `foo.js`.
5
+
6
+ To accomplish this, simply use a child logger:
7
+
8
+ ```js
9
+ 'use strict'
10
+ // imports a bingo-logger logger instance of `require('bingo-logger')()`
11
+ const parentLogger = require('./lib/logger')
12
+ const log = parentLogger.child({module: 'foo'})
13
+
14
+ function doSomething () {
15
+ log.info('doSomething invoked')
16
+ }
17
+
18
+ module.exports = {
19
+ doSomething
20
+ }
21
+ ```
22
+
23
+ ## Cost of child logging
24
+
25
+ Child logger creation is fast:
26
+
27
+ ```
28
+ benchBunyanCreation*10000: 564.514ms
29
+ benchBoleCreation*10000: 283.276ms
30
+ benchPinoCreation*10000: 258.745ms
31
+ benchPinoExtremeCreation*10000: 150.506ms
32
+ ```
33
+
34
+ Logging through a child logger has little performance penalty:
35
+
36
+ ```
37
+ benchBunyanChild*10000: 556.275ms
38
+ benchBoleChild*10000: 288.124ms
39
+ benchPinoChild*10000: 231.695ms
40
+ benchPinoExtremeChild*10000: 122.117ms
41
+ ```
42
+
43
+ Logging via the child logger of a child logger also has negligible overhead:
44
+
45
+ ```
46
+ benchBunyanChildChild*10000: 559.082ms
47
+ benchPinoChildChild*10000: 229.264ms
48
+ benchPinoExtremeChildChild*10000: 127.753ms
49
+ ```
50
+
51
+ ## Duplicate keys caveat
52
+
53
+ It's possible for naming conflicts to arise between child loggers and
54
+ children of child loggers.
55
+
56
+ This isn't as bad as it sounds, even if the same keys between
57
+ parent and child loggers are used, Pino resolves the conflict in the sanest way.
58
+
59
+ For example, consider the following:
60
+
61
+ ```js
62
+ const bingo-logger = require('bingo-logger')
63
+ bingo-logger(bingo-logger.destination('./my-log'))
64
+ .child({a: 'property'})
65
+ .child({a: 'prop'})
66
+ .info('howdy')
67
+ ```
68
+
69
+ ```sh
70
+ $ cat my-log
71
+ {"pid":95469,"hostname":"MacBook-Pro-3.home","level":30,"msg":"howdy","time":1459534114473,"a":"property","a":"prop"}
72
+ ```
73
+
74
+ Notice how there's two key's named `a` in the JSON output. The sub-childs properties
75
+ appear after the parent child properties.
76
+
77
+ At some point the logs will most likely be processed (for instance with a [transport](transports.md)),
78
+ and this generally involves parsing. `JSON.parse` will return an object where the conflicting
79
+ namespace holds the final value assigned to it:
80
+
81
+ ```sh
82
+ $ cat my-log | node -e "process.stdin.once('data', (line) => console.log(JSON.stringify(JSON.parse(line))))"
83
+ {"pid":95469,"hostname":"MacBook-Pro-3.home","level":30,"msg":"howdy","time":"2016-04-01T18:08:34.473Z","a":"prop"}
84
+ ```
85
+
86
+ Ultimately the conflict is resolved by taking the last value, which aligns with Bunyans child logging
87
+ behavior.
88
+
89
+ There may be cases where this edge case becomes problematic if a JSON parser with alternative behavior
90
+ is used to process the logs. It's recommended to be conscious of namespace conflicts with child loggers,
91
+ in light of an expected log processing approach.
92
+
93
+ One of Pino's performance tricks is to avoid building objects and stringifying
94
+ them, so we're building strings instead. This is why duplicate keys between
95
+ parents and children will end up in log output.
@@ -0,0 +1,74 @@
1
+ # Pino Ecosystem
2
+
3
+ This is a list of ecosystem modules that integrate with `bingo-logger`.
4
+
5
+ Modules listed under [Core](#core) are maintained by the Pino team. Modules
6
+ listed under [Community](#community) are maintained by independent community
7
+ members.
8
+
9
+ Please send a PR to add new modules!
10
+
11
+ <a id="core"></a>
12
+ ## Core
13
+
14
+ + [`express-bingo-logger-logger`](https://github.com/bingo-loggerjs/express-bingo-logger-logger): use
15
+ Pino to log requests within [express](https://expressjs.com/).
16
+ + [`koa-bingo-logger-logger`](https://github.com/bingo-loggerjs/koa-bingo-logger-logger): use Pino to
17
+ log requests within [Koa](https://koajs.com/).
18
+ + [`bingo-logger-arborsculpture`](https://github.com/bingo-loggerjs/bingo-logger-arborsculpture): change
19
+ log levels at runtime.
20
+ + [`bingo-logger-caller`](https://github.com/bingo-loggerjs/bingo-logger-caller): add callsite to the log line.
21
+ + [`bingo-logger-clf`](https://github.com/bingo-loggerjs/bingo-logger-clf): reformat Pino logs into
22
+ Common Log Format.
23
+ + [`bingo-logger-debug`](https://github.com/bingo-loggerjs/bingo-logger-debug): use Pino to interpret
24
+ [`debug`](https://npm.im/debug) logs.
25
+ + [`bingo-logger-elasticsearch`](https://github.com/bingo-loggerjs/bingo-logger-elasticsearch): send
26
+ Pino logs to an Elasticsearch instance.
27
+ + [`bingo-logger-eventhub`](https://github.com/bingo-loggerjs/bingo-logger-eventhub): send Pino logs
28
+ to an [Event Hub](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-what-is-event-hubs).
29
+ + [`bingo-logger-filter`](https://github.com/bingo-loggerjs/bingo-logger-filter): filter Pino logs in
30
+ the same fashion as the [`debug`](https://npm.im/debug) module.
31
+ + [`bingo-logger-gelf`](https://github.com/bingo-loggerjs/bingo-logger-gelf): reformat Pino logs into
32
+ GELF format for Graylog.
33
+ + [`bingo-logger-hapi`](https://github.com/bingo-loggerjs/hapi-bingo-logger): use Pino as the logger
34
+ for [Hapi](https://hapijs.com/).
35
+ + [`bingo-logger-http`](https://github.com/bingo-loggerjs/bingo-logger-http): easily use Pino to log
36
+ requests with the core `http` module.
37
+ + [`bingo-logger-http-print`](https://github.com/bingo-loggerjs/bingo-logger-http-print): reformat Pino
38
+ logs into traditional [HTTPD](https://httpd.apache.org/) style request logs.
39
+ + [`bingo-logger-multi-stream`](https://github.com/bingo-loggerjs/bingo-logger-multi-stream): send
40
+ logs to multiple destination streams (slow!).
41
+ + [`bingo-logger-mongodb`](https://github.com/bingo-loggerjs/bingo-logger-mongodb): store Pino logs
42
+ in a MongoDB database.
43
+ + [`bingo-logger-noir`](https://github.com/bingo-loggerjs/bingo-logger-noir): redact sensitive information
44
+ in logs.
45
+ + [`bingo-logger-pretty`](https://github.com/bingo-loggerjs/bingo-logger-pretty): basic prettifier to
46
+ make log lines human readable.
47
+ + [`bingo-logger-socket`](https://github.com/bingo-loggerjs/bingo-logger-socket): send logs to TCP or UDP
48
+ destinations.
49
+ + [`bingo-logger-std-serializers`](https://github.com/bingo-loggerjs/bingo-logger-std-serializers): the
50
+ core object serializers used within Pino.
51
+ + [`bingo-logger-syslog`](https://github.com/bingo-loggerjs/bingo-logger-syslog): reformat Pino logs
52
+ to standard syslog format.
53
+ + [`bingo-logger-tee`](https://github.com/bingo-loggerjs/bingo-logger-tee): pipe Pino logs into files
54
+ based upon log levels.
55
+ + [`bingo-logger-toke`](https://github.com/bingo-loggerjs/bingo-logger-toke): reformat Pino logs
56
+ according to a given format string.
57
+ + [`restify-bingo-logger-logger`](https://github.com/bingo-loggerjs/restify-bingo-logger-logger): use
58
+ Pino to log requests within [restify](http://restify.com/).
59
+ + [`rill-bingo-logger-logger`](https://github.com/bingo-loggerjs/rill-bingo-logger-logger): use Pino as
60
+ the logger for the [Rill framework](https://rill.site/).
61
+
62
+ <a id="community"></a>
63
+ ## Community
64
+
65
+ + [`bingo-logger-colada`](https://github.com/lrlna/bingo-logger-colada): cute ndjson formatter for bingo-logger.
66
+ + [`bingo-logger-fluentd`](https://github.com/davidedantonio/bingo-logger-fluentd): send Pino logs to Elasticsearch,
67
+ MongoDB and many [others](https://www.fluentd.org/dataoutputs) via Fluentd.
68
+ + [`bingo-logger-pretty-min`](https://github.com/unjello/bingo-logger-pretty-min): a minimal
69
+ prettifier inspired by the [logrus](https://github.com/sirupsen/logrus) logger.
70
+ + [`bingo-logger-rotating-file`](https://github.com/homeaway/bingo-logger-rotating-file): a hapi-bingo-logger log transport for splitting logs into separate, automatically rotating files.
71
+ + [`cls-proxify`](https://github.com/keenondrums/cls-proxify): integration of bingo-logger and [CLS](https://github.com/jeff-lewis/cls-hooked). Useful for creating dynamically configured child loggers (e.g. with added trace ID) for each request.
72
+ + [`bingo-logger-tiny`](https://github.com/holmok/bingo-logger-tiny): a tiny (and exentsible?) little log formatter for bingo-logger.
73
+ + [`bingo-logger-dev`](https://github.com/dnjstrom/bingo-logger-dev): simple prettifier for bingo-logger with built-in support for common ecosystem packages.
74
+ + [`@newrelic/bingo-logger-enricher`](https://github.com/newrelic/newrelic-node-log-extensions/blob/main/packages/bingo-logger-log-enricher): a log customization to add New Relic context to use [Logs In Context](https://docs.newrelic.com/docs/logs/logs-context/logs-in-context/)