1 |
import DiscordClient from "../client/Client"; |
2 |
import { Guild } from "discord.js"; |
3 |
import { appendFile } from "fs/promises"; |
4 |
import Service from "../utils/structures/Service"; |
5 |
|
6 |
export enum LogLevel { |
7 |
LOG = 'log', |
8 |
INFO = 'info', |
9 |
WARN = 'warn', |
10 |
CRITICAL = 'critical', |
11 |
ERROR = 'error' |
12 |
} |
13 |
|
14 |
export default class DebugLogger extends Service { |
15 |
private joinLeaveLogFile = __dirname + '/../../logs/join-leave.log'; |
16 |
private appLogFile = __dirname + '/../../logs/app.log'; |
17 |
|
18 |
async logApp(level: LogLevel, message: string) { |
19 |
await this.log(this.appLogFile, level, message); |
20 |
} |
21 |
|
22 |
async logLeaveJoin(level: LogLevel, message: string) { |
23 |
await this.log(this.joinLeaveLogFile, level, message); |
24 |
} |
25 |
|
26 |
async log(stream: string, level: LogLevel, message: string) { |
27 |
await appendFile(stream, `[${new Date().toISOString()}] [${level}] ${message}\n`); |
28 |
} |
29 |
} |