0.0.18 • Published 5 years ago
@lupu60/nestjs-toolbox v0.0.18
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:!