@payk/nestjs-winston
Advanced tools
Comparing version 1.1.6 to 1.2.0
export * from './winston.module'; | ||
export * from './winston.constants'; | ||
export * from './winston.format'; | ||
export * from './winston.logger'; |
@@ -9,1 +9,2 @@ "use strict"; | ||
__export(require("./winston.format")); | ||
__export(require("./winston.logger")); |
{ | ||
"name": "@payk/nestjs-winston", | ||
"version": "1.1.6", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
@@ -31,11 +31,11 @@ "description": "Winston for Nest has never been this easy", | ||
"devDependencies": { | ||
"@nestjs/common": "^6.6.7", | ||
"@nestjs/core": "^6.6.7", | ||
"@nestjs/platform-express": "^6.6.7", | ||
"@nestjs/testing": "^6.6.7", | ||
"@types/chai": "^4.2.2", | ||
"@nestjs/common": "^6.7.2", | ||
"@nestjs/core": "^6.7.2", | ||
"@nestjs/platform-express": "^6.7.2", | ||
"@nestjs/testing": "^6.7.2", | ||
"@types/chai": "^4.2.3", | ||
"@types/mocha": "^5.2.7", | ||
"mocha-junit-reporter": "^1.23.1", | ||
"chai": "^4.2.0", | ||
"mocha": "^6.2.0", | ||
"mocha-junit-reporter": "^1.23.1", | ||
"reflect-metadata": "^0.1.13", | ||
@@ -45,3 +45,3 @@ "rimraf": "^3.0.0", | ||
"source-map-support": "^0.5.13", | ||
"ts-node": "^8.3.0", | ||
"ts-node": "^8.4.1", | ||
"tslint": "^5.20.0", | ||
@@ -48,0 +48,0 @@ "typescript": "^3.6.3" |
@@ -88,32 +88,9 @@ <h1 align="center"> | ||
```typescript | ||
import { WinstonLogger } from '@payk/nestjs-winston'; | ||
export class ClassName { | ||
private readonly logger = new Logger(ClassName.name); | ||
private readonly logger = new WinstonLogger(ClassName.name); | ||
} | ||
``` | ||
## Injection usage | ||
`WinstonModule` is a global module, it will be available in all you feature modules. | ||
A provider will then be exposed to allow easy injection. | ||
```typescript | ||
import { Controller, Inject, Logger } from '@nestjs/common'; | ||
import { WINSTON_MODULE_PROVIDER } from '@payk/nestjs-winston'; | ||
@Controller('cats') | ||
export class CatsController { | ||
constructor(@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) { } | ||
} | ||
@Get() | ||
public getCats() { | ||
// To send metadata we need to pass the message inside an object | ||
// since the nestjs logger doesn't support meta by default | ||
let moreMeta = 3333; | ||
this.logger.log({ message: 'Your message here', { meta: 'data', goes: 'here'}, moreMeta}); | ||
// If we just want a message, it can be passed as it | ||
this.logger.log('Only a message if no metadata is needed') | ||
} | ||
``` | ||
## Nest Winston Formatter | ||
@@ -120,0 +97,0 @@ To allow a better visibility a unique formatter is provided |
13560
16
200
117