Del: ログ発生場所から.tsを削除 / Feat: トークン削除時もログを記録

This commit is contained in:
2026-03-21 12:17:39 +09:00
parent a1ffb7f1c6
commit a4960e780b
6 changed files with 13 additions and 5 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ declare module "fastify" {
} }
} }
const logger = new Logger("Lib | access.ts"); const logger = new Logger("Lib | access");
const AccessLog: FastifyPluginCallback = (fastify) => { const AccessLog: FastifyPluginCallback = (fastify) => {
fastify.addHook("onRequest", (req, res, done) => { fastify.addHook("onRequest", (req, res, done) => {
+1 -1
View File
@@ -10,7 +10,7 @@ declare module "fastify" {
} }
} }
const logger = new Logger("Lib | auth.ts"); const logger = new Logger("Lib | auth");
const Authorization: FastifyPluginCallback = (fastify) => { const Authorization: FastifyPluginCallback = (fastify) => {
fastify.addHook("onRequest", async (req, res) => { fastify.addHook("onRequest", async (req, res) => {
+1 -1
View File
@@ -4,7 +4,7 @@ import { parse as yamlParse } from "yaml";
import { EOL } from "node:os"; import { EOL } from "node:os";
import Logger from "@/lib/logger"; import Logger from "@/lib/logger";
const logger = new Logger("Lib | config.ts"); const logger = new Logger("Lib | config");
const schema = z.object({ const schema = z.object({
server: z.object({ server: z.object({
+1 -1
View File
@@ -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 Database: FastifyPluginAsync = async (fastify) => {
const orm = await MikroORM.init(config); const orm = await MikroORM.init(config);
+1 -1
View File
@@ -25,7 +25,7 @@ const createLog = (
`${content.toString().replace(/\x1B\[[0-9;]*m/g, '')}${EOL}` `${content.toString().replace(/\x1B\[[0-9;]*m/g, '')}${EOL}`
); );
} catch (err) { } 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) if (fastify)
fastify.orm.em.clear(); fastify.orm.em.clear();
logger.info(
"Token deleted:",
`User: @${token.user.userid}`,
`Type: ${token.isNative
? "Native"
: "API Token"}`
);
} }
} }