Skip to content

A simple log decorator or (TypeScript) for Nest framework (node.js) unified approach for class and function logging.

License

Notifications You must be signed in to change notification settings

dmytropaduchak/nestjs-log

Repository files navigation

🇺🇦 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.

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

Build Status Coverage Status NPM Version

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.

About

A simple log decorator or (TypeScript) for Nest framework (node.js) unified approach for class and function logging.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published