1 |
|
/** |
2 |
|
* This file is part of SudoBot. |
3 |
|
* |
4 |
|
* Copyright (C) 2021-2022 OSN Inc. |
5 |
|
* |
6 |
|
* SudoBot is free software; you can redistribute it and/or modify it |
7 |
|
* under the terms of the GNU Affero General Public License as published by |
8 |
|
* the Free Software Foundation, either version 3 of the License, or |
9 |
|
* (at your option) any later version. |
10 |
|
* |
11 |
|
* SudoBot is distributed in the hope that it will be useful, but |
12 |
|
* WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
* GNU Affero General Public License for more details. |
15 |
|
* |
16 |
|
* You should have received a copy of the GNU Affero General Public License |
17 |
|
* along with SudoBot. If not, see <https://www.gnu.org/licenses/>. |
18 |
|
*/ |
19 |
|
|
20 |
import { MessageEmbed, WebhookClient } from "discord.js"; |
import { MessageEmbed, WebhookClient } from "discord.js"; |
21 |
import { appendFile } from "fs/promises"; |
import { appendFile } from "fs/promises"; |
22 |
|
import path from "path"; |
23 |
import Service from "../utils/structures/Service"; |
import Service from "../utils/structures/Service"; |
24 |
import { splitMessage } from "../utils/util"; |
import { splitMessage } from "../utils/util"; |
25 |
|
|
32 |
} |
} |
33 |
|
|
34 |
export default class DebugLogger extends Service { |
export default class DebugLogger extends Service { |
35 |
private joinLeaveLogFile = __dirname + '/../../logs/join-leave.log'; |
private joinLeaveLogFile = path.join(process.env.SUDO_PREFIX ?? (__dirname + '/../../'), 'logs/join-leave.log'); |
36 |
private appLogFile = __dirname + '/../../logs/app.log'; |
private appLogFile = path.join(process.env.SUDO_PREFIX ?? (__dirname + '/../../'), 'logs/app.log'); |
37 |
|
|
38 |
async logApp(level: LogLevel, message: string) { |
async logApp(level: LogLevel, message: string) { |
39 |
await this.log(this.appLogFile, level, message); |
await this.log(this.appLogFile, level, message); |
86 |
] |
] |
87 |
}); |
}); |
88 |
} |
} |
89 |
|
|
90 |
|
await webhookClient.destroy(); |
91 |
} |
} |
92 |
catch (e) { |
catch (e) { |
93 |
console.log(e); |
console.log(e); |