pino-seq 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/node.js.yml +0 -1
- package/README.md +0 -42
- package/index.d.ts +1 -1
- package/package.json +6 -11
- package/cli.js +0 -60
package/README.md
CHANGED
|
@@ -2,48 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
A stream to send [Pino](https://github.com/pinojs/pino) events to [Seq](https://datalust.co/seq). Tested with Node.js versions 18.x and up.
|
|
4
4
|
|
|
5
|
-
### Out-of-process (transport) usage <sup>recommended</sup>
|
|
6
|
-
|
|
7
|
-
First, install and use `pino` in your Node.js app, following the instructions in the [Pino documentation](https://getpino.io).
|
|
8
|
-
|
|
9
|
-
This will look something like:
|
|
10
|
-
|
|
11
|
-
```js
|
|
12
|
-
const logger = (await import('pino'))();
|
|
13
|
-
logger.info('Hello, World!');
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Pino will, by default, write newline-delimited JSON events to `STDOUT`. These events are piped into the `pino-seq` transport.
|
|
17
|
-
|
|
18
|
-
First, install `pino-seq` as a global tool:
|
|
19
|
-
|
|
20
|
-
```shell
|
|
21
|
-
npm install -g pino-seq
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Then, pipe the output of your Pino-enabled app to it:
|
|
25
|
-
|
|
26
|
-
```shell
|
|
27
|
-
node your-app.js | pino-seq --serverUrl http://localhost:5341 --apiKey 1234567890 --property applicationName=PinoSeqExampleApp
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
`pino-seq` accepts the following parameters:
|
|
31
|
-
|
|
32
|
-
- `serverUrl` - this is the base URL of your Seq server; if omitted, the default value of `http://localhost:5341` will be used
|
|
33
|
-
- `apiKey` - your Seq API key, if one is required; the default does not send an API key
|
|
34
|
-
- `logOtherAs` - log other output (not formatted through pino) to seq at this loglevel. Useful to capture messages if the node process crashes or smilar.
|
|
35
|
-
- `property` - add additional properties to all logs sent to Seq
|
|
36
|
-
|
|
37
|
-
#### Capturing other output
|
|
38
|
-
|
|
39
|
-
To enable capture of output not formatted through pino use the `logOtherAs` parameter. It's possible to use different settings for STDOUT/STDERR like this, when using bash:
|
|
40
|
-
|
|
41
|
-
```shell
|
|
42
|
-
node your-app.js 2> >(pino-seq --logOtherAs Error --serverUrl http://localhost:5341 --apiKey 1234567890) > >(pino-seq --logOtherAs Information --serverUrl http://localhost:5341 --apiKey 1234567890)
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### In-process (stream) usage
|
|
46
|
-
|
|
47
5
|
Use the `createStream()` method to create a Pino stream configuration, passing `serverUrl`, `apiKey` and batching parameters.
|
|
48
6
|
|
|
49
7
|
```js
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pino-seq",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A stream that sends Pino log events to Seq",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -10,9 +10,6 @@
|
|
|
10
10
|
"start": "node ./example/example.js",
|
|
11
11
|
"start:ts": "tsx ./example/example.ts"
|
|
12
12
|
},
|
|
13
|
-
"bin": {
|
|
14
|
-
"pino-seq": "./cli.js"
|
|
15
|
-
},
|
|
16
13
|
"repository": {
|
|
17
14
|
"type": "git",
|
|
18
15
|
"url": "git+https://github.com/datalust/pino-seq.git"
|
|
@@ -28,17 +25,15 @@
|
|
|
28
25
|
},
|
|
29
26
|
"homepage": "https://github.com/datalust/pino-seq#readme",
|
|
30
27
|
"devDependencies": {
|
|
31
|
-
"mocha": "^11.
|
|
32
|
-
"tsx": "^4.
|
|
33
|
-
"typescript": "^5.
|
|
28
|
+
"mocha": "^11.7.4",
|
|
29
|
+
"tsx": "^4.20.6",
|
|
30
|
+
"typescript": "^5.9.3"
|
|
34
31
|
},
|
|
35
32
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"seq-logging": "^3.0.0",
|
|
38
|
-
"split2": "^4.2.0"
|
|
33
|
+
"seq-logging": "^3.0.0"
|
|
39
34
|
},
|
|
40
35
|
"peerDependencies": {
|
|
41
|
-
"pino": "
|
|
36
|
+
"pino": "10.x"
|
|
42
37
|
},
|
|
43
38
|
"engines": {
|
|
44
39
|
"node": ">=18.0.0"
|
package/cli.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { program } from 'commander';
|
|
4
|
-
import split2 from 'split2';
|
|
5
|
-
import pinoSeq from './index.js';
|
|
6
|
-
|
|
7
|
-
function main() {
|
|
8
|
-
program
|
|
9
|
-
.option('-s, --serverUrl <serverUrl>', 'Seq server instance')
|
|
10
|
-
.option('-k, --apiKey <apiKey>', 'Seq API key')
|
|
11
|
-
.option(
|
|
12
|
-
'-o, --logOtherAs <Verbose|Debug|Information|Warning|Error|Fatal>',
|
|
13
|
-
'Log other output (not formatted through pino) to seq at this loglevel. Useful to capture messages if the node process crashes or smilar.',
|
|
14
|
-
(string) => {
|
|
15
|
-
if (['Verbose', 'Debug', 'Information', 'Warning', 'Error', 'Fatal'].includes(string)) {
|
|
16
|
-
return string;
|
|
17
|
-
}
|
|
18
|
-
console.error(`Warning, skipping option "logOtherAs": Invalid value supplied: "${string}"`);
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
)
|
|
22
|
-
.option('-p, --property <property>', 'Properties to add to all logs', (value, previous) => {
|
|
23
|
-
const valueSplit = value.split('=')
|
|
24
|
-
if(valueSplit.length !== 2)
|
|
25
|
-
{
|
|
26
|
-
console.error(`Warning, skipping option "property": Invalid value specified: "${value}`)
|
|
27
|
-
return previous;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const current = {
|
|
31
|
-
[valueSplit[0]]: valueSplit[1]
|
|
32
|
-
}
|
|
33
|
-
return Object.assign(previous, current);
|
|
34
|
-
}, {})
|
|
35
|
-
.action(({ serverUrl, apiKey, logOtherAs, property }) => {
|
|
36
|
-
try {
|
|
37
|
-
const writeStream = pinoSeq.createStream({ serverUrl, apiKey, logOtherAs, additionalProperties: property });
|
|
38
|
-
|
|
39
|
-
process.stdin.pipe(split2()).pipe(writeStream).on("error", console.error);
|
|
40
|
-
|
|
41
|
-
const handler = (err, name) => {
|
|
42
|
-
writeStream.end(() => {
|
|
43
|
-
process.exit(0);
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
process.on('SIGINT', () => handler(null, 'SIGINT'));
|
|
48
|
-
process.on('SIGQUIT', () => handler(null, 'SIGQUIT'));
|
|
49
|
-
process.on('SIGTERM', () => handler(null, 'SIGTERM'));
|
|
50
|
-
process.on('SIGLOST', () => handler(null, 'SIGLOST'));
|
|
51
|
-
process.on('SIGABRT', () => handler(null, 'SIGABRT'));
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error(error);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
program.parse(process.argv);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
main();
|