0.0.9 • Published 5 months ago
otostogan-nest-logger v0.0.9
Description
Nest utility module for multi level logging. Includes logging in Nest Console, Logs Files and Grafana Loki
Installation
$ npm install otostogan-nest-logger
Logger Config
import { ConfigModule, ConfigService } from '@nestjs/config';
import { ILoggerModuleAsyncOptions } from 'otostogan-nest-logger';
export const getLoggerConfig = (): ILoggerModuleAsyncOptions => ({
inject: [ConfigService],
imports: [ConfigModule],
useFactory: (configService: ConfigService) => ({
APP_NAME: configService.get('APP_NAME') ?? 'API',
LOG_PATH: `${process.cwd()}/publisher/${configService.get('APP_NAME')}`,
LOKI_HOST: configService.get<string>('LOKI_URL'),
}),
});
Declaring Logger Module
@Module({
imports: [
ConfigModule.forRoot({ envFilePath: '.env', isGlobal: true }),
LogModule.forRootAsync(getLoggerConfig()),
],
exports: [LogModule],
})
export class SetupConfigModule {}
Support
otostogan-nest-logger is an open source project. It can grow thanks to the sponsors and support by the amazing backers.