/[sudobot]/trunk/src/events/debug/DebugEvent.ts
ViewVC logotype

Contents of /trunk/src/events/debug/DebugEvent.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 288 - (show annotations)
Mon Jul 29 17:29:22 2024 UTC (8 months, 2 weeks ago) by rakin
File MIME type: application/typescript
File size: 949 byte(s)
feat: add debug logger
1 import { format } from "date-fns";
2 import { appendFile } from "fs/promises";
3 import path from "path";
4 import DiscordClient from "../../client/Client";
5 import BaseEvent from "../../utils/structures/BaseEvent";
6
7 export default class DebugEvent extends BaseEvent {
8 logFile: string = path.resolve(__dirname, "..", "..", "..", "logs", 'debug.log');
9
10 constructor() {
11 super("debug");
12 appendFile(this.logFile, `\n\n[${format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")}] [STARTUP] The system has started.\n`);
13 }
14
15 async run(client: DiscordClient, e: string): Promise <void> {
16 if (e.includes("Provided token") || e.includes(process.env.TOKEN!) || e.includes("[READY] Session ")) {
17 console.log('DEBUG: [One hidden log]');
18 return;
19 }
20
21 console.log("DEBUG: ", e);
22 await appendFile(this.logFile, `[${format(new Date(), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx")}] [LOG] ${e}\n`);
23 }
24 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26