summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-10-20 21:48:33 -0700
committerFuwn <[email protected]>2025-10-20 21:48:33 -0700
commitaaef2ffebe106e30612c70bb86a2f8447968ce15 (patch)
treedb529fa00fd66ffda24814f1539238a3e7ca91a8 /packages
parentfeat(gateway:messageCreate): Add dmForwarder (diff)
downloadumabotdiscord-aaef2ffebe106e30612c70bb86a2f8447968ce15.tar.xz
umabotdiscord-aaef2ffebe106e30612c70bb86a2f8447968ce15.zip
feat(shared): Add logging framework
Diffstat (limited to 'packages')
-rw-r--r--packages/gateway/src/listeners/clientReady/voiceConnection.ts1
-rw-r--r--packages/shared/log.ts29
2 files changed, 30 insertions, 0 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`,
+ );
+};