mirror of
https://git.vectorsigma.ru/public/immich.git
synced 2026-07-29 11:08:16 +00:00
* chore(server): sql versioning * chore: always add newline to end of file * refactor: generator * chore: pr feedback * chore: pr feedback
28 lines
615 B
TypeScript
28 lines
615 B
TypeScript
import { Logger } from 'typeorm';
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
const { format } = require('sql-formatter');
|
|
|
|
export class SqlLogger implements Logger {
|
|
queries: string[] = [];
|
|
errors: Array<{ error: string | Error; query: string }> = [];
|
|
|
|
clear() {
|
|
this.queries = [];
|
|
this.errors = [];
|
|
}
|
|
|
|
logQuery(query: string) {
|
|
this.queries.push(format(query, { language: 'postgresql' }));
|
|
}
|
|
|
|
logQueryError(error: string | Error, query: string) {
|
|
this.errors.push({ error, query });
|
|
}
|
|
|
|
logQuerySlow() {}
|
|
logSchemaBuild() {}
|
|
logMigration() {}
|
|
log() {}
|
|
}
|