1.5.1 • Published 1 year ago

@nest-toolbox/bunyan-logger v1.5.1

Weekly downloads
221
License
MIT
Repository
github
Last release
1 year ago

Bunyan Logger Service

NestJS LoggerService that uses Bunyan.

Installation

npm i @nest-toolbox/bunyan-logger

Example

You can pass any custom stream supported by Bunyan

import { NestFactory } from '@nestjs/core';
import { BunyanLoggerService } from "@nest-toolbox/bunyan-logger";
import { AppModule } from './app.module';
const Elasticsearch = require('bunyan-elasticsearch');

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

  const esStream = new Elasticsearch({
    type: 'logs',
    host: 'localhost:9300',
  });

  const app = await NestFactory.create<NestExpressApplication>(
    ApplicationModule,
    {
      logger: new BunyanLoggerService({
        projectId: 'project',
        formatterOptions: {
          outputMode: 'long',
        },
        extraFields?: {
          environment:'production',
          microservice: 'users',
        };
        customStreams: [
          { stream: esStream },
          {
            path: 'foo.log',
          },
        ],
      }),
    },
  );

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

BunyanLoggerService constructor options

check https://github.com/thlorenz/bunyan-format

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

1 year ago

1.4.19

2 years ago

1.4.17

2 years ago

1.4.6

2 years ago

1.4.9

2 years ago

1.4.8

2 years ago

1.4.7

2 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.1.20

4 years ago

1.1.18

4 years ago

1.1.11

4 years ago

1.1.14

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago