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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 226 - (show annotations)
Mon Jul 29 17:29:06 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 903 byte(s)
refactor: make all services inherit a base class
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 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26