diff options
| author | Fuwn <[email protected]> | 2025-10-20 21:48:33 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-10-20 21:48:33 -0700 |
| commit | aaef2ffebe106e30612c70bb86a2f8447968ce15 (patch) | |
| tree | db529fa00fd66ffda24814f1539238a3e7ca91a8 | |
| parent | feat(gateway:messageCreate): Add dmForwarder (diff) | |
| download | umabotdiscord-aaef2ffebe106e30612c70bb86a2f8447968ce15.tar.xz umabotdiscord-aaef2ffebe106e30612c70bb86a2f8447968ce15.zip | |
feat(shared): Add logging framework
| -rw-r--r-- | packages/gateway/src/listeners/clientReady/voiceConnection.ts | 1 | ||||
| -rw-r--r-- | packages/shared/log.ts | 29 | ||||
| -rw-r--r-- | tsconfig.json | 3 |
3 files changed, 32 insertions, 1 deletions
diff --git a/packages/gateway/src/listeners/clientReady/voiceConnection.ts b/packages/gateway/src/listeners/clientReady/voiceConnection.ts index 87101d8..3665536 100644 --- a/packages/gateway/src/listeners/clientReady/voiceConnection.ts +++ b/packages/gateway/src/listeners/clientReady/voiceConnection.ts @@ -28,6 +28,7 @@ const createVoiceConnection = ( console.error( `Voice channel ${channelId} not found or is not a voice channel for guild ${guildId}`, ); + return; } diff --git a/packages/shared/log.ts b/packages/shared/log.ts new file mode 100644 index 0000000..35a3590 --- /dev/null +++ b/packages/shared/log.ts @@ -0,0 +1,29 @@ +/* eslint-disable no-unused-vars */ + +export enum LogLevel { + Error = "ERROR", + Warning = "WARNING", + Info = "INFO", + Debug = "DEBUG", + Trace = "TRACE", +} + +export const log = ( + unit: string, + message: string, + level: LogLevel = LogLevel.Info, +) => { + const timestamp = new Date().toISOString(); + const levelColors = { + [LogLevel.Error]: "\x1b[31m", + [LogLevel.Warning]: "\x1b[33m", + [LogLevel.Info]: "\x1b[32m", + [LogLevel.Debug]: "\x1b[34m", + [LogLevel.Trace]: "\x1b[35m", + }; + const levelColor = levelColors[level]; + + console.log( + `\x1b[37m${timestamp}\x1b[0m ${levelColor}${level}\x1b[0m \x1b[1m${unit}\x1b[22m \x1b[37m> ${message}\x1b[0m`, + ); +}; diff --git a/tsconfig.json b/tsconfig.json index b0ed945..7198a2e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,7 +21,8 @@ } }, "include": [ - "packages/interactions/**/*" + "packages/interactions/**/*", + "packages/shared/**/*" ], "exclude": [ "node_modules", |