import { Logger as TypeOrmLoggerInterface , QueryRunner } from 'typeorm' ; import { Logger } from './mpcast-logger' ; const context = 'TypeORM' ; /**
 * 使用 Base Logger 自定义 TypeORM 的日志记录
 */ export class TypeOrmLogger implements TypeOrmLoggerInterface { log ( level , message , queryRunner ? ) { switch ( level ) { case 'info' : Logger . info ( message , context ) ; break ; case 'log' : Logger . verbose ( message , context ) ; break ; case 'warn' : Logger . warn ( message , context ) ; break ; } } logMigration ( message , queryRunner ? ) { Logger . info ( message , context ) ; } param query param parameters param queryRunner logQuery ( query , parameters ? , queryRunner ? ) { Logger . debug ( `Query: "${ query }" -- [${ parameters }]` , context ) ; } param error param query param parameters param queryRunner logQueryError ( error , query , parameters ? , queryRunner ? ) { Logger . error ( `Query error: ${ error }, "${ query }" -- [${ parameters }]` , context ) ; } param time param query param parameters param queryRunner logQuerySlow ( time , query , parameters ? , queryRunner ? ) { Logger . warn ( `Slow query (${ time }): "${ query }" -- [${ parameters }]` , context ) ; } param message param queryRunner logSchemaBuild ( message , queryRunner ? ) { Logger . info ( message , context ) ; } }