@abbacchio/transport 0.1.2 → 0.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/README.md +121 -0
- package/package.json +20 -6
- package/pino-transport.cjs +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# @abbacchio/transport
|
|
2
|
+
|
|
3
|
+
Node.js log transports for sending logs to [Abbacchio](https://github.com/pekonchan/pino-live) - a real-time log viewer dashboard.
|
|
4
|
+
|
|
5
|
+
Supports **Pino**, **Winston**, **Bunyan**, and **Console**.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @abbacchio/transport
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Pino
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import pino from "pino";
|
|
19
|
+
|
|
20
|
+
const logger = pino({
|
|
21
|
+
transport: {
|
|
22
|
+
targets: [
|
|
23
|
+
{ target: "pino-pretty" },
|
|
24
|
+
{
|
|
25
|
+
target: "@abbacchio/transport/transports/pino",
|
|
26
|
+
options: {
|
|
27
|
+
url: "http://localhost:4000/api/logs",
|
|
28
|
+
channel: "my-app",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
logger.info({ user: "john" }, "User logged in");
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Winston
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import winston from "winston";
|
|
42
|
+
import { winstonTransport } from "@abbacchio/transport/transports/winston";
|
|
43
|
+
|
|
44
|
+
const logger = winston.createLogger({
|
|
45
|
+
transports: [
|
|
46
|
+
new winston.transports.Console(),
|
|
47
|
+
winstonTransport({
|
|
48
|
+
url: "http://localhost:4000/api/logs",
|
|
49
|
+
channel: "my-app",
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
logger.info("User logged in", { user: "john" });
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Bunyan
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import bunyan from "bunyan";
|
|
61
|
+
import { bunyanStream } from "@abbacchio/transport/transports/bunyan";
|
|
62
|
+
|
|
63
|
+
const logger = bunyan.createLogger({
|
|
64
|
+
name: "myapp",
|
|
65
|
+
streams: [
|
|
66
|
+
{ stream: process.stdout },
|
|
67
|
+
bunyanStream({
|
|
68
|
+
url: "http://localhost:4000/api/logs",
|
|
69
|
+
channel: "my-app",
|
|
70
|
+
}),
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
logger.info({ user: "john" }, "User logged in");
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Console
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { interceptConsole, restoreConsole } from "@abbacchio/transport/transports/console";
|
|
81
|
+
|
|
82
|
+
interceptConsole({
|
|
83
|
+
url: "http://localhost:4000/api/logs",
|
|
84
|
+
channel: "my-app",
|
|
85
|
+
passthrough: true,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
console.log("This will be sent to Abbacchio!");
|
|
89
|
+
|
|
90
|
+
restoreConsole();
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Options
|
|
94
|
+
|
|
95
|
+
| Option | Type | Default | Description |
|
|
96
|
+
| ----------- | ------ | -------------------------------- | --------------------------------------- |
|
|
97
|
+
| `url` | string | `http://localhost:4000/api/logs` | Abbacchio server URL |
|
|
98
|
+
| `channel` | string | `default` | Channel name for multi-app support |
|
|
99
|
+
| `secretKey` | string | - | Encryption key (enables E2E encryption) |
|
|
100
|
+
| `batchSize` | number | `10` | Send batch when this many logs accumulate |
|
|
101
|
+
| `interval` | number | `1000` | Send batch after this many ms |
|
|
102
|
+
| `headers` | object | `{}` | Additional HTTP headers |
|
|
103
|
+
|
|
104
|
+
## End-to-End Encryption
|
|
105
|
+
|
|
106
|
+
Add `secretKey` to encrypt logs before sending:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
{
|
|
110
|
+
target: "@abbacchio/transport/transports/pino",
|
|
111
|
+
options: {
|
|
112
|
+
url: "http://localhost:4000/api/logs",
|
|
113
|
+
channel: "my-app",
|
|
114
|
+
secretKey: process.env.LOG_SECRET_KEY,
|
|
115
|
+
},
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abbacchio/transport",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Node.js log transports for Pino, Winston, and Bunyan - send logs to Abbacchio",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./
|
|
13
|
+
"./pino": {
|
|
14
14
|
"types": "./dist/transports/pino.d.ts",
|
|
15
|
+
"require": "./pino-transport.cjs",
|
|
15
16
|
"default": "./dist/transports/pino.js"
|
|
16
17
|
},
|
|
17
18
|
"./transports/winston": {
|
|
@@ -27,6 +28,10 @@
|
|
|
27
28
|
"default": "./dist/transports/console.js"
|
|
28
29
|
}
|
|
29
30
|
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"dev": "tsc --watch"
|
|
34
|
+
},
|
|
30
35
|
"keywords": [
|
|
31
36
|
"pino",
|
|
32
37
|
"winston",
|
|
@@ -42,15 +47,24 @@
|
|
|
42
47
|
"pino-abstract-transport": "^3.0.0",
|
|
43
48
|
"winston-transport": "^4.9.0"
|
|
44
49
|
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"pino": "^8.0.0 || ^9.0.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"pino": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
45
58
|
"devDependencies": {
|
|
46
59
|
"@types/node": "^22.10.5",
|
|
60
|
+
"pino": "^9.0.0",
|
|
47
61
|
"typescript": "^5.7.2"
|
|
48
62
|
},
|
|
49
63
|
"engines": {
|
|
50
64
|
"node": ">=18"
|
|
51
65
|
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
66
|
+
"repository": {
|
|
67
|
+
"type": "git",
|
|
68
|
+
"url": "https://github.com/mood-agency/abbacchio"
|
|
55
69
|
}
|
|
56
|
-
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CommonJS wrapper for the Pino transport.
|
|
5
|
+
*
|
|
6
|
+
* Pino runs transports in worker threads using require(), which doesn't
|
|
7
|
+
* work well with ESM subpath exports. This CJS wrapper allows users to
|
|
8
|
+
* simply use: target: '@abbacchio/transport'
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```javascript
|
|
12
|
+
* const pino = require('pino');
|
|
13
|
+
*
|
|
14
|
+
* const logger = pino({
|
|
15
|
+
* transport: {
|
|
16
|
+
* target: '@abbacchio/transport',
|
|
17
|
+
* options: {
|
|
18
|
+
* url: 'http://localhost:4000/api/logs',
|
|
19
|
+
* channel: 'my-app',
|
|
20
|
+
* },
|
|
21
|
+
* },
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
// Dynamic import the ESM module
|
|
27
|
+
module.exports = async function(opts) {
|
|
28
|
+
const { default: pinoTransport } = await import('./dist/transports/pino.js');
|
|
29
|
+
return pinoTransport(opts);
|
|
30
|
+
};
|