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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 77 - (hide annotations)
Mon Jul 29 17:28:30 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 899 byte(s)
Added command line system
1 rakin 77 import DiscordClient from "../client/Client";
2     import { Guild } from "discord.js";
3     import { appendFile } from "fs/promises";
4    
5     export enum LogLevel {
6     LOG = 'log',
7     INFO = 'info',
8     WARN = 'warn',
9     CRITICAL = 'critical',
10     ERROR = 'error'
11     }
12    
13     export default class DebugLogger {
14     private joinLeaveLogFile = __dirname + '/../../logs/join-leave.log';
15     private appLogFile = __dirname + '/../../logs/app.log';
16    
17     constructor(protected client: DiscordClient) {
18    
19     }
20    
21     async logApp(level: LogLevel, message: string) {
22     await this.log(this.appLogFile, level, message);
23     }
24    
25     async logLeaveJoin(level: LogLevel, message: string) {
26     await this.log(this.joinLeaveLogFile, level, message);
27     }
28    
29     async log(stream: string, level: LogLevel, message: string) {
30     await appendFile(stream, `[${new Date().toISOString()}] [${level}] ${message}\n`);
31     }
32     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26