@iti-tic/mystica

1.0.6 • Public • Published

Mystica

ITI Logo

Nest Logo

Information

Mystica is an open source project that simplifies logging on Nest projects, using other existent loggers such as winston with winston-daily-rotate-file.

Installation

On the root of your Nest project, run the following command:

$ npm i --save @iti/mystica

Usage

Mystica implements the LoggerService interface defined by Nest, so you can replace the default Nest logger with it.

On main.ts:

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { Mystica } from '@iti/mystica'

async function bootstrap() {
  const app = await NestFactory.create(AppModule, {
    logger: Mystica.forRoot(); // Replace default logger with Mystica
  });
  await app.listen(3000);
}
bootstrap();

Configuration

In order to specify a configuration for Mystica, a MysticaOptions object must be passed to the forRoot method. If no options are provided, Mystica will use the default configuration.

The MysticaOptions interface has two fields:

  • transport: Indicates the type of transport used
  • options (optional): Indicates the options for the type of transport. If no options are provided, the default options for the transport specified will be used

Example:

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { Mystica } from '@iti/mystica'
import { TransportType } from '@iti/mystica/options';

async function bootstrap() {
  const app = await NestFactory.create(AppModule, {
    logger: Mystica.forRoot({
      transport: TransportType.DAILY_ROTATE_FILE,

      options: {
        filename: "logs/%DATE%.log",
        datePattern: "YYYY-MM-DD",
        zippedArchive: false,
        maxSize: "100m",
        maxFiles: "30d"
      }
    })
  });
  await app.listen(3000);
}
bootstrap();

Feedback

Pull requests and issues are welcome!

License

Mystica is MIT licensed.

Readme

Keywords

none

Package Sidebar

Install

npm i @iti-tic/mystica

Weekly Downloads

2

Version

1.0.6

License

MIT

Unpacked Size

27.6 kB

Total Files

29

Last publish

Collaborators

  • fjbarrena