1.1.3 • Published 2 years ago

@thedigitalbunch/logger-nestjs v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Installation:

$ npm install @thedigitalbunch/logger-nestjs

Initialization:

First, import the initializer function:

import { initializeLogger } from '@thedigitalbunch/logger-nestjs';

Then run it within the bootstrap function:

const app = await NestFactory.create(AppModule, { bufferLogs: true });

// bootstrap code

initializeLogger(app);
Initialization options

You can specify an exception filter for your NestJS application, by using exceptionFilter argument. This logger exports AllExceptionsFilter and uses it as a default, but any class that implements ExceptionFilter can be passed. You can also pass null to not use the exception filter at all.

initializeLogger(app, { exceptionFilter: null });

initializeLogger(app, { exceptionFilter: new AllExceptionsFilter() });

If your project uses Sentry, you can pass useSentry: true as an argument or specify the log levels that should be captured by Sentry.

By default it captures error and warning logs.

initializeLogger(app, { useSentry: true });

initializeLogger(app, { useSentry: ['error', 'warning', 'debug'] });

Usage:

In a development environment, use environmental variable LOGGER=dev.

import { Injectable } from '@nestjs/common';
import { Logger } from '@thedigitalbunch/logger-nestjs';

@Injectable()
export class TestService {
    private logger = new Logger(TestService.name);
    
    hello() {
        this.logger.log('Hello World!');
    }
}
1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago