fix
This commit is contained in:
parent
5edd511f2a
commit
4ed904316d
4 changed files with 21 additions and 27 deletions
|
|
@ -4,18 +4,29 @@ import { DataSource, LogLevel, LogMessage } from "typeorm";
|
|||
import { Logger } from "typeorm";
|
||||
import { QueryRunner } from "typeorm/browser";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { addLogSequence } from "../interfaces/utils";
|
||||
|
||||
export class MyCustomLogger implements Logger {
|
||||
log(level: "log" | "info" | "warn", message: any, queryRunner?: QueryRunner) {}
|
||||
|
||||
logQuery(query: string, parameters?: any[], queryRunner?: QueryRunner): void {
|
||||
const req = queryRunner?.data as RequestWithUser | undefined;
|
||||
const logData = req?.app?.locals.logData?.sequence?.at(-1);
|
||||
const req = queryRunner?.data as RequestWithUser;
|
||||
if (req?.app?.locals.logData?.sequence) {
|
||||
addLogSequence(req, {
|
||||
action: "database",
|
||||
status: "success",
|
||||
description: "Query Data.",
|
||||
query: "Query: " + query + (parameters ? " - Parameters:" + JSON.stringify(parameters) : ""),
|
||||
});
|
||||
}
|
||||
|
||||
// const req = queryRunner?.data as RequestWithUser | undefined;
|
||||
// const logData = req?.app?.locals.logData?.sequence?.at(-1);
|
||||
|
||||
if (logData && !logData.query) logData.query = [];
|
||||
if (logData) logData.query.push(
|
||||
"Query: " + query + (parameters ? (" - Parameters:" + JSON.stringify(parameters)) : '')
|
||||
);
|
||||
// if (logData && !logData.query) logData.query = [];
|
||||
// if (logData) logData.query.push(
|
||||
// "Query: " + query + (parameters ? (" - Parameters:" + JSON.stringify(parameters)) : '')
|
||||
// );
|
||||
}
|
||||
|
||||
logMigration(message: string, queryRunner?: QueryRunner) {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue