chai-as-resolved 2.3.2
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/CONTRIBUTING.md +30 -0
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/SECURITY.md +68 -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/favicon-16x16.png +0 -0
- package/favicon-32x32.png +0 -0
- package/favicon.ico +0 -0
- package/file.js +12 -0
- package/index.d.ts +899 -0
- package/index.html +55 -0
- package/index.js +55 -0
- package/lib/caller.js +32 -0
- package/lib/const.js +7 -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/package.json +34 -0
- package/pretty-demo.png +0 -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)
|
|
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
|
+
}
|