@dmytropaduchak/nestjs-log
v1.0.8
Published
A simple log decorator or (TypeScript) for Nest framework (node.js) unified approach for class and function logging.
Downloads
10
Maintainers
Readme
🇺🇦 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-log
How 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 test
All unit test report you can find at report/
folder.
For run test at watch mode, use:
npm run test:dev
Linting
For check eslint rules, use:
npm run lint
For auto fix all eslint bugs, use:
npm run lint:fix
License
Nest is MIT licensed.