@nestjs-labs/nestjs-pino-extra 1.5.0 → 1.5.1
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 +10 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module-option.d.ts.map +1 -1
- package/dist/module-option.js +12 -14
- package/dist/module-option.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ pnpm install @nestjs-labs/nestjs-pino-extra nestjs-pino @nestjs-labs/pino-http-e
|
|
|
23
23
|
### Peer Dependencies
|
|
24
24
|
|
|
25
25
|
- **@nestjs/config** (^4.0.0): Configuration management
|
|
26
|
-
- **nestjs-pino** (^4.4.0): NestJS Pino integration
|
|
26
|
+
- **nestjs-pino** (^4.4.0): NestJS Pino integration
|
|
27
27
|
- **@nestjs-labs/pino-http-extra** (^1.0.0): Enhanced pino-http functionality
|
|
28
28
|
|
|
29
29
|
## Quick Start
|
|
@@ -40,8 +40,9 @@ import { LoggerModule } from '@nestjs-labs/nestjs-pino-extra';
|
|
|
40
40
|
ConfigModule.forRoot(),
|
|
41
41
|
LoggerModule.forRootAsync({
|
|
42
42
|
imports: [ConfigModule],
|
|
43
|
-
useFactory: (configService: ConfigService) =>
|
|
44
|
-
getNestjsPinoModuleOptions(configService)
|
|
43
|
+
useFactory: (configService: ConfigService) => {
|
|
44
|
+
return getNestjsPinoModuleOptions(configService);
|
|
45
|
+
}
|
|
45
46
|
inject: [ConfigService],
|
|
46
47
|
}),
|
|
47
48
|
],
|
|
@@ -75,7 +76,7 @@ import { LoggerModule } from '@nestjs-labs/nestjs-pino-extra';
|
|
|
75
76
|
ConfigModule.forRoot(),
|
|
76
77
|
LoggerModule.forRootAsync({
|
|
77
78
|
imports: [ConfigModule],
|
|
78
|
-
useFactory: (configService: ConfigService) =>
|
|
79
|
+
useFactory: (configService: ConfigService) =>
|
|
79
80
|
getNestjsPinoModuleOptions(configService, {
|
|
80
81
|
exclude: [
|
|
81
82
|
{ method: 0, path: '/health' },
|
|
@@ -98,6 +99,7 @@ export class AppModule {}
|
|
|
98
99
|
Get nestjs-pino module options with improved type safety and validation.
|
|
99
100
|
|
|
100
101
|
**Parameters:**
|
|
102
|
+
|
|
101
103
|
- `configService`: ConfigService - NestJS configuration service
|
|
102
104
|
- `overrides`: Params (optional) - Overrides for the module options
|
|
103
105
|
|
|
@@ -108,6 +110,7 @@ Get nestjs-pino module options with improved type safety and validation.
|
|
|
108
110
|
Get pino-http options with OpenTelemetry integration.
|
|
109
111
|
|
|
110
112
|
**Parameters:**
|
|
113
|
+
|
|
111
114
|
- `level`: string (default: 'info') - Log level
|
|
112
115
|
- `spanIdKey`: string (default: 'spanId') - OpenTelemetry span ID key
|
|
113
116
|
- `traceIdKey`: string (default: 'traceId') - OpenTelemetry trace ID key
|
|
@@ -119,6 +122,7 @@ Get pino-http options with OpenTelemetry integration.
|
|
|
119
122
|
Create multi-destination stream supporting pretty, file, and Loki outputs.
|
|
120
123
|
|
|
121
124
|
**Parameters:**
|
|
125
|
+
|
|
122
126
|
- `app`: string - Application name
|
|
123
127
|
- `level`: pino.Level (default: 'info') - Log level
|
|
124
128
|
- `filepath`: string (optional) - Log file path for rotation
|
|
@@ -147,6 +151,7 @@ export class AppService {
|
|
|
147
151
|
### HTTP Request Logging
|
|
148
152
|
|
|
149
153
|
The middleware automatically logs HTTP requests with:
|
|
154
|
+
|
|
150
155
|
- Request ID generation
|
|
151
156
|
- Response time tracking
|
|
152
157
|
- Status code-based log levels
|
|
@@ -154,4 +159,4 @@ The middleware automatically logs HTTP requests with:
|
|
|
154
159
|
|
|
155
160
|
## License
|
|
156
161
|
|
|
157
|
-
MIT
|
|
162
|
+
MIT
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAGhE,cAAc,aAAa,CAAC;AAG5B,cAAc,8BAA8B,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAMA,uDAAgE;AAAvD,8HAAA,0BAA0B,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAMA,uDAAgE;AAAvD,8HAAA,0BAA0B,OAAA;AAGnC,8CAA4B;AAG5B,+DAA6C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-option.d.ts","sourceRoot":"","sources":["../src/module-option.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAgD,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"module-option.d.ts","sourceRoot":"","sources":["../src/module-option.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAgD,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAY9G,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAOD,wBAAgB,cAAc,CAAC,aAAa,EAAE,aAAa,GAAG,WAAW,GAAG,SAAS,CAyBpF;AAOD,wBAAgB,cAAc,CAAC,aAAa,EAAE,aAAa,GAAG;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAKA;AAKD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS,CAuBxE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,CAK3E;AAQD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAQjF;AAmBD,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,aAAa,EAAE,SAAS,GAAE,MAAW,GAAG,MAAM,CAIvG"}
|
package/dist/module-option.js
CHANGED
|
@@ -11,16 +11,21 @@ function getLokiOptions(configService) {
|
|
|
11
11
|
const host = configService.get('LOG_LOKI_HOST');
|
|
12
12
|
const username = configService.get('LOG_LOKI_USERNAME');
|
|
13
13
|
const password = configService.get('LOG_LOKI_PASSWORD');
|
|
14
|
-
const labels = configService
|
|
14
|
+
const labels = configService
|
|
15
|
+
.get('LOG_LOKI_LABELS')
|
|
16
|
+
?.split(',')
|
|
17
|
+
?.reduce((acc, label) => {
|
|
15
18
|
const [key, value] = label.split('=');
|
|
16
19
|
acc[key] = value;
|
|
17
20
|
return acc;
|
|
18
21
|
}, {});
|
|
19
|
-
return host
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
return host
|
|
23
|
+
? {
|
|
24
|
+
host,
|
|
25
|
+
basicAuth: username && password ? { username, password } : undefined,
|
|
26
|
+
labels,
|
|
27
|
+
}
|
|
28
|
+
: undefined;
|
|
24
29
|
}
|
|
25
30
|
function getOtelOptions(configService) {
|
|
26
31
|
const spanIdKey = configService.get('OTEL_SPAN_ID_KEY') ?? 'spanId';
|
|
@@ -33,14 +38,7 @@ function extractLogConfig(configService) {
|
|
|
33
38
|
const filename = configService.get('LOG_FILE');
|
|
34
39
|
const lokiOptions = getLokiOptions(configService);
|
|
35
40
|
const otelOptions = getOtelOptions(configService);
|
|
36
|
-
const validLevels = [
|
|
37
|
-
'fatal',
|
|
38
|
-
'error',
|
|
39
|
-
'warn',
|
|
40
|
-
'info',
|
|
41
|
-
'debug',
|
|
42
|
-
'trace',
|
|
43
|
-
];
|
|
41
|
+
const validLevels = ['fatal', 'error', 'warn', 'info', 'debug', 'trace'];
|
|
44
42
|
if (!validLevels.includes(level)) {
|
|
45
43
|
throw new Error(`Invalid LOG_LEVEL: ${level}. Must be one of: ${validLevels.join(', ')}`);
|
|
46
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-option.js","sourceRoot":"","sources":["../src/module-option.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"module-option.js","sourceRoot":"","sources":["../src/module-option.ts"],"names":[],"mappings":";;AA+BA,wCAyBC;AAOD,wCAQC;AAKD,4CAuBC;AAED,sDAKC;AAQD,kDAQC;AAmBD,gEAIC;AA5ID,kEAA8G;AA0B9G,SAAgB,cAAc,CAAC,aAA4B;IACzD,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAS,eAAe,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAS,mBAAmB,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAS,mBAAmB,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,aAAa;SACzB,GAAG,CAAS,iBAAiB,CAAC;QAC/B,EAAE,KAAK,CAA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nestjs-pino-extra",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Enhanced nestjs-pino with OpenTelemetry, Loki, file rotation and enterprise features",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/index.js",
|
|
11
|
-
"require": "./dist/index.js"
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
12
13
|
},
|
|
13
14
|
"./module-option": {
|
|
14
15
|
"import": "./dist/module-option.js",
|
|
15
|
-
"require": "./dist/module-option.js"
|
|
16
|
+
"require": "./dist/module-option.js",
|
|
17
|
+
"types": "./dist/module-option.d.ts"
|
|
16
18
|
}
|
|
17
19
|
},
|
|
18
20
|
"repository": {
|
|
@@ -46,16 +48,14 @@
|
|
|
46
48
|
"eslint": "^9.32.0",
|
|
47
49
|
"pino": "^9.7.0",
|
|
48
50
|
"prettier": "^3.6.2",
|
|
49
|
-
"semantic-release": "^24.2.7",
|
|
50
51
|
"tslib": "^2.8.0",
|
|
51
|
-
"typedoc": "^0.28.7",
|
|
52
52
|
"typescript": "^5.5.4",
|
|
53
|
-
"@nestjs-labs/pino-http-extra": "1.5.
|
|
53
|
+
"@nestjs-labs/pino-http-extra": "1.5.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@nestjs/config": "^4.0.0",
|
|
57
57
|
"nestjs-pino": "^4.0.0",
|
|
58
|
-
"@nestjs-labs/pino-http-extra": "1.5.
|
|
58
|
+
"@nestjs-labs/pino-http-extra": "1.5.1"
|
|
59
59
|
},
|
|
60
60
|
"peerDependenciesMeta": {
|
|
61
61
|
"@nestjs/config": {
|