0.0.5 • Published 6 years ago

@implicity/nest-logger v0.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
6 years ago

Nest Logger

Implicity flavored logger for Nest.js service

Install

npm install --save @implicity/nest-logger

Usage

Nest.js logger: main.ts

import { Logger } from '@implicity/nest-logger';

const serviceLogger = new Logger();
async function bootstrap() {
  const app = await NestFactory.create(AppModule, {
    logger: serviceLogger
  });

  await app.listen(process.env.SERVICE_PORT);
}

bootstrap()
  .catch((e) => {
    serviceLogger.handleError(e);
    process.exit(1);
  });

Route logger: app.module.ts

import { APP_INTERCEPTOR } from '@nestjs/core';
import { LoggingInterceptor } from '@implicity/nest-logger';


@Module({
  imports: [],
  controllers: [],
  providers: [{
    provide: APP_INTERCEPTOR,
    useClass: LoggingInterceptor  }]
})
export class AppModule {}

Using the static instance:

import { Logger } from '@implicity/nest-logger';

Logger.info('This is a log message');
Logger.info({
    message: 'This is a log message with meta !',
    meta: 'toto',
    context: 'MyController'
});

Instancing a logger instance:

import { Logger } from '@implicity/nest-logger';

const myLoggerWithMeta = new Logger({
    myMeta: 'lol'
});
myLoggerWithMeta.info('This is a log message');
myLoggerWithMeta.info({
    message: 'This is a log message with meta !',
    meta: 'toto',
    context: 'MyController'
});
0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago