at the moment this is what my database module looks like
import { Global, InternalServerErrorException, Logger, Module, OnModuleInit } from '@nestjs/common'
//import { databaseProviders } from './database.provider'
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm'
import { ApiConfigModule } from '../config/config.module'
import { ApiConfigService } from '../config/config.service'
import { DatabaseLogger } from './database-logger/database-logger'
import { DataSource } from 'typeorm'
// https://docs.nestjs.com/techniques/database
@Global()
@Module({
imports: [
TypeOrmModule.forRootAsync({
imports: [ApiConfigModule],
inject: [ApiConfigService],
useFactory: async (config: ApiConfigService) => ({
type: config.database.type,
host: config.database.host,
port: config.database.port,
username: config.database.user,
password: config.database.pass,
database: config.database.name,
autoLoadEntities: true,
synchronize: config.isDev,
logger: new DatabaseLogger(),
retryAttempts: 3,
}),
dataSourceFactory: async (options) => {
return await new DataSource(options).initialize().then((dataSource) => {
const logger = new Logger('TyepOrm')
logger.verbose('Connected to Database')
return dataSource
})
},
}),
],
})
export class DatabaseModule {}
ps: is this ok how i use the logger here?