mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
fix TypeORM logging to native console instead of NestJS logger
This commit is contained in:
parent
b057d3be0d
commit
04160af3ae
1 changed files with 9 additions and 7 deletions
|
@ -101,6 +101,7 @@ const sqlLogger = dbLogger.createSubLogger('sql', 'gray');
|
||||||
|
|
||||||
export type LoggerProps = {
|
export type LoggerProps = {
|
||||||
disableQueryTruncation?: boolean;
|
disableQueryTruncation?: boolean;
|
||||||
|
enableQueryLogging?: boolean;
|
||||||
enableQueryParamLogging?: boolean;
|
enableQueryParamLogging?: boolean;
|
||||||
printReplicationMode?: boolean,
|
printReplicationMode?: boolean,
|
||||||
};
|
};
|
||||||
|
@ -150,6 +151,8 @@ class MyCustomLogger implements Logger {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public logQuery(query: string, parameters?: any[], queryRunner?: QueryRunner) {
|
public logQuery(query: string, parameters?: any[], queryRunner?: QueryRunner) {
|
||||||
|
if (!this.props.enableQueryLogging) return;
|
||||||
|
|
||||||
const prefix = (this.props.printReplicationMode && queryRunner)
|
const prefix = (this.props.printReplicationMode && queryRunner)
|
||||||
? `[${queryRunner.getReplicationMode()}] `
|
? `[${queryRunner.getReplicationMode()}] `
|
||||||
: undefined;
|
: undefined;
|
||||||
|
@ -314,13 +317,12 @@ export function createPostgresDataSource(config: Config) {
|
||||||
},
|
},
|
||||||
} : false,
|
} : false,
|
||||||
logging: log,
|
logging: log,
|
||||||
logger: log
|
logger: new MyCustomLogger({
|
||||||
? new MyCustomLogger({
|
disableQueryTruncation: config.logging?.sql?.disableQueryTruncation,
|
||||||
disableQueryTruncation: config.logging?.sql?.disableQueryTruncation,
|
enableQueryLogging: log,
|
||||||
enableQueryParamLogging: config.logging?.sql?.enableQueryParamLogging,
|
enableQueryParamLogging: config.logging?.sql?.enableQueryParamLogging,
|
||||||
printReplicationMode: !!config.dbReplications,
|
printReplicationMode: !!config.dbReplications,
|
||||||
})
|
}),
|
||||||
: undefined,
|
|
||||||
maxQueryExecutionTime: config.db.slowQueryThreshold,
|
maxQueryExecutionTime: config.db.slowQueryThreshold,
|
||||||
entities: entities,
|
entities: entities,
|
||||||
migrations: ['../../migration/*.js'],
|
migrations: ['../../migration/*.js'],
|
||||||
|
|
Loading…
Add table
Reference in a new issue