1.0.8 β’ Published 1 year ago
@dmytropaduchak/nestjs-log v1.0.8
πΊπ¦ HELP UKRAINE
GOOD EVENING WE ARE FROM UKRAINE.
We fight for democratic values, for freedom, for our future. We need your support. There are dozen ways to help us, JUST DO IT.
NestJS Log
A simple log decorator or (TypeScript) for Nest framework (node.js) unified approach for class and function logging.
Installation
You can install this package using NPM:
npm i --save @dmytropaduchak/nestjs-logHow use
Example with simple implementation:
import { Log } from '@dmytropaduchak/nestjs-log';
class Service {
@log() async test(): Promise<void> {}
}Example with custom looger implementation:
import { LoggerService } from '@nestjs/common';
import { Log } from '@dmytropaduchak/nestjs-log';
class CustomLogger extends LoggerService {}
const logger = new CustomLogger();
class Service {
@log({ logger }) async test(): Promise<void> {}
}Example with transform logging data implementation:
import { LoggerService } from '@nestjs/common';
import { Log } from '@dmytropaduchak/nestjs-log';
class MyLogger extends LoggerService {}
const logger = new MyLogger();
const transform = (key, value) => [key, value];
class Service {
@log({ logger, transform }) async test(): Promise<void> {}
}Example with override default log options implementation:
import { Log } from '@dmytropaduchak/nestjs-log';
const timestamp = true;
const prefix = 'Test';
class Service {
@log({ prefix, timestamp }) async test(): Promise<void> {}
}Unit testing
For run unit tests, use:
npm run testAll unit test report you can find at report/ folder.
For run test at watch mode, use:
npm run test:devLinting
For check eslint rules, use:
npm run lintFor auto fix all eslint bugs, use:
npm run lint:fixLicense
Nest is MIT licensed.