jsonspecific 0.0.1-security → 3.14.7
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.
Potentially problematic release.
This version of jsonspecific might be problematic. Click here for more details.
- package/.eslintignore +2 -0
- package/.eslintrc +8 -0
- package/.github/dependabot.yml +13 -0
- package/.github/workflows/bench.yml +61 -0
- package/.github/workflows/ci.yml +88 -0
- package/.github/workflows/lock-threads.yml +30 -0
- package/.github/workflows/target-main.yml +23 -0
- package/.nojekyll +0 -0
- package/.prettierignore +1 -0
- package/.taprc.yaml +8 -0
- package/CNAME +1 -0
- package/CONTRIBUTING.md +30 -0
- package/LICENSE +21 -0
- package/README.md +159 -3
- package/SECURITY.md +68 -0
- package/benchmarks/basic.bench.js +95 -0
- package/benchmarks/child-child.bench.js +52 -0
- package/benchmarks/child-creation.bench.js +73 -0
- package/benchmarks/child.bench.js +62 -0
- package/benchmarks/deep-object.bench.js +88 -0
- package/benchmarks/formatters.bench.js +50 -0
- package/benchmarks/internal/custom-levels.js +67 -0
- package/benchmarks/internal/just-pino-heavy.bench.js +76 -0
- package/benchmarks/internal/just-pino.bench.js +182 -0
- package/benchmarks/internal/parent-vs-child.bench.js +75 -0
- package/benchmarks/internal/redact.bench.js +86 -0
- package/benchmarks/long-string.bench.js +81 -0
- package/benchmarks/multi-arg.bench.js +193 -0
- package/benchmarks/multistream.js +98 -0
- package/benchmarks/object.bench.js +82 -0
- package/benchmarks/utils/generate-benchmark-doc.js +36 -0
- package/benchmarks/utils/runbench.js +138 -0
- package/benchmarks/utils/wrap-log-level.js +55 -0
- package/bin.js +6 -0
- package/browser.js +484 -0
- package/build/sync-version.js +10 -0
- package/docs/api.md +1487 -0
- package/docs/asynchronous.md +40 -0
- package/docs/benchmarks.md +55 -0
- package/docs/browser.md +227 -0
- package/docs/bundling.md +40 -0
- package/docs/child-loggers.md +95 -0
- package/docs/ecosystem.md +84 -0
- package/docs/help.md +345 -0
- package/docs/lts.md +64 -0
- package/docs/pretty.md +35 -0
- package/docs/redaction.md +135 -0
- package/docs/transports.md +1238 -0
- package/docs/web.md +269 -0
- package/docsify/sidebar.md +26 -0
- package/examples/basic.js +43 -0
- package/examples/transport.js +68 -0
- package/favicon-16x16.png +0 -0
- package/favicon-32x32.png +0 -0
- package/favicon.ico +0 -0
- package/file.js +12 -0
- package/inc-version.sh +42 -0
- package/index.html +55 -0
- package/lib/caller.js +30 -0
- package/lib/constants.js +28 -0
- package/lib/deprecations.js +8 -0
- package/lib/levels.js +241 -0
- package/lib/meta.js +3 -0
- package/lib/multistream.js +188 -0
- package/lib/proto.js +234 -0
- package/lib/redaction.js +118 -0
- package/lib/symbols.js +74 -0
- package/lib/time.js +11 -0
- package/lib/tools.js +394 -0
- package/lib/transport-stream.js +56 -0
- package/lib/transport.js +167 -0
- package/lib/worker.js +194 -0
- package/lib/writer.js +42 -0
- package/package.json +118 -3
- package/pino-banner.png +0 -0
- package/pino-logo-hire.png +0 -0
- package/pino-tree.png +0 -0
- package/pino.d.ts +889 -0
- package/pino.js +236 -0
- package/pretty-demo.png +0 -0
- package/test/basic.test.js +874 -0
- package/test/broken-pipe.test.js +57 -0
- package/test/browser-child.test.js +132 -0
- package/test/browser-disabled.test.js +87 -0
- package/test/browser-early-console-freeze.test.js +12 -0
- package/test/browser-levels.test.js +241 -0
- package/test/browser-serializers.test.js +352 -0
- package/test/browser-timestamp.test.js +88 -0
- package/test/browser-transmit.test.js +417 -0
- package/test/browser.test.js +659 -0
- package/test/complex-objects.test.js +34 -0
- package/test/crlf.test.js +32 -0
- package/test/custom-levels.test.js +253 -0
- package/test/error.test.js +398 -0
- package/test/errorKey.test.js +34 -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 +27 -0
- package/test/exit.test.js +77 -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 +13 -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/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/noop-transport.js +10 -0
- package/test/fixtures/pretty/null-prototype.js +8 -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/syntax-error-esm.mjs +2 -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-uses-pino-config.js +33 -0
- package/test/fixtures/transport-with-on-exit.js +12 -0
- package/test/fixtures/transport-worker-data.js +19 -0
- package/test/fixtures/transport-worker.js +15 -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.ts +11 -0
- package/test/fixtures/ts/transpile.cjs +36 -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 +118 -0
- package/test/http.test.js +242 -0
- package/test/internals/version.test.js +15 -0
- package/test/is-level-enabled.test.js +185 -0
- package/test/jest/basic.spec.js +10 -0
- package/test/levels.test.js +772 -0
- package/test/metadata.test.js +106 -0
- package/test/mixin-merge-strategy.test.js +55 -0
- package/test/mixin.test.js +218 -0
- package/test/multistream.test.js +673 -0
- package/test/pkg/index.js +46 -0
- package/test/pkg/pkg.config.json +17 -0
- package/test/pkg/pkg.test.js +56 -0
- package/test/redact.test.js +847 -0
- package/test/serializers.test.js +253 -0
- package/test/stdout-protection.test.js +39 -0
- package/test/syncfalse.test.js +188 -0
- package/test/timestamp.test.js +121 -0
- package/test/transport/big.test.js +43 -0
- package/test/transport/bundlers-support.test.js +97 -0
- package/test/transport/caller.test.js +23 -0
- package/test/transport/core.test.js +644 -0
- package/test/transport/core.test.ts +236 -0
- package/test/transport/core.transpiled.test.ts +112 -0
- package/test/transport/module-link.test.js +239 -0
- package/test/transport/pipeline.test.js +135 -0
- package/test/transport/repl.test.js +14 -0
- package/test/transport/syncTrue.test.js +55 -0
- package/test/transport/syncfalse.test.js +68 -0
- package/test/transport/targets.test.js +44 -0
- package/test/transport/uses-pino-config.test.js +167 -0
- package/test/transport-stream.test.js +26 -0
- package/test/types/pino-import.test-d.ts +29 -0
- package/test/types/pino-multistream.test-d.ts +28 -0
- package/test/types/pino-top-export.test-d.ts +35 -0
- package/test/types/pino-transport.test-d.ts +145 -0
- package/test/types/pino-type-only.test-d.ts +64 -0
- package/test/types/pino.test-d.ts +468 -0
- package/test/types/pino.ts +78 -0
- package/tsconfig.json +14 -0
package/docs/web.md
ADDED
@@ -0,0 +1,269 @@
|
|
1
|
+
# Web Frameworks
|
2
|
+
|
3
|
+
Since HTTP logging is a primary use case, Pino has first-class support for the Node.js
|
4
|
+
web framework ecosystem.
|
5
|
+
|
6
|
+
- [Web Frameworks](#web-frameworks)
|
7
|
+
- [Pino with Fastify](#pino-with-fastify)
|
8
|
+
- [Pino with Express](#pino-with-express)
|
9
|
+
- [Pino with Hapi](#pino-with-hapi)
|
10
|
+
- [Pino with Restify](#pino-with-restify)
|
11
|
+
- [Pino with Koa](#pino-with-koa)
|
12
|
+
- [Pino with Node core `http`](#pino-with-node-core-http)
|
13
|
+
- [Pino with Nest](#pino-with-nest)
|
14
|
+
- [Pino with H3](#pino-with-h3)
|
15
|
+
|
16
|
+
<a id="fastify"></a>
|
17
|
+
## Pino with Fastify
|
18
|
+
|
19
|
+
The Fastify web framework comes bundled with Pino by default, simply set Fastify's
|
20
|
+
`logger` option to `true` and use `request.log` or `reply.log` for log messages that correspond
|
21
|
+
to each request:
|
22
|
+
|
23
|
+
```js
|
24
|
+
const fastify = require('fastify')({
|
25
|
+
logger: true
|
26
|
+
})
|
27
|
+
|
28
|
+
fastify.get('/', async (request, reply) => {
|
29
|
+
request.log.info('something')
|
30
|
+
return { hello: 'world' }
|
31
|
+
})
|
32
|
+
|
33
|
+
fastify.listen({ port: 3000 }, (err) => {
|
34
|
+
if (err) {
|
35
|
+
fastify.log.error(err)
|
36
|
+
process.exit(1)
|
37
|
+
}
|
38
|
+
})
|
39
|
+
```
|
40
|
+
|
41
|
+
The `logger` option can also be set to an object, which will be passed through directly
|
42
|
+
as the [`pino` options object](/docs/api.md#options-object).
|
43
|
+
|
44
|
+
See the [fastify documentation](https://www.fastify.io/docs/latest/Reference/Logging/) for more information.
|
45
|
+
|
46
|
+
<a id="express"></a>
|
47
|
+
## Pino with Express
|
48
|
+
|
49
|
+
```sh
|
50
|
+
npm install pino-http
|
51
|
+
```
|
52
|
+
|
53
|
+
```js
|
54
|
+
const app = require('express')()
|
55
|
+
const pino = require('pino-http')()
|
56
|
+
|
57
|
+
app.use(pino)
|
58
|
+
|
59
|
+
app.get('/', function (req, res) {
|
60
|
+
req.log.info('something')
|
61
|
+
res.send('hello world')
|
62
|
+
})
|
63
|
+
|
64
|
+
app.listen(3000)
|
65
|
+
```
|
66
|
+
|
67
|
+
See the [pino-http README](https://npm.im/pino-http) for more info.
|
68
|
+
|
69
|
+
<a id="hapi"></a>
|
70
|
+
## Pino with Hapi
|
71
|
+
|
72
|
+
```sh
|
73
|
+
npm install hapi-pino
|
74
|
+
```
|
75
|
+
|
76
|
+
```js
|
77
|
+
'use strict'
|
78
|
+
|
79
|
+
const Hapi = require('@hapi/hapi')
|
80
|
+
const Pino = require('hapi-pino');
|
81
|
+
|
82
|
+
async function start () {
|
83
|
+
// Create a server with a host and port
|
84
|
+
const server = Hapi.server({
|
85
|
+
host: 'localhost',
|
86
|
+
port: 3000
|
87
|
+
})
|
88
|
+
|
89
|
+
// Add the route
|
90
|
+
server.route({
|
91
|
+
method: 'GET',
|
92
|
+
path: '/',
|
93
|
+
handler: async function (request, h) {
|
94
|
+
// request.log is HAPI's standard way of logging
|
95
|
+
request.log(['a', 'b'], 'Request into hello world')
|
96
|
+
|
97
|
+
// a pino instance can also be used, which will be faster
|
98
|
+
request.logger.info('In handler %s', request.path)
|
99
|
+
|
100
|
+
return 'hello world'
|
101
|
+
}
|
102
|
+
})
|
103
|
+
|
104
|
+
await server.register(Pino)
|
105
|
+
|
106
|
+
// also as a decorated API
|
107
|
+
server.logger.info('another way for accessing it')
|
108
|
+
|
109
|
+
// and through Hapi standard logging system
|
110
|
+
server.log(['subsystem'], 'third way for accessing it')
|
111
|
+
|
112
|
+
await server.start()
|
113
|
+
|
114
|
+
return server
|
115
|
+
}
|
116
|
+
|
117
|
+
start().catch((err) => {
|
118
|
+
console.log(err)
|
119
|
+
process.exit(1)
|
120
|
+
})
|
121
|
+
```
|
122
|
+
|
123
|
+
See the [hapi-pino README](https://npm.im/hapi-pino) for more info.
|
124
|
+
|
125
|
+
<a id="restify"></a>
|
126
|
+
## Pino with Restify
|
127
|
+
|
128
|
+
```sh
|
129
|
+
npm install restify-pino-logger
|
130
|
+
```
|
131
|
+
|
132
|
+
```js
|
133
|
+
const server = require('restify').createServer({name: 'server'})
|
134
|
+
const pino = require('restify-pino-logger')()
|
135
|
+
|
136
|
+
server.use(pino)
|
137
|
+
|
138
|
+
server.get('/', function (req, res) {
|
139
|
+
req.log.info('something')
|
140
|
+
res.send('hello world')
|
141
|
+
})
|
142
|
+
|
143
|
+
server.listen(3000)
|
144
|
+
```
|
145
|
+
|
146
|
+
See the [restify-pino-logger README](https://npm.im/restify-pino-logger) for more info.
|
147
|
+
|
148
|
+
<a id="koa"></a>
|
149
|
+
## Pino with Koa
|
150
|
+
|
151
|
+
```sh
|
152
|
+
npm install koa-pino-logger
|
153
|
+
```
|
154
|
+
|
155
|
+
```js
|
156
|
+
const Koa = require('koa')
|
157
|
+
const app = new Koa()
|
158
|
+
const pino = require('koa-pino-logger')()
|
159
|
+
|
160
|
+
app.use(pino)
|
161
|
+
|
162
|
+
app.use((ctx) => {
|
163
|
+
ctx.log.info('something else')
|
164
|
+
ctx.body = 'hello world'
|
165
|
+
})
|
166
|
+
|
167
|
+
app.listen(3000)
|
168
|
+
```
|
169
|
+
|
170
|
+
See the [koa-pino-logger README](https://github.com/pinojs/koa-pino-logger) for more info.
|
171
|
+
|
172
|
+
<a id="http"></a>
|
173
|
+
## Pino with Node core `http`
|
174
|
+
|
175
|
+
```sh
|
176
|
+
npm install pino-http
|
177
|
+
```
|
178
|
+
|
179
|
+
```js
|
180
|
+
const http = require('http')
|
181
|
+
const server = http.createServer(handle)
|
182
|
+
const logger = require('pino-http')()
|
183
|
+
|
184
|
+
function handle (req, res) {
|
185
|
+
logger(req, res)
|
186
|
+
req.log.info('something else')
|
187
|
+
res.end('hello world')
|
188
|
+
}
|
189
|
+
|
190
|
+
server.listen(3000)
|
191
|
+
```
|
192
|
+
|
193
|
+
See the [pino-http README](https://npm.im/pino-http) for more info.
|
194
|
+
|
195
|
+
|
196
|
+
<a id="nest"></a>
|
197
|
+
## Pino with Nest
|
198
|
+
|
199
|
+
```sh
|
200
|
+
npm install nestjs-pino
|
201
|
+
```
|
202
|
+
|
203
|
+
```ts
|
204
|
+
import { NestFactory } from '@nestjs/core'
|
205
|
+
import { Controller, Get, Module } from '@nestjs/common'
|
206
|
+
import { LoggerModule, Logger } from 'nestjs-pino'
|
207
|
+
|
208
|
+
@Controller()
|
209
|
+
export class AppController {
|
210
|
+
constructor(private readonly logger: Logger) {}
|
211
|
+
|
212
|
+
@Get()
|
213
|
+
getHello() {
|
214
|
+
this.logger.log('something')
|
215
|
+
return `Hello world`
|
216
|
+
}
|
217
|
+
}
|
218
|
+
|
219
|
+
@Module({
|
220
|
+
controllers: [AppController],
|
221
|
+
imports: [LoggerModule.forRoot()]
|
222
|
+
})
|
223
|
+
class MyModule {}
|
224
|
+
|
225
|
+
async function bootstrap() {
|
226
|
+
const app = await NestFactory.create(MyModule)
|
227
|
+
await app.listen(3000)
|
228
|
+
}
|
229
|
+
bootstrap()
|
230
|
+
```
|
231
|
+
|
232
|
+
See the [nestjs-pino README](https://npm.im/nestjs-pino) for more info.
|
233
|
+
|
234
|
+
|
235
|
+
<a id="h3"></a>
|
236
|
+
## Pino with H3
|
237
|
+
|
238
|
+
```sh
|
239
|
+
npm install pino-http h3
|
240
|
+
```
|
241
|
+
|
242
|
+
Save as `server.mjs`:
|
243
|
+
|
244
|
+
```js
|
245
|
+
import { createApp, createRouter, eventHandler, fromNodeMiddleware } from "h3";
|
246
|
+
import pino from 'pino-http'
|
247
|
+
|
248
|
+
export const app = createApp();
|
249
|
+
|
250
|
+
const router = createRouter();
|
251
|
+
app.use(router);
|
252
|
+
app.use(fromNodeMiddleware(pino()))
|
253
|
+
|
254
|
+
app.use(eventHandler((event) => {
|
255
|
+
event.node.req.log.info('something')
|
256
|
+
return 'hello world'
|
257
|
+
}))
|
258
|
+
|
259
|
+
router.get(
|
260
|
+
"/",
|
261
|
+
eventHandler((event) => {
|
262
|
+
return { path: event.path, message: "Hello World!" };
|
263
|
+
}),
|
264
|
+
);
|
265
|
+
```
|
266
|
+
|
267
|
+
Execute `npx --yes listhen -w --open ./server.mjs`.
|
268
|
+
|
269
|
+
See the [pino-http README](https://npm.im/pino-http) for more info.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
* [Readme](/)
|
2
|
+
* [API](/docs/api.md)
|
3
|
+
* [Browser API](/docs/browser.md)
|
4
|
+
* [Redaction](/docs/redaction.md)
|
5
|
+
* [Child Loggers](/docs/child-loggers.md)
|
6
|
+
* [Transports](/docs/transports.md)
|
7
|
+
* [Web Frameworks](/docs/web.md)
|
8
|
+
* [Pretty Printing](/docs/pretty.md)
|
9
|
+
* [Asynchronous Logging](/docs/asynchronous.md)
|
10
|
+
* [Ecosystem](/docs/ecosystem.md)
|
11
|
+
* [Benchmarks](/docs/benchmarks.md)
|
12
|
+
* [Long Term Support](/docs/lts.md)
|
13
|
+
* [Help](/docs/help.md)
|
14
|
+
* [Log rotation](/docs/help.md#rotate)
|
15
|
+
* [Reopening log files](/docs/help.md#reopening)
|
16
|
+
* [Saving to multiple files](/docs/help.md#multiple)
|
17
|
+
* [Log filtering](/docs/help.md#filter-logs)
|
18
|
+
* [Transports and systemd](/docs/help.md#transport-systemd)
|
19
|
+
* [Duplicate keys](/docs/help.md#dupe-keys)
|
20
|
+
* [Log levels as labels instead of numbers](/docs/help.md#level-string)
|
21
|
+
* [Pino with `debug`](/docs/help.md#debug)
|
22
|
+
* [Unicode and Windows terminal](/docs/help.md#windows)
|
23
|
+
* [Mapping Pino Log Levels to Google Cloud Logging (Stackdriver) Severity Levels](/docs/help.md#stackdriver)
|
24
|
+
* [Avoid Message Conflict](/docs/help.md#avoid-message-conflict)
|
25
|
+
* [Best performance for logging to `stdout`](/docs/help.md#best-performance-for-stdout)
|
26
|
+
* [Testing](/docs/help.md#testing)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
// Pino's primary usage writes ndjson to `stdout`:
|
4
|
+
const pino = require('..')()
|
5
|
+
|
6
|
+
// However, if "human readable" output is desired,
|
7
|
+
// `pino-pretty` can be provided as the destination
|
8
|
+
// stream by uncommenting the following line in place
|
9
|
+
// of the previous declaration:
|
10
|
+
// const pino = require('..')(require('pino-pretty')())
|
11
|
+
|
12
|
+
pino.info('hello world')
|
13
|
+
pino.error('this is at error level')
|
14
|
+
pino.info('the answer is %d', 42)
|
15
|
+
pino.info({ obj: 42 }, 'hello world')
|
16
|
+
pino.info({ obj: 42, b: 2 }, 'hello world')
|
17
|
+
pino.info({ nested: { obj: 42 } }, 'nested')
|
18
|
+
setImmediate(() => {
|
19
|
+
pino.info('after setImmediate')
|
20
|
+
})
|
21
|
+
pino.error(new Error('an error'))
|
22
|
+
|
23
|
+
const child = pino.child({ a: 'property' })
|
24
|
+
child.info('hello child!')
|
25
|
+
|
26
|
+
const childsChild = child.child({ another: 'property' })
|
27
|
+
childsChild.info('hello baby..')
|
28
|
+
|
29
|
+
pino.debug('this should be mute')
|
30
|
+
|
31
|
+
pino.level = 'trace'
|
32
|
+
|
33
|
+
pino.debug('this is a debug statement')
|
34
|
+
|
35
|
+
pino.child({ another: 'property' }).debug('this is a debug statement via child')
|
36
|
+
pino.trace('this is a trace statement')
|
37
|
+
|
38
|
+
pino.debug('this is a "debug" statement with "')
|
39
|
+
|
40
|
+
pino.info(new Error('kaboom'))
|
41
|
+
pino.info(null)
|
42
|
+
|
43
|
+
pino.info(new Error('kaboom'), 'with', 'a', 'message')
|
@@ -0,0 +1,68 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
const pino = require('..')
|
4
|
+
const { tmpdir } = require('node:os')
|
5
|
+
const { join } = require('node:path')
|
6
|
+
|
7
|
+
const file = join(tmpdir(), `pino-${process.pid}-example`)
|
8
|
+
|
9
|
+
const transport = pino.transport({
|
10
|
+
targets: [{
|
11
|
+
level: 'warn',
|
12
|
+
target: 'pino/file',
|
13
|
+
options: {
|
14
|
+
destination: file
|
15
|
+
}
|
16
|
+
/*
|
17
|
+
}, {
|
18
|
+
level: 'info',
|
19
|
+
target: 'pino-elasticsearch',
|
20
|
+
options: {
|
21
|
+
node: 'http://localhost:9200'
|
22
|
+
}
|
23
|
+
*/
|
24
|
+
}, {
|
25
|
+
level: 'info',
|
26
|
+
target: 'pino-pretty'
|
27
|
+
}]
|
28
|
+
})
|
29
|
+
|
30
|
+
const logger = pino(transport)
|
31
|
+
|
32
|
+
logger.info({
|
33
|
+
file
|
34
|
+
}, 'logging destination')
|
35
|
+
|
36
|
+
logger.info('hello world')
|
37
|
+
logger.error('this is at error level')
|
38
|
+
logger.info('the answer is %d', 42)
|
39
|
+
logger.info({ obj: 42 }, 'hello world')
|
40
|
+
logger.info({ obj: 42, b: 2 }, 'hello world')
|
41
|
+
logger.info({ nested: { obj: 42 } }, 'nested')
|
42
|
+
logger.warn('WARNING!')
|
43
|
+
setImmediate(() => {
|
44
|
+
logger.info('after setImmediate')
|
45
|
+
})
|
46
|
+
logger.error(new Error('an error'))
|
47
|
+
|
48
|
+
const child = logger.child({ a: 'property' })
|
49
|
+
child.info('hello child!')
|
50
|
+
|
51
|
+
const childsChild = child.child({ another: 'property' })
|
52
|
+
childsChild.info('hello baby..')
|
53
|
+
|
54
|
+
logger.debug('this should be mute')
|
55
|
+
|
56
|
+
logger.level = 'trace'
|
57
|
+
|
58
|
+
logger.debug('this is a debug statement')
|
59
|
+
|
60
|
+
logger.child({ another: 'property' }).debug('this is a debug statement via child')
|
61
|
+
logger.trace('this is a trace statement')
|
62
|
+
|
63
|
+
logger.debug('this is a "debug" statement with "')
|
64
|
+
|
65
|
+
logger.info(new Error('kaboom'))
|
66
|
+
logger.info(null)
|
67
|
+
|
68
|
+
logger.info(new Error('kaboom'), 'with', 'a', 'message')
|
Binary file
|
Binary file
|
package/favicon.ico
ADDED
Binary file
|
package/file.js
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
const pino = require('./pino')
|
4
|
+
const { once } = require('node:events')
|
5
|
+
|
6
|
+
module.exports = async function (opts = {}) {
|
7
|
+
const destOpts = Object.assign({}, opts, { dest: opts.destination || 1, sync: false })
|
8
|
+
delete destOpts.destination
|
9
|
+
const destination = pino.destination(destOpts)
|
10
|
+
await once(destination, 'ready')
|
11
|
+
return destination
|
12
|
+
}
|
package/inc-version.sh
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
PATH=./node_modules/.bin:${PATH}
|
6
|
+
CURRENT_VERSION=$(jq -r .version package.json)
|
7
|
+
|
8
|
+
case ${1} in
|
9
|
+
Major | MAJOR | major)
|
10
|
+
LEVEL=major
|
11
|
+
;;
|
12
|
+
|
13
|
+
Minor | MINOR | minor)
|
14
|
+
LEVEL=minor
|
15
|
+
;;
|
16
|
+
|
17
|
+
Patch | PATCH | patch)
|
18
|
+
LEVEL=patch
|
19
|
+
;;
|
20
|
+
|
21
|
+
*)
|
22
|
+
LEVEL=patch
|
23
|
+
;;
|
24
|
+
esac
|
25
|
+
|
26
|
+
NEW_VERSION=$(semver -i ${LEVEL} ${CURRENT_VERSION})
|
27
|
+
echo "${CURRENT_VERSION} => ${NEW_VERSION}"
|
28
|
+
read -n 1 -s -r -p "Press any key to continue (ctrl+c to abort)..."
|
29
|
+
echo ""
|
30
|
+
|
31
|
+
echo "Patching package.json..."
|
32
|
+
cat package.json | \
|
33
|
+
jq --arg vers "${NEW_VERSION}" '.version = $vers' | \
|
34
|
+
tee package.json 1>/dev/null
|
35
|
+
|
36
|
+
echo "Patching lib/meta.js ..."
|
37
|
+
SED_SCRIPT=$(printf 's/%s/%s/' ${CURRENT_VERSION//\./\\.} ${NEW_VERSION//\./\\.})
|
38
|
+
cat ./lib/meta.js | \
|
39
|
+
sed -e ${SED_SCRIPT} | \
|
40
|
+
tee ./lib/meta.js 1>/dev/null
|
41
|
+
|
42
|
+
echo "Done."
|
package/index.html
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<title>Pino - Super fast, all natural JSON logger for Node.js</title>
|
6
|
+
<meta name="description" content="Super fast, all natural JSON logger for Node.js">
|
7
|
+
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
8
|
+
<link rel="stylesheet" href="//unpkg.com/docsify-themeable/dist/css/theme-simple.css">
|
9
|
+
<style>
|
10
|
+
:root {
|
11
|
+
--base-font-size: 16px;
|
12
|
+
--theme-color: rgb(104, 118, 52);
|
13
|
+
--link-color: rgb(104, 118, 52);
|
14
|
+
--link-color--hover: rgb(137, 152, 100);
|
15
|
+
--sidebar-name-margin: 0;
|
16
|
+
--sidebar-name-padding: 0;
|
17
|
+
--code-font-size: .9em;
|
18
|
+
}
|
19
|
+
.sidebar > h1 {
|
20
|
+
margin-bottom: -.75em;
|
21
|
+
margin-top: .75em;
|
22
|
+
}
|
23
|
+
.sidebar > h1 img {
|
24
|
+
height: 4em;
|
25
|
+
}
|
26
|
+
.markdown-section a code {
|
27
|
+
color: var(--link-color)!important;
|
28
|
+
}
|
29
|
+
.markdown-section code:not([class*="lang-"]):not([class*="language-"]) {
|
30
|
+
white-space: unset
|
31
|
+
}
|
32
|
+
</style>
|
33
|
+
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
|
34
|
+
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
|
35
|
+
</head>
|
36
|
+
<body>
|
37
|
+
<div id="app"></div>
|
38
|
+
</body>
|
39
|
+
<script>
|
40
|
+
window.$docsify = {
|
41
|
+
name: 'pino',
|
42
|
+
logo: './pino-tree.png',
|
43
|
+
loadSidebar: 'docsify/sidebar.md',
|
44
|
+
repo: 'https://github.com/pinojs/pino',
|
45
|
+
auto2top: true,
|
46
|
+
ga: 'UA-103155139-1'
|
47
|
+
}
|
48
|
+
</script>
|
49
|
+
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
50
|
+
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
|
51
|
+
<script src="//unpkg.com/docsify/lib/plugins/ga.min.js"></script>
|
52
|
+
<!-- To enable syntax highlighting on TypeScript codes: -->
|
53
|
+
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-typescript.min.js"></script>
|
54
|
+
|
55
|
+
</html>
|
package/lib/caller.js
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
'use strict'
|
2
|
+
|
3
|
+
function noOpPrepareStackTrace (_, stack) {
|
4
|
+
return stack
|
5
|
+
}
|
6
|
+
|
7
|
+
module.exports = function getCallers () {
|
8
|
+
const originalPrepare = Error.prepareStackTrace
|
9
|
+
Error.prepareStackTrace = noOpPrepareStackTrace
|
10
|
+
const stack = new Error().stack
|
11
|
+
Error.prepareStackTrace = originalPrepare
|
12
|
+
|
13
|
+
if (!Array.isArray(stack)) {
|
14
|
+
return undefined
|
15
|
+
}
|
16
|
+
|
17
|
+
const entries = stack.slice(2)
|
18
|
+
|
19
|
+
const fileNames = []
|
20
|
+
|
21
|
+
for (const entry of entries) {
|
22
|
+
if (!entry) {
|
23
|
+
continue
|
24
|
+
}
|
25
|
+
|
26
|
+
fileNames.push(entry.getFileName())
|
27
|
+
}
|
28
|
+
|
29
|
+
return fileNames
|
30
|
+
}
|
package/lib/constants.js
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
/**
|
2
|
+
* Represents default log level values
|
3
|
+
*
|
4
|
+
* @enum {number}
|
5
|
+
*/
|
6
|
+
const DEFAULT_LEVELS = {
|
7
|
+
trace: 10,
|
8
|
+
debug: 20,
|
9
|
+
info: 30,
|
10
|
+
warn: 40,
|
11
|
+
error: 50,
|
12
|
+
fatal: 60
|
13
|
+
}
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Represents sort order direction: `ascending` or `descending`
|
17
|
+
*
|
18
|
+
* @enum {string}
|
19
|
+
*/
|
20
|
+
const SORTING_ORDER = {
|
21
|
+
ASC: 'ASC',
|
22
|
+
DESC: 'DESC'
|
23
|
+
}
|
24
|
+
|
25
|
+
module.exports = {
|
26
|
+
DEFAULT_LEVELS,
|
27
|
+
SORTING_ORDER
|
28
|
+
}
|