Del: ログ発生場所から.tsを削除 / Feat: トークン削除時もログを記録
This commit is contained in:
@@ -8,7 +8,7 @@ declare module "fastify" {
|
||||
}
|
||||
}
|
||||
|
||||
const logger = new Logger("Lib | access.ts");
|
||||
const logger = new Logger("Lib | access");
|
||||
|
||||
const AccessLog: FastifyPluginCallback = (fastify) => {
|
||||
fastify.addHook("onRequest", (req, res, done) => {
|
||||
|
||||
@@ -10,7 +10,7 @@ declare module "fastify" {
|
||||
}
|
||||
}
|
||||
|
||||
const logger = new Logger("Lib | auth.ts");
|
||||
const logger = new Logger("Lib | auth");
|
||||
|
||||
const Authorization: FastifyPluginCallback = (fastify) => {
|
||||
fastify.addHook("onRequest", async (req, res) => {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { parse as yamlParse } from "yaml";
|
||||
import { EOL } from "node:os";
|
||||
import Logger from "@/lib/logger";
|
||||
|
||||
const logger = new Logger("Lib | config.ts");
|
||||
const logger = new Logger("Lib | config");
|
||||
|
||||
const schema = z.object({
|
||||
server: z.object({
|
||||
|
||||
@@ -10,7 +10,7 @@ declare module "fastify" {
|
||||
}
|
||||
}
|
||||
|
||||
const logger = new Logger("Lib | db.ts");
|
||||
const logger = new Logger("Lib | database");
|
||||
|
||||
const Database: FastifyPluginAsync = async (fastify) => {
|
||||
const orm = await MikroORM.init(config);
|
||||
|
||||
@@ -25,7 +25,7 @@ const createLog = (
|
||||
`${content.toString().replace(/\x1B\[[0-9;]*m/g, '')}${EOL}`
|
||||
);
|
||||
} catch (err) {
|
||||
console.error(`${new Date().toLocaleString()} [ERROR] [Lib | logger.ts] Failed to write to file.`);
|
||||
console.error(`${new Date().toLocaleString()} [ERROR] [Lib | logger] Failed to write to file.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,5 +91,13 @@ export class TokenRepository extends EntityRepository<TokenEntity> {
|
||||
|
||||
if (fastify)
|
||||
fastify.orm.em.clear();
|
||||
|
||||
logger.info(
|
||||
"Token deleted:",
|
||||
`User: @${token.user.userid}`,
|
||||
`Type: ${token.isNative
|
||||
? "Native"
|
||||
: "API Token"}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user