/[sudobot]/trunk/src/services/DebugLogger.ts
ViewVC logotype

Diff of /trunk/src/services/DebugLogger.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 237 by rakin, Mon Jul 29 17:29:09 2024 UTC revision 393 by rakin, Mon Jul 29 17:29:59 2024 UTC
# Line 1  Line 1 
1  import DiscordClient from "../client/Client";  /**
2  import { Guild, MessageEmbed, WebhookClient } from "discord.js";  * 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";
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    
# Line 13  export enum LogLevel { Line 32  export enum LogLevel {
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);
# Line 67  export default class DebugLogger extends Line 86  export default class DebugLogger extends
86                      ]                      ]
87                  });                  });
88              }              }
89    
90                await webhookClient.destroy();
91          }          }
92          catch (e) {          catch (e) {
93              console.log(e);              console.log(e);

Legend:
Removed from v.237  
changed lines
  Added in v.393

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26