@iti-tic/mystica
v1.0.6
Published
Logging service for Nest
Downloads
24
Readme
Mystica
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 usedoptions
(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.