@payk/nestjs-winston
Advanced tools
Comparing version 1.1.3 to 1.1.4
{ | ||
"name": "@payk/nestjs-winston", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Winston for Nest has never been this easy", |
@@ -16,2 +16,8 @@ <p align="center"> | ||
## What does it do? | ||
This package not only wraps winston into a Nest Module like other packages, it also creates a <b>Nest LoggerService</b>, so you can keep using the default NestJS logger, which enjoying winston. | ||
But that's not all, it also takes those great things from the NestJS Logger. It adds the context into the winston meta (so it can later be search and indexed in your <b>ELK/Datadog</b>). | ||
Another great feature is the <b>winston formatter</b> add to the class that in local mode allows easy and readable logs to the console. | ||
## Quick Start | ||
@@ -91,4 +97,3 @@ | ||
```typescript | ||
import { Controller, Inject } from '@nestjs/common'; | ||
import { Logger } from 'winston'; | ||
import { Controller, Inject, Logger } from '@nestjs/common'; | ||
import { WINSTON_MODULE_PROVIDER } from '@payk/nestjs-winston'; | ||
@@ -100,2 +105,12 @@ | ||
} | ||
@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 | ||
this.logger.log({ message: 'Your message here', { meta: 'data', goes: 'here'}}); | ||
// If we just want a message, it can be passed as it | ||
this.logger.log('Only a message if no metadata is needed') | ||
} | ||
``` | ||
@@ -114,3 +129,7 @@ ## Nest Winston Formatter | ||
new winston.transports.Console({ | ||
format: winston.format.combine(winston.format.timestamp(), winston.format.colorize({ all: true }), winstonConsoleFormat | ||
format: winston.format.combine( | ||
winston.format.timestamp(), | ||
winston.format.colorize({ all: true }), | ||
winstonConsoleFormat | ||
) | ||
}) | ||
@@ -117,0 +136,0 @@ ] |
12464
136