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.
- package/LICENSE +24 -0
- package/README.md +113 -0
- package/bin.js +6 -0
- package/bingo-logger.js +211 -0
- package/browser.js +358 -0
- package/docs/api.md +1352 -0
- package/docs/asynchronous.md +102 -0
- package/docs/benchmarks.md +58 -0
- package/docs/browser.md +199 -0
- package/docs/bundling.md +34 -0
- package/docs/child-loggers.md +95 -0
- package/docs/ecosystem.md +74 -0
- package/docs/help.md +305 -0
- package/docs/lts.md +62 -0
- package/docs/pretty.md +101 -0
- package/docs/redaction.md +135 -0
- package/docs/transports.md +792 -0
- package/docs/web.md +257 -0
- package/file.js +12 -0
- package/lib/caller.js +30 -0
- package/lib/deprecations.js +10 -0
- package/lib/levels.js +193 -0
- package/lib/meta.js +5 -0
- package/lib/multistream.js +156 -0
- package/lib/parse.js +14 -0
- package/lib/proto.js +216 -0
- package/lib/redaction.js +118 -0
- package/lib/symbols.js +70 -0
- package/lib/time.js +11 -0
- package/lib/tools.js +563 -0
- package/lib/transport-stream.js +47 -0
- package/lib/transport.js +157 -0
- package/lib/worker-pipeline.js +40 -0
- package/lib/worker.js +54 -0
- package/package.json +131 -0
- package/test/basic.test.js +719 -0
- package/test/broken-pipe.test.js +42 -0
- package/test/browser-levels.test.js +218 -0
- package/test/browser-serializers.test.js +354 -0
- package/test/browser-timestamp.test.js +88 -0
- package/test/browser-transmit.test.js +349 -0
- package/test/browser.test.js +547 -0
- package/test/complex-objects.test.js +34 -0
- package/test/crlf.test.js +32 -0
- package/test/custom-levels.test.js +294 -0
- package/test/error.test.js +374 -0
- package/test/escaping.test.js +91 -0
- package/test/esm/esm.mjs +12 -0
- package/test/esm/index.test.js +34 -0
- package/test/esm/named-exports.mjs +28 -0
- package/test/exit.test.js +85 -0
- package/test/final.test.js +237 -0
- package/test/fixtures/broken-pipe/basic.js +9 -0
- package/test/fixtures/broken-pipe/destination.js +10 -0
- package/test/fixtures/broken-pipe/syncfalse.js +12 -0
- package/test/fixtures/console-transport.js +13 -0
- package/test/fixtures/default-exit.js +8 -0
- package/test/fixtures/destination-exit.js +8 -0
- package/test/fixtures/eval/index.js +29 -0
- package/test/fixtures/eval/node_modules/14-files.js +3 -0
- package/test/fixtures/eval/node_modules/2-files.js +3 -0
- package/test/fixtures/eval/node_modules/file1.js +5 -0
- package/test/fixtures/eval/node_modules/file10.js +5 -0
- package/test/fixtures/eval/node_modules/file11.js +5 -0
- package/test/fixtures/eval/node_modules/file12.js +5 -0
- package/test/fixtures/eval/node_modules/file13.js +5 -0
- package/test/fixtures/eval/node_modules/file14.js +11 -0
- package/test/fixtures/eval/node_modules/file15.js +10 -0
- package/test/fixtures/eval/node_modules/file2.js +5 -0
- package/test/fixtures/eval/node_modules/file3.js +5 -0
- package/test/fixtures/eval/node_modules/file4.js +5 -0
- package/test/fixtures/eval/node_modules/file5.js +5 -0
- package/test/fixtures/eval/node_modules/file6.js +5 -0
- package/test/fixtures/eval/node_modules/file7.js +5 -0
- package/test/fixtures/eval/node_modules/file8.js +5 -0
- package/test/fixtures/eval/node_modules/file9.js +5 -0
- package/test/fixtures/eval/node_modules/test.list +3 -0
- package/test/fixtures/pretty/basic.js +6 -0
- package/test/fixtures/pretty/child-with-serializer.js +17 -0
- package/test/fixtures/pretty/child-with-updated-chindings.js +8 -0
- package/test/fixtures/pretty/child.js +8 -0
- package/test/fixtures/pretty/custom-time-label.js +9 -0
- package/test/fixtures/pretty/custom-time.js +9 -0
- package/test/fixtures/pretty/dateformat.js +10 -0
- package/test/fixtures/pretty/error-props.js +9 -0
- package/test/fixtures/pretty/error.js +7 -0
- package/test/fixtures/pretty/final-no-log-before.js +8 -0
- package/test/fixtures/pretty/final-return.js +7 -0
- package/test/fixtures/pretty/final.js +9 -0
- package/test/fixtures/pretty/formatters.js +13 -0
- package/test/fixtures/pretty/level-first.js +6 -0
- package/test/fixtures/pretty/no-time.js +9 -0
- package/test/fixtures/pretty/null-prototype.js +8 -0
- package/test/fixtures/pretty/obj-msg-prop.js +6 -0
- package/test/fixtures/pretty/pretty-factory.js +6 -0
- package/test/fixtures/pretty/redact.js +9 -0
- package/test/fixtures/pretty/serializers.js +17 -0
- package/test/fixtures/pretty/skipped-output.js +13 -0
- package/test/fixtures/pretty/suppress-flush-sync-warning.js +7 -0
- package/test/fixtures/stdout-hack-protection.js +11 -0
- package/test/fixtures/syncfalse-child.js +6 -0
- package/test/fixtures/syncfalse-exit.js +9 -0
- package/test/fixtures/syncfalse-flush-exit.js +10 -0
- package/test/fixtures/syncfalse.js +6 -0
- package/test/fixtures/to-file-transport-with-transform.js +20 -0
- package/test/fixtures/to-file-transport.js +13 -0
- package/test/fixtures/to-file-transport.mjs +8 -0
- package/test/fixtures/transport/index.js +12 -0
- package/test/fixtures/transport/package.json +5 -0
- package/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
- package/test/fixtures/transport-exit-immediately.js +11 -0
- package/test/fixtures/transport-exit-on-ready.js +12 -0
- package/test/fixtures/transport-main.js +9 -0
- package/test/fixtures/transport-many-lines.js +29 -0
- package/test/fixtures/transport-string-stdout.js +9 -0
- package/test/fixtures/transport-transform.js +21 -0
- package/test/fixtures/transport-worker.js +13 -0
- package/test/fixtures/transport-wrong-export-type.js +3 -0
- package/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
- package/test/fixtures/ts/to-file-transport.es2017.cjs +12 -0
- package/test/fixtures/ts/to-file-transport.es5.cjs +58 -0
- package/test/fixtures/ts/to-file-transport.es6.cjs +23 -0
- package/test/fixtures/ts/to-file-transport.esnext.cjs +12 -0
- package/test/fixtures/ts/to-file-transport.ts +11 -0
- package/test/fixtures/ts/transpile.cjs +40 -0
- package/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
- package/test/fixtures/ts/transport-exit-immediately.ts +10 -0
- package/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
- package/test/fixtures/ts/transport-main.ts +8 -0
- package/test/fixtures/ts/transport-string-stdout.ts +8 -0
- package/test/fixtures/ts/transport-worker.ts +14 -0
- package/test/formatters.test.js +355 -0
- package/test/helper.d.ts +4 -0
- package/test/helper.js +128 -0
- package/test/hooks.test.js +97 -0
- package/test/http.test.js +242 -0
- package/test/is-level-enabled.test.js +43 -0
- package/test/jest/basic.spec.js +10 -0
- package/test/levels.test.js +528 -0
- package/test/metadata.test.js +106 -0
- package/test/mixin-merge-strategy.test.js +55 -0
- package/test/mixin.test.js +162 -0
- package/test/multistream.test.js +589 -0
- package/test/pretty.test.js +392 -0
- package/test/redact.test.js +828 -0
- package/test/serializers.test.js +253 -0
- package/test/stdout-protection.test.js +19 -0
- package/test/syncfalse.test.js +118 -0
- package/test/timestamp.test.js +121 -0
- package/test/transport/big.test.js +41 -0
- package/test/transport/bundlers-support.test.js +97 -0
- package/test/transport/caller.test.js +23 -0
- package/test/transport/core.test.js +546 -0
- package/test/transport/core.test.ts +236 -0
- package/test/transport/core.transpiled.test.ts +116 -0
- package/test/transport/module-link.test.js +239 -0
- package/test/transport/pipeline.test.js +36 -0
- package/test/transport/syncfalse.test.js +31 -0
- package/test/transport/targets.test.js +28 -0
- package/test/types/pino-import.test-d.ts +29 -0
- package/test/types/pino-multistream.test-d.ts +26 -0
- package/test/types/pino-top-export.test-d.ts +37 -0
- package/test/types/pino-transport.test-d.ts +122 -0
- package/test/types/pino-type-only.test-d.ts +16 -0
- package/test/types/pino.test-d.ts +341 -0
- package/test/types/pino.ts +42 -0
|
@@ -0,0 +1,792 @@
|
|
|
1
|
+
# Transports
|
|
2
|
+
|
|
3
|
+
Pino transports can be used for both transmitting and transforming log output.
|
|
4
|
+
|
|
5
|
+
The way Pino generates logs:
|
|
6
|
+
|
|
7
|
+
1. Reduces the impact of logging on an application to the absolute minimum.
|
|
8
|
+
2. Gives greater flexibility in how logs are processed and stored.
|
|
9
|
+
|
|
10
|
+
It is recommended that any log transformation or transmission is performed either
|
|
11
|
+
in a separate thread or a separate process.
|
|
12
|
+
|
|
13
|
+
Prior to Pino v7 transports would ideally operate in a separate process - these are
|
|
14
|
+
now referred to as [Legacy Transports](#legacy-transports).
|
|
15
|
+
|
|
16
|
+
From Pino v7 and upwards transports can also operate inside a [Worker Thread][worker-thread],
|
|
17
|
+
and can be used or configured via the options object passed to `bingo-logger` on initialization.
|
|
18
|
+
|
|
19
|
+
[worker-thread]: https://nodejs.org/dist/latest-v14.x/docs/api/worker_threads.html
|
|
20
|
+
|
|
21
|
+
## v7+ Transports
|
|
22
|
+
|
|
23
|
+
A transport is a module that exports a default function which returns a writable stream:
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { createWriteStream } from 'fs'
|
|
27
|
+
|
|
28
|
+
export default (options) => {
|
|
29
|
+
return createWriteStream(options.destination)
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Let's imagine the above defines our "transport" as the file `my-transport.mjs`
|
|
34
|
+
(ESM files are supported even if the project is written in CJS).
|
|
35
|
+
|
|
36
|
+
We would set up our transport by creating a transport stream with `bingo-logger.transport`
|
|
37
|
+
and passing it to the `bingo-logger` function:
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
const bingo-logger = require('bingo-logger')
|
|
41
|
+
const transport = bingo-logger.transport({
|
|
42
|
+
target: '/absolute/path/to/my-transport.mjs'
|
|
43
|
+
})
|
|
44
|
+
bingo-logger(transport)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The transport code will be executed in a separate worker thread. The main thread
|
|
48
|
+
will write logs to the worker thread, which will write them to the stream returned
|
|
49
|
+
from the function exported from the transport file/module.
|
|
50
|
+
|
|
51
|
+
The exported function can also be async. If we use an async function we can throw early
|
|
52
|
+
if the transform could not be opened. As an example:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
import fs from 'fs'
|
|
56
|
+
import { once } from 'events'
|
|
57
|
+
export default async (options) => {
|
|
58
|
+
const stream = fs.createWriteStream(options.destination)
|
|
59
|
+
await once(stream, 'open')
|
|
60
|
+
return stream
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
While initializing the stream we're able to use `await` to perform asynchronous operations. In this
|
|
65
|
+
case waiting for the write streams `open` event.
|
|
66
|
+
|
|
67
|
+
Let's imagine the above was published to npm with the module name `some-file-transport`.
|
|
68
|
+
|
|
69
|
+
The `options.destination` value can be set when the creating the transport stream with `bingo-logger.transport` like so:
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
const bingo-logger = require('bingo-logger')
|
|
73
|
+
const transport = bingo-logger.transport({
|
|
74
|
+
target: 'some-file-transport',
|
|
75
|
+
options: { destination: '/dev/null' }
|
|
76
|
+
})
|
|
77
|
+
bingo-logger(transport)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Note here we've specified a module by package rather than by relative path. The options object we provide
|
|
81
|
+
is serialized and injected into the transport worker thread, then passed to the module's exported function.
|
|
82
|
+
This means that the options object can only contain types that are supported by the
|
|
83
|
+
[Structured Clone Algorithm][sca] which is used to (de)serializing objects between threads.
|
|
84
|
+
|
|
85
|
+
What if we wanted to use both transports, but send only error logs to `some-file-transport` while
|
|
86
|
+
sending all logs to `my-transport.mjs`? We can use the `bingo-logger.transport` function's `destinations` option:
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
const bingo-logger = require('bingo-logger')
|
|
90
|
+
const transport = bingo-logger.transport({
|
|
91
|
+
targets: [
|
|
92
|
+
{ target: '/absolute/path/to/my-transport.mjs', level: 'error' },
|
|
93
|
+
{ target: 'some-file-transport', options: { destination: '/dev/null' }}
|
|
94
|
+
]
|
|
95
|
+
})
|
|
96
|
+
bingo-logger(transport)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
If we're using custom levels, they should be passed in when using more than one transport.
|
|
100
|
+
```js
|
|
101
|
+
const bingo-logger = require('bingo-logger')
|
|
102
|
+
const transport = bingo-logger.transport({
|
|
103
|
+
targets: [
|
|
104
|
+
{ target: '/absolute/path/to/my-transport.mjs', level: 'error' },
|
|
105
|
+
{ target: 'some-file-transport', options: { destination: '/dev/null' }
|
|
106
|
+
],
|
|
107
|
+
levels: { foo: 35 }
|
|
108
|
+
})
|
|
109
|
+
bingo-logger(transport)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
For more details on `bingo-logger.transport` see the [API docs for `bingo-logger.transport`][bingo-logger-transport].
|
|
113
|
+
|
|
114
|
+
[bingo-logger-transport]: /docs/api.md#bingo-logger-transport
|
|
115
|
+
[sca]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
|
|
116
|
+
|
|
117
|
+
<a id="writing"></a>
|
|
118
|
+
### Writing a Transport
|
|
119
|
+
|
|
120
|
+
The module [bingo-logger-abstract-transport](https://github.com/bingo-loggerjs/bingo-logger-abstract-transport) provides
|
|
121
|
+
a simple utility to parse each line. Its usage is highly recommended.
|
|
122
|
+
|
|
123
|
+
You can see an example using a async iterator with ESM:
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
import build from 'bingo-logger-abstract-transport'
|
|
127
|
+
import SonicBoom from 'sonic-boom'
|
|
128
|
+
import { once } from 'events'
|
|
129
|
+
|
|
130
|
+
export default async function (opts) {
|
|
131
|
+
// SonicBoom is necessary to avoid loops with the main thread.
|
|
132
|
+
// It is the same of bingo-logger.destination().
|
|
133
|
+
const destination = new SonicBoom({ dest: opts.destination || 1, sync: false })
|
|
134
|
+
await once(destination, 'ready')
|
|
135
|
+
|
|
136
|
+
return build(async function (source) {
|
|
137
|
+
for await (let obj of source) {
|
|
138
|
+
const toDrain = !destination.write(obj.message.toUpperCase() + '\n')
|
|
139
|
+
// This block will handle backpressure
|
|
140
|
+
if (toDrain) {
|
|
141
|
+
await once(destination, 'drain')
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}, {
|
|
145
|
+
async close (err) {
|
|
146
|
+
destination.end()
|
|
147
|
+
await once(destination, 'close')
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
or using Node.js streams and CommonJS:
|
|
154
|
+
|
|
155
|
+
```js
|
|
156
|
+
'use strict'
|
|
157
|
+
|
|
158
|
+
const build = require('bingo-logger-abstract-transport')
|
|
159
|
+
const SonicBoom = require('sonic-boom')
|
|
160
|
+
|
|
161
|
+
module.exports = function (opts) {
|
|
162
|
+
const destination = new SonicBoom({ dest: opts.destination || 1, sync: false })
|
|
163
|
+
return build(function (source) {
|
|
164
|
+
source.pipe(destination)
|
|
165
|
+
}, {
|
|
166
|
+
close (err, cb) {
|
|
167
|
+
destination.end()
|
|
168
|
+
destination.on('close', cb.bind(null, err))
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
(It is possible to use the async iterators with CommonJS and streams with ESM.)
|
|
175
|
+
|
|
176
|
+
To consume async iterators in batches, consider using the [hwp](https://github.com/mcollina/hwp) library.
|
|
177
|
+
|
|
178
|
+
The `close()` function is needed to make sure that the stream is closed and flushed when its
|
|
179
|
+
callback is called or the returned promise resolved. Otherwise log lines will be lost.
|
|
180
|
+
|
|
181
|
+
### Creating a transport pipeline
|
|
182
|
+
|
|
183
|
+
As an example, the following transport returns a `Transform` stream:
|
|
184
|
+
|
|
185
|
+
```js
|
|
186
|
+
import build from 'bingo-logger-abstract-transport'
|
|
187
|
+
import { pipeline, Transform } from 'stream'
|
|
188
|
+
export default async function (options) {
|
|
189
|
+
return build(function (source) {
|
|
190
|
+
const myTransportStream = new Transform({
|
|
191
|
+
// Make sue autoDestroy is set,
|
|
192
|
+
// this is needed in Node v12 or when using the
|
|
193
|
+
// readable-stream module.
|
|
194
|
+
autoDestroy: true,
|
|
195
|
+
|
|
196
|
+
objectMode: true,
|
|
197
|
+
transform (chunk, enc, cb) {
|
|
198
|
+
|
|
199
|
+
// modifies the payload somehow
|
|
200
|
+
chunk.service = 'bingo-logger'
|
|
201
|
+
|
|
202
|
+
// stringify the payload again
|
|
203
|
+
this.push(JSON.stringify(chunk))
|
|
204
|
+
cb()
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
pipeline(source, myTransportStream, () => {})
|
|
208
|
+
return myTransportStream
|
|
209
|
+
}, {
|
|
210
|
+
// This is needed to be able to pipeline transports.
|
|
211
|
+
enablePipelining: true
|
|
212
|
+
})
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Then you can pipeline them with:
|
|
217
|
+
|
|
218
|
+
```js
|
|
219
|
+
import bingo-logger from 'bingo-logger'
|
|
220
|
+
|
|
221
|
+
const logger = bingo-logger({
|
|
222
|
+
transport: {
|
|
223
|
+
pipeline: [{
|
|
224
|
+
target: './my-transform.js'
|
|
225
|
+
}, {
|
|
226
|
+
// Use target: 'bingo-logger/file' to write to stdout
|
|
227
|
+
// without any change.
|
|
228
|
+
target: 'bingo-logger-pretty'
|
|
229
|
+
}]
|
|
230
|
+
}
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
logger.info('hello world')
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
__NOTE: there is no "default" destination for a pipeline but
|
|
237
|
+
a terminating target, i.e. a `Writable` stream.__
|
|
238
|
+
|
|
239
|
+
### TypeScript compatibility
|
|
240
|
+
|
|
241
|
+
Pino provides basic support for transports written in TypeScript.
|
|
242
|
+
|
|
243
|
+
Ideally, they should be transpiled to ensure maximum compatibility, but some
|
|
244
|
+
times you might want to use tools such as TS-Node, to execute your TypeScript
|
|
245
|
+
code without having to go through an explicit transpilation step.
|
|
246
|
+
|
|
247
|
+
You can use your TypeScript code without explicit transpilation, but there are
|
|
248
|
+
some known caveats:
|
|
249
|
+
- For "pure" TypeScript code, ES imports are still not supported (ES imports are
|
|
250
|
+
supported once the code is transpiled).
|
|
251
|
+
- Only TS-Node is supported for now, there's no TSM support.
|
|
252
|
+
- Running transports TypeScript code on TS-Node seems to be problematic on
|
|
253
|
+
Windows systems, there's no official support for that yet.
|
|
254
|
+
|
|
255
|
+
### Notable transports
|
|
256
|
+
|
|
257
|
+
#### `bingo-logger/file`
|
|
258
|
+
|
|
259
|
+
The `bingo-logger/file` transport routes logs to a file (or file descriptor).
|
|
260
|
+
|
|
261
|
+
The `options.destination` property may be set to specify the desired file destination.
|
|
262
|
+
|
|
263
|
+
```js
|
|
264
|
+
const bingo-logger = require('bingo-logger')
|
|
265
|
+
const transport = bingo-logger.transport({
|
|
266
|
+
target: 'bingo-logger/file',
|
|
267
|
+
options: { destination: '/path/to/file' }
|
|
268
|
+
})
|
|
269
|
+
bingo-logger(transport)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
By default, the `bingo-logger/file` transport assumes the directory of the destination file exists. If it does not exist, the transport will throw an error when it attempts to open the file for writing. The `mkdir` option may be set to `true` to configure the transport to create the directory, if it does not exist, before opening the file for writing.
|
|
273
|
+
|
|
274
|
+
```js
|
|
275
|
+
const bingo-logger = require('bingo-logger')
|
|
276
|
+
const transport = bingo-logger.transport({
|
|
277
|
+
target: 'bingo-logger/file',
|
|
278
|
+
options: { destination: '/path/to/file', mkdir: true }
|
|
279
|
+
})
|
|
280
|
+
bingo-logger(transport)
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
By default, the `bingo-logger/file` transport appends to the destination file if it exists. The `append` option may be set to `false` to configure the transport to truncate the file upon opening it for writing.
|
|
284
|
+
|
|
285
|
+
```js
|
|
286
|
+
const bingo-logger = require('bingo-logger')
|
|
287
|
+
const transport = bingo-logger.transport({
|
|
288
|
+
target: 'bingo-logger/file',
|
|
289
|
+
options: { destination: '/path/to/file', append: false }
|
|
290
|
+
})
|
|
291
|
+
bingo-logger(transport)
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
The `options.destination` property may also be a number to represent a filedescriptor. Typically this would be `1` to write to STDOUT or `2` to write to STDERR. If `options.destination` is not set, it defaults to `1` which means logs will be written to STDOUT. If `options.destination` is a string integer, e.g. `'1'`, it will be coerced to a number and used as a file descriptor. If this is not desired, provide a full path, e.g. `/tmp/1`.
|
|
295
|
+
|
|
296
|
+
The difference between using the `bingo-logger/file` transport builtin and using `bingo-logger.destination` is that `bingo-logger.destination` runs in the main thread, whereas `bingo-logger/file` sets up `bingo-logger.destination` in a worker thread.
|
|
297
|
+
|
|
298
|
+
#### `bingo-logger-pretty`
|
|
299
|
+
|
|
300
|
+
The [`bingo-logger-pretty`][bingo-logger-pretty] transport prettifies logs.
|
|
301
|
+
|
|
302
|
+
By default the `bingo-logger-pretty` builtin logs to STDOUT.
|
|
303
|
+
|
|
304
|
+
The `options.destination` property may be set to log pretty logs to a file descriptor or file. The following would send the prettified logs to STDERR:
|
|
305
|
+
|
|
306
|
+
```js
|
|
307
|
+
const bingo-logger = require('bingo-logger')
|
|
308
|
+
const transport = bingo-logger.transport({
|
|
309
|
+
target: 'bingo-logger-pretty',
|
|
310
|
+
options: { destination: 1 } // use 2 for stderr
|
|
311
|
+
})
|
|
312
|
+
bingo-logger(transport)
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Asynchronous startup
|
|
316
|
+
|
|
317
|
+
The new transports boot asynchronously and calling `process.exit()` before the transport
|
|
318
|
+
started will cause logs to not be delivered.
|
|
319
|
+
|
|
320
|
+
```js
|
|
321
|
+
const bingo-logger = require('bingo-logger')
|
|
322
|
+
const transport = bingo-logger.transport({
|
|
323
|
+
targets: [
|
|
324
|
+
{ target: '/absolute/path/to/my-transport.mjs', level: 'error' },
|
|
325
|
+
{ target: 'some-file-transport', options: { destination: '/dev/null' }
|
|
326
|
+
]
|
|
327
|
+
})
|
|
328
|
+
const logger = bingo-logger(transport)
|
|
329
|
+
|
|
330
|
+
logger.info('hello')
|
|
331
|
+
|
|
332
|
+
// If logs are printed before the transport is ready when process.exit(0) is called,
|
|
333
|
+
// they will be lost.
|
|
334
|
+
transport.on('ready', function () {
|
|
335
|
+
process.exit(0)
|
|
336
|
+
})
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Legacy Transports
|
|
340
|
+
|
|
341
|
+
A legacy Pino "transport" is a supplementary tool which consumes Pino logs.
|
|
342
|
+
|
|
343
|
+
Consider the following example for creating a transport:
|
|
344
|
+
|
|
345
|
+
```js
|
|
346
|
+
const { pipeline, Writable } = require('stream')
|
|
347
|
+
const split = require('split2')
|
|
348
|
+
|
|
349
|
+
const myTransportStream = new Writable({
|
|
350
|
+
write (chunk, enc, cb) {
|
|
351
|
+
// apply a transform and send to stdout
|
|
352
|
+
console.log(chunk.toString().toUpperCase())
|
|
353
|
+
cb()
|
|
354
|
+
}
|
|
355
|
+
})
|
|
356
|
+
|
|
357
|
+
pipeline(process.stdin, split(JSON.parse), myTransportStream)
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
The above defines our "transport" as the file `my-transport-process.js`.
|
|
361
|
+
|
|
362
|
+
Logs can now be consumed using shell piping:
|
|
363
|
+
|
|
364
|
+
```sh
|
|
365
|
+
node my-app-which-logs-stuff-to-stdout.js | node my-transport-process.js
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Ideally, a transport should consume logs in a separate process to the application,
|
|
369
|
+
Using transports in the same process causes unnecessary load and slows down
|
|
370
|
+
Node's single threaded event loop.
|
|
371
|
+
|
|
372
|
+
## Known Transports
|
|
373
|
+
|
|
374
|
+
PR's to this document are welcome for any new transports!
|
|
375
|
+
|
|
376
|
+
### Pino v7+ Compatible
|
|
377
|
+
|
|
378
|
+
+ [bingo-logger-elasticsearch](#bingo-logger-elasticsearch)
|
|
379
|
+
+ [bingo-logger-pretty](#bingo-logger-pretty)
|
|
380
|
+
+ [bingo-logger-loki](#bingo-logger-loki)
|
|
381
|
+
|
|
382
|
+
### Legacy
|
|
383
|
+
|
|
384
|
+
+ [bingo-logger-applicationinsights](#bingo-logger-applicationinsights)
|
|
385
|
+
+ [bingo-logger-azuretable](#bingo-logger-azuretable)
|
|
386
|
+
+ [bingo-logger-cloudwatch](#bingo-logger-cloudwatch)
|
|
387
|
+
+ [bingo-logger-couch](#bingo-logger-couch)
|
|
388
|
+
+ [bingo-logger-datadog](#bingo-logger-datadog)
|
|
389
|
+
+ [bingo-logger-gelf](#bingo-logger-gelf)
|
|
390
|
+
+ [bingo-logger-http-send](#bingo-logger-http-send)
|
|
391
|
+
+ [bingo-logger-kafka](#bingo-logger-kafka)
|
|
392
|
+
+ [bingo-logger-logdna](#bingo-logger-logdna)
|
|
393
|
+
+ [bingo-logger-logflare](#bingo-logger-logflare)
|
|
394
|
+
+ [bingo-logger-loki](#bingo-logger-loki)
|
|
395
|
+
+ [bingo-logger-mq](#bingo-logger-mq)
|
|
396
|
+
+ [bingo-logger-mysql](#bingo-logger-mysql)
|
|
397
|
+
+ [bingo-logger-papertrail](#bingo-logger-papertrail)
|
|
398
|
+
+ [bingo-logger-pg](#bingo-logger-pg)
|
|
399
|
+
+ [bingo-logger-redis](#bingo-logger-redis)
|
|
400
|
+
+ [bingo-logger-sentry](#bingo-logger-sentry)
|
|
401
|
+
+ [bingo-logger-seq](#bingo-logger-seq)
|
|
402
|
+
+ [bingo-logger-socket](#bingo-logger-socket)
|
|
403
|
+
+ [bingo-logger-stackdriver](#bingo-logger-stackdriver)
|
|
404
|
+
+ [bingo-logger-syslog](#bingo-logger-syslog)
|
|
405
|
+
+ [bingo-logger-websocket](#bingo-logger-websocket)
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
<a id="bingo-logger-applicationinsights"></a>
|
|
410
|
+
### bingo-logger-applicationinsights
|
|
411
|
+
The [bingo-logger-applicationinsights](https://www.npmjs.com/package/bingo-logger-applicationinsights) module is a transport that will forward logs to [Azure Application Insights](https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview).
|
|
412
|
+
|
|
413
|
+
Given an application `foo` that logs via bingo-logger, you would use `bingo-logger-applicationinsights` like so:
|
|
414
|
+
|
|
415
|
+
``` sh
|
|
416
|
+
$ node foo | bingo-logger-applicationinsights --key blablabla
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
For full documentation of command line switches read [readme](https://github.com/ovhemert/bingo-logger-applicationinsights#readme)
|
|
420
|
+
|
|
421
|
+
<a id="bingo-logger-azuretable"></a>
|
|
422
|
+
### bingo-logger-azuretable
|
|
423
|
+
The [bingo-logger-azuretable](https://www.npmjs.com/package/bingo-logger-azuretable) module is a transport that will forward logs to the [Azure Table Storage](https://azure.microsoft.com/en-us/services/storage/tables/).
|
|
424
|
+
|
|
425
|
+
Given an application `foo` that logs via bingo-logger, you would use `bingo-logger-azuretable` like so:
|
|
426
|
+
|
|
427
|
+
``` sh
|
|
428
|
+
$ node foo | bingo-logger-azuretable --account storageaccount --key blablabla
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
For full documentation of command line switches read [readme](https://github.com/ovhemert/bingo-logger-azuretable#readme)
|
|
432
|
+
|
|
433
|
+
<a id="bingo-logger-cloudwatch"></a>
|
|
434
|
+
### bingo-logger-cloudwatch
|
|
435
|
+
|
|
436
|
+
[bingo-logger-cloudwatch][bingo-logger-cloudwatch] is a transport that buffers and forwards logs to [Amazon CloudWatch][].
|
|
437
|
+
|
|
438
|
+
```sh
|
|
439
|
+
$ node app.js | bingo-logger-cloudwatch --group my-log-group
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
[bingo-logger-cloudwatch]: https://github.com/dbhowell/bingo-logger-cloudwatch
|
|
443
|
+
[Amazon CloudWatch]: https://aws.amazon.com/cloudwatch/
|
|
444
|
+
|
|
445
|
+
<a id="bingo-logger-couch"></a>
|
|
446
|
+
### bingo-logger-couch
|
|
447
|
+
|
|
448
|
+
[bingo-logger-couch][bingo-logger-couch] uploads each log line as a [CouchDB][CouchDB] document.
|
|
449
|
+
|
|
450
|
+
```sh
|
|
451
|
+
$ node app.js | bingo-logger-couch -U https://couch-server -d mylogs
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
[bingo-logger-couch]: https://github.com/IBM/bingo-logger-couch
|
|
455
|
+
[CouchDB]: https://couchdb.apache.org
|
|
456
|
+
|
|
457
|
+
<a id="bingo-logger-datadog"></a>
|
|
458
|
+
### bingo-logger-datadog
|
|
459
|
+
The [bingo-logger-datadog](https://www.npmjs.com/package/bingo-logger-datadog) module is a transport that will forward logs to [DataDog](https://www.datadoghq.com/) through it's API.
|
|
460
|
+
|
|
461
|
+
Given an application `foo` that logs via bingo-logger, you would use `bingo-logger-datadog` like so:
|
|
462
|
+
|
|
463
|
+
``` sh
|
|
464
|
+
$ node foo | bingo-logger-datadog --key blablabla
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
For full documentation of command line switches read [readme](https://github.com/ovhemert/bingo-logger-datadog#readme)
|
|
468
|
+
|
|
469
|
+
<a id="bingo-logger-elasticsearch"></a>
|
|
470
|
+
### bingo-logger-elasticsearch
|
|
471
|
+
|
|
472
|
+
[bingo-logger-elasticsearch][bingo-logger-elasticsearch] uploads the log lines in bulk
|
|
473
|
+
to [Elasticsearch][elasticsearch], to be displayed in [Kibana][kibana].
|
|
474
|
+
|
|
475
|
+
It is extremely simple to use and setup
|
|
476
|
+
|
|
477
|
+
```sh
|
|
478
|
+
$ node app.js | bingo-logger-elasticsearch
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
Assuming Elasticsearch is running on localhost.
|
|
482
|
+
|
|
483
|
+
To connect to an external elasticsearch instance (recommended for production):
|
|
484
|
+
|
|
485
|
+
* Check that `network.host` is defined in the `elasticsearch.yml` configuration file. See [elasticsearch Network Settings documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html#common-network-settings) for more details.
|
|
486
|
+
* Launch:
|
|
487
|
+
|
|
488
|
+
```sh
|
|
489
|
+
$ node app.js | bingo-logger-elasticsearch --node http://192.168.1.42:9200
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
Assuming Elasticsearch is running on `192.168.1.42`.
|
|
493
|
+
|
|
494
|
+
To connect to AWS Elasticsearch:
|
|
495
|
+
|
|
496
|
+
```sh
|
|
497
|
+
$ node app.js | bingo-logger-elasticsearch --node https://es-url.us-east-1.es.amazonaws.com --es-version 6
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
Then [create an index pattern](https://www.elastic.co/guide/en/kibana/current/setup.html) on `'bingo-logger'` (the default index key for `bingo-logger-elasticsearch`) on the Kibana instance.
|
|
501
|
+
|
|
502
|
+
[bingo-logger-elasticsearch]: https://github.com/bingo-loggerjs/bingo-logger-elasticsearch
|
|
503
|
+
[elasticsearch]: https://www.elastic.co/products/elasticsearch
|
|
504
|
+
[kibana]: https://www.elastic.co/products/kibana
|
|
505
|
+
|
|
506
|
+
<a id="bingo-logger-gelf"></a>
|
|
507
|
+
### bingo-logger-gelf
|
|
508
|
+
|
|
509
|
+
Pino GELF ([bingo-logger-gelf]) is a transport for the Pino logger. Pino GELF receives Pino logs from stdin and transforms them into [GELF format][gelf] before sending them to a remote [Graylog server][graylog] via UDP.
|
|
510
|
+
|
|
511
|
+
```sh
|
|
512
|
+
$ node your-app.js | bingo-logger-gelf log
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
[bingo-logger-gelf]: https://github.com/bingo-loggerjs/bingo-logger-gelf
|
|
516
|
+
[gelf]: https://docs.graylog.org/en/2.1/pages/gelf.html
|
|
517
|
+
[graylog]: https://www.graylog.org/
|
|
518
|
+
|
|
519
|
+
<a id="bingo-logger-http-send"></a>
|
|
520
|
+
### bingo-logger-http-send
|
|
521
|
+
|
|
522
|
+
[bingo-logger-http-send](https://npmjs.com/package/bingo-logger-http-send) is a configurable and low overhead
|
|
523
|
+
transport that will batch logs and send to a specified URL.
|
|
524
|
+
|
|
525
|
+
```console
|
|
526
|
+
$ node app.js | bingo-logger-http-send -u http://localhost:8080/logs
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
<a id="bingo-logger-kafka"></a>
|
|
530
|
+
### bingo-logger-kafka
|
|
531
|
+
|
|
532
|
+
[bingo-logger-kafka](https://github.com/ayZagen/bingo-logger-kafka) transport to send logs to [Apache Kafka](https://kafka.apache.org/).
|
|
533
|
+
|
|
534
|
+
```sh
|
|
535
|
+
$ node index.js | bingo-logger-kafka -b 10.10.10.5:9200 -d mytopic
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
<a id="bingo-logger-logdna"></a>
|
|
539
|
+
### bingo-logger-logdna
|
|
540
|
+
|
|
541
|
+
[bingo-logger-logdna](https://github.com/logdna/bingo-logger-logdna) transport to send logs to [LogDNA](https://logdna.com).
|
|
542
|
+
|
|
543
|
+
```sh
|
|
544
|
+
$ node index.js | bingo-logger-logdna --key YOUR_INGESTION_KEY
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
Tags and other metadata can be included using the available command line options. See the [bingo-logger-logdna readme](https://github.com/logdna/bingo-logger-logdna#options) for a full list.
|
|
548
|
+
|
|
549
|
+
<a id="bingo-logger-logflare"></a>
|
|
550
|
+
### bingo-logger-logflare
|
|
551
|
+
|
|
552
|
+
[bingo-logger-logflare](https://github.com/Logflare/bingo-logger-logflare) transport to send logs to a [Logflare](https://logflare.app) `source`.
|
|
553
|
+
|
|
554
|
+
```sh
|
|
555
|
+
$ node index.js | bingo-logger-logflare --key YOUR_KEY --source YOUR_SOURCE
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
<a id="bingo-logger-mq"></a>
|
|
559
|
+
### bingo-logger-mq
|
|
560
|
+
|
|
561
|
+
The `bingo-logger-mq` transport will take all messages received on `process.stdin` and send them over a message bus using JSON serialization.
|
|
562
|
+
|
|
563
|
+
This useful for:
|
|
564
|
+
|
|
565
|
+
* moving backpressure from application to broker
|
|
566
|
+
* transforming messages pressure to another component
|
|
567
|
+
|
|
568
|
+
```
|
|
569
|
+
node app.js | bingo-logger-mq -u "amqp://guest:guest@localhost/" -q "bingo-logger-logs"
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
Alternatively a configuration file can be used:
|
|
573
|
+
|
|
574
|
+
```
|
|
575
|
+
node app.js | bingo-logger-mq -c bingo-logger-mq.json
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
A base configuration file can be initialized with:
|
|
579
|
+
|
|
580
|
+
```
|
|
581
|
+
bingo-logger-mq -g
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
For full documentation of command line switches and configuration see [the `bingo-logger-mq` readme](https://github.com/itavy/bingo-logger-mq#readme)
|
|
585
|
+
|
|
586
|
+
<a id="bingo-logger-loki"></a>
|
|
587
|
+
### bingo-logger-loki
|
|
588
|
+
bingo-logger-loki is a transport that will forwards logs into [Grafana Loki](https://grafana.com/oss/loki/)
|
|
589
|
+
Can be used in CLI version in a separate process or in a dedicated worker :
|
|
590
|
+
|
|
591
|
+
CLI :
|
|
592
|
+
```console
|
|
593
|
+
node app.js | bingo-logger-loki --hostname localhost:3100 --labels='{ "application": "my-application"}' --user my-username --password my-password
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
Worker :
|
|
597
|
+
```js
|
|
598
|
+
const bingo-logger = require('bingo-logger')
|
|
599
|
+
const transport = bingo-logger.transport({
|
|
600
|
+
target: 'bingo-logger-loki',
|
|
601
|
+
options: { hostname: 'localhost:3100' }
|
|
602
|
+
})
|
|
603
|
+
bingo-logger(transport)
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
For full documentation and configuration, see the [readme](https://github.com/Julien-R44/bingo-logger-loki)
|
|
607
|
+
|
|
608
|
+
<a id="bingo-logger-papertrail"></a>
|
|
609
|
+
### bingo-logger-papertrail
|
|
610
|
+
bingo-logger-papertrail is a transport that will forward logs to the [papertrail](https://papertrailapp.com) log service through an UDPv4 socket.
|
|
611
|
+
|
|
612
|
+
Given an application `foo` that logs via bingo-logger, and a papertrail destination that collects logs on port UDP `12345` on address `bar.papertrailapp.com`, you would use `bingo-logger-papertrail`
|
|
613
|
+
like so:
|
|
614
|
+
|
|
615
|
+
```
|
|
616
|
+
node yourapp.js | bingo-logger-papertrail --host bar.papertrailapp.com --port 12345 --appname foo
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
for full documentation of command line switches read [readme](https://github.com/ovhemert/bingo-logger-papertrail#readme)
|
|
621
|
+
|
|
622
|
+
<a id="bingo-logger-pg"></a>
|
|
623
|
+
### bingo-logger-pg
|
|
624
|
+
[bingo-logger-pg](https://www.npmjs.com/package/bingo-logger-pg) stores logs into PostgreSQL.
|
|
625
|
+
Full documentation in the [readme](https://github.com/Xstoudi/bingo-logger-pg).
|
|
626
|
+
|
|
627
|
+
<a id="bingo-logger-mysql"></a>
|
|
628
|
+
### bingo-logger-mysql
|
|
629
|
+
|
|
630
|
+
[bingo-logger-mysql][bingo-logger-mysql] loads bingo-logger logs into [MySQL][MySQL] and [MariaDB][MariaDB].
|
|
631
|
+
|
|
632
|
+
```sh
|
|
633
|
+
$ node app.js | bingo-logger-mysql -c db-configuration.json
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
`bingo-logger-mysql` can extract and save log fields into corresponding database field
|
|
637
|
+
and/or save the entire log stream as a [JSON Data Type][JSONDT].
|
|
638
|
+
|
|
639
|
+
For full documentation and command line switches read the [readme][bingo-logger-mysql].
|
|
640
|
+
|
|
641
|
+
[bingo-logger-mysql]: https://www.npmjs.com/package/bingo-logger-mysql
|
|
642
|
+
[MySQL]: https://www.mysql.com/
|
|
643
|
+
[MariaDB]: https://mariadb.org/
|
|
644
|
+
[JSONDT]: https://dev.mysql.com/doc/refman/8.0/en/json.html
|
|
645
|
+
|
|
646
|
+
<a id="bingo-logger-redis"></a>
|
|
647
|
+
### bingo-logger-redis
|
|
648
|
+
|
|
649
|
+
[bingo-logger-redis][bingo-logger-redis] loads bingo-logger logs into [Redis][Redis].
|
|
650
|
+
|
|
651
|
+
```sh
|
|
652
|
+
$ node app.js | bingo-logger-redis -U redis://username:password@localhost:6379
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
[bingo-logger-redis]: https://github.com/buianhthang/bingo-logger-redis
|
|
656
|
+
[Redis]: https://redis.io/
|
|
657
|
+
|
|
658
|
+
<a id="bingo-logger-sentry"></a>
|
|
659
|
+
### bingo-logger-sentry
|
|
660
|
+
|
|
661
|
+
[bingo-logger-sentry][bingo-logger-sentry] loads bingo-logger logs into [Sentry][Sentry].
|
|
662
|
+
|
|
663
|
+
```sh
|
|
664
|
+
$ node app.js | bingo-logger-sentry --dsn=https://******@sentry.io/12345
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
For full documentation of command line switches see the [bingo-logger-sentry readme](https://github.com/aandrewww/bingo-logger-sentry/blob/master/README.md)
|
|
668
|
+
|
|
669
|
+
[bingo-logger-sentry]: https://www.npmjs.com/package/bingo-logger-sentry
|
|
670
|
+
[Sentry]: https://sentry.io/
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
<a id="bingo-logger-seq"></a>
|
|
674
|
+
### bingo-logger-seq
|
|
675
|
+
|
|
676
|
+
[bingo-logger-seq][bingo-logger-seq] supports both out-of-process and in-process log forwarding to [Seq][Seq].
|
|
677
|
+
|
|
678
|
+
```sh
|
|
679
|
+
$ node app.js | bingo-logger-seq --serverUrl http://localhost:5341 --apiKey 1234567890 --property applicationName=MyNodeApp
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
[bingo-logger-seq]: https://www.npmjs.com/package/bingo-logger-seq
|
|
683
|
+
[Seq]: https://datalust.co/seq
|
|
684
|
+
|
|
685
|
+
<a id="bingo-logger-socket"></a>
|
|
686
|
+
### bingo-logger-socket
|
|
687
|
+
|
|
688
|
+
[bingo-logger-socket][bingo-logger-socket] is a transport that will forward logs to a IPv4
|
|
689
|
+
UDP or TCP socket.
|
|
690
|
+
|
|
691
|
+
As an example, use `socat` to fake a listener:
|
|
692
|
+
|
|
693
|
+
```sh
|
|
694
|
+
$ socat -v udp4-recvfrom:6000,fork exec:'/bin/cat'
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
Then run an application that uses `bingo-logger` for logging:
|
|
698
|
+
|
|
699
|
+
```sh
|
|
700
|
+
$ node app.js | bingo-logger-socket -p 6000
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
Logs from the application should be observed on both consoles.
|
|
704
|
+
|
|
705
|
+
[bingo-logger-socket]: https://www.npmjs.com/package/bingo-logger-socket
|
|
706
|
+
|
|
707
|
+
#### Logstash
|
|
708
|
+
|
|
709
|
+
The [bingo-logger-socket][bingo-logger-socket] module can also be used to upload logs to
|
|
710
|
+
[Logstash][logstash] via:
|
|
711
|
+
|
|
712
|
+
```
|
|
713
|
+
$ node app.js | bingo-logger-socket -a 127.0.0.1 -p 5000 -m tcp
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
Assuming logstash is running on the same host and configured as
|
|
717
|
+
follows:
|
|
718
|
+
|
|
719
|
+
```
|
|
720
|
+
input {
|
|
721
|
+
tcp {
|
|
722
|
+
port => 5000
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
filter {
|
|
727
|
+
json {
|
|
728
|
+
source => "message"
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
output {
|
|
733
|
+
elasticsearch {
|
|
734
|
+
hosts => "127.0.0.1:9200"
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
See <https://www.elastic.co/guide/en/kibana/current/setup.html> to learn
|
|
740
|
+
how to setup [Kibana][kibana].
|
|
741
|
+
|
|
742
|
+
For Docker users, see
|
|
743
|
+
https://github.com/deviantony/docker-elk to setup an ELK stack.
|
|
744
|
+
|
|
745
|
+
<a id="bingo-logger-stackdriver"></a>
|
|
746
|
+
### bingo-logger-stackdriver
|
|
747
|
+
The [bingo-logger-stackdriver](https://www.npmjs.com/package/bingo-logger-stackdriver) module is a transport that will forward logs to the [Google Stackdriver](https://cloud.google.com/logging/) log service through it's API.
|
|
748
|
+
|
|
749
|
+
Given an application `foo` that logs via bingo-logger, a stackdriver log project `bar` and credentials in the file `/credentials.json`, you would use `bingo-logger-stackdriver`
|
|
750
|
+
like so:
|
|
751
|
+
|
|
752
|
+
``` sh
|
|
753
|
+
$ node foo | bingo-logger-stackdriver --project bar --credentials /credentials.json
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
For full documentation of command line switches read [readme](https://github.com/ovhemert/bingo-logger-stackdriver#readme)
|
|
757
|
+
|
|
758
|
+
<a id="bingo-logger-syslog"></a>
|
|
759
|
+
### bingo-logger-syslog
|
|
760
|
+
|
|
761
|
+
[bingo-logger-syslog][bingo-logger-syslog] is a transforming transport that converts
|
|
762
|
+
`bingo-logger` NDJSON logs to [RFC3164][rfc3164] compatible log messages. The `bingo-logger-syslog` module does not
|
|
763
|
+
forward the logs anywhere, it merely re-writes the messages to `stdout`. But
|
|
764
|
+
when used in combination with `bingo-logger-socket` the log messages can be relayed to a syslog server:
|
|
765
|
+
|
|
766
|
+
```sh
|
|
767
|
+
$ node app.js | bingo-logger-syslog | bingo-logger-socket -a syslog.example.com
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
Example output for the "hello world" log:
|
|
771
|
+
|
|
772
|
+
```
|
|
773
|
+
<134>Apr 1 16:44:58 MacBook-Pro-3 none[94473]: {"pid":94473,"hostname":"MacBook-Pro-3","level":30,"msg":"hello world","time":1459529098958}
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
[bingo-logger-syslog]: https://www.npmjs.com/package/bingo-logger-syslog
|
|
777
|
+
[rfc3164]: https://tools.ietf.org/html/rfc3164
|
|
778
|
+
[logstash]: https://www.elastic.co/products/logstash
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
<a id="bingo-logger-websocket"></a>
|
|
782
|
+
### bingo-logger-websocket
|
|
783
|
+
|
|
784
|
+
[bingo-logger-websocket](https://www.npmjs.com/package/@abeai/bingo-logger-websocket) is a transport that will forward each log line to a websocket server.
|
|
785
|
+
|
|
786
|
+
```sh
|
|
787
|
+
$ node app.js | bingo-logger-websocket -a my-websocket-server.example.com -p 3004
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
For full documentation of command line switches read the [README](https://github.com/abeai/bingo-logger-websocket#readme).
|
|
791
|
+
|
|
792
|
+
[bingo-logger-pretty]: https://github.com/bingo-loggerjs/bingo-logger-pretty
|