nestjs-pino
Advanced tools
Comparing version 1.1.3 to 1.2.0
@@ -5,2 +5,2 @@ export { LoggerModule } from "./LoggerModule"; | ||
export { PinoLogger } from "./PinoLogger"; | ||
export { InjectPinoLogger } from "./InjectPinoLogger"; | ||
export { InjectPinoLogger, getLoggerToken } from "./InjectPinoLogger"; |
@@ -11,2 +11,3 @@ "use strict"; | ||
exports.InjectPinoLogger = InjectPinoLogger_1.InjectPinoLogger; | ||
exports.getLoggerToken = InjectPinoLogger_1.getLoggerToken; | ||
//# sourceMappingURL=index.js.map |
import { Provider } from "@nestjs/common"; | ||
import { PinoLogger } from "./PinoLogger"; | ||
export declare function InjectPinoLogger(context?: string): (target: Object, key: string | symbol, index?: number | undefined) => void; | ||
export declare function InjectPinoLogger(context?: string): (target: object, key: string | symbol, index?: number | undefined) => void; | ||
export declare function createProvidersForDecorated(): Array<Provider<PinoLogger>>; | ||
export declare function getLoggerToken(context: string): string; |
@@ -9,3 +9,3 @@ "use strict"; | ||
decoratedLoggers.add(context); | ||
return common_1.Inject(`${decoratedTokenPrefix}${context}`); | ||
return common_1.Inject(getLoggerToken(context)); | ||
} | ||
@@ -15,3 +15,3 @@ exports.InjectPinoLogger = InjectPinoLogger; | ||
return { | ||
provide: `${decoratedTokenPrefix}${context}`, | ||
provide: getLoggerToken(context), | ||
useFactory: (logger) => { | ||
@@ -28,2 +28,6 @@ logger.setContext(context); | ||
exports.createProvidersForDecorated = createProvidersForDecorated; | ||
function getLoggerToken(context) { | ||
return `${decoratedTokenPrefix}${context}`; | ||
} | ||
exports.getLoggerToken = getLoggerToken; | ||
//# sourceMappingURL=InjectPinoLogger.js.map |
{ | ||
"name": "nestjs-pino", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Pino logger for NestJS", | ||
@@ -34,5 +34,5 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@types/pino-http": "^4.3.2", | ||
"@types/pino-http": "^5.0.0", | ||
"express-ctx": "^0.1.1", | ||
"pino-http": "^4.3.0" | ||
"pino-http": "^5.0.0" | ||
}, | ||
@@ -42,7 +42,7 @@ "devDependencies": { | ||
"@nestjs/core": "^6.6.7", | ||
"@nestjs/platform-express": "^6.6.7", | ||
"@nestjs/platform-fastify": "^6.7.2", | ||
"@nestjs/platform-express": "^7.0.0", | ||
"@nestjs/platform-fastify": "^7.0.0", | ||
"@nestjs/testing": "^6.6.7", | ||
"@types/express": "^4.17.1", | ||
"@types/jest": "^24.0.18", | ||
"@types/jest": "^25.1.0", | ||
"@types/memorystream": "^0.3.0", | ||
@@ -53,3 +53,3 @@ "@types/node": "^13.1.0", | ||
"express": "^4.17.1", | ||
"jest": "^24.9.0", | ||
"jest": "^25.1.0", | ||
"memorystream": "^0.3.1", | ||
@@ -59,4 +59,4 @@ "reflect-metadata": "^0.1.13", | ||
"supertest": "^4.0.2", | ||
"ts-jest": "^24.0.2", | ||
"tslint": "^5.19.0", | ||
"ts-jest": "^25.0.0", | ||
"tslint": "^6.0.0", | ||
"typescript": "^3.6.2" | ||
@@ -63,0 +63,0 @@ }, |
@@ -411,2 +411,19 @@ <p align="center"> | ||
#### Testing a class that uses @InjectPinoLogger | ||
This package exposes a getLoggerToken() function that returns a prepared injection token based on the provided context. | ||
Using this token, you can easily provide a mock implementation of the logger using any of the standard custom provider techniques, including useClass, useValue, and useFactory. | ||
```ts | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [ | ||
MyService, | ||
{ | ||
provide: getLoggerToken(MyService.name), | ||
useValue: mockLogger, | ||
}, | ||
], | ||
}).compile(); | ||
``` | ||
## Usage as NestJS app logger | ||
@@ -413,0 +430,0 @@ |
45518
442
564
+ Added@types/node@22.10.10(transitive)
+ Added@types/pino@6.3.12(transitive)
+ Added@types/pino-http@5.8.4(transitive)
+ Added@types/pino-pretty@5.0.0(transitive)
+ Added@types/pino-std-serializers@4.0.0(transitive)
+ Addedcolorette@2.0.20(transitive)
+ Addeddateformat@4.6.3(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedfast-copy@3.0.2(transitive)
+ Addedhelp-me@5.0.0(transitive)
+ Addedjoycon@3.1.1(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpino@6.14.0(transitive)
+ Addedpino-http@5.8.0(transitive)
+ Addedpino-pretty@13.0.0(transitive)
+ Addedpino-std-serializers@3.2.04.0.0(transitive)
+ Addedprocess-warning@1.0.0(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedsecure-json-parse@2.7.0(transitive)
+ Addedsonic-boom@1.4.12.8.0(transitive)
+ Addedstrip-json-comments@3.1.1(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removed@types/pino@7.0.5(transitive)
- Removed@types/pino-http@4.4.0(transitive)
- Removedfast-redact@2.1.0(transitive)
- Removedpino@5.17.09.6.0(transitive)
- Removedpino-http@4.5.0(transitive)
- Removedpino-std-serializers@2.5.0(transitive)
- Removedprocess-warning@4.0.1(transitive)
- Removedquick-format-unescaped@3.0.3(transitive)
- Removedreal-require@0.2.0(transitive)
- Removedsafe-stable-stringify@2.5.0(transitive)
- Removedsonic-boom@0.7.7(transitive)
- Removedthread-stream@3.1.0(transitive)
Updated@types/pino-http@^5.0.0
Updatedpino-http@^5.0.0