nestjs-pino 2.2.0 → 2.3.0-alpha.1be480
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 +19 -4
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<a href="https://snyk.io/test/github/iamolegga/nestjs-pino">
|
|
16
16
|
<img alt="Snyk Vulnerabilities for npm package" src="https://img.shields.io/snyk/vulnerabilities/npm/nestjs-pino" />
|
|
17
17
|
</a>
|
|
18
|
-
<img alt="
|
|
18
|
+
<img alt="Libraries.io" src="https://img.shields.io/librariesio/release/npm/nestjs-pino">
|
|
19
19
|
<img alt="Dependabot" src="https://badgen.net/dependabot/iamolegga/nestjs-pino/?icon=dependabot">
|
|
20
20
|
<img alt="Supported platforms: Express & Fastify" src="https://img.shields.io/badge/platforms-Express%20%26%20Fastify-green" />
|
|
21
21
|
</p>
|
|
@@ -231,7 +231,9 @@ import { LoggerModule } from 'nestjs-pino';
|
|
|
231
231
|
name: 'add some name to every JSON line',
|
|
232
232
|
level: process.env.NODE_ENV !== 'production' ? 'debug' : 'info',
|
|
233
233
|
// install 'pino-pretty' package in order to use the following option
|
|
234
|
-
|
|
234
|
+
transport: process.env.NODE_ENV !== 'production'
|
|
235
|
+
? { target: 'pino-pretty' }
|
|
236
|
+
: {},
|
|
235
237
|
useLevelLabels: true,
|
|
236
238
|
// and all the others...
|
|
237
239
|
},
|
|
@@ -406,6 +408,8 @@ class MyService {
|
|
|
406
408
|
}
|
|
407
409
|
```
|
|
408
410
|
|
|
411
|
+
Due to the [limitation](https://github.com/pinojs/pino-http/issues/30) of the underlying `pino-http` `PinoLogger.assign` cannot extend `Request completed` logs.
|
|
412
|
+
|
|
409
413
|
## Change pino params at runtime
|
|
410
414
|
|
|
411
415
|
Pino root instance with passed via module registration params creates a separate child logger for every request. This root logger params can be changed at runtime via `PinoLogger.root` property which is the pointer to logger instance. Example:
|
|
@@ -443,6 +447,19 @@ import { Logger } from 'nestjs-pino';
|
|
|
443
447
|
// ...
|
|
444
448
|
```
|
|
445
449
|
|
|
450
|
+
Note that for [standalone applications](https://docs.nestjs.com/standalone-applications), buffering has to be [flushed using app.flushLogs()](https://github.com/nestjs/nest/blob/24e6c821a0859448646fd88831f20e4c5ae50980/packages/core/nest-application-context.ts#L136) manually after custom logger is ready to be used by NestJS (refer to [this issue](https://github.com/iamolegga/nestjs-pino/issues/553) for more details):
|
|
451
|
+
|
|
452
|
+
```ts
|
|
453
|
+
// main.ts
|
|
454
|
+
import { Logger } from 'nestjs-pino';
|
|
455
|
+
|
|
456
|
+
// ...
|
|
457
|
+
const app = await NestFactory.createApplicationContext(AppModule, { bufferLogs: true });
|
|
458
|
+
app.useLogger(app.get(Logger));
|
|
459
|
+
app.flushLogs();
|
|
460
|
+
// ...
|
|
461
|
+
```
|
|
462
|
+
|
|
446
463
|
In all the other places you can use built-in `Logger`:
|
|
447
464
|
|
|
448
465
|
```ts
|
|
@@ -545,8 +562,6 @@ All the other cases are lead to either code duplication or unexpected behavior.
|
|
|
545
562
|
|
|
546
563
|
<h2 align="center">Do you use this library?<br/>Don't be shy to give it a star! ★</h2>
|
|
547
564
|
|
|
548
|
-
---
|
|
549
|
-
|
|
550
565
|
Also if you are into NestJS ecosystem you may be interested in one of my other libs:
|
|
551
566
|
|
|
552
567
|
[nestjs-pino](https://github.com/iamolegga/nestjs-pino)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestjs-pino",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-alpha.1be480",
|
|
4
4
|
"description": "Pino logger for NestJS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
"@types/node": "^16.0.0",
|
|
50
50
|
"@types/pino-http": "^5.4.3",
|
|
51
51
|
"@types/supertest": "^2.0.11",
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
53
|
-
"@typescript-eslint/parser": "^
|
|
54
|
-
"eslint": "^
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^5.3.1",
|
|
53
|
+
"@typescript-eslint/parser": "^5.3.1",
|
|
54
|
+
"eslint": "^8.2.0",
|
|
55
55
|
"eslint-config-prettier": "^8.3.0",
|
|
56
56
|
"eslint-plugin-import": "^2.24.2",
|
|
57
|
-
"eslint-plugin-prettier": "^
|
|
58
|
-
"jest": "27.1
|
|
57
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
58
|
+
"jest": "27.3.1",
|
|
59
59
|
"memorystream": "^0.3.1",
|
|
60
|
-
"pino-http": "^
|
|
60
|
+
"pino-http": "^6.0.0",
|
|
61
61
|
"prettier": "^2.3.2",
|
|
62
62
|
"reflect-metadata": "^0.1.13",
|
|
63
63
|
"rimraf": "^3.0.2",
|
|
@@ -86,6 +86,6 @@
|
|
|
86
86
|
"testEnvironment": "node"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
|
-
"pino-http": "^
|
|
89
|
+
"pino-http": "^6.0.0"
|
|
90
90
|
}
|
|
91
91
|
}
|