0.0.18 • Published 5 years ago

@lupu60/nestjs-toolbox v0.0.18

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

Install

npm i @lupu60/nestjs-toolbox -save

List of packages

Bunyan Logger Service

NestJS LoggerService that uses Bunyan.

Example

You can pass any custom stream supported by Bunyan

import { NestFactory } from '@nestjs/core';
import { BunyanLoggerService } from "@lupu60/nestjs-toolbox";
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(
    ApplicationModule,
    {
      logger: new BunyanLoggerService({
        projectName: 'project',
        formatterOptions: {
          outputMode: 'long',
        },
      }),
    },
  );

  const app = await NestFactory.create<NestExpressApplication>(
    ApplicationModule,
    {
      logger: new BunyanLoggerService({
        projectName: 'project',
        formatterOptions: {
          outputMode: 'long',
        },
        customStreams: [
          {
            path: 'foo.log',
          },
        ],
      }),
    },
  );

  await app.listen(3000);
}
bootstrap();

BunyanLoggerService constructor options

options: {
    projectName: string;
    formatterOptions: {
      outputMode: string;
      color?: boolean;
      levelInString?: boolean;
      colorFromLevel?: any;
    };
    customStreams?: any[];
}

Winston Logger Service

NestJS LoggerService that uses Winston.

Example

You can pass any custom transports supported by Winston

import { NestFactory } from '@nestjs/core';
import { WinstonLoggerService } from '@lupu60/nestjs-toolbox';
import { AppModule } from './app.module';
import * as winston from 'winston';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(
    ApplicationModule,
    {
      logger: new WinstonLoggerService({
        projectName: 'project',
      }),
    },
  );

  const app = await NestFactory.create<NestExpressApplication>(
    ApplicationModule,
    {
      logger: new WinstonLoggerService({
        projectName: 'project',
        transports: [
          new winston.transports.File({
            filename: 'combined.log',
            level: 'info',
          }),
        ],
      }),
    },
  );

  await app.listen(3000);
}
bootstrap();

WinstonLoggerService constructor options

options: {
  projectName: string,
  transports?: any[],
  timeFormatStr?: string,
  customFormatter?: any
}

Support on Beerpay

Hey dude! Help me out for a couple of :beers:!

Beerpay Beerpay

0.0.18

5 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

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